diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js
index 73313ec2..0b748a52 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js
@@ -15,7 +15,7 @@ function onRequest(context) {
var dashboardLink = {
title: "Go back to Dashboard",
icon: "fw-left-arrow",
- url: "/iotserver"
+ url: "/iotserver/dashboard"
};
var deviceMgtLink = {
@@ -24,21 +24,32 @@ function onRequest(context) {
url: "/iotserver/devices"
};
+ var groupMgtLink = {
+ title: "Go back to Groups",
+ icon: "fw-left-arrow",
+ url: "/iotserver/groups"
+ };
+
var storeLink = {
title: "Go back to Store",
icon: "fw-left-arrow",
url: "/iotserver"
};
-
links.users.push(dashboardLink);
links.policies.push(dashboardLink);
links.profiles.push(dashboardLink);
links.store.push(dashboardLink);
links.store.push(storeLink);
- links.analytics.push(deviceMgtLink);
- links['device-mgt'].push(dashboardLink);
links['group-mgt'].push(dashboardLink);
+ var groupId = request.getParameter("groupId");
+ if (groupId){
+ links.analytics.push(groupMgtLink);
+ links['device-mgt'].push(groupMgtLink);
+ }else{
+ links.analytics.push(deviceMgtLink);
+ links['device-mgt'].push(dashboardLink);
+ }
if (!carbonUser) {
//user is not logged in
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs
index da18ac9d..dff6f92e 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs
@@ -87,12 +87,6 @@
Device was successfully removed.
-
-
@@ -128,12 +122,6 @@
Device was successfully updated.
-
-
@@ -166,12 +154,6 @@
Device was successfully associated with group.
-
-
@@ -182,12 +164,6 @@
Device was successfully removed from group.
-
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js
index 48494228..16d9af6e 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js
@@ -39,9 +39,9 @@ var groupId, user;
}
});
Handlebars.registerHelper("if_owner", function (owner, opts) {
- if (owner == user){
+ if (owner == user) {
return opts.fn(this);
- }else{
+ } else {
opts.inverse(this);
}
});
@@ -164,40 +164,38 @@ function loadDevices() {
groups = data.data;
}
viewModel.groups = groups;
- if (!groups || groups.length <= 0) {
- if (groupId && groupId != "0") {
- $("#ast-container-parent").html($("#no-grouped-devices-div-content").html());
- } else {
- $("#ast-container-parent").html($("#no-devices-div-content").html());
- }
- } else {
- var content = template(viewModel);
- $("#ast-container-parent").html(content);
- var deviceListing = $("#device-listing");
- var deviceListingSrc = deviceListing.attr("src");
- var imageResource = deviceListing.data("image-resource");
- $.template("device-listing", deviceListingSrc, function (template) {
- for (var g in groups) {
- if (groups[g].devices && groups[g].devices.length > 0){
- viewModel = {};
- viewModel.devices = groups[g].devices;
- viewModel.imageLocation = imageResource;
- content = template(viewModel);
- }else{
+ var content = template(viewModel);
+ $("#ast-container-parent").html(content);
+ var deviceListing = $("#device-listing");
+ var deviceListingSrc = deviceListing.attr("src");
+ var imageResource = deviceListing.data("image-resource");
+ $.template("device-listing", deviceListingSrc, function (template) {
+ for (var g in groups) {
+ if (groups[g].devices && groups[g].devices.length > 0) {
+ viewModel = {};
+ viewModel.devices = groups[g].devices;
+ viewModel.imageLocation = imageResource;
+ content = template(viewModel);
+ } else {
+ if (groupId && groupId != "0") {
+ content = $("#no-grouped-devices-div-content").html();
+ } else if (groups[g].id == 0 && g == 0) {
+ content = $("#no-devices-div-content").html();
+ } else {
content = $("#no-devices-in-group-div-content").html();
}
- $("#ast-container-" + groups[g].id).html(content);
}
- /*
- * On device checkbox select add parent selected style class
- */
- $(deviceCheckbox).click(function () {
- addDeviceSelectedClass(this);
- });
- attachEvents();
- formatDates();
+ $("#ast-container-" + groups[g].id).html(content);
+ }
+ /*
+ * On device checkbox select add parent selected style class
+ */
+ $(deviceCheckbox).click(function () {
+ addDeviceSelectedClass(this);
});
- }
+ attachEvents();
+ formatDates();
+ });
};
invokerUtil.get(serviceURL,
successCallback, function (message) {
@@ -283,9 +281,9 @@ function attachEvents() {
if (status == 200) {
$(modalPopupContent).html($('#remove-device-200-content').html());
$('div[data-deviceid="' + deviceId + '"]').remove();
- $("a#remove-device-200-link").click(function () {
+ setTimeout(function () {
hidePopup();
- });
+ }, 2000);
} else if (status == 400) {
$(modalPopupContent).html($('#remove-device-400-content').html());
$("a#remove-device-400-link").click(function () {
@@ -344,9 +342,9 @@ function attachEvents() {
if (status == 200) {
$(modalPopupContent).html($('#edit-device-200-content').html());
$("div[data-deviceid='" + deviceId + "'] .ast-name").html(newDeviceName);
- $("a#edit-device-200-link").click(function () {
+ setTimeout(function () {
hidePopup();
- });
+ }, 2000);
} else if (status == 400) {
$(modalPopupContent).html($('#device-400-content').html());
$("a#device-400-link").click(function () {
@@ -383,9 +381,7 @@ function attachEvents() {
* when a user clicks on "Group" link
* on Device Management page in WSO2 MDM Console.
*/
- if (groupId && groupId != "0") {
- $("a.group-device-link").remove();
- } else {
+ if ($("a.group-device-link").length > 0) {
$("a.group-device-link").click(function () {
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
@@ -423,9 +419,10 @@ function attachEvents() {
var status = jqxhr.status;
if (status == 200) {
$(modalPopupContent).html($('#group-associate-device-200-content').html());
- $("a#group-associate-device-200-link").click(function () {
+ loadDevices();
+ setTimeout(function () {
hidePopup();
- });
+ }, 2000);
} else if (status == 400) {
$(modalPopupContent).html($('#device-400-content').html());
$("a#device-400-link").click(function () {
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs
index faef2959..7ed62951 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs
@@ -14,10 +14,10 @@
{{name}}
Device Type: {{type}}
- Date of Enrollment: {{enrolmentInfo.dateOfEnrolment}}
+ Enrolled On: {{enrolmentInfo.dateOfEnrolment}}
-
{{enrolmentInfo.owner}}
+
Owner: {{enrolmentInfo.owner}}
{{status}}
@@ -113,12 +107,6 @@
Group was successfully removed.
-
-
@@ -160,12 +148,6 @@
Group successfully added.
-
-
@@ -207,12 +189,6 @@
Group was successfully updated.
-
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js
index b0923fcd..2eef24d0 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js
@@ -253,10 +253,10 @@ function attachGroupAdding() {
if (status == 200) {
if (data != "false") {
$(modalPopupContent).html($('#add-group-200-content').html());
- $("a#add-group-200-link").click(function () {
+ loadGroups();
+ setTimeout(function () {
hidePopup();
- window.location.href = '/iotserver/groups';
- });
+ }, 2000);
} else {
$(modalPopupContent).html($('#group-400-content').html());
$("a#group-400-link").click(function () {
@@ -299,7 +299,7 @@ function attachEvents() {
* when a user clicks on "Share" link
* on Group Management page in WSO2 IoT Server Console.
*/
- $("a.view-group-link").click(function () {
+ $(".view-group-link").click(function () {
var groupId = $(this).data("groupid");
$("#group-data-form-" + groupId).closest('form').submit();
});
@@ -367,7 +367,7 @@ function attachEvents() {
$("a#share-group-yes-link").click(function () {
var updatedRoleMap = [];
for (var role in roleMap) {
- if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned){
+ if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) {
roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked');
updatedRoleMap.push(roleMap[role]);
}
@@ -378,10 +378,11 @@ function attachEvents() {
var status = jqxhr.status;
if (status == 200) {
$(modalPopupContent).html($('#share-group-200-content').html());
- $("a#share-group-200-link").click(function () {
+ loadGroups();
+ setTimeout(function () {
hidePopup();
- });
- }else {
+ }, 2000);
+ } else {
displayErrors(status);
}
}, errorHandler);
@@ -423,18 +424,11 @@ function attachEvents() {
function (data, txtStatus, jqxhr) {
var status = jqxhr.status;
if (status == 200) {
- if (data != "false") {
- $(modalPopupContent).html($('#remove-group-200-content').html());
- $('div[data-group="' + groupId + '"]').remove();
- $("a#remove-group-200-link").click(function () {
- hidePopup();
- });
- } else {
- $(modalPopupContent).html($('#group-409-content').html());
- $("a#group-409-link").click(function () {
- hidePopup();
- });
- }
+ $(modalPopupContent).html($('#remove-group-200-content').html());
+ loadGroups();
+ setTimeout(function () {
+ hidePopup();
+ }, 2000);
} else {
displayErrors(status);
}
@@ -483,10 +477,9 @@ function attachEvents() {
if (data != "false") {
$(modalPopupContent).html($('#edit-group-200-content').html());
$("div[data-groupid='" + groupId + "'] .ast-name").html(newGroupName);
- $("a#edit-group-200-link").click(function () {
+ setTimeout(function () {
hidePopup();
- window.location.href = '/iotserver/groups';
- });
+ }, 2000);
} else {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs
index a6858c40..1b960976 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs
@@ -9,7 +9,7 @@
-