diff --git a/api/router/tl_ops_api_get_store.lua b/api/router/tl_ops_api_get_store.lua index d0d8612..c9bacc9 100644 --- a/api/router/tl_ops_api_get_store.lua +++ b/api/router/tl_ops_api_get_store.lua @@ -101,6 +101,14 @@ local Router = function() if not waf_cc_content then waf_cc_content = {} end + local auth, auth_size = read("tl-ops-auth.tlstore"); + if not auth then + auth = {} + end + local time_alert, time_alert_size = read("tl-ops-time-alert.tlstore"); + if not time_alert then + time_alert = {} + end local res_data = { api = { @@ -207,6 +215,20 @@ local Router = function() size = waf_cc_size, version = #waf_cc_content, list = waf_cc_content, + }, + auth = { + id = 16, + name = "tl-ops-auth.tlstore", + size = auth_size, + version = #auth, + list = auth, + }, + time_alert = { + id = 17, + name = "tl-ops-time-alert.tlstore", + size = time_alert_size, + version = #time_alert, + list = time_alert, } } diff --git a/api/router/tl_ops_api_set_balance.lua b/api/router/tl_ops_api_set_balance.lua index d550517..837658e 100644 --- a/api/router/tl_ops_api_set_balance.lua +++ b/api/router/tl_ops_api_set_balance.lua @@ -16,7 +16,7 @@ cjson.encode_empty_table_as_object(false) local Router = function() - local change = "" + local change = "success" local service_empty, _ = tl_ops_utils_func:get_req_post_args_by_name("service_empty", 1); if service_empty then diff --git a/api/router/tl_ops_api_set_waf.lua b/api/router/tl_ops_api_set_waf.lua index d8f416d..792e0ff 100644 --- a/api/router/tl_ops_api_set_waf.lua +++ b/api/router/tl_ops_api_set_waf.lua @@ -15,7 +15,7 @@ cjson.encode_empty_table_as_object(false) local Router = function() - local change = "" + local change = "success" local waf_ip, _ = tl_ops_utils_func:get_req_post_args_by_name("waf_ip", 1); if waf_ip then diff --git a/bin/install_centeros.sh b/bin/install_centeros.sh index d7e0603..de22624 100644 --- a/bin/install_centeros.sh +++ b/bin/install_centeros.sh @@ -6,7 +6,7 @@ TL_OPS_PATH="/usr/local/tl-ops-manage/" TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf" TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;" TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;" -TL_OPS_VER="v2.8.9" +TL_OPS_VER="v2.9.0" echo_msg(){ cur_time=$(date "+%Y-%m-%d %H:%M:%S") diff --git a/bin/install_ubuntu.sh b/bin/install_ubuntu.sh index 69c844f..cdf8a97 100644 --- a/bin/install_ubuntu.sh +++ b/bin/install_ubuntu.sh @@ -6,7 +6,7 @@ TL_OPS_PATH="/usr/local/tl-ops-manage/" TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf" TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;" TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;" -TL_OPS_VER="v2.8.9" +TL_OPS_VER="v2.9.0" echo_msg(){ cur_time=$(date "+%Y-%m-%d %H:%M:%S") diff --git a/doc/change.md b/doc/change.md index b822fce..992e91c 100644 --- a/doc/change.md +++ b/doc/change.md @@ -1,6 +1,31 @@ ## 事务更新日程 +2022-09-15 + + 1. 支持登录插件配置实时修改 + + 2. 支持请求耗时告警策略实时修改 + + 3. 支持集群节点查看 + + 4. 调整部分插件变量命名 + + 5. 调整公共js文件路径 + + 6. 调整控制台展示名称错误 + + 7. 移除控制台调试日志 + + 8. 修复告警插件异常跳出问题 + + 9. 调整部分注释 + + 10. 负载和waf详情统计功能预告 + + 11. 事务日程调整 + + 2022-09-08 1. 逐步支持模块测试用例 diff --git a/plugins/tl_ops_auth/auth.lua b/plugins/tl_ops_auth/auth.lua index c8925f5..4d0d357 100644 --- a/plugins/tl_ops_auth/auth.lua +++ b/plugins/tl_ops_auth/auth.lua @@ -4,12 +4,15 @@ -- @author iamtsm -- @email 1905333456@qq.com +local cache = require("cache.tl_ops_cache_core"):new("tl-ops-auth"); local tlog = require("utils.tl_ops_utils_log"):new("tl_ops_plugin_auth") -local auth_constant = require("plugins.tl_ops_auth.tl_ops_plugin_constant") -local login_router = require("plugins.tl_ops_auth.login") +local constant_auth = require("plugins.tl_ops_auth.tl_ops_plugin_constant") +local login_router = require("plugins.tl_ops_auth.login_auth") local cjson = require("cjson.safe") local shared = tlops.plugin_shared local utils = tlops.utils +local cjson = require("cjson.safe"); +cjson.encode_empty_table_as_object(false) local _M = { _VERSION = '0.01' @@ -21,10 +24,10 @@ function _M:new() return setmetatable({}, mt) end --- 添加登录态 +-- 获取登录态 function _M:auth_get_session(id) - local key = auth_constant.cache_key.session .. id + local key = constant_auth.cache_key.session .. id tlog:dbg("auth_get_session, key=",key) @@ -40,9 +43,21 @@ end -- 添加登录态 function _M:auth_add_session(id, user) - local key = auth_constant.cache_key.session .. id + local login_str, _ = cache:get(constant_auth.cache_key.login) + if not login_str then + tlog:err("auth_add_session get login cache err login_str=",login_str,",err=",_) + return + end + + local login, _ = cjson.decode(login_str) + if not login then + tlog:err("auth_add_session decode login cache err login=",login,",err=",_) + return + end + + local key = constant_auth.cache_key.session .. id local value = cjson.encode(user) - local time = auth_constant.login.auth_time + local time = login.auth_time tlog:dbg("auth_add_session, key=",key,",value=",value,",time=",time) @@ -57,7 +72,7 @@ end -- 删除登录态 function _M:auth_del_session(id) - local key = auth_constant.cache_key.session .. id + local key = constant_auth.cache_key.session .. id tlog:dbg("auth_del_session, key=",key) @@ -71,7 +86,7 @@ end local uri_in_intercept_uri = function(ctx) - for i, intercept_uri in ipairs(auth_constant.login.intercept) do + for i, intercept_uri in ipairs(constant_auth.login.intercept) do if ngx.re.find(ctx.request_uri, intercept_uri, 'jo') then return true end @@ -82,8 +97,20 @@ end function _M:auth_core(ctx) + local login_str, _ = cache:get(constant_auth.cache_key.login) + if not login_str then + tlog:err("auth_core get login cache err login_str=",login_str,",err=",_) + return + end + + local login, _ = cjson.decode(login_str) + if not login then + tlog:err("auth_core decode login cache err login=",login,",err=",_) + return + end + -- 处理白名单 - for i, filter_ui in ipairs(auth_constant.login.filter) do + for i, filter_ui in ipairs(login.filter) do if ngx.re.find(ctx.request_uri, filter_ui, 'jo') then return end @@ -96,7 +123,7 @@ function _M:auth_core(ctx) -- cookie校验 local cookie_utils = require("lib.cookie"):new(); - local auth_cid, _ = cookie_utils:get(auth_constant.login.auth_cid); + local auth_cid, _ = cookie_utils:get(login.auth_cid); if auth_cid ~= nil and auth_cid then local session = self:auth_get_session(auth_cid) if session then @@ -106,7 +133,7 @@ function _M:auth_core(ctx) -- header校验 local headers = ngx.req.get_headers() - local auth_hid = headers[auth_constant.login.auth_hid] + local auth_hid = headers[login.auth_hid] if auth_hid ~= nil then local session = self:auth_get_session(auth_hid) if session then @@ -117,9 +144,9 @@ function _M:auth_core(ctx) tlog:dbg("req uri no auth, uri=",ctx.request_uri) utils:set_ngx_req_return_content( - auth_constant.login.code, - auth_constant.login.content, - auth_constant.login.content_type + login.code, + login.content, + login.content_type ) return end diff --git a/plugins/tl_ops_auth/get_auth.lua b/plugins/tl_ops_auth/get_auth.lua new file mode 100644 index 0000000..8475210 --- /dev/null +++ b/plugins/tl_ops_auth/get_auth.lua @@ -0,0 +1,36 @@ +-- tl_ops_auth_get +-- en : get auth config/list +-- zn : 获取auth插件配置列表 +-- @author iamtsm +-- @email 1905333456@qq.com + +local cache = require("cache.tl_ops_cache_core"):new("tl-ops-auth"); +local constant_auth = require("plugins.tl_ops_auth.tl_ops_plugin_constant"); +local tl_ops_rt = tlops.constant.comm.tl_ops_rt; +local tl_ops_utils_func = tlops.utils +local cjson = require("cjson.safe"); +cjson.encode_empty_table_as_object(false) + + +local Router = function() + + local list_str, _ = cache:get(constant_auth.cache_key.list); + if not list_str or list_str == nil then + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.not_found, "not found list", _); + return; + end + + local login_str, _ = cache:get(constant_auth.cache_key.login); + if not login_str or login_str == nil then + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.not_found, "not found login", _); + return; + end + + local res_data = {} + res_data[constant_auth.cache_key.list] = cjson.decode(list_str) + res_data[constant_auth.cache_key.login] = cjson.decode(login_str) + + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.ok, "success", res_data); +end + +return Router \ No newline at end of file diff --git a/plugins/tl_ops_auth/login.lua b/plugins/tl_ops_auth/login_auth.lua similarity index 59% rename from plugins/tl_ops_auth/login.lua rename to plugins/tl_ops_auth/login_auth.lua index 7e23247..a33b0ed 100644 --- a/plugins/tl_ops_auth/login.lua +++ b/plugins/tl_ops_auth/login_auth.lua @@ -4,14 +4,16 @@ -- @author iamtsm -- @email 1905333456@qq.com +local cache = require("cache.tl_ops_cache_core"):new("tl-ops-auth"); local tlog = require("utils.tl_ops_utils_log"):new("tl_ops_plugin_auth") -local auth_constant = require("plugins.tl_ops_auth.tl_ops_plugin_constant") +local constant_auth = require("plugins.tl_ops_auth.tl_ops_plugin_constant") local auth = require("plugins.tl_ops_auth.auth") local uuid = require("lib.jit-uuid") local utils = tlops.utils local shared = tlops.plugin_shared local tl_ops_rt = tlops.constant.comm.tl_ops_rt - +local cjson = require("cjson.safe"); +cjson.encode_empty_table_as_object(false) local Router = function() @@ -27,18 +29,42 @@ local Router = function() return; end - for i, user in ipairs(auth_constant.list) do + local login_str, _ = cache:get(constant_auth.cache_key.login) + if not login_str then + utils:set_ngx_req_return_ok(tl_ops_rt.args_error ,"auth login_str err3", _); + return + end + + local login, _ = cjson.decode(login_str) + if not login then + utils:set_ngx_req_return_ok(tl_ops_rt.args_error ,"auth login err4", _); + return + end + + local list_str, _ = cache:get(constant_auth.cache_key.list) + if not list_str then + utils:set_ngx_req_return_ok(tl_ops_rt.args_error ,"auth list_str err5", _); + return + end + + local list, _ = cjson.decode(list_str) + if not list then + utils:set_ngx_req_return_ok(tl_ops_rt.args_error ,"auth list err6", _); + return + end + + for i, user in ipairs(list) do if user.username == username and user.password == password then -- add cookie local cookie_utils = require("lib.cookie"):new(); local auth_cid = uuid() cookie_utils:set({ - key = auth_constant.login.auth_cid, + key = login.auth_cid, value = auth_cid, path = "/", domain = ngx.var.host, httponly = true, - max_age = auth_constant.login.auth_time, + max_age = login.auth_time, }) -- add session diff --git a/plugins/tl_ops_auth/set_auth.lua b/plugins/tl_ops_auth/set_auth.lua new file mode 100644 index 0000000..69f1584 --- /dev/null +++ b/plugins/tl_ops_auth/set_auth.lua @@ -0,0 +1,61 @@ +-- tl_ops_set_auth +-- en : set auth config/list +-- zn : 更新auth插件配置列表 +-- @author iamtsm +-- @email 1905333456@qq.com + +local snowflake = require("lib.snowflake"); +local cache = require("cache.tl_ops_cache_core"):new("tl-ops-auth"); +local constant_auth = require("plugins.tl_ops_auth.tl_ops_plugin_constant"); +local tl_ops_rt = tlops.constant.comm.tl_ops_rt; +local tl_ops_utils_func = tlops.utils +local cjson = require("cjson.safe"); +cjson.encode_empty_table_as_object(false) + + +local Router = function() + + local change = "success" + + local list, _ = tl_ops_utils_func:get_req_post_args_by_name(constant_auth.cache_key.list, 1); + if list then + -- 更新生成id + for _, user in ipairs(list) do + if not user.id or user.id == nil or user.id == '' then + user.id = snowflake.generate_id( 100 ) + end + if not user.updatetime or user.updatetime == nil or user.updatetime == '' then + user.updatetime = ngx.localtime() + end + if user.change and user.change == true then + user.updatetime = ngx.localtime() + user.change = nil + end + end + + local res, _ = cache:set(constant_auth.cache_key.list, cjson.encode(list)); + if not res then + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.error, "set list err ", _) + return; + end + + change = "list" + end + + local login, _ = tl_ops_utils_func:get_req_post_args_by_name(constant_auth.cache_key.login, 1); + if login then + local res, _ = cache:set(constant_auth.cache_key.login, cjson.encode(login)); + if not res then + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.error, "set login err ", _) + return; + end + + change = "login" + end + + local res_data = {} + + tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.ok, change, res_data) + end + +return Router diff --git a/plugins/tl_ops_auth/sync.lua b/plugins/tl_ops_auth/sync.lua new file mode 100644 index 0000000..25d71bc --- /dev/null +++ b/plugins/tl_ops_auth/sync.lua @@ -0,0 +1,213 @@ +-- tl_ops_auth_sync +-- en : sync auth config list +-- zn : 同步、预热登录权限相关数据 +-- @author iamtsm +-- @email 1905333456@qq.com + +local tlog = require("utils.tl_ops_utils_log"):new("tl_ops_plugin_auth") +local cache = require("cache.tl_ops_cache_core"):new("tl-ops-auth") +local constant_auth = require("plugins.tl_ops_auth.tl_ops_plugin_constant") +local tl_ops_rt = tlops.constant.comm.tl_ops_rt +local cjson = require("cjson.safe") +cjson.encode_empty_table_as_object(false) + + +-- 静态文件中的未同步到store的配置数据 +local sync_data_need_sync = function (constant_data, store_data) + local add = {} + for i = 1, #constant_data do + local synced = false + for j = 1, #store_data do + if constant_data[i]['id'] == store_data[j]['id'] then + synced = true + break + end + end + if not synced then + table.insert(add, constant_data[i]) + end + end + return add +end + + + +local sync_fields_list_config = function() + + local cache_key_list = constant_auth.cache_key.list; + + local demo = constant_auth.demo.list + + local data_str, _ = cache:get(cache_key_list); + if not data_str then + local res, _ = cache:set(cache_key_list, cjson.encode(constant_auth.list)) + if not res then + tlog:err("auth list sync_fields new store data err, res=",res) + return tl_ops_rt.error + end + + data_str, _ = cache:get(cache_key_list) + + tlog:dbg("auth list sync_fields new store data, res=",res) + end + + local data = cjson.decode(data_str); + if not data and type(data) ~= 'table' then + tlog:err("auth sync_fields err, old=",data) + return tl_ops_rt.error + end + + tlog:dbg("auth list sync_fields start, old=",data) + + local add_keys = {} + + -- demo fileds check + for key , _ in pairs(demo) do + -- data fileds check + for i = 1, #data do + -- add keys + if data[i][key] == nil then + data[i][key] = demo[key] + table.insert(add_keys , { + key = data[i][key] + }) + end + end + end + + local res = cache:set(cache_key_list, cjson.encode(data)) + if not res then + tlog:err("auth list sync_fields err, res=",res,",new=",data) + return tl_ops_rt.error + end + + tlog:dbg("auth list sync_fields done, new=",data,",add_keys=",add_keys) + + return tl_ops_rt.ok +end + + +local sync_fields_login_config = function() + + local cache_keys = { + login = { + cache_key = constant_auth.cache_key.login, + constant = constant_auth.login, + demo = constant_auth.demo.login + } + } + + for key, obj in pairs(cache_keys) do + local cache_key = obj.cache_key + local constant_data = obj.constant + local demo = obj.demo + + local data_str, _ = cache:get(cache_key); + if not data_str then + local res, _ = cache:set(cache_key, cjson.encode(constant_data)) + if not res then + tlog:err("auth login sync_fields new store err, cache_key=",cache_key,",res=",res) + break + end + + data_str, _ = cache:get(cache_key); + + tlog:dbg("auth login sync_fields new store, cache_key=",cache_key,",res=",res) + end + + local data = cjson.decode(data_str); + if not data and type(data) ~= 'table' then + tlog:err("auth login sync_fields err, cache_key=",cache_key,",old=",data) + break + end + + tlog:dbg("auth login sync_fields start, cache_key=",cache_key,",old=",data) + + local add_keys = {} + + -- demo fileds check + for key , _ in pairs(demo) do + -- data fileds check + -- add keys + if data[key] == nil then + data[key] = demo[key] + table.insert(add_keys , key) + end + end + + local res = cache:set(cache_key, cjson.encode(data)) + if not res then + tlog:err("auth login sync_fields err, cache_key=",cache_key,",res=",res,",new=",data) + break + end + + tlog:dbg("auth login sync_fields done, cache_key=",cache_key,",new=",data,",add_keys=",add_keys) + end + + return tl_ops_rt.ok +end + + + +-- 静态配置数据同步 +local sync_data = function () + local cache_key_list = constant_auth.cache_key.list + + local data_str, _ = cache:get(cache_key_list); + if not data_str then + local res, _ = cache:set(cache_key_list, cjson.encode(constant_auth.list)) + if not res then + tlog:err("auth sync_data new store data err, res=",res) + return tl_ops_rt.error + end + + tlog:dbg("auth sync_data new store data, res=",res) + return tl_ops_rt.ok + end + + local data = cjson.decode(data_str); + if not data and type(data) ~= 'table' then + tlog:err("auth sync_data err, old=",data) + return tl_ops_rt.error + end + + tlog:dbg("auth sync_data start, old=",data) + + -- 静态配置 + local constant_data = constant_auth.list + + -- 获取需要同步的配置 + local add = sync_data_need_sync(constant_data, data) + for i = 1, #add do + table.insert(data, add[i]) + end + + local res = cache:set(cache_key_list, cjson.encode(data)) + if not res then + tlog:err("auth sync_data err, res=",res,",new=",data) + return tl_ops_rt.error + end + + tlog:dbg("auth sync_data done, new=",data) + + return tl_ops_rt.ok +end + + + +-- 字段数据同步 +local sync_fields = function () + + sync_fields_list_config() + + sync_fields_login_config() + + return tl_ops_rt.ok +end + + + +return { + sync_data = sync_data, + sync_fields = sync_fields +} \ No newline at end of file diff --git a/plugins/tl_ops_auth/tl_ops_plugin_constant.lua b/plugins/tl_ops_auth/tl_ops_plugin_constant.lua index ea665bc..55be297 100644 --- a/plugins/tl_ops_auth/tl_ops_plugin_constant.lua +++ b/plugins/tl_ops_auth/tl_ops_plugin_constant.lua @@ -1,5 +1,5 @@ -local content_page = [[ +local default_content_page = [[ @@ -10,7 +10,7 @@ local content_page = [[
-
+
- + - + diff --git a/web/balance/tl_ops_web_api.js b/web/balance/tl_ops_web_api.js index d76833b..f1e8e06 100644 --- a/web/balance/tl_ops_web_api.js +++ b/web/balance/tl_ops_web_api.js @@ -13,7 +13,7 @@ const tl_ops_web_api_main = function (){ tl_ops_web_api_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_api_event()[type] ? tl_ops_web_api_event()[type].call(this) : ''; diff --git a/web/balance/tl_ops_web_api_form.html b/web/balance/tl_ops_web_api_form.html index ffc4962..12719aa 100644 --- a/web/balance/tl_ops_web_api_form.html +++ b/web/balance/tl_ops_web_api_form.html @@ -91,7 +91,7 @@ - + - + diff --git a/web/balance/tl_ops_web_balance_form.html b/web/balance/tl_ops_web_balance_form.html index 81093cf..de9347b 100644 --- a/web/balance/tl_ops_web_balance_form.html +++ b/web/balance/tl_ops_web_balance_form.html @@ -71,7 +71,7 @@ - + - + diff --git a/web/balance/tl_ops_web_cookie.js b/web/balance/tl_ops_web_cookie.js index ceb4622..ebbb504 100644 --- a/web/balance/tl_ops_web_cookie.js +++ b/web/balance/tl_ops_web_cookie.js @@ -13,7 +13,7 @@ const tl_ops_web_cookie_main = function (){ tl_ops_web_cookie_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_cookie_event()[type] ? tl_ops_web_cookie_event()[type].call(this) : ''; diff --git a/web/balance/tl_ops_web_cookie_form.html b/web/balance/tl_ops_web_cookie_form.html index 91d38fb..6dfef15 100644 --- a/web/balance/tl_ops_web_cookie_form.html +++ b/web/balance/tl_ops_web_cookie_form.html @@ -93,7 +93,7 @@ - + - + diff --git a/web/balance/tl_ops_web_header.js b/web/balance/tl_ops_web_header.js index cf7610b..fb0ce27 100644 --- a/web/balance/tl_ops_web_header.js +++ b/web/balance/tl_ops_web_header.js @@ -13,7 +13,7 @@ const tl_ops_web_header_main = function (){ tl_ops_web_header_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_header_event()[type] ? tl_ops_web_header_event()[type].call(this) : ''; diff --git a/web/balance/tl_ops_web_header_form.html b/web/balance/tl_ops_web_header_form.html index 2ba757f..e7e88f7 100644 --- a/web/balance/tl_ops_web_header_form.html +++ b/web/balance/tl_ops_web_header_form.html @@ -91,7 +91,7 @@ - + - + diff --git a/web/balance/tl_ops_web_param.js b/web/balance/tl_ops_web_param.js index 20526d4..ee33b9e 100644 --- a/web/balance/tl_ops_web_param.js +++ b/web/balance/tl_ops_web_param.js @@ -13,7 +13,7 @@ const tl_ops_web_param_main = function (){ tl_ops_web_param_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_param_event()[type] ? tl_ops_web_param_event()[type].call(this) : ''; diff --git a/web/balance/tl_ops_web_param_form.html b/web/balance/tl_ops_web_param_form.html index 1f585c7..6dd0727 100644 --- a/web/balance/tl_ops_web_param_form.html +++ b/web/balance/tl_ops_web_param_form.html @@ -91,7 +91,7 @@ - + + - + + - + + + + + + + + + +
+
+
+
+ + +
+ +
+ +
+
+
+ + + + + + diff --git a/web/plugins/alert/tl_ops_web_alert.js b/web/plugins/alert/tl_ops_web_alert.js new file mode 100644 index 0000000..2cd371a --- /dev/null +++ b/web/plugins/alert/tl_ops_web_alert.js @@ -0,0 +1,302 @@ +const _table_id_name = "tl-ops-web-alert-table"; +const _search_id_name = "tl-ops-web-alert-search"; +const _add_form_btn_id_name = "tl-ops-web-alert-form-submit"; +const _add_form_id_name = "tl-ops-web-alert-form"; +let res_data = {}; + +const tl_ops_web_alert_main = function (){ + window.$ = layui.$; + window.form = layui.form; + window.table = layui.table; + window.layedit = layui.layedit; + + tl_ops_web_alert_render(); + + //事件操作 + $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ + let type = $(this).data('type'); + tl_ops_web_alert_event()[type] ? tl_ops_web_alert_event()[type].call(this) : ''; + }); + + //搜索 + form.on('submit('+_search_id_name+')', function(data){ + tl_ops_web_alert_reload(data.field); + }); + + //行事件操作 + table.on('tool('+_table_id_name+')', function(obj) { + let type = obj.event; + let data = obj.data; + tl_ops_web_alert_event()[type] ? tl_ops_web_alert_event()[type].call(this, data) : ''; + }); + +}; + +//事件监听定义 +const tl_ops_web_alert_event = function () { + return { + add: tl_ops_web_alert_add, + edit : tl_ops_web_alert_edit, + delete : tl_ops_web_alert_delete + } +}; + +//表格cols +const tl_ops_web_alert_cols = function () { + return [[ + { + type:'checkbox',fixed : 'left', width: "5%" + }, { + field: 'id', title: 'ID',width:"5%" + }, { + field: 'time', title: '耗时阈值', width:"10%" + }, { + field: 'count', title: '触发次数',width:"10%" + }, { + field: 'interval', title: '周期时间',width:"10%" + }, { + field: 'mode', title: '告警模式',width:"15%" + }, { + field: 'target', title: '告警对象',width:"20%" + }, { + field: 'updatetime', title: '更新时间',width:"15%", + }, { + width: "10%", + align: 'center', + fixed: 'right', + title: '操作', + toolbar: '#tl-ops-web-alert-operate' + } + ]]; +}; + + +//表格render +const tl_ops_web_alert_render = function () { + table.render(tl_ajax_data({ + elem: '#'+_table_id_name, + url: '/tlops/alert/get', + cols: tl_ops_web_alert_cols(), + page:true, + needReloadMsg : false, + toolbar: '#tl-ops-web-alert-toolbar', + defaultToolbar: ['filter', 'print', 'exports'], + totalRow: true, //开启合计行 + parseData: function(res){ + if (res.code !== 0){ + return { + "code": res.code, + "msg": res.msg, + "count": 0, + "data": [] + }; + } + res_data = res.data; + let datas = res_data.tl_ops_plugin_time_alert_options; + if (datas === undefined){ datas = []; } + datas = datas.sort(function(a, b){return b.id - a.id}) + return { + "code": res.code, + "msg": res.msg, + "count": datas.length, + "data": datas + }; + } + })); +}; + +//表格reload +const tl_ops_web_alert_reload = function (matcher) { + table.render(tl_ajax_data({ + elem: '#'+_table_id_name, + url: '/tlops/alert/get', + where : matcher, + cols: tl_ops_web_alert_cols(), + page:true, + needReloadMsg : false, + toolbar: '#tl-ops-web-alert-toolbar', + defaultToolbar: ['filter', 'print', 'exports'], + totalRow: true, //开启合计行 + parseData: function(res){ + if (res.code !== 0){ + return { + "code": res.code, + "msg": res.msg, + "count": 0, + "data": [] + }; + } + res_data = res.data; + let datas = res_data.tl_ops_plugin_time_alert_options; + if (datas === undefined){ datas = []; } + datas = datas.sort(function(a, b){return b.id - a.id}) + return { + "code": res.code, + "msg": res.msg, + "count": datas.length, + "data": datas + }; + } + })); +}; + + +//删除alert +const tl_ops_web_alert_delete = function () { + let checkStatus = table.checkStatus(_table_id_name) + ,checkData = checkStatus.data; //得到选中的数据 + + if(checkData.length === 0){ + layer.msg('请选删除择数据'); + return; + } + + let idList = []; + for(let i = 0; i < checkData.length; i++){ + idList.push(checkData[i].id); + } + + let new_list = res_data.tl_ops_plugin_time_alert_options.filter(item=>{ + return !idList.includes(item.id); + }) + + res_data.tl_ops_plugin_time_alert_options = new_list; + + $.ajax(tl_ajax_data({ + url: '/tlops/alert/set', + data : JSON.stringify(res_data), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_alert_reload() + } + })); +} + + +//添加 +const tl_ops_web_alert_add = function () { + let index = layer.open({ + type: 2 + ,title: '添加自定义告警配置' + ,content: 'tl_ops_web_alert_form.html' + ,maxmin: true + ,minStack:false + ,area: ['700px', '600px'] + ,btn: ['确定', '取消'] + ,yes: function(sub_index, layero){ + let iframeWindow = window['layui-layer-iframe'+ sub_index] + ,submit = layero.find('iframe').contents().find('#'+ _add_form_btn_id_name); + + iframeWindow.layui.form.on('submit('+ _add_form_btn_id_name +')', function(data){ + if(!tl_ops_alert_data_add_filter(data)){ + return; + } + $.ajax(tl_ajax_data({ + url: '/tlops/alert/set', + data : JSON.stringify(res_data), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_alert_reload() + } + })); + layer.close(sub_index); + }); + submit.trigger('click'); + } + }); + layer.full(index) +}; + + +//编辑 +const tl_ops_web_alert_edit = function (evtdata) { + let index = layer.open({ + type: 2 + ,title: '编辑告警自定义配置' + ,content: 'tl_ops_web_alert_form.html' + ,maxmin: true + ,minStack:false + ,area: ['700px', '600px'] + ,btn: ['确定', '取消'] + ,yes: function(sub_index, dom){ + let iframeWindow = window['layui-layer-iframe'+ sub_index] + ,submit = dom.find('iframe').contents().find('#'+ _add_form_btn_id_name); + iframeWindow.layui.form.on('submit('+ _add_form_btn_id_name +')', function(data){ + if(!tl_ops_alert_data_edit_filter(data)){ + return; + } + $.ajax(tl_ajax_data({ + url: '/tlops/alert/set', + data : JSON.stringify(res_data), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_alert_reload() + } + })); + layer.close(sub_index); + }); + submit.trigger('click'); + }, + success: function(dom, index) { + let editForm = dom.find('iframe')[0].contentWindow; + editForm.tl_ops_web_alert_form_render(evtdata); + }, + }); + layer.full(index) +}; + + +//过滤新增数据 +const tl_ops_alert_data_add_filter = function( data ) { + delete data.field.file; + for(let key in data.field){ + if(key === 'id'){ + continue; + } + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + if(key === 'time' || key === 'count' || key === 'interval'){ + data.field[key] = parseInt(data.field[key]) + } + } + res_data.tl_ops_plugin_time_alert_options.push(data.field) + + res_data.tl_ops_plugin_time_alert_options.forEach(item=>{ + if( item.LAY_TABLE_INDEX !== undefined){ + delete item.LAY_TABLE_INDEX + } + }) + + return true +} + + +//过滤编辑数据 +const tl_ops_alert_data_edit_filter = function( data ) { + delete data.field.file; + for(let key in data.field){ + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + } + let cur_list = [] + res_data.tl_ops_plugin_time_alert_options.forEach((item)=>{ + if(parseInt(item.id) === parseInt(data.field.id)){ + data.field.change = true; + item = data.field; + } + cur_list.push(item) + }) + res_data.tl_ops_plugin_time_alert_options = cur_list; + + res_data.tl_ops_plugin_time_alert_options.forEach(item=>{ + if( item.LAY_TABLE_INDEX !== undefined){ + delete item.LAY_TABLE_INDEX + } + }) + + return true +} \ No newline at end of file diff --git a/web/plugins/alert/tl_ops_web_alert_form.html b/web/plugins/alert/tl_ops_web_alert_form.html new file mode 100644 index 0000000..afc9271 --- /dev/null +++ b/web/plugins/alert/tl_ops_web_alert_form.html @@ -0,0 +1,97 @@ + + + + + + tl-spb-blog-后台添加配置 + + + + + + + + + + +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ 日志 + 邮件 + 企微机器人 +
+
+
+ +
+ +
+
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/web/plugins/auth/tl_ops_web_auth.html b/web/plugins/auth/tl_ops_web_auth.html new file mode 100644 index 0000000..2601e16 --- /dev/null +++ b/web/plugins/auth/tl_ops_web_auth.html @@ -0,0 +1,116 @@ + + + + + + tl-ops-manage后台 + + + + + + + + + + + +
+
+
+
+
+
+
+ 登录基础配置 +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ 登录拦截配置 +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/web/plugins/auth/tl_ops_web_auth.js b/web/plugins/auth/tl_ops_web_auth.js new file mode 100644 index 0000000..6b15386 --- /dev/null +++ b/web/plugins/auth/tl_ops_web_auth.js @@ -0,0 +1,96 @@ +const _submit_btn_id_name = "tl-ops-web-auth-btn"; +const _auth_form_id_name = "tl-ops-web-auth-form"; +const _user_form_btn_id_name = "tl-ops-web-auth-user-form-submit"; + + +const tl_ops_web_auth_main = function (){ + window.$ = layui.$; + window.form = layui.form; + window.code = layui.code; + window.layedit = layui.layedit; + + //加载数据 + tl_ops_web_auth_render(); + + $("#tl-ops-web-auth-user-btn").on("click",function(){ + tl_ops_web_auth_user_list() + }) + + //提交保存 + form.on('submit('+_submit_btn_id_name+')', function(data){ + tl_ops_web_auth_login_update(data) + }); + +}; + + +//加载 +const tl_ops_web_auth_render = function () { + let index = layer.load(); + $.ajax(tl_ajax_data({ + url: '/tlops/auth/get', + success: (res)=>{ + layer.close(index); + if(res.code === 0){ + let data = res.data + form.val(_auth_form_id_name, data.tl_ops_plugin_auth_login); + }else{ + layer.msg(res.msg) + } + }, + error : (res)=>{ + window.location.reload() + } + })); +}; + + +//更新 +const tl_ops_web_auth_login_update = function (data) { + data = tl_ops_web_auth_login_edit_filter(data) + + $.ajax(tl_ajax_data({ + url: '/tlops/auth/set', + data : JSON.stringify({ + tl_ops_plugin_auth_login : data + }), + contentType : "application/json", + success : (res)=>{ + if(res.code === 0){ + layer.msg("success") + setTimeout(() => { + tl_ops_web_auth_render(); + }, 500); + }else{ + layer.msg(res.msg) + } + } + })); +}; + + +//过滤编辑数据 +const tl_ops_web_auth_login_edit_filter = function( data ) { + delete data.field.file; + + for(let key in data.field){ + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + if(key === 'auth_time' || key === 'code'){ + data.field[key] = parseInt(data.field[key]) + } + if(key === 'code' && (data.field[key] < 200 || data.field[key] > 599)){ + layer.msg(key + "需要在200 ~ 599范围内") + return false; + } + if(key === 'intercept' || key === 'filter'){ + let valueList = data.field[key].split(","); + data.field[key] = valueList + } + } + + return data.field +} + diff --git a/web/plugins/auth/tl_ops_web_auth_user.html b/web/plugins/auth/tl_ops_web_auth_user.html new file mode 100644 index 0000000..7788732 --- /dev/null +++ b/web/plugins/auth/tl_ops_web_auth_user.html @@ -0,0 +1,43 @@ + + + + + tl-ops-manage后台 + + + + + + + + + +
+
+
+
+ + + +
+ +
+ +
+
+
+ + + + + + diff --git a/web/plugins/auth/tl_ops_web_auth_user.js b/web/plugins/auth/tl_ops_web_auth_user.js new file mode 100644 index 0000000..3f90f10 --- /dev/null +++ b/web/plugins/auth/tl_ops_web_auth_user.js @@ -0,0 +1,322 @@ +const _table_id_name = "tl-ops-web-auth-user-table"; +const _search_id_name = "tl-ops-web-auth-user-search"; +const _add_form_btn_id_name = "tl-ops-web-auth-user-form-submit"; +const _add_form_id_name = "tl-ops-web-auth-user-form"; +let res_data = {}; + +const tl_ops_web_auth_user_main = function (){ + window.$ = layui.$; + window.form = layui.form; + window.table = layui.table; + window.layedit = layui.layedit; + + tl_ops_web_auth_user_render(); + + //事件操作 + $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ + let type = $(this).data('type'); + tl_ops_web_auth_user_event()[type] ? tl_ops_web_auth_user_event()[type].call(this) : ''; + }); + + //搜索 + form.on('submit('+_search_id_name+')', function(data){ + tl_ops_web_auth_user_reload(data.field); + }); + + //行事件操作 + table.on('tool('+_table_id_name+')', function(obj) { + let type = obj.event; + let data = obj.data; + tl_ops_web_auth_user_event()[type] ? tl_ops_web_auth_user_event()[type].call(this, data) : ''; + }); + +}; + +//事件监听定义 +const tl_ops_web_auth_user_event = function () { + return { + add: tl_ops_web_auth_user_add, + edit : tl_ops_web_auth_user_edit, + delete : tl_ops_web_auth_user_delete, + config : tl_ops_web_auth_config + } +}; + +//表格cols +const tl_ops_web_auth_user_cols = function () { + return [[ + { + type:'checkbox',fixed : 'left', width: "10%" + }, { + field: 'id', title: 'ID',width:"15%" + }, { + field: 'username', title: '用户名',width:"25%" + }, { + field: 'password', title: '密码', width:"20%" + }, { + field: 'updatetime', title: '更新时间',width:"15%", + }, { + width: "15%", + align: 'center', + fixed: 'right', + title: '操作', + toolbar: '#tl-ops-web-auth-user-operate' + } + ]]; +}; + + + +//用户列表 +const tl_ops_web_auth_config = function(){ + let index = layer.open({ + type: 2 + ,title: '管理登录配置' + ,content: 'tl_ops_web_auth.html' + ,maxmin: true + ,minStack:false + ,area: ['700px', '750px'] + ,end : function () { + tl_ops_web_auth_user_render() + } + }); + layer.full(index); +} + + +//表格render +const tl_ops_web_auth_user_render = function () { + table.render(tl_ajax_data({ + elem: '#'+_table_id_name, + url: '/tlops/auth/get', + cols: tl_ops_web_auth_user_cols(), + page:true, + needReloadMsg : false, + toolbar: '#tl-ops-web-auth-user-toolbar', + defaultToolbar: ['filter', 'print', 'exports'], + totalRow: true, //开启合计行 + parseData: function(res){ + if (res.code !== 0){ + return { + "code": res.code, + "msg": res.msg, + "count": 0, + "data": [] + }; + } + res_data = res.data; + let datas = res_data.tl_ops_plugin_auth_list; + if (datas === undefined){ datas = []; } + datas = datas.sort(function(a, b){return b.id - a.id}) + return { + "code": res.code, + "msg": res.msg, + "count": datas.length, + "data": datas + }; + } + })); +}; + +//表格reload +const tl_ops_web_auth_user_reload = function (matcher) { + table.render(tl_ajax_data({ + elem: '#'+_table_id_name, + url: '/tlops/auth/get', + where : matcher, + cols: tl_ops_web_auth_user_cols(), + page:true, + needReloadMsg : false, + toolbar: '#tl-ops-web-auth-user-toolbar', + defaultToolbar: ['filter', 'print', 'exports'], + totalRow: true, //开启合计行 + parseData: function(res){ + if (res.code !== 0){ + return { + "code": res.code, + "msg": res.msg, + "count": 0, + "data": [] + }; + } + res_data = res.data; + let datas = res_data.tl_ops_plugin_auth_list; + if (datas === undefined){ datas = []; } + datas = datas.sort(function(a, b){return b.id - a.id}) + return { + "code": res.code, + "msg": res.msg, + "count": datas.length, + "data": datas + }; + } + })); +}; + + +//删除ssl +const tl_ops_web_auth_user_delete = function () { + let checkStatus = table.checkStatus(_table_id_name) + ,checkData = checkStatus.data; //得到选中的数据 + + if(checkData.length === 0){ + layer.msg('请选删除择数据'); + return; + } + + let idList = []; + for(let i = 0; i < checkData.length; i++){ + idList.push(checkData[i].id); + } + + let new_list = res_data.tl_ops_plugin_auth_list.filter(item=>{ + return !idList.includes(item.id); + }) + + $.ajax(tl_ajax_data({ + url: '/tlops/auth/set', + data : JSON.stringify({ + tl_ops_plugin_auth_list : new_list + }), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_auth_user_reload() + } + })); +} + + +//添加 +const tl_ops_web_auth_user_add = function () { + let index = layer.open({ + type: 2 + ,title: '添加用户' + ,content: 'tl_ops_web_auth_user_form.html' + ,maxmin: true + ,minStack:false + ,area: ['700px', '600px'] + ,btn: ['确定', '取消'] + ,yes: function(sub_index, layero){ + let iframeWindow = window['layui-layer-iframe'+ sub_index] + ,submit = layero.find('iframe').contents().find('#'+ _add_form_btn_id_name); + + iframeWindow.layui.form.on('submit('+ _add_form_btn_id_name +')', function(data){ + if(!tl_ops_auth_user_data_add_filter(data)){ + return; + } + $.ajax(tl_ajax_data({ + url: '/tlops/auth/set', + data : JSON.stringify({ + tl_ops_plugin_auth_list : res_data.tl_ops_plugin_auth_list + }), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_auth_user_reload() + } + })); + layer.close(sub_index); + }); + submit.trigger('click'); + } + }); + layer.full(index) +}; + + +//编辑 +const tl_ops_web_auth_user_edit = function (evtdata) { + let index = layer.open({ + type: 2 + ,title: '编辑用户' + ,content: 'tl_ops_web_auth_user_form.html' + ,maxmin: true + ,minStack:false + ,area: ['700px', '600px'] + ,btn: ['确定', '取消'] + ,yes: function(sub_index, dom){ + let iframeWindow = window['layui-layer-iframe'+ sub_index] + ,submit = dom.find('iframe').contents().find('#'+ _add_form_btn_id_name); + iframeWindow.layui.form.on('submit('+ _add_form_btn_id_name +')', function(data){ + if(!tl_ops_auth_user_data_edit_filter(data)){ + return; + } + $.ajax(tl_ajax_data({ + url: '/tlops/auth/set', + data : JSON.stringify({ + tl_ops_plugin_auth_list : res_data.tl_ops_plugin_auth_list + }), + contentType : "application/json", + success : (res)=>{ + tl_ops_web_auth_user_reload() + } + })); + layer.close(sub_index); + }); + submit.trigger('click'); + }, + success: function(dom, index) { + let editForm = dom.find('iframe')[0].contentWindow; + editForm.tl_ops_web_auth_user_form_render(evtdata); + }, + }); + layer.full(index) +}; + + +//过滤新增数据 +const tl_ops_auth_user_data_add_filter = function( data ) { + delete data.field.file; + for(let key in data.field){ + if(key === 'id'){ + continue; + } + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + } + res_data.tl_ops_plugin_auth_list.push(data.field) + + res_data.tl_ops_plugin_auth_list.forEach(item=>{ + if( item.LAY_TABLE_INDEX !== undefined){ + delete item.LAY_TABLE_INDEX + } + if( item.LAY_CHECKED !== undefined){ + delete item.LAY_CHECKED + } + }) + + return true +} + + +//过滤编辑数据 +const tl_ops_auth_user_data_edit_filter = function( data ) { + delete data.field.file; + for(let key in data.field){ + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + } + let cur_list = [] + res_data.tl_ops_plugin_auth_list.forEach((item)=>{ + if(parseInt(item.id) === parseInt(data.field.id)){ + data.field.change = true; + item = data.field; + } + cur_list.push(item) + }) + res_data.tl_ops_plugin_auth_list = cur_list; + + res_data.tl_ops_plugin_auth_list.forEach(item=>{ + if( item.LAY_TABLE_INDEX !== undefined){ + delete item.LAY_TABLE_INDEX + } + if( item.LAY_CHECKED !== undefined){ + delete item.LAY_CHECKED + } + }) + + return true +} \ No newline at end of file diff --git a/web/plugins/auth/tl_ops_web_auth_user_form.html b/web/plugins/auth/tl_ops_web_auth_user_form.html new file mode 100644 index 0000000..35cf725 --- /dev/null +++ b/web/plugins/auth/tl_ops_web_auth_user_form.html @@ -0,0 +1,67 @@ + + + + + + tl-spb-blog-后台添加配置 + + + + + + + + + + +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/web/plugins/cluster/tl_ops_web_cluster.html b/web/plugins/cluster/tl_ops_web_cluster.html new file mode 100644 index 0000000..bfa79ac --- /dev/null +++ b/web/plugins/cluster/tl_ops_web_cluster.html @@ -0,0 +1,109 @@ + + + + + tl-ops-manage后台 + + + + + + + + + + + +
+
+
+
+
集群节点列表
+
+
+
+
+
+
+
+ + + + + + + + diff --git a/web/plugins/cluster/tl_ops_web_cluster.js b/web/plugins/cluster/tl_ops_web_cluster.js new file mode 100644 index 0000000..c6a9d3b --- /dev/null +++ b/web/plugins/cluster/tl_ops_web_cluster.js @@ -0,0 +1,113 @@ +const _cluster_view_id_name = "tl-ops-web-cluster-service-view"; +const _cluster_tlp_id_name = "tl-ops-web-cluster-service-tpl"; +const _cluster_form_btn_id_name = "tl-ops-web-cluster-btn"; + +const _add_form_btn_id_name = "tl-ops-web-cluster-form-submit" + +let res_data = {}; + +const tl_ops_web_cluster_main = function (){ + window.$ = layui.$; + window.form = layui.form; + window.table = layui.table; + window.laytpl = layui.laytpl; + window.element = layui.element; + + axios.get("/tlops/cluster/get").then((res)=>{ + res = res.data; + if(res.code === 0){ + res_data = res.data; + let current = res_data.tl_ops_plugin_sync_cluster_current + let other = res_data.tl_ops_plugin_sync_cluster_other + other.push(current) + tl_ops_web_cluster_render(other) + } + }) +}; + +const tl_ops_web_cluster_render = function( data ){ + laytpl(document.getElementById(_cluster_tlp_id_name).innerHTML).render((()=>{ + return data; + })(), (html)=>{ + document.getElementById(_cluster_view_id_name).innerHTML = html; + }); + form.render() +} + + +//管理节点 +const tl_ops_web_cluster_edit = function (node) { + let index = layer.open({ + type: 2 + ,title: '管理【'+node.ip+'】节点' + ,content: 'tl_ops_web_cluster_form.html?id='+node.id + ,maxmin: true + ,minStack:false + ,area: ['650px', '650px'] + ,btn: ['确定', '取消'] + ,yes: function(index, dom){ + let iframeWindow = window['layui-layer-iframe'+ index] + ,submit = dom.find('iframe').contents().find('#'+ _add_form_btn_id_name); + + iframeWindow.layui.form.on('submit('+ _add_form_btn_id_name +')', function(data){ + // if(!tl_ops_cluster_data_edit_filter(data)){ + // return; + // } + // let updateInfo = {} + // updateInfo[node.id] = res_data[name] + + // $.ajax(tl_ajax_data({ + // url: '/tlops/cluster/set', + // data : JSON.stringify(updateInfo), + // contentType : "application/json", + // success : (res)=>{ + // layer.msg(res.msg) + // tl_ops_web_cluster_render() + // } + // })); + layer.close(index); + }); + submit.trigger('click'); + }, + success: function(dom, index) { + // let evtdata = res_data[name] + // if (evtdata){ + // let editForm = dom.find('iframe')[0].contentWindow; + // editForm.tl_ops_web_cluster_form_render(evtdata); + // }else{ + // layer.msg("渲染编辑框失败") + // } + }, + }); + if(parent.window.tl_side_screen() < 1){ + layer.full(index); + } +}; + + +//过滤数据 +const tl_ops_cluster_data_edit_filter = function( data ) { + let name = data.field.name + delete data.field.file; + delete data.field.err_name; + delete data.field.content_sub; + delete data.field.name; + for(let key in data.field){ + if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){ + layer.msg(key + "未填写") + return false; + } + if(key === 'code'){ + data.field[key] = parseInt(data.field[key]) + } + if(key === 'code'){ + if(data.field[key] < 200 || data.field[key] > 599){ + layer.msg(key + "应该在200~599范围内") + return false; + } + } + } + + res_data[name] = data.field; + return true; +} \ No newline at end of file diff --git a/web/plugins/cluster/tl_ops_web_cluster_form.html b/web/plugins/cluster/tl_ops_web_cluster_form.html new file mode 100644 index 0000000..6f49e83 --- /dev/null +++ b/web/plugins/cluster/tl_ops_web_cluster_form.html @@ -0,0 +1,80 @@ + + + + + + tl-ops-manage后台 + + + + + + + + + +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/web/plugins/log/tl_ops_web_log.html b/web/plugins/log/tl_ops_web_log.html new file mode 100644 index 0000000..ae2f4a9 --- /dev/null +++ b/web/plugins/log/tl_ops_web_log.html @@ -0,0 +1 @@ +日志分析管理页面 \ No newline at end of file diff --git a/web/plugins/log/tl_ops_web_log.js b/web/plugins/log/tl_ops_web_log.js new file mode 100644 index 0000000..e69de29 diff --git a/web/plugins/log/tl_ops_web_log_form.html b/web/plugins/log/tl_ops_web_log_form.html new file mode 100644 index 0000000..e69de29 diff --git a/web/plugins/ssl/tl_ops_web_ssl.html b/web/plugins/ssl/tl_ops_web_ssl.html index ef6e576..3ffbd74 100644 --- a/web/plugins/ssl/tl_ops_web_ssl.html +++ b/web/plugins/ssl/tl_ops_web_ssl.html @@ -34,7 +34,7 @@ - + diff --git a/web/plugins/ssl/tl_ops_web_ssl.js b/web/plugins/ssl/tl_ops_web_ssl.js index a891ef7..239c877 100644 --- a/web/plugins/ssl/tl_ops_web_ssl.js +++ b/web/plugins/ssl/tl_ops_web_ssl.js @@ -12,7 +12,7 @@ const tl_ops_web_ssl_main = function (){ tl_ops_web_ssl_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_ssl_event()[type] ? tl_ops_web_ssl_event()[type].call(this) : ''; diff --git a/web/plugins/ssl/tl_ops_web_ssl_form.html b/web/plugins/ssl/tl_ops_web_ssl_form.html index 454738e..2a7fe71 100644 --- a/web/plugins/ssl/tl_ops_web_ssl_form.html +++ b/web/plugins/ssl/tl_ops_web_ssl_form.html @@ -51,7 +51,7 @@ - + - + diff --git a/web/service/tl_ops_web_service.js b/web/service/tl_ops_web_service.js index 2e988f2..8abd9eb 100644 --- a/web/service/tl_ops_web_service.js +++ b/web/service/tl_ops_web_service.js @@ -24,7 +24,7 @@ const tl_ops_web_service_main = function (){ } }); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_service_event()[type] ? tl_ops_web_service_event()[type].call(this) : ''; diff --git a/web/service/tl_ops_web_service_form.html b/web/service/tl_ops_web_service_form.html index 61b8115..c9dee6f 100644 --- a/web/service/tl_ops_web_service_form.html +++ b/web/service/tl_ops_web_service_form.html @@ -35,7 +35,7 @@ - + - + diff --git a/web/service/tl_ops_web_service_node.js b/web/service/tl_ops_web_service_node.js index 9882150..c724b7e 100644 --- a/web/service/tl_ops_web_service_node.js +++ b/web/service/tl_ops_web_service_node.js @@ -20,7 +20,7 @@ const tl_ops_web_service_node_main = function (){ //首次渲染 tl_ops_web_service_node_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_service_node_event()[type] ? tl_ops_web_service_node_event()[type].call(this) : ''; diff --git a/web/service/tl_ops_web_service_node_form.html b/web/service/tl_ops_web_service_node_form.html index 770a4cd..aab269d 100644 --- a/web/service/tl_ops_web_service_node_form.html +++ b/web/service/tl_ops_web_service_node_form.html @@ -63,7 +63,7 @@ - + - + diff --git a/web/store/tl_ops_web_store_view.html b/web/store/tl_ops_web_store_view.html index 3cadc7c..964b7f0 100644 --- a/web/store/tl_ops_web_store_view.html +++ b/web/store/tl_ops_web_store_view.html @@ -45,7 +45,7 @@

{{item.time}}

- + - + - + diff --git a/web/waf/tl_ops_web_waf_api.html b/web/waf/tl_ops_web_waf_api.html index 3158021..f3dae55 100644 --- a/web/waf/tl_ops_web_waf_api.html +++ b/web/waf/tl_ops_web_waf_api.html @@ -40,7 +40,7 @@ - + diff --git a/web/waf/tl_ops_web_waf_api.js b/web/waf/tl_ops_web_waf_api.js index 1b2f05b..80e1660 100644 --- a/web/waf/tl_ops_web_waf_api.js +++ b/web/waf/tl_ops_web_waf_api.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_api_main = function (){ tl_ops_web_waf_api_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_api_event()[type] ? tl_ops_web_waf_api_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_api_form.html b/web/waf/tl_ops_web_waf_api_form.html index b29abb0..95194e1 100644 --- a/web/waf/tl_ops_web_waf_api_form.html +++ b/web/waf/tl_ops_web_waf_api_form.html @@ -80,7 +80,7 @@ - + - + diff --git a/web/waf/tl_ops_web_waf_cc.js b/web/waf/tl_ops_web_waf_cc.js index 06b4ca5..78e311f 100644 --- a/web/waf/tl_ops_web_waf_cc.js +++ b/web/waf/tl_ops_web_waf_cc.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_cc_main = function (){ tl_ops_web_waf_cc_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_cc_event()[type] ? tl_ops_web_waf_cc_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_cc_form.html b/web/waf/tl_ops_web_waf_cc_form.html index acf4054..142a7af 100644 --- a/web/waf/tl_ops_web_waf_cc_form.html +++ b/web/waf/tl_ops_web_waf_cc_form.html @@ -80,7 +80,7 @@ - + - + diff --git a/web/waf/tl_ops_web_waf_cookie.js b/web/waf/tl_ops_web_waf_cookie.js index 72c54e6..cc5fb7d 100644 --- a/web/waf/tl_ops_web_waf_cookie.js +++ b/web/waf/tl_ops_web_waf_cookie.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_cookie_main = function (){ tl_ops_web_waf_cookie_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_cookie_event()[type] ? tl_ops_web_waf_cookie_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_cookie_form.html b/web/waf/tl_ops_web_waf_cookie_form.html index 465c05a..2716d57 100644 --- a/web/waf/tl_ops_web_waf_cookie_form.html +++ b/web/waf/tl_ops_web_waf_cookie_form.html @@ -80,7 +80,7 @@ - + + - + diff --git a/web/waf/tl_ops_web_waf_header.js b/web/waf/tl_ops_web_waf_header.js index 9e935f1..b01830e 100644 --- a/web/waf/tl_ops_web_waf_header.js +++ b/web/waf/tl_ops_web_waf_header.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_header_main = function (){ tl_ops_web_waf_header_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_header_event()[type] ? tl_ops_web_waf_header_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_header_form.html b/web/waf/tl_ops_web_waf_header_form.html index ec600e0..afcb55a 100644 --- a/web/waf/tl_ops_web_waf_header_form.html +++ b/web/waf/tl_ops_web_waf_header_form.html @@ -88,7 +88,7 @@ - + - + diff --git a/web/waf/tl_ops_web_waf_ip.js b/web/waf/tl_ops_web_waf_ip.js index 2ae00d5..4b236bf 100644 --- a/web/waf/tl_ops_web_waf_ip.js +++ b/web/waf/tl_ops_web_waf_ip.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_ip_main = function (){ tl_ops_web_waf_ip_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_ip_event()[type] ? tl_ops_web_waf_ip_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_ip_form.html b/web/waf/tl_ops_web_waf_ip_form.html index bfe0638..0059802 100644 --- a/web/waf/tl_ops_web_waf_ip_form.html +++ b/web/waf/tl_ops_web_waf_ip_form.html @@ -80,7 +80,7 @@ - + - + diff --git a/web/waf/tl_ops_web_waf_param.js b/web/waf/tl_ops_web_waf_param.js index 8a7a024..5a77547 100644 --- a/web/waf/tl_ops_web_waf_param.js +++ b/web/waf/tl_ops_web_waf_param.js @@ -12,7 +12,7 @@ const tl_ops_web_waf_param_main = function (){ tl_ops_web_waf_param_render(); - //表格外部事件操作 + //事件操作 $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){ let type = $(this).data('type'); tl_ops_web_waf_param_event()[type] ? tl_ops_web_waf_param_event()[type].call(this) : ''; diff --git a/web/waf/tl_ops_web_waf_param_form.html b/web/waf/tl_ops_web_waf_param_form.html index f54dd0d..5f7f472 100644 --- a/web/waf/tl_ops_web_waf_param_form.html +++ b/web/waf/tl_ops_web_waf_param_form.html @@ -80,7 +80,7 @@ - +