forked from Tank/braga
add limits
This commit is contained in:
parent
0bb077bd0b
commit
bdbf6f900e
@ -1,52 +0,0 @@
|
|||||||
local template = require "resty.template"
|
|
||||||
local auth = require('framework.auth')
|
|
||||||
local handle = require('framework.handle')
|
|
||||||
local lfs = require("lfs")
|
|
||||||
local proxy = require("core.proxy")
|
|
||||||
|
|
||||||
local path = proxy['config']
|
|
||||||
|
|
||||||
-- чтение файла
|
|
||||||
|
|
||||||
local function read_file()
|
|
||||||
local file = io.open(path) or error("Не могу открыть file: " .. path)
|
|
||||||
local content = file:read("*a") or error("Не могу прочитать " .. path)
|
|
||||||
file:close()
|
|
||||||
return content
|
|
||||||
end
|
|
||||||
|
|
||||||
-- запись файла
|
|
||||||
|
|
||||||
local function write_file(content)
|
|
||||||
file = io.open(path,'w+')
|
|
||||||
local result = file:write(content) or error("Не могу записать " .. path)
|
|
||||||
file:close()
|
|
||||||
proxy.restart()
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
local function render()
|
|
||||||
local view = template.new("config.html", "layout.html")
|
|
||||||
view.title = "Настройки прокси-сервера"
|
|
||||||
view.data = read_file()
|
|
||||||
view:render()
|
|
||||||
end
|
|
||||||
|
|
||||||
local request = {
|
|
||||||
POST = function()
|
|
||||||
ngx.req.read_body()
|
|
||||||
local args, err = ngx.req.get_post_args()
|
|
||||||
if args['config'] then
|
|
||||||
write_file(args['config'])
|
|
||||||
end
|
|
||||||
render()
|
|
||||||
end,
|
|
||||||
GET = function()
|
|
||||||
local req = ngx.req.get_uri_args()
|
|
||||||
render()
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
if auth.session() then
|
|
||||||
ngx.say(handle(request))
|
|
||||||
end
|
|
||||||
33
tcp.lua
33
tcp.lua
@ -3,6 +3,39 @@ local base64 = require('base64')
|
|||||||
local flatdb = require('database.flatdb')
|
local flatdb = require('database.flatdb')
|
||||||
local db = flatdb('/home/braga/database')
|
local db = flatdb('/home/braga/database')
|
||||||
|
|
||||||
|
local limits = {
|
||||||
|
weather = {
|
||||||
|
temp = {
|
||||||
|
optimal = {0,10},
|
||||||
|
critical = {-25,35}
|
||||||
|
},
|
||||||
|
warm = {
|
||||||
|
optimal = {40,60},
|
||||||
|
critical = {10,90}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cellar = {
|
||||||
|
temp = {
|
||||||
|
optimal = {10,12},
|
||||||
|
critical = {8,14}
|
||||||
|
},
|
||||||
|
warm = {
|
||||||
|
optimal = {65,80},
|
||||||
|
critical = {50,90}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
room = {
|
||||||
|
temp = {
|
||||||
|
optimal = {18,24},
|
||||||
|
critical = {16,28}
|
||||||
|
},
|
||||||
|
warm = {
|
||||||
|
optimal = {60,75},
|
||||||
|
critical = {50,80}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Расшифровка сообщения от устройства
|
-- Расшифровка сообщения от устройства
|
||||||
|
|
||||||
local function decode(rec)
|
local function decode(rec)
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
<section class="container">
|
|
||||||
<h1 class="title">{{title}}</h1>
|
|
||||||
|
|
||||||
<div class="section">
|
|
||||||
<form id="add-tank-form" method="post" action="/save_tank">
|
|
||||||
<input type="hidden" name="id" value="">
|
|
||||||
|
|
||||||
<!-- Основные поля -->
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column is-half">
|
|
||||||
<label for="tank_name">Название емкости:</label>
|
|
||||||
<input class="input" type="text" name="tank_name" placeholder="Имя емкости">
|
|
||||||
|
|
||||||
<label for="device_id">ID блока датчиков:</label>
|
|
||||||
<input class="input" type="input" name="device_id">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="column is-half">
|
|
||||||
<label for="comments">Комментарии:</label>
|
|
||||||
<textarea class="textarea" name="comments" rows="3" placeholder="Дополнительная информация..."></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<section>
|
|
||||||
<h1 class="title">Редактирование конфигурации</h1>
|
|
||||||
<div class="block">
|
|
||||||
<form method="POST">
|
|
||||||
<div class="field">
|
|
||||||
<textarea class="textarea" name="config" rows="30">{{data}}</textarea>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<button class="button" name="submit" type="submit" class="is-info">Сохранить изменения</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Вход в PROXY ADMIN</title>
|
|
||||||
<link rel="stylesheet" href="/public/css/font-awesome.min.css">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Questrial&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="/public/css/bulma-dracula.css" />
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body style="background-image:url('/public/img/carbon.png');background-repeat: repeat;">
|
|
||||||
<section class="hero is-white-ter is-fullheight">
|
|
||||||
<div class="hero-body">
|
|
||||||
<div class="container has-text-centered">
|
|
||||||
<div class="column is-4 is-offset-4">
|
|
||||||
<div class="box has-background-dark">
|
|
||||||
<figure>
|
|
||||||
<img src="/public/img/proxy_small.png">
|
|
||||||
</figure>
|
|
||||||
<form method="POST">
|
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<input class="input is-large" placeholder="Логин" name="login" autofocus="">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<input class="input is-large" type="password" name="password" placeholder="Пароль">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" name="submit" class="button is-block is-danger is-large is-fullwidth">Войти</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<p class="has-text-danger">
|
|
||||||
{{message}}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script async type="text/javascript" src="/public/js/bulma.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user