From 8ca85f1177a4be2cb2289ce916f77e0cdad964e8 Mon Sep 17 00:00:00 2001 From: Supun94 Date: Fri, 28 Apr 2017 03:11:48 +0530 Subject: [PATCH 1/4] Adding UI permissions for topics view --- .../main/resources/jaggeryapps/devicemgt/app/conf/config.json | 1 + .../devicemgt/app/modules/business-controllers/user.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index f6120a5c146..b8934f0f164 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -64,6 +64,7 @@ "scopes": [ "perm:sign-csr", "perm:admin:devices:view", + "perm:admin:topics:view", "perm:roles:add", "perm:roles:add-users", "perm:roles:update", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index f8c420d58c6..0666bb653d4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -615,6 +615,9 @@ var userModule = function () { if (publicMethods.isAuthorized("/permission/admin/device-mgt")) { permissions["IS_ADMIN"] = true; } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/topics/view")) { + permissions["VIEW_TOPICS"] = true; + } return permissions; }; From df06953069f23ce72d3a1f02c94976eb32ffcbdb Mon Sep 17 00:00:00 2001 From: Supun94 Date: Tue, 13 Jun 2017 10:29:10 +0530 Subject: [PATCH 2/4] Adding MQTT pagination details --- .../integration/client/OAuthRequestInterceptor.java | 1 + .../config/pagination/PaginationConfiguration.java | 11 +++++++++++ .../src/main/resources/conf/cdm-config.xml | 1 + 3 files changed, 13 insertions(+) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java index d9afb2aa55e..a7fe693c970 100755 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/pagination/PaginationConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/pagination/PaginationConfiguration.java index 46e16aff6dc..d2b1ea55180 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/pagination/PaginationConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/pagination/PaginationConfiguration.java @@ -32,6 +32,7 @@ public class PaginationConfiguration { private int operationListPageSize; private int notificationListPageSize; private int activityListPageSize; + private int topicListPageSize; public int getDeviceListPageSize() { return deviceListPageSize; @@ -78,4 +79,14 @@ public class PaginationConfiguration { this.activityListPageSize = activityListPageSize; } + public int getTopicListPageSize() { + return deviceListPageSize; + } + + @XmlElement(name = "TopicListPageSize", required = true) + public void setTopicListPageSize(int topicListPageSize) { + this.topicListPageSize = topicListPageSize; + } + + } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index ec27d993e3a..81caae253ca 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -65,6 +65,7 @@ 20 20 20 + 20 From 022e1eefe363be95265aa4894fc707566a7a60f5 Mon Sep 17 00:00:00 2001 From: Supun94 Date: Fri, 30 Jun 2017 15:55:56 +0530 Subject: [PATCH 3/4] Adding MQTT Dashboard UI page --- .../public/js/topic-listing.js | 363 ++++++++++++++++++ .../app/pages/cdmf.page.topic/topic.hbs | 268 +++++++++++++ .../app/pages/cdmf.page.topic/topic.js | 44 +++ .../app/pages/cdmf.page.topic/topic.json | 5 + 4 files changed, 680 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/public/js/topic-listing.js create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.json 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 new file mode 100644 index 00000000000..007af1de903 --- /dev/null +++ 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 @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Following function would execute + * when a user clicks on the list item + * initial mode and with out select mode. + */ +function InitiateViewOption(url) { + if (!$(".select-enable-btn").text() == "Select" && !$(this).hasClass("btn")) { + url = $(this).parent().data("url"); + $(location).attr('href', 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. + */ +var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; +var assetContainer = "#ast-container"; + +var deviceListing, currentUser,name; + +/* + * DOM ready functions. + */ +$(document).ready(function () { + + var permissionSet = {}; + $.setPermission = function (permission) { + permissionSet[permission] = true; + }; + + $.hasPermission = function (permission) { + return permissionSet[permission]; + }; + + deviceListing = $("#device-listing"); + currentUser = deviceListing.data("current-user"); + + name = getParameterByName("name"); + + + /* Adding selected class for selected devices */ + $(deviceCheckbox).each(function () { + addDeviceSelectedClass(this); + }); + + /* for device list sorting drop down */ + $(".ctrl-filter-type-switcher").popover({ + html: true, + content: function () { + return $("#content-filter-types").html(); + } + }); +}); + +/* + * Add selected style class to the parent element function. + * + * @param checkbox: Selected checkbox + */ +function addDeviceSelectedClass(checkbox) { + if ($(checkbox).is(":checked")) { + $(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select"); + } else { + $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); + } +} + +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"; + console.log("serviceURL------"+serviceURL); + } else { + $("#loading-content").remove(); + $('#device-table').addClass('hidden'); + $('#device-listing-status-msg').text('Permission denied.'); + $("#device-listing-status").removeClass(' hidden'); + return; + } + + var columns = [ + { + targets: 0, + data: 'localSubscribedQueueOrTopicName', + class: 'remove-padding-top viewEnabledIcon', + render: function (data, type, row, meta) { + return '
'; + } + }, + { + targets: 1, + data: 'localSubscribedQueueOrTopicName', + class: 'remove-padding-top viewEnabledIcon', + }, + { + targets: 2, + data: 'localNumberOfMessagesRemainingForSubscriber', + class: 'remove-padding-top viewEnabledIcon', + }, + { + targets: 3, + data: 'localActive', + class: 'remove-padding-top viewEnabledIcon', + }, + { + targets: 4, + data: 'localDurable', + class: 'remove-padding-top viewEnabledIcon', + }, + { + targets: 5, + data: 'localSubscriberQueueName', + class: 'remove-padding-top viewEnabledIcon', + }, + { + targets: 6, + data: 'localSubscriptionIdentifier', + class: 'remove-padding-top viewEnabledIcon', + } + ]; + + var fnCreatedRow = function (row, data, dataIndex) { + $(row).attr('data-type', 'selectable'); + $(row).attr('localSubscribedQueueOrTopicName', htmlspecialchars(data.localSubscribedQueueOrTopicName)); + $(row).attr('localNumberOfMessagesRemainingForSubscriber', htmlspecialchars(data.localNumberOfMessagesRemainingForSubscriber)); + $(row).attr('data-url', context + '/device/' + htmlspecialchars(data.localSubscribedQueueOrTopicName) + '?id=' + htmlspecialchars(data.localNumberOfMessagesRemainingForSubscriber)); + + var topicName = htmlspecialchars(data.localSubscribedQueueOrTopicName); + var remainingMesgCount = htmlspecialchars(data.localNumberOfMessagesRemainingForSubscriber); + var isActive = htmlspecialchars(data.localActive); + var isDurable = htmlspecialchars(data.localDurable); + var localSubscriberQueueName = htmlspecialchars(data.localSubscriberQueueName); + var subscriptionIdentifier = htmlspecialchars(data.localSubscriptionIdentifier); + $.each($('td', row), function (colIndex) { + switch (colIndex) { + case 1: + $(this).attr('data-grid-label', "Topic Name"); + $(this).attr('data-search', topicName); + $(this).attr('data-display', topicName); + break; + case 2: + $(this).attr('data-grid-label', "Remaining Messages"); + $(this).attr('data-search', remainingMesgCount); + $(this).attr('data-display', remainingMesgCount); + break; + case 3: + $(this).attr('data-grid-label', "Active"); + $(this).attr('data-search', isActive); + $(this).attr('data-display', isActive); + break; + case 4: + $(this).attr('data-grid-label', "Durable"); + $(this).attr('data-search', isDurable); + $(this).attr('data-display', isDurable); + break; + case 5: + $(this).attr('data-grid-label', "Subscriber Queue Name"); + $(this).attr('data-search', localSubscriberQueueName); + $(this).attr('data-display', localSubscriberQueueName); + break; + case 6: + $(this).attr('data-grid-label', "SubscriptionIdentifier"); + $(this).attr('data-search', subscriptionIdentifier); + $(this).attr('data-display', subscriptionIdentifier); + break; + } + }); + }; + + function htmlspecialchars(text) { + return jQuery('
').text(text).html(); + } + + var dataFilter = function (data) { + data = JSON.parse(data); + var objects = []; + $(data.subscriptions).each(function (index) { + objects.push( + { + localSubscribedQueueOrTopicName: data.subscriptions[index].localSubscribedQueueOrTopicName, + localNumberOfMessagesRemainingForSubscriber: data.subscriptions[index].localNumberOfMessagesRemainingForSubscriber, + localActive: data.subscriptions[index].localActive, + localDurable: data.subscriptions[index].localDurable, + localSubscriberQueueName: data.subscriptions[index].localSubscriberQueueName, + localSubscriptionIdentifier: data.subscriptions[index].localSubscriptionIdentifier, + name: data.subscriptions[index].localSubscribedQueueOrTopicName + } + ); + }); + + var json = { + "recordsTotal": Object.keys(data).length, + "recordsFiltered": Object.keys(data).length, + "data": objects + }; + var table = $('#device-grid1').DataTable(); + + + + setInterval( function () { + table.ajax.reload(); + }, 300000 ); + + return JSON.stringify(json); + }; + + $('#device-grid1').datatables_extended_serverside_paging( + null, + serviceURL, + dataFilter, + columns, + fnCreatedRow, + function () { + $(".icon .text").res_text(0.2); + $('#device-grid1').removeClass('hidden'); + $("#loading-content").remove(); + + + }, { + "placeholder": "Search By Topic Name", + "searchKey": "name" + } + ); +} + +/* + * DOM ready functions. + */ +$(document).ready(function () { + /* Adding selected class for selected devices */ + var permissionList = $("#permission").data("permission"); + for (var key in permissionList) { + if (permissionList.hasOwnProperty(key)) { + $.setPermission(key); + } + } + loadTopics(); + $(".dataTables_toolbar").css("display", "none"); + + /* for device list sorting drop down */ + $(".ctrl-filter-type-switcher").popover({ + html: true, + content: function () { + return $("#content-filter-types").html(); + } + }); + + /* for data tables*/ + $('[data-toggle="tooltip"]').tooltip(); + + $("[data-toggle=popover]").popover(); + + $(".ctrl-filter-type-switcher").popover({ + html: true, + content: function () { + return $('#content-filter-types').html(); + } + }); + + $('#nav').affix({ + offset: { + top: $('header').height() + } + }); + + var table = $('#example').DataTable(); + +// #myInput is a element + $('#myInput').on( 'keyup', function () { + table.search( this.value ).draw(); + } ); + +}); + +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; +var body = "body"; + +/* + * set popup maximum height function. + */ +function setPopupMaxHeight() { + $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); + $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); +} + +/* + * show popup function. + */ +function showPopup() { + $(modalPopup).modal('show'); +} + +/* + * hide popup function. + */ +function hidePopup() { + $(modalPopupContent).html(""); + $(modalPopupContent).removeClass("operation-data"); + $(modalPopup).modal('hide'); + $('body').removeClass('modal-open').css('padding-right', '0px'); + $('.modal-backdrop').remove(); +} + +function getParameterByName(name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + 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 new file mode 100644 index 00000000000..ccbe352057e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.hbs @@ -0,0 +1,268 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}}` +{{unit "cdmf.unit.ui.title" pageTitle="MQTT Dashboard"}} + +{{unit "cdmf.unit.data-tables-extended"}} +{{unit "cdmf.unit.lib.ui-permissions-utility"}} + +{{#zone "breadcrumbs"}} +
  • + + + +
  • +
  • + + + Dashboard + +
  • +
  • + + MQTT + +
  • +{{/zone}} + + +{{#zone "content"}} +
    +
    +
    +
    + + {{unit "cdmf.unit.device.operation-mod"}} + {{#if deviceCount}} +
    + + Loading subscriptions . . . +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +
    + + {{else}} +
    + +
    + {{/if}} + +
    + + + +
    + +
    + + + +
    +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + + {{js "js/topic-listing.js"}} +{{/zone}} + +{{#zone "topCss"}} + +{{/zone}} 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 new file mode 100644 index 00000000000..d5f4374303b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest(context) { + var constants = require("/app/modules/constants.js"); + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + + var groupId = request.getParameter("groupId"); + + var viewModel = {}; + var title = "Topics"; + viewModel.title = title; + var currentUser = session.get(constants.USER_SESSION_KEY); + if (currentUser) { + viewModel.permissions = {}; + var uiPermissions = userModule.getUIPermissions(); + viewModel.permissions.list = stringify(uiPermissions); + if (uiPermissions.VIEW_TOPICS) { + viewModel.permissions.enroll = true; + } + viewModel.currentUser = currentUser; + var deviceCount = 1; + viewModel.deviceCount = deviceCount; + var utility = require("/app/modules/utility.js").utility; + } + return viewModel; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.json new file mode 100644 index 00000000000..a7f2976443a --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.topic/topic.json @@ -0,0 +1,5 @@ +{ + "version": "1.0.0", + "uri": "/topics", + "layout": "cdmf.layout.default" +} \ No newline at end of file From 8d38f6490cc6874f957465b72d449001c5e3f20a Mon Sep 17 00:00:00 2001 From: Supun94 Date: Fri, 30 Jun 2017 16:31:43 +0530 Subject: [PATCH 4/4] 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 007af1de903..2c9291e694c 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 ccbe352057e..ea85b67cb30 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 d5f4374303b..13cd619d8ae 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; }