@@ -60,8 +60,273 @@
{{unit "cdmf.unit.device.operation-mod"}}
- {{unit "cdmf.unit.device.listing"}}
+ {{#if deviceCount}}
+
+
+
+
+ Loading devices . . .
+
+
+
+
+
+
+
+ |
+ By Device Name |
+ By Owner |
+ By Status |
+ By Platform |
+ By Ownership |
+ |
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ {{unit "mdm.unit.device.operation-bar"}}
+
+
+ Enabling Device Operations
+ To enable device operations, select the desired platform from above
+ filter.
+
+ |
+
+
+
+
+
+
+
+
+
+
+ {{else}}
+
+ {{/if}}
+
+
+
+
+
+
Please select group
+
Loading...
+
+
+
+
+
+
+
+
+
+
+
Device was successfully associated with group.
+
+
+
+
+
+
+
+
+
+
Device was successfully removed from group.
+
+
+
+
+
+
+
+
+
+
Do you really want to remove this device from your Devices List?
+
+
+
+
+
+
+
+
+
+
+
+
Device was successfully removed.
+
+
+
+
+
+
+
+
+
+
Please enter new name for the device?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Device was successfully updated.
+
+
+
+
+
+
+
+
+
+
Exception at backend. Try Later.
+
+
+
+
+
+
+
+
+
+
+
+
Operation not permitted.
+
+
+
+
+
+
+
+
+
+
+
+
Device does not exist.
+
+
+
+
+
+
+{{/zone}}
+
+{{#zone "bottomJs"}}
+
+ {{js "js/listing.js"}}
{{/zone}}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
index 50480ab828..88cb32d704 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
@@ -18,19 +18,61 @@
function onRequest(context) {
var constants = require("/app/modules/constants.js");
- var page = {};
+ var userModule = require("/app/modules/user.js").userModule;
+ var deviceModule = require("/app/modules/device.js").deviceModule;
+
var groupName = request.getParameter("groupName");
+ var groupOwner = request.getParameter("groupOwner");
+
+ var page = {};
var title = "Devices";
if (groupName) {
title = groupName + " " + title;
page.groupName = groupName;
}
- page.title =title;
+ page.title = title;
page.permissions = {};
var currentUser = session.get(constants.USER_SESSION_KEY);
+ var permissions = [];
if (currentUser) {
+ if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/list")) {
+ permissions.push("LIST_DEVICES");
+ } else if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
+ permissions.push("LIST_OWN_DEVICES");
+ } else if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/policies/list")) {
+ permissions.push("LIST_POLICIES");
+ }
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/add")) {
- page.permissions.enroll = true;
+ permissions.enroll = true;
+ }
+ if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/remove")) {
+ permissions.push("REMOVE_DEVICE");
+ }
+
+ page.permissions.list = permissions;
+ page.currentUser = currentUser;
+ var deviceCount = 0;
+ if (groupName && groupOwner) {
+ var groupModule = require("/app/modules/group.js").groupModule;
+ deviceCount = groupModule.getGroupDeviceCount(groupName, groupOwner);
+ page.groupOwner = groupOwner;
+ } else {
+ deviceCount = deviceModule.getOwnDevicesCount();
+ }
+ if (deviceCount > 0) {
+ page.deviceCount = deviceCount;
+ var utility = require("/app/modules/utility.js").utility;
+ var data = deviceModule.getDeviceTypes();
+ var deviceTypes = [];
+ if (data.data) {
+ for (var i = 0; i < data.data.length; i++) {
+ deviceTypes.push({
+ "type": data.data[i].name,
+ "category": utility.getDeviceTypeConfig(data.data[i].name).deviceType.category
+ });
+ }
+ }
+ page.deviceTypes = deviceTypes;
}
}
return page;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
similarity index 63%
rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/js/listing.js
rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
index bc1d6f7d6a..2711b2b29c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
@@ -16,6 +16,17 @@
* 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") {
+ $(location).attr('href', url);
+ }
+}
+
(function () {
var cache = {};
var permissionSet = {};
@@ -50,6 +61,44 @@
var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container";
+/*
+ * DOM ready functions.
+ */
+$(document).ready(function () {
+ /* Adding selected class for selected devices */
+ $(deviceCheckbox).each(function () {
+ addDeviceSelectedClass(this);
+ });
+
+ var i;
+ var permissionList = $("#permission").data("permission");
+ for (i = 0; i < permissionList.length; i++) {
+ $.setPermission(permissionList[i]);
+ }
+
+ /* for device list sorting drop down */
+ $(".ctrl-filter-type-switcher").popover({
+ html : true,
+ content : function () {
+ return $("#content-filter-types").html();
+ }
+ });
+
+ $(".ast-container").on("click", ".claim-btn", function(e){
+ e.stopPropagation();
+ var deviceId = $(this).data("deviceid");
+ var deviceListing = $("#device-listing");
+ var currentUser = deviceListing.data("current-user");
+ var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser;
+ var deviceIdentifier = {id: deviceId, type: "TemperatureController"};
+ invokerUtil.put(serviceURL, deviceIdentifier, function(message){
+ console.log(message);
+ }, function(message){
+ console.log(message.content);
+ });
+ });
+});
+
/*
* On Select All Device button click function.
*
@@ -110,52 +159,149 @@ function toTitleCase(str) {
});
}
-function loadDevices() {
+function loadDevices(searchType, searchParam){
var deviceListing = $("#device-listing");
var deviceListingSrc = deviceListing.attr("src");
var imageResource = deviceListing.data("image-resource");
var currentUser = deviceListing.data("currentUser");
- $.template("device-listing", deviceListingSrc, function (template) {
- var serviceURL;
- if ($.hasPermission("LIST_OWN_DEVICES") || $.hasPermission("LIST_DEVICES")) {
- //Get authenticated users devices
- serviceURL = "/devicemgt_admin/users/devices?username=" + currentUser;
- } else {
- $("#loading-content").remove();
- $('#device-table').addClass('hidden');
- $('#device-listing-status-msg').text('Permission denied.');
- return;
- }
+ var frontEndPagination = false;
+
+ var serviceURL;
+ if ($.hasPermission("LIST_DEVICES")) {
+ serviceURL = "/devicemgt_admin/devices";
+ } else if ($.hasPermission("LIST_OWN_DEVICES")) {
+ //Get authenticated users devices
+ serviceURL = "/devicemgt_admin/users/devices?username="+currentUser;
+ } else {
+ $("#loading-content").remove();
+ $('#device-table').addClass('hidden');
+ $('#device-listing-status-msg').text('Permission denied.');
+ $("#device-listing-status").removeClass(' hidden');
+ return;
+ }
- var successCallback = function (data) {
- data = JSON.parse(data);
- var viewModel = {};
- viewModel.devices = data;
- viewModel.imageLocation = imageResource;
- if (data.length > 0) {
- $('#device-listing-container').removeClass('hidden');
- $('#empty-device-listing-container').addClass('hidden');
- var content = template(viewModel);
- $("#ast-container").html(content);
- /*
- * On device checkbox select add parent selected style class
- */
- $(deviceCheckbox).click(function () {
- addDeviceSelectedClass(this);
- });
- attachDeviceEvents();
- } else {
- $('#device-listing-container').addClass('hidden');
- $('#empty-device-listing-container').removeClass('hidden');
+ function getPropertyValue(deviceProperties, propertyName) {
+ var property;
+ for (var i =0; i < deviceProperties.length; i++) {
+ property = deviceProperties[i];
+ if (property.name == propertyName) {
+ return property.value;
}
- $("#loading-content").remove();
- $('#device-grid').datatables_extended();
+ }
+ return {};
+ }
+
+ $('#device-grid').datatables_extended ({
+ serverSide: true,
+ processing: false,
+ searching: true,
+ ordering: false,
+ filter: false,
+ pageLength : 16,
+ ajax: { url : '/devicemgt/api/devices', data : {url : serviceURL},
+ dataSrc: function ( json ) {
+ $('#device-grid').removeClass('hidden');
+ $("#loading-content").remove();
+ var $list = $("#device-table :input[type='search']");
+ $list.each(function(){
+ $(this).addClass("hidden");
+ });
+ return json.data;
+ }
+ },
+ columnDefs: [
+ { targets: 0, data: 'name', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
+ return '';
+ }},
+ { targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
+ var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
+ var vendor = getPropertyValue(row.properties, 'VENDOR');
+ var html = 'Device ' + name + '
';
+ if (model) {
+ html += '(' + vendor + '-' + model + ')
';
+ }
+ return html;
+ }},
+ { targets: 2, data: 'enrolmentInfo.owner', className: 'fade-edge remove-padding-top'},
+ { targets: 3, data: 'enrolmentInfo.status', className: 'fade-edge remove-padding-top' ,
+ render: function ( status, type, row, meta ) {
+ var html;
+ switch (status) {
+ case 'ACTIVE' :
+ html = ' Active';
+ break;
+ case 'INACTIVE' :
+ html = ' Inactive';
+ break;
+ case 'BLOCKED' :
+ html = ' Blocked';
+ break;
+ case 'REMOVED' :
+ html = ' Removed';
+ break;
+ }
+ return html;
+ }},
+ { targets: 4, data: 'type' , className: 'fade-edge remove-padding-top' },
+ { targets: 5, data: 'enrolmentInfo.ownership' , className: 'fade-edge remove-padding-top' },
+ { targets: 6, data: 'enrolmentInfo.status' , className: 'text-right content-fill text-left-on-grid-view no-wrap' ,
+ render: function ( status, type, row, meta ) {
+ var deviceType = row.type;
+ var deviceIdentifier = row.deviceIdentifier;
+ var html = '';
+ if (status != 'REMOVED') {
+ html = '' +
+ 'View';
+ }
+ return html;
+ }}
+ ],
+ "createdRow": function( row, data, dataIndex ) {
+ $(row).attr('data-type', 'selectable');
+ $(row).attr('data-deviceid', data.deviceIdentifier);
+ $(row).attr('data-devicetype', data.type);
+ var model = getPropertyValue(data.properties, 'DEVICE_MODEL');
+ var vendor = getPropertyValue(data.properties, 'VENDOR');
+ var owner = data.enrolmentInfo.owner;
+ var status = data.enrolmentInfo.status;
+ var ownership = data.enrolmentInfo.ownership;
+ var deviceType = data.type;
+ $.each($('td', row), function (colIndex) {
+ switch(colIndex) {
+ case 1:
+ $(this).attr('data-search', model + ',' + vendor);
+ $(this).attr('data-display', model);
+ break;
+ case 2:
+ $(this).attr('data-grid-label', "Owner");
+ $(this).attr('data-search', owner);
+ $(this).attr('data-display', owner);
+ break;
+ case 3:
+ $(this).attr('data-grid-label', "Status");
+ $(this).attr('data-search', status);
+ $(this).attr('data-display', status);
+ break;
+ case 4:
+ $(this).attr('data-grid-label', "Type");
+ $(this).attr('data-search', deviceType);
+ $(this).attr('data-display', deviceType);
+ break;
+ case 5:
+ $(this).attr('data-grid-label', "Ownership");
+ $(this).attr('data-search', ownership);
+ $(this).attr('data-display', ownership);
+ break;
+ }
+ });
+ },
+ "fnDrawCallback": function( oSettings ) {
$(".icon .text").res_text(0.2);
- };
- invokerUtil.get(serviceURL,
- successCallback, function (message) {
- console.log(message.content);
- });
+ }
+ });
+ $(deviceCheckbox).click(function () {
+ addDeviceSelectedClass(this);
});
}
@@ -218,20 +364,37 @@ function loadGroupedDevices(groupId) {
}
+function initPage() {
+ var groupId = getParameterByName('groupId');
+ invokerUtil.get(
+ "/devicemgt_admin/devices/count",
+ function (data) {
+ if (data) {
+ data = JSON.parse(data);
+ if (Number(data) > 0) {
+ if (groupId) {
+ loadGroupedDevices(groupId);
+ } else {
+ loadDevices();
+ }
+ } else {
+ $("#loading-content").remove();
+ $("#device-listing-status-msg").text("No enrolled devices found.");
+ $("#device-listing-status").removeClass(' hidden');
+ }
+ }
+ }, function (message) {
+ initPage();
+ }
+ );
+}
+
/*
* DOM ready functions.
*/
$(document).ready(function () {
- var groupId = getParameterByName('groupId');
-
- if (groupId) {
- loadGroupedDevices(groupId);
- } else {
- loadDevices();
- }
-
- //$('#device-grid').datatables_extended();
+ initPage();
/* Adding selected class for selected devices */
$(deviceCheckbox).each(function () {
@@ -246,29 +409,43 @@ $(document).ready(function () {
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
- html: true,
- content: function () {
- return $("#content-filter-types").html();
- }
- });
+ html : true,
+ content : function () {
+ return $("#content-filter-types").html();
+ }
+ });
+
+ $(".ast-container").on("click", ".claim-btn", function(e) {
+ e.stopPropagation();
+ var deviceId = $(this).data("deviceid");
+ var deviceListing = $("#device-listing");
+ var currentUser = deviceListing.data("current-user");
+ var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser;
+ var deviceIdentifier = {id: deviceId, type: "TemperatureController"};
+ invokerUtil.put(serviceURL, deviceIdentifier, function(message) {
+ console.log(message);
+ }, function(message){
+ console.log(message.content);
+ });
+ });
/* 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()
- }
- });
+ $(".ctrl-filter-type-switcher").popover ({
+ html : true,
+ content: function() {
+ return $('#content-filter-types').html();
+ }
+ });
+
+ $('#nav').affix ({
+ offset: {
+ top: $('header').height()
+ }
+ });
});
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/templates/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/templates/listing.hbs
similarity index 90%
rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/templates/listing.hbs
rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/templates/listing.hbs
index f0d3b54d84..07965cfd66 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.listing/public/templates/listing.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/templates/listing.hbs
@@ -28,17 +28,9 @@
{{type}} |
- {{#if enrolmentInfo.ownership}}
-
- {{enrolmentInfo.ownership}}
- |
- {{else}}
-
- |
- {{/if}}
+ {{enrolmentInfo.ownership}} |
{{#unequal enrolmentInfo.status "REMOVED"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
index b42f90ceea..8852bbd67e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
@@ -54,59 +54,11 @@
-
+
- Exception at backend. Try Later.
-
-
-
-
-
-
-
-
-
-
-
- Operation not permitted.
-
-
-
-
-
-
-
-
-
-
-
- Group Name already exists.
-
-
-
-
-
-
-
-
-
-
-
- Unexpected error occurred!
+ Unexpected error occurred!
- {{policyListingStatusMsg}}
+
{{#equal noPolicy false}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js
index b8e06726a5..b3c27be6cd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js
@@ -49,6 +49,12 @@ function onRequest(context) {
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/delete")) {
context["removePermitted"] = true;
}
+ if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) {
+ context["removePermitted"] = true;
+ }
+ if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) {
+ context["editPermitted"] = true;
+ }
return context;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js
index 29a0307604..2ea6a2ccfd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js
@@ -137,7 +137,10 @@ $(document).ready(function () {
$("#policy-users").hide();
}
- $("#policy-listing-status-msg").removeClass("hidden");
+ if ($("#policy-listing-status-msg").text()) {
+ $("#policy-listing-status").removeClass("hidden");
+ }
+
// Click functions related to Policy Listing
var isUpdated = $('#is-updated').val();
if (!isUpdated) {
@@ -218,7 +221,7 @@ $(document).ready(function () {
$(".policy-unpublish-link").click(function () {
var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates();
- if (($.inArray('Inactive/Updated', statusList) > -1) || ($.inArray('Inactive', statusList) > -1)) {
+ if ( ($.inArray( 'Inactive/Updated', statusList ) > -1) || ($.inArray( 'Inactive', statusList ) > -1) ) {
$(modalPopupContent).html($("#errorPolicyUnPublishSelection").html());
showPopup();
} else {
@@ -262,7 +265,7 @@ $(document).ready(function () {
$(".policy-publish-link").click(function () {
var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates();
- if (($.inArray('Active/Updated', statusList) > -1) || ($.inArray('Active', statusList) > -1)) {
+ if ( ($.inArray( 'Active/Updated', statusList ) > -1) || ($.inArray( 'Active', statusList ) > -1) ) {
$(modalPopupContent).html($("#errorPolicyPublishSelection").html());
showPopup();
} else {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
index 00f8df9c09..db5498211f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
@@ -1,15 +1,31 @@
|