Fixes #4709 unexpected new device plugin (#4728)

* Added unexpected new device plugin, needs review

* Fixes #4709 unexpected new device plugin

Co-authored-by: matteo <biscosi@ntop.org>
This commit is contained in:
Matteo Biscosi 2020-11-16 12:41:19 +01:00 committed by GitHub
parent 4990491d06
commit a8cf3836d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 222 additions and 24 deletions

View file

@ -613,7 +613,7 @@ const ItemsList = (gui, hooks, script_subdir, script_key) => {
const $table_editor = $("#script-config-editor");
const render_template = () => {
const enabled = hooks.all ? hooks.all.enabled : hooks.min.enabled
const $component_container = $(`<tr></tr>`);
const callback_checkbox = function (e) {
@ -629,15 +629,14 @@ const ItemsList = (gui, hooks, script_subdir, script_key) => {
};
const $checkbox_enabled = generate_checkbox_enabled(
'itemslist-checkbox', hooks.all.enabled, callback_checkbox
'itemslist-checkbox', enabled, callback_checkbox
);
const items_list = hooks.all.script_conf.items || [];
const $text_area = $(`
const items_list = hooks.all ? hooks.all.script_conf.items : (hooks.min.script_conf.items || []); const $text_area = $(`
<td>
<div class='form-group template w-100'>
<textarea
${!hooks.all.enabled ? "readonly" : ""}
${!enabled ? "readonly" : ""}
name='items-list'
id='itemslist-textarea'
class="w-100 form-control"
@ -662,9 +661,9 @@ const ItemsList = (gui, hooks, script_subdir, script_key) => {
const textarea_value = $('#itemslist-textarea').val().trim();
const items_list = textarea_value ? textarea_value.split(',').map(x => x.trim()) : [];
const hook = (hooks.all === undefined) ? "min" : "all";
const template_data = {
all: {
[hook]: {
enabled: hook_enabled,
script_conf: {
items: items_list
@ -682,7 +681,7 @@ const ItemsList = (gui, hooks, script_subdir, script_key) => {
reset_script_defaults(script_key, script_subdir, (reset_data) => {
const items_list = reset_data.hooks.all.script_conf.items;
const enabled = reset_data.hooks.all.enabled;
const enabled = reset_data.hooks.all ? reset_data.hooks.all.enabled : reset_data.hooks.min.enabled;
// set textarea value with default's one
$('#itemslist-textarea').val(items_list.join(','));