From 8d38f6490cc6874f957465b72d449001c5e3f20a Mon Sep 17 00:00:00 2001 From: Supun94 Date: Fri, 30 Jun 2017 16:31:43 +0530 Subject: [PATCH] MQTT Dashboard UI code refactor --- .../public/js/topic-listing.js | 47 +------------------ .../app/pages/cdmf.page.topic/topic.hbs | 2 +- .../app/pages/cdmf.page.topic/topic.js | 4 +- 3 files changed, 5 insertions(+), 48 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/public/js/topic-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/public/js/topic-listing.js index 007af1de90..2c9291e694 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/public/js/topic-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/public/js/topic-listing.js @@ -28,24 +28,6 @@ function InitiateViewOption(url) { } } -(function () { - var cache = {}; - var validateAndReturn = function (value) { - return (value == undefined || value == null) ? "Unspecified" : value; - }; - Handlebars.registerHelper("deviceMap", function (device) { - device.owner = validateAndReturn(device.owner); - device.ownership = validateAndReturn(device.ownership); - var arr = device.properties; - if (arr) { - device.properties = arr.reduce(function (total, current) { - total[current.name] = validateAndReturn(current.value); - return total; - }, {}); - } - }); -})(); - /* * Setting-up global variables. */ @@ -68,13 +50,10 @@ $(document).ready(function () { return permissionSet[permission]; }; - deviceListing = $("#device-listing"); - currentUser = deviceListing.data("current-user"); - name = getParameterByName("name"); - /* Adding selected class for selected devices */ + /* Adding selected class for selected topics */ $(deviceCheckbox).each(function () { addDeviceSelectedClass(this); }); @@ -103,16 +82,6 @@ function addDeviceSelectedClass(checkbox) { function loadTopics(searchType, searchParam) { - function getDeviceTypeThumb(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - return deviceTypes[i].thumb; - } - } - return type; - } - var serviceURL; if ($.hasPermission("VIEW_TOPICS")) { serviceURL = "/api/mqtt-topics/v1.0/admin/topics"; @@ -284,7 +253,7 @@ $(document).ready(function () { loadTopics(); $(".dataTables_toolbar").css("display", "none"); - /* for device list sorting drop down */ + /* for topic list sorting drop down */ $(".ctrl-filter-type-switcher").popover({ html: true, content: function () { @@ -310,13 +279,6 @@ $(document).ready(function () { } }); - var table = $('#example').DataTable(); - -// #myInput is a element - $('#myInput').on( 'keyup', function () { - table.search( this.value ).draw(); - } ); - }); var modalPopup = ".modal"; @@ -356,8 +318,3 @@ function getParameterByName(name) { results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } - -function disableSelectButtons() { - var x = document.getElementById('toggle-selectable'); - x.display = 'none'; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs index ccbe352057..ea85b67cb3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs @@ -28,7 +28,7 @@
  • - + Dashboard
  • diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js index d5f4374303..13cd619d8a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js @@ -37,8 +37,8 @@ function onRequest(context) { } viewModel.currentUser = currentUser; var deviceCount = 1; - viewModel.deviceCount = deviceCount; - var utility = require("/app/modules/utility.js").utility; + viewModel.deviceCount = deviceCount; + var utility = require("/app/modules/utility.js").utility; } return viewModel; }