From a8ed1ef5a94e2821c431956f92012104c86d0160 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 11 Nov 2019 21:19:44 +0100 Subject: [PATCH] Update sensor configuration to use util function --- resource/web/js/hal.js | 25 +++++++++++++--------- resource/web/sensor_config.tmpl | 38 +++++++++------------------------ 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/resource/web/js/hal.js b/resource/web/js/hal.js index a85bb4de..8f290c34 100755 --- a/resource/web/js/hal.js +++ b/resource/web/js/hal.js @@ -130,22 +130,27 @@ function getChartData(json){ ////////////// Dynamic forms var dynamicConf = {}; -function initDynamicModalForm(modalId, formTemplateId, templateID){ +function initDynamicModalForm(modalId, formTemplateId = null, templateID = null){ // read in all configurations into global variable (to skip naming issues) - dynamicConf[formTemplateId] = []; - $("#"+templateID+" div").each(function(){ - dynamicConf[formTemplateId][$(this).attr("id")] = $(this).html(); - }); - // Update dynamic inputs - $("#"+modalId+" select[name=type]").change(function(){ - $("#"+modalId+" #"+formTemplateId).html(dynamicConf[formTemplateId][$(this).val()]); - }); + if (formTemplateId != null) { + dynamicConf[formTemplateId] = []; + $("#"+templateID+" div").each(function(){ + dynamicConf[formTemplateId][$(this).attr("id")] = $(this).html(); + }); + // Update dynamic inputs + $("#"+modalId+" select[name=type]").change(function(){ + $("#"+modalId+" #"+formTemplateId).html(dynamicConf[formTemplateId][$(this).val()]); + }); + } + // click event $("#"+modalId).on('show.bs.modal', function (event) { var button = $(event.relatedTarget); var modal = $(this); + // Reset all inputs - modal.find("#"+formTemplateId).empty(); // clear form div + if (formTemplateId != null) + modal.find("#"+formTemplateId).empty(); // clear form div // select dynamic form var selector = modal.find("select[name=type]"); diff --git a/resource/web/sensor_config.tmpl b/resource/web/sensor_config.tmpl index e4dd0a49..789ec4c5 100755 --- a/resource/web/sensor_config.tmpl +++ b/resource/web/sensor_config.tmpl @@ -4,7 +4,7 @@
Local Sensors
-

List of local sensors.

+

This is a local list of sensors connected to this node.

@@ -13,8 +13,8 @@ @@ -30,8 +30,7 @@
-
@@ -130,8 +128,7 @@
-
Public Configuration -
-
Hostname Port -