mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
parent
c43466412c
commit
b32541bcdf
1 changed files with 10 additions and 15 deletions
|
|
@ -1221,7 +1221,7 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
local function build_on_off_toggle(submit_field)
|
||||
local function build_on_off_toggle(submit_field, active)
|
||||
local on_value = "on"
|
||||
local off_value = "off"
|
||||
local value
|
||||
|
|
@ -1231,7 +1231,9 @@ local function build_on_off_toggle(submit_field)
|
|||
local on_active
|
||||
local off_active
|
||||
|
||||
tprint(active)
|
||||
if active then
|
||||
|
||||
value = on_value
|
||||
on_active = "btn-"..on_color.." active"
|
||||
off_active = "btn-default"
|
||||
|
|
@ -1241,14 +1243,12 @@ local function build_on_off_toggle(submit_field)
|
|||
off_active = "btn-"..off_color.." active"
|
||||
end
|
||||
|
||||
local on_active = "btn-default"
|
||||
local off_active = "btn-"..off_color.." active"
|
||||
|
||||
return [[
|
||||
<div class="btn-group btn-toggle">
|
||||
<button type="button" onclick="]]..submit_field..[[_on_fn()" id="]]..submit_field..[[_on_id" class="btn btn-sm ]]..on_active..[[">On</button>
|
||||
<button type="button" onclick="]]..submit_field..[[_off_fn()" id="]]..submit_field..[[_off_id" class="btn btn-sm ]]..off_active..[[">Off</button>
|
||||
</div>
|
||||
<input type=hidden id="]]..submit_field..[[_input" name="]]..submit_field..[[" value="]]..value..[["/>
|
||||
<script>
|
||||
|
||||
|
||||
|
|
@ -1259,6 +1259,7 @@ function ]]..submit_field..[[_on_fn() {
|
|||
class_off.removeAttribute("class");
|
||||
class_on.setAttribute("class", "btn btn-sm btn-]]..on_color..[[ active");
|
||||
class_off.setAttribute("class", "btn btn-sm btn-default");
|
||||
$("#]]..submit_field..[[_input").val("]]..on_value..[[").trigger('change');
|
||||
}
|
||||
|
||||
function ]]..submit_field..[[_off_fn() {
|
||||
|
|
@ -1268,6 +1269,7 @@ function ]]..submit_field..[[_off_fn() {
|
|||
class_off.removeAttribute("class");
|
||||
class_on.setAttribute("class", "btn btn-sm btn-default");
|
||||
class_off.setAttribute("class", "btn btn-sm btn-]]..off_color..[[ active");
|
||||
$("#]]..submit_field..[[_input").val("]]..off_value..[[").trigger('change');
|
||||
}
|
||||
</script>
|
||||
]]
|
||||
|
|
@ -1276,23 +1278,16 @@ end
|
|||
-- ##############################################
|
||||
|
||||
function alerts_api.checkbox_input_builder(gui_conf, input_id, value)
|
||||
return(string.format([[
|
||||
<input type="hidden", value="off", name="%s"/>
|
||||
<input type="checkbox" name="%s" %s/>
|
||||
]], input_id, input_id, ternary(value, "checked", "")))
|
||||
local built = build_on_off_toggle(input_id, value == 1)
|
||||
|
||||
return built
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function alerts_api.flow_checkbox_input_builder(check_module)
|
||||
local input_id = string.format("enabled_%s", check_module.key)
|
||||
|
||||
local built = string.format([[
|
||||
%s
|
||||
<input type="hidden" value="off", name="%s"/>
|
||||
<input type="checkbox" name="%s" %s/>
|
||||
]], "", -- build_on_off_toggle(check_module.key),
|
||||
input_id, input_id, ternary(check_module.conf.enabled, "checked", ""))
|
||||
local built = build_on_off_toggle(input_id, check_module.conf.enabled)
|
||||
|
||||
return built
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue