mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-10 00:42:14 +00:00
Adds lifetime selection button to CP users
This commit is contained in:
parent
40b258e43e
commit
844a34df92
3 changed files with 40 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
local host_pools_utils = require 'host_pools_utils'
|
||||
require("prefs_utils")
|
||||
|
||||
local messages = {ntopng="Add ntopng User", captive_portal="Add Captive Portal User"}
|
||||
|
||||
|
|
@ -152,13 +153,36 @@ else -- a captive portal user is being added
|
|||
<label class="form-label">Authentication Lifetime</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline"><input type="radio" id="lifetime_unlimited" name="lifetime_unlimited" checked>Unlimited</label>
|
||||
<label class="radio-inline"><input type="radio" id="lifetime_limited" name="lifetime_limited">Expires at midnight</label>
|
||||
<label class="radio-inline"><input type="radio" id="lifetime_limited" name="lifetime_limited">Expires at</label>
|
||||
</div>
|
||||
<!-- optionally allow to specify a certain number of days
|
||||
<input id="lifetime_days" name="lifetime_days" type="number" min="1" max="100" value="" class="form-control pull-right text-right" style="display: inline; width: 8em; padding-right: 1em;" disabled required>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6 has-feedback">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 has-feedback text-center">
|
||||
|
||||
<table class="form-group" id="lifetime_selection_table">
|
||||
<tr>
|
||||
|
||||
<td style="vertical-align:top;">
|
||||
]]
|
||||
-- require("prefs_utils")
|
||||
local res = prefsResolutionButtons("hd", 3600)
|
||||
tprint(res)
|
||||
print[[
|
||||
</td>
|
||||
<td style="padding-left: 2em;">
|
||||
<input class="form-control text-right" style="display:inline; width:5em; padding-right:1em;" name="lifetime_secs" id="lifetime_secs" type="number" data-min="3600" value="]] print(tostring(res)) print[[">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
@ -197,19 +221,18 @@ print[[
|
|||
</form>
|
||||
<script>
|
||||
|
||||
<!-- use the following scripts when the user lifetime can be specified in days
|
||||
$("#lifetime_selection_table input,label").attr("disabled", "disabled")
|
||||
|
||||
$("#lifetime_unlimited").click(function(){
|
||||
$("#lifetime_days").prop("disabled", true);
|
||||
$("#lifetime_selection_table input,label").attr("disabled", "disabled")
|
||||
$("#lifetime_limited").removeAttr("checked");
|
||||
});
|
||||
|
||||
$("#lifetime_limited").click(function() {
|
||||
$("#lifetime_days").prop("disabled", false);
|
||||
$("#lifetime_selection_table input,label").removeAttr("disabled")
|
||||
$("#lifetime_unlimited").removeAttr("checked");
|
||||
});
|
||||
|
||||
-->
|
||||
|
||||
var frmadduser = $('#form_add_user');
|
||||
|
||||
function resetAddUserForm() {
|
||||
|
|
|
|||
|
|
@ -2623,16 +2623,22 @@ function makeResolutionButtons(fmt_to_data, ctrl_id, fmt, value, extra)
|
|||
function resol_selector_on_form_submit(event) {
|
||||
var form = $(this);
|
||||
|
||||
if (event.isDefaultPrevented()) /* isDefaultPrevented is true when the form is invalid */
|
||||
return false;
|
||||
]]
|
||||
|
||||
if false then
|
||||
js_init_code = js_init_code..[[
|
||||
if (event.isDefaultPrevented()) /* isDefaultPrevented is true when the form is invalid */
|
||||
return false;
|
||||
]]
|
||||
end
|
||||
|
||||
js_init_code = js_init_code..[[
|
||||
$.each(_resol_inputs, function(i, elem) {
|
||||
var selected = $(elem).find("input[checked]");
|
||||
var input = resol_selector_get_input(selected);
|
||||
|
||||
/* remove added input names */
|
||||
$(elem).find("input").removeAttr("name");
|
||||
|
||||
/* transform in raw units */
|
||||
var new_input = $("<input type=\"hidden\"/>");
|
||||
new_input.attr("name", input.attr("name"));
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ end
|
|||
local options_script_loaded = false
|
||||
local options_ctr = 0
|
||||
|
||||
local function prefsResolutionButtons(fmt, value)
|
||||
function prefsResolutionButtons(fmt, value)
|
||||
local fmt_to_data = {
|
||||
["s"] = {label="Secs", value=1},
|
||||
["m"] = {label="Mins", value=60},
|
||||
|
|
@ -35,6 +35,7 @@ local function prefsResolutionButtons(fmt, value)
|
|||
|
||||
local ctrl_id = "options_group_" .. options_ctr
|
||||
options_ctr = options_ctr + 1
|
||||
|
||||
local res = makeResolutionButtons(fmt_to_data, ctrl_id, fmt, value, {classes={"pull-right"}})
|
||||
|
||||
print(res.html)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue