diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceToGroupsAssignment.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceToGroupsAssignment.java new file mode 100644 index 0000000000..ef696f0c27 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceToGroupsAssignment.java @@ -0,0 +1,56 @@ +/* + * 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. + * + */ +package org.wso2.carbon.device.mgt.jaxrs.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.jaxrs.beans.BasePaginatedResult; + +import java.util.ArrayList; +import java.util.List; + +public class DeviceToGroupsAssignment extends BasePaginatedResult { + + @ApiModelProperty(value = "List of device group ids.") + @JsonProperty("deviceGroupIds") + private List deviceGroupIds = new ArrayList<>(); + + @ApiModelProperty(value = "Device identifier of the device needed to be assigned with group") + @JsonProperty("deviceIdentifier") + private DeviceIdentifier deviceIdentifier; + + + public List getDeviceGroupIds() { + return deviceGroupIds; + } + + public void setDeviceGroupIds(List deviceGroupIds) { + this.deviceGroupIds = deviceGroupIds; + } + + public DeviceIdentifier getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java index a982a3c3d5..9d1b255e96 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java @@ -37,6 +37,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; +import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceToGroupsAssignment; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; @@ -774,4 +775,115 @@ public interface GroupManagementService { required = true) @Valid List deviceIdentifiers); + @Path("/device/assign") + @POST + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Assign devices to groups", + notes = "Add existing device to device groups.", + tags = "Device Group Management", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/groups/devices/add", + description = "Add devices")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. \n Successfully assign the device to groups.", + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client has already the latest version of " + + "the requested resource."), + @ApiResponse( + code = 404, + message = "No groups found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding devices to the group.", + response = ErrorResponse.class) + }) + Response updateDeviceAssigningToGroups( + @ApiParam( + name = "deviceToGroupsAssignment", + value = "Device to groups assignment", + required = true) + @Valid DeviceToGroupsAssignment deviceToGroupsAssignment); + + @Path("/device") + @GET + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_GET, + value = "List of groups that have the device", + notes = "List of groups that have the device.", + tags = "Device Group Management", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/groups/devices/view", + description = "Add devices")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK.", + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client has already the latest version of " + + "the requested resource."), + @ApiResponse( + code = 404, + message = "No groups found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred.", + response = ErrorResponse.class) + }) + Response getGroups( + @ApiParam( + name = "deviceId", + value = "Id of the device.") + @QueryParam("deviceId") String deviceId, + @ApiParam( + name = "deviceType", + value = "Type of the device.") + @QueryParam("deviceType") String deviceType); + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java index 4d7f4319fa..4811e9b902 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; @@ -35,12 +36,14 @@ import org.wso2.carbon.device.mgt.common.group.mgt.RoleDoesNotExistException; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; +import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceToGroupsAssignment; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; import org.wso2.carbon.device.mgt.jaxrs.service.api.GroupManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import javax.ws.rs.core.Response; +import java.util.ArrayList; import java.util.List; public class GroupManagementServiceImpl implements GroupManagementService { @@ -243,7 +246,8 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } - @Override public Response removeDevicesFromGroup(int groupId, List deviceIdentifiers) { + @Override + public Response removeDevicesFromGroup(int groupId, List deviceIdentifiers) { try { DeviceMgtAPIUtils.getGroupManagementProviderService().removeDevice(groupId, deviceIdentifiers); return Response.status(Response.Status.OK).build(); @@ -256,4 +260,45 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } + @Override + public Response updateDeviceAssigningToGroups(DeviceToGroupsAssignment deviceToGroupsAssignment) { + try { + List deviceIdentifiers = new ArrayList<>(); + deviceIdentifiers.add(deviceToGroupsAssignment.getDeviceIdentifier()); + GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService(); + List deviceGroups = service.getGroups(deviceToGroupsAssignment.getDeviceIdentifier()); + for (DeviceGroup group : deviceGroups) { + Integer groupId = group.getGroupId(); + if (deviceToGroupsAssignment.getDeviceGroupIds().contains(groupId)) { + deviceToGroupsAssignment.getDeviceGroupIds().remove(groupId); + } else if (!CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(group.getOwner())) { + DeviceMgtAPIUtils.getGroupManagementProviderService().removeDevice(groupId, deviceIdentifiers); + } + } + for (int groupId : deviceToGroupsAssignment.getDeviceGroupIds()) { + DeviceMgtAPIUtils.getGroupManagementProviderService().addDevices(groupId, deviceIdentifiers); + } + return Response.status(Response.Status.OK).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while assigning device to groups."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (DeviceNotFoundException e) { + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + @Override + public Response getGroups(String deviceId, String deviceType) { + try { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); + List deviceGroups = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(deviceIdentifier); + return Response.status(Response.Status.OK).entity(deviceGroups).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while removing devices from group."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index fefd73bd0b..de20da586d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -105,4 +105,33 @@ var groupModule = {}; ); }; + groupModule.getGroup = function (groupId) { + return serviceInvokers.XMLHttp.get( + deviceServiceEndpoint + "/groups/id/" + groupId, function (responsePayload) { + return JSON.parse(responsePayload.responseText); + }, + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + + groupModule.getRolesOfGroup = function (groupId) { + return serviceInvokers.XMLHttp.get( + deviceServiceEndpoint + "/groups/id/" + groupId + "/roles", function (responsePayload) { + var data = JSON.parse(responsePayload.responseText); + if(data) { + return data.roles; + } else { + return []; + } + }, + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + }(groupModule)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs index 6b466d90a3..a294732b26 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs @@ -171,7 +171,7 @@ {{/if}} - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index 2b50aa21c3..8a32659700 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -26,7 +26,7 @@ - {{#if groupName}} + {{#if group}}
  • Groups @@ -34,7 +34,7 @@
  • - {{groupName}} + {{group.name}}
  • {{else}} @@ -47,7 +47,7 @@ {{/zone}} {{#zone "navbarActions"}} - {{#if groupName}} + {{#if group}}
  • @@ -57,6 +57,15 @@ Assign from My Devices
  • +
  • + + + + + + View Analytics + +
  • {{else}} {{#if permissions.enroll}}
  • @@ -73,6 +82,55 @@ {{/zone}} {{#zone "content"}} + {{#if group}} +

    + {{group.name}} group +

    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + Overview +
    + + + + + + + + + + + + + + + + + + + +
    Owner{{group.owner}}
    Shared with roles + {{#each roles}} + {{this}}
    + {{/each}} +
    Device Count{{deviceCount}}
    Description{{group.description}}
    +
    +
    +
    +
    +
    +

    + Devices in {{group.name}} group +

    + {{/if}}
    @@ -82,7 +140,6 @@ {{#if deviceCount}}
    - Loading devices . . .
    @@ -157,7 +214,7 @@

    You don't have any device - {{#if groupName}} + {{#if group}} assigned to this group {{else}} enrolled @@ -165,7 +222,7 @@ at the moment.

    - {{#if groupName}} + {{#if group}} @@ -208,20 +265,16 @@ -
    -

    - Please select group -
    -
    Loading...
    -

    -
    +
    Loading...

    '; + hasGroups = true; + } + } + if (hasGroups) { + html = '

    Please select device group(s)


    ' + html; + markAlreadyAssignedGroups(deviceId, deviceType); + $("a#group-device-yes-link").show(); + $("a#group-add-link").hide(); + } else { + $("a#group-device-yes-link").hide(); + $("a#group-add-link").show(); + html += '

    You don\'t have any existing device groups. Please add new device group first.

    ' } - str += ''; - $('#user-groups').html(str); - $("a#group-device-yes-link").show(); + $('#user-groups').html(html); $("a#group-device-yes-link").click(function () { - var selectedGroup = $('#assign-group-selector').val(); - serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices/add"; - var deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; - invokerUtil.post(serviceURL, deviceIdentifiers, function (data) { + var deviceIdentifier = {"id": deviceId, "type": deviceType}; + var deviceGroupIds = []; + $('.modal .groupCheckBoxes').each( + function () { + if ($(this).is(':checked')) { + deviceGroupIds.push($(this).data('groupid')); + } + } + ); + var deviceToGroupsAssignment = { + deviceIdentifier: deviceIdentifier, + deviceGroupIds: deviceGroupIds + }; + serviceURL = "/api/device-mgt/v1.0/groups/device/assign"; + invokerUtil.post(serviceURL, deviceToGroupsAssignment, function (data) { $(modalPopupContent).html($('#group-associate-device-200-content').html()); setTimeout(function () { hidePopup(); @@ -640,8 +692,8 @@ function attachDeviceEvents() { showPopup(); $("a#remove-device-yes-link").click(function () { - if(groupId && groupName) { - var deviceIdentifiers = [{"id": deviceId,"type": deviceType}]; + if (groupId) { + var deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove"; invokerUtil.post(serviceURL, deviceIdentifiers, function (message) { $(modalPopupContent).html($('#remove-device-from-group-200-content').html()); @@ -733,6 +785,6 @@ function displayDeviceErrors(jqXHR) { function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); + results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs index 24d69f8ce4..c7cfdffad3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs @@ -37,7 +37,7 @@
  • - + {{groupName}}
  • diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js index 19f783ed56..6a34a26b0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js @@ -19,8 +19,8 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - var groupName = context.uriParams.name; var groupId = context.uriParams.id; + var group = groupModule.getGroup(groupId); var devices = []; var deviceResponse = groupModule.getGroupDevices(groupId).responseText; @@ -29,8 +29,9 @@ function onRequest(context) { devices = deviceResponseObj.devices; } var page = { - "groupName": groupName, - "title": groupName + " Analytics" + "groupId": groupId, + "groupName": group.name, + "title": group.name + " Analytics" }; if (devices) { var deviceTypes = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json index 2e2fea333e..8535dab982 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/group/{name}/{id}/analytics", + "uri": "/group/{id}/analytics", "layout": "cdmf.layout.default" } \ 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.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index 4597a71297..6661e775b4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -16,18 +16,41 @@ * 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 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 groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; var assetContainer = "#ast-container"; -function InitiateViewOption() { - if ($(".select-enable-btn").text() == "Select") { - $(location).attr('href', $(this).data("url")); - } -} - /* * On Select All Groups button click function. * @@ -118,9 +141,9 @@ function loadGroups() { }); var json = { "recordsTotal": data.count, + "recordsFiltered": data.count, "data": objects - } - + }; return JSON.stringify(json); }; @@ -129,7 +152,14 @@ function loadGroups() { data: 'id', class: 'remove-padding icon-only content-fill', render: function (data, type, row, meta) { - return '
    '; + if ($.hasPermission("VIEW_GROUP_DEVICES")) { + return '
    '; + } else { + return '
    '; + } } }, { @@ -154,13 +184,7 @@ function loadGroups() { render: function (id, type, row, meta) { var html = ''; if ($.hasPermission("VIEW_GROUP_DEVICES")) { - html = '' + - '' - + - ''; - - html += '' + '' + @@ -224,21 +248,23 @@ function loadGroups() { }); }; - $('#group-grid').datatables_extended_serverside_paging( - null, - serviceURL, - dataFilter, - columns, - fnCreatedRow, - function (oSettings) { - $(".icon .text").res_text(0.2); - attachEvents(); - }, - { - "placeholder": "Search By Group Name", - "searchKey": "name" - }); + null, + serviceURL, + dataFilter, + columns, + fnCreatedRow, + function (oSettings) { + $(".icon .text").res_text(0.2); + attachEvents(); + var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.removeClass("table-selectable"); + }, + { + "placeholder": "Search By Group Name", + "searchKey": "name" + } + ); $(groupCheckbox).click(function () { addGroupSelectedClass(this); }); @@ -257,6 +283,11 @@ function openCollapsedNav() { * DOM ready functions. */ $(document).ready(function () { + /* Adding selected class for selected devices */ + $(groupCheckbox).each(function () { + addGroupSelectedClass(this); + }); + var permissionSet = {}; //This method is used to setup permission for device listing @@ -278,11 +309,6 @@ $(document).ready(function () { loadGroups(); //$('#device-grid').datatables_extended(); - /* Adding selected class for selected devices */ - $(groupCheckbox).each(function () { - addGroupSelectedClass(this); - }); - /* for device list sorting drop down */ $(".ctrl-filter-type-switcher").popover( { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs index 08ab1c8095..5069d083d4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.hbs @@ -16,26 +16,44 @@ under the License. }} -
    -
    - Device Types +{{#if virtualDeviceTypesList}} +
    +
    + Device Types +
    -
    - -
    - - - - - - - - - - -
    By Device Type
    -
    +
    + + + + + + + + + + +
    By Device Type
    +
    +{{else}} +
    +{{/if}}
    {{#if virtualDeviceTypesList}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js index 62ca011b0b..1e1cefcb83 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js @@ -29,6 +29,9 @@ function onRequest(context) { if (typesListResponse["status"] == "success") { var deviceTypes = typesListResponse.content.deviceTypes; if (deviceTypes) { + if (deviceTypes.length > 0){ + viewModel.hasDeviceTypes = true; + } var deviceTypesList = [], virtualDeviceTypesList = []; for (var i = 0; i < deviceTypes.length; i++) { var deviceType = deviceTypes[i]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js index 1fbbe479c2..ba9a4be94a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/js/listing.js @@ -142,13 +142,6 @@ function loadDevices(searchType, searchParam){ } } else { $('#device-type-grid').addClass('hidden'); - $('#device-listing-status-msg').html( - '

    ' + - '

    No device type is available to be displayed.

    ' + - '' + - ' ' + - 'Quick Startup Guide
    '); } $(".icon .text").res_text(0.2);