From b2eb1f9b44c46a2f0b88ebe1fe3173bcf8f3339a Mon Sep 17 00:00:00 2001 From: charithag Date: Mon, 20 Jul 2015 15:26:59 +0530 Subject: [PATCH 1/8] Fixed issue with bundle export --- .../repository/conf/datasources/cdm-datasources.xml | 3 +-- modules/p2-profile-gen/pom.xml | 7 +++++++ pom.xml | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml b/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml index 646f9df4..87dbf428 100755 --- a/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml +++ b/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader @@ -16,7 +16,6 @@ wso2carbon wso2carbon org.h2.Driver - true 50 60000 true diff --git a/modules/p2-profile-gen/pom.xml b/modules/p2-profile-gen/pom.xml index dec9c823..803c0d0b 100644 --- a/modules/p2-profile-gen/pom.xml +++ b/modules/p2-profile-gen/pom.xml @@ -108,6 +108,9 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.server.feature:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.group.server.feature:${carbon.device.mgt.version} + org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.server.feature:${carbon.device.mgt.version} @@ -339,6 +342,10 @@ org.wso2.carbon.device.mgt.user.server.feature.group ${carbon.device.mgt.version} + + org.wso2.carbon.device.mgt.group.server.feature.group + ${carbon.device.mgt.version} + org.wso2.carbon.webapp.authenticator.framework.server.feature.group ${carbon.device.mgt.version} diff --git a/pom.xml b/pom.xml index f0729c8a..8bb9de0c 100644 --- a/pom.xml +++ b/pom.xml @@ -331,6 +331,16 @@ org.wso2.carbon.device.mgt.common ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.group.core + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.group.common + ${carbon.device.mgt.version} + org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common From 30df14b2844a08c32d74d400bbcfb93bb7ea1426 Mon Sep 17 00:00:00 2001 From: charithag Date: Thu, 23 Jul 2015 12:36:58 +0530 Subject: [PATCH 2/8] Add permissions required to grouping --- .../conf/datasources/cdm-datasources.xml | 2 +- .../jaggeryapps/iotserver/modules/utility.js | 30 +++++++++++++++++++ modules/p2-profile-gen/pom.xml | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml b/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml index 8827a1e1..07e6dfa0 100755 --- a/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml +++ b/modules/distribution/src/repository/conf/datasources/cdm-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js index db2d6110..176aef7c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js @@ -87,6 +87,36 @@ utility = function () { key: "devices/operation", name: "Perform Operation" }], "device-mgt/user", "init"); + + // Group Management Permissions + userModule.addPermissions([{ + key: "groups/monitor", + name: "Monitor Devices in Group" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/operation", + name: "Perform Device Operation" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/add_devices", + name: "Add Devices to Group" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/remove_devices", + name: "Remove Devices from Group" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/modify", + name: "Modify Group" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/share", + name: "Change Group Sharing" + }], "group-mgt/user", "init"); + userModule.addPermissions([{ + key: "groups/delete", + name: "Delete Group" + }], "group-mgt/user", "init"); }; return publicMethods; diff --git a/modules/p2-profile-gen/pom.xml b/modules/p2-profile-gen/pom.xml index 833551ef..b5635113 100644 --- a/modules/p2-profile-gen/pom.xml +++ b/modules/p2-profile-gen/pom.xml @@ -339,7 +339,7 @@ ${carbon.device.mgt.version} - org.wso2.carbon.device.mgt.user.server.feature.group + org.wso2.carbon.device.mgt.group.server.feature.group ${carbon.device.mgt.version} From 92bcaef0fc69608b517ed7f8888f600e77da8126 Mon Sep 17 00:00:00 2001 From: charithag Date: Thu, 23 Jul 2015 22:33:44 +0530 Subject: [PATCH 3/8] Add permissions required to grouping --- .../jaggeryapps/iotserver/modules/utility.js | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js index 917e86a0..94dbd066 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js @@ -60,6 +60,28 @@ utility = function () { name: "Perform Operation" }], "device-mgt/admin", type); + userModule.addPermissions([{key: "groups", name: "Groups"}], "device-mgt/admin", type); + userModule.addPermissions([{ + key: "groups/add_devices", + name: "Add Devices to Group" + }], "device-mgt/admin", type); + userModule.addPermissions([{ + key: "groups/remove_devices", + name: "Remove Devices from Group" + }], "device-mgt/admin", type); + userModule.addPermissions([{ + key: "groups/modify", + name: "Modify Group" + }], "device-mgt/admin", type); + userModule.addPermissions([{ + key: "groups/share", + name: "Change Group Sharing" + }], "device-mgt/admin", type); + userModule.addPermissions([{ + key: "groups/delete", + name: "Delete Group" + }], "device-mgt/admin", type); + userModule.addPermissions([{key: "users", name: "Users"}], "device-mgt/admin", type); userModule.addPermissions([{ key: "users/add", @@ -88,35 +110,15 @@ utility = function () { name: "Perform Operation" }], "device-mgt/user", "init"); - // Group Management Permissions + userModule.addPermissions([{key: "groups", name: "Groups"}], "device-mgt/user", type); userModule.addPermissions([{ key: "groups/monitor", name: "Monitor Devices in Group" - }], "group-mgt/user", "init"); + }], "device-mgt/user", type); userModule.addPermissions([{ key: "groups/operation", name: "Perform Device Operation" - }], "group-mgt/user", "init"); - userModule.addPermissions([{ - key: "groups/add_devices", - name: "Add Devices to Group" - }], "group-mgt/user", "init"); - userModule.addPermissions([{ - key: "groups/remove_devices", - name: "Remove Devices from Group" - }], "group-mgt/user", "init"); - userModule.addPermissions([{ - key: "groups/modify", - name: "Modify Group" - }], "group-mgt/user", "init"); - userModule.addPermissions([{ - key: "groups/share", - name: "Change Group Sharing" - }], "group-mgt/user", "init"); - userModule.addPermissions([{ - key: "groups/delete", - name: "Delete Group" - }], "group-mgt/user", "init"); + }], "device-mgt/user", type); }; return publicMethods; From 35aaffd7e03ac1e201cc831ca742283a09b40901 Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 24 Jul 2015 22:59:29 +0530 Subject: [PATCH 4/8] Commit before unified framework changes [Unstable] --- .../jaggeryapps/iotserver/api/group-api.jag | 200 ++++++++++ .../jaggeryapps/iotserver/jaggery.conf | 4 + .../iotserver/pages/devices/index.hbs | 2 +- .../jaggeryapps/iotserver/pages/group.hbs | 23 ++ .../iotserver/units/appbar/appbar.js | 9 + .../extended-search-box.hbs | 8 +- .../public/js/extended-search-box.js | 6 +- .../units/group-detail/group-detail.hbs | 174 +++++++++ .../units/group-detail/group-detail.js | 55 +++ .../units/group-detail/group-detail.json | 3 + .../units/group-detail/public/img/graph.png | Bin 0 -> 5431 bytes .../group-detail/public/img/group-icon.png | Bin 0 -> 6097 bytes .../group-detail/public/js/group-detail.js | 69 ++++ .../units/group-listing/group-listing.hbs | 168 +++++++++ .../units/group-listing/group-listing.js | 12 + .../units/group-listing/group-listing.json | 3 + .../public/images/group-icon.png | Bin 0 -> 6097 bytes .../group-listing/public/js/group-listing.js | 343 ++++++++++++++++++ .../public/templates/group-listing.hbs | 54 +++ .../units/theme/public/css/custom-desktop.css | 10 +- 20 files changed, 1130 insertions(+), 13 deletions(-) create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.json create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/graph.png create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/group-icon.png create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/js/group-detail.js create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.json create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/images/group-icon.png create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag new file mode 100644 index 00000000..fb9535c1 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag @@ -0,0 +1,200 @@ +<% +/* + * Copyright (c) 2015, 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. + */ + +var uri = request.getRequestURI(); +var uriMatcher = new URIMatcher(String(uri)); + +var log = new Log("api/group-api.jag"); + +var constants = require("/modules/constants.js"); +var dcProps = require('/config/dc-props.js').config(); + +var carbon = require('carbon'); +var carbonHttpsServletTransport = carbon.server.address('https'); +var deviceCloudService = carbonHttpsServletTransport + "/devicecloud/group_manager"; + +var user = session.get(constants.USER_SESSION_KEY); +if (!user) { + response.sendRedirect(dcProps.appContext + "login?#login-required"); + exit();//stop execution +} + +var result; +var endPoint; +var data; +var groupId; + +if (uriMatcher.match("/{context}/api/group/add")) { + + var name = request.getParameter("name"); + var description = request.getParameter("description"); + + //URL: POST https://localhost:9443/devicecloud/group_manager/group/add + endPoint = deviceCloudService + "/group/add"; + data = {"name": name, "username": user.username, "description": description}; + result = post(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) { + + groupId = uriMatcher.elements().groupId; + name = request.getParameter("name"); + description = request.getParameter("description"); + + //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId} + endPoint = deviceCloudService + "id/" + groupId; + data = {"name": name, "username": user.username, "description": description}; + result = put(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/remove")) { + + groupId = uriMatcher.elements().groupId; + + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId} + endPoint = deviceCloudService + "id/" + groupId; + data = {"username": user.username}; + result = del(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) { + + groupId = uriMatcher.elements().groupId; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId} + endPoint = deviceCloudService + "id/" + groupId; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) { + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/name/{name} + endPoint = deviceCloudService + "name/" + uriMatcher.elements().groupName; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/all")) { + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/all + endPoint = deviceCloudService + "/group/all"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/all/count")) { + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/all/count + endPoint = deviceCloudService + "/group/all/count"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { + + groupId = uriMatcher.elements().groupId; + var shareUser = request.getParameter("shareUser"); + role = request.getParameter("role"); + + //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share + endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; + data = {"username": user.username, "shareUser":shareUser, "role":role}; + result = post(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { + + groupId = uriMatcher.elements().groupId; + var unShareUser = request.getParameter("unShareUser"); + role = request.getParameter("role"); + + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share + endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; + data = {"username": user.username, "unShareUser":unShareUser, "role":role}; + result = del(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) { + + groupId = uriMatcher.elements().groupId; + var permissions = request.getParameter("permissions"); + role = request.getParameter("role"); + + //URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role + endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; + data = {"username": user.username, "permissions":permissions, "role":role}; + result = post(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) { + + groupId = uriMatcher.elements().groupId; + role = request.getParameter("role"); + + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role + endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; + data = {"username": user.username, "role":role}; + result = del(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) { + + groupId = uriMatcher.elements().groupId; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/role/all"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/role/all")) { + + groupId = uriMatcher.elements().groupId; + var userId = uriMatcher.elements().userId; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/{user}/role/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/" + userId +"/role/all"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/user/all")) { + + groupId = uriMatcher.elements().groupId; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/user/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/user/all"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/all")) { + + groupId = uriMatcher.elements().groupId; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/device/all"; + data = {"username": user.username}; + result = get(endPoint, data, "json"); + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) { + + groupId = uriMatcher.elements().groupId; + var deviceId = request.getParameter("deviceId"); + var deviceType = request.getParameter("deviceType"); + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/assign + endPoint = deviceCloudService + "/group/id/" + groupId + "/device/assign"; + data = {"username": user.username, "deviceId":deviceId, "deviceType":deviceType}; + result = put(endPoint, data, "json"); + +} + +// returning the result. +if (result) { + print(result); +} +%> diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/jaggery.conf b/modules/distribution/src/repository/jaggeryapps/iotserver/jaggery.conf index 420fe87e..2771f3c3 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/jaggery.conf +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/jaggery.conf @@ -19,6 +19,10 @@ "url": "/api/devices/*", "path": "/api/device-api.jag" }, + { + "url": "/api/group/*", + "path": "/api/group-api.jag" + }, { "url": "/api/operation/*", "path": "/api/operation-api.jag" diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/index.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/index.hbs index ea9cd1a3..c2ec062f 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/index.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/index.hbs @@ -5,7 +5,7 @@ {{/zone}} {{#zone "body"}} {{unit "appbar" link="device-mgt" title="My Devices"}} - {{unit "extended-search-box"}} + {{unit "extended-search-box" item="Device"}} {{unit "operation-mod"}}
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs new file mode 100644 index 00000000..3246f4c5 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs @@ -0,0 +1,23 @@ +{{authorized}} +{{layout "fluid"}} +{{#zone "title"}} + Groups +{{/zone}} +{{#zone "body"}} + {{unit "appbar" link="group-mgt" title="My Groups"}} + {{unit "extended-search-box" item="Group"}} + {{unit "operation-mod"}} +
+
+ +
+
+ +
+ {{unit "operation-bar"}} + {{unit "group-listing"}} +
+ +
+
+{{/zone}} \ No newline at end of file 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 381b757a..56288fb8 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js @@ -7,6 +7,7 @@ function onRequest(context) { "policies": [], "profiles": [], "device-mgt": [], + "group-mgt": [], "store": [], "dashboard": [], "analytics" : [] @@ -37,6 +38,7 @@ function onRequest(context) { links.store.push(storeLink); links.analytics.push(deviceMgtLink); links['device-mgt'].push(dashboardLink); + links['group-mgt'].push(dashboardLink); if (!carbonUser) { //user is not logged in @@ -74,6 +76,13 @@ function onRequest(context) { url: "/iotserver/devices/add-device" }); } + if (permissions.ADD_DEVICE) { + links["group-mgt"].push({ + title: "Add Group", + icon: "fw-add", + url: "/iotserver/group#add-device" + }); + } }// end-if-user context.currentActions = links[context.link]; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/extended-search-box.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/extended-search-box.hbs index 62bace1d..edad07c6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/extended-search-box.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/extended-search-box.hbs @@ -71,7 +71,7 @@
- +
@@ -79,9 +79,9 @@ diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/public/js/extended-search-box.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/public/js/extended-search-box.js index 3f6ea637..3ba305e0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/public/js/extended-search-box.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/extended-search-box/public/js/extended-search-box.js @@ -51,7 +51,7 @@ $(document).ready(function(){ $(searchBtn).click(function(){ var input = $(searchField).html(); var searchType = $(searchField).data("search-type"); - loadDevices(searchType, input); + loadGroups(searchType, input); }); }); @@ -123,7 +123,7 @@ function containerUpdate(asset){ function selectAsset(asset){ var platformType = $(asset).data("type"); loadOperationBar(platformType); - loadDevices("type", platformType); + loadGroups("type", platformType); //$(tagsContainer +' span').each(function(){ // if($(this).attr('level') == $(asset).attr('level')){ // removeTags(this); @@ -218,5 +218,5 @@ function removeTags(tag){ $(this).remove(); }); unloadOperationBar(); - loadDevices(); + loadGroups(); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs new file mode 100644 index 00000000..92c4f7e4 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs @@ -0,0 +1,174 @@ +{{#zone "main"}} +
+
+ +
+
+
+
+ +
+
+ {{unit "operation-bar"}} +
+
+ + + +
+
+
+ +
+
+
Owner: {{group.ownerId}}
+
Date of Enrollment:
{{group.enrollment}}
+
+
+
+ +
+ + +
+ +
+ {{#if group.viewModel.BatteryLevel}} +
+
+
BATTERY
+
+
+
{{group.viewModel.BatteryLevel}}%
+
+
+
+ {{/if}} + + {{#if group.viewModel.DeviceCapacity}} +
+
+
STORAGE
+
+
+
{{group.viewModel.DeviceCapacityPercentage}}%{{group.viewModel.DeviceCapacityUsed}} GB Free
+
+
+
+ {{/if}} + {{#if group.viewModel.internal_memory.FreeCapacity}} +
+
+
LOCAL STORAGE
+
+
+
{{group.viewModel.internal_memory.DeviceCapacityPercentage}}%{{group.viewModel.internal_memory.FreeCapacity}} GB Free
+
+
+
+ {{/if}} + {{#if group.viewModel.external_memory.FreeCapacity}} +
+
+
EXTERNAL STORAGE
+
+
+
{{group.viewModel.external_memory.DeviceCapacityPercentage}}%{{group.viewModel.external_memory.FreeCapacity}} GB Free
+
+
+
+ {{/if}} +
+ +
+ + +
+ + + + + +
+ +
+
+ Not available yet +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+
+ +{{/zone}} +{{#zone "bottomJs"}} + + +{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js new file mode 100644 index 00000000..ac6935bd --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js @@ -0,0 +1,55 @@ +function onRequest(context) { + var uri = request.getRequestURI(); + var uriMatcher = new URIMatcher(String(uri)); + var isMatched = uriMatcher.match("/{context}/group/id/{groupId}"); + if (isMatched) { + var matchedElements = uriMatcher.elements(); + var groupId = matchedElements.groupId; + context.groupId = groupId; + //var group = deviceModule.viewDevice(deviceType, deviceId); + //if (device){ + // var viewModel = {}; + // var deviceInfo = device.properties.DEVICE_INFO; + // if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0){ + // deviceInfo = JSON.parse(deviceInfo); + // if (device.type == "ios"){ + // viewModel.imei = device.properties.IMEI; + // viewModel.phoneNumber = deviceInfo.PhoneNumber; + // viewModel.udid = deviceInfo.UDID; + // viewModel.BatteryLevel = Math.round(deviceInfo.BatteryLevel * 100); + // viewModel.DeviceCapacity = Math.round(deviceInfo.DeviceCapacity * 100) / 100; + // viewModel.AvailableDeviceCapacity = Math.round(deviceInfo.AvailableDeviceCapacity * 100) / 100; + // viewModel.DeviceCapacityUsed = Math.round((viewModel.DeviceCapacity + // - viewModel.AvailableDeviceCapacity) * 100) / 100; + // viewModel.DeviceCapacityPercentage = Math.round(viewModel.DeviceCapacityUsed + // / viewModel.DeviceCapacity * 10000) /100; + // }else if(device.type == "android"){ + // viewModel.imei = device.properties.IMEI; + // viewModel.model = device.properties.DEVICE_MODEL; + // viewModel.vendor = device.properties.VENDOR; + // viewModel.internal_memory = {}; + // viewModel.external_memory = {}; + // viewModel.location = { + // latitude: device.properties.LATITUDE, + // longitude: device.properties.LONGITUDE + // }; + // viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL; + // viewModel.internal_memory.FreeCapacity = Math.round((deviceInfo.INTERNAL_TOTAL_MEMORY - + // deviceInfo.INTERNAL_AVAILABLE_MEMORY) * 100) / 100; + // viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY + // / deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100; + // viewModel.external_memory.FreeCapacity = Math.round((deviceInfo.EXTERNAL_TOTAL_MEMORY - + // deviceInfo.EXTERNAL_AVAILABLE_MEMORY) * 100) / 100; + // viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY + // /deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) /100; + // } + // viewModel.enrollment = device.enrollment; + // device.viewModel = viewModel; + // } + //} + context.group = groupId; + } else { + response.sendError(404); + } + return context; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.json new file mode 100644 index 00000000..3dbff381 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.json @@ -0,0 +1,3 @@ +{ + "predicate": "false" +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/graph.png b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/graph.png new file mode 100644 index 0000000000000000000000000000000000000000..dd819ef4fcd087ae7e802a23fec22bb60d05e42c GIT binary patch literal 5431 zcmaJ_c|4Te+qY*+h)IeWBV-+8pUD!2LL}>iYAl1X%rJ{>#2~VjB1@L6DcP3@$&w|6 zDEnI3_h;@_1cfv-25IB)Xpo|eytKV66be#Ol7T8HDk(vwKytEBIf(4Ztt1UqfGaA&<&;5x zUEmXMcn3$g2}1WTUniCt*qKQ5fI}eO-rh3a@-jHQ69fu_!G3GV$w{9eqzS%QqOFfK zmLUAM0s>92$74K*7#tS#ThZ1IMwxnni2sQqobqyHy44kC%L1s#J{-?|K;lZEBALPxO<#n|RL}43KV^Gj{8RX7 z>`ArbPs;jvNcSEM4OhM%LetD=WI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OXQw{G-I3AQlet*L?7!HfTVqPx><)=~<$8p;+5+f2Uj^y*%>WBekO^Yd7ej<@+oL97o=) zNKPiPU88aB&&vV7Lf4+DZ7YOq2ZzpXMvZf=!eWslj~I?xF<*?xG37hGb(k~1xRZs4?>&91F|`5r@C3v*$7eRA1a4JKj?iHqZXlhh}kpAQ9PeWWyFf zQbf*I4V#+27$_JMe>L4K4+iW)jLPjU7>z;jp6ba_ajMhGOK%w$#azP4&Ax~ zu^wM|I31J<`25A@g5AJ(L_!9msk- z$0KxAgt^2o%kpSVAz!qf>nNtsfjV-OduBO|91v$qOEF$GkY(#Hy@gt6l}x`TBD!3B zOeEWVZPc_F(En8Z(BT<-%jMpTsn^pCF0q@J+ z3CFPejSIcb4Qe`t%zhmBBzO#c>&Z(+wN}5qT4o^p8hxjVhLsZHNo)l$0WV;ED;$Boi5hP0Q{2i%Fu z^ppQg7;+k#Wq-I$x>1@j3S~rCvUG z3{Uc!SYv!)93`X`@=Tk$PX19qnMa(__w0_3Yi5vIWgnVsCK}a#!Bf9eyMO5UMPXA1 zY`y{mb#0W=KF9?sG!s<%E^G1AO$R;KR=bvKxRXxM)FbDvR|m&YW~{O~nsM1slrWY! z{a`Tpjn-&ESO!NcpM&F#Lut1}U=;Gf6KG do5ytQG>>z2#Y$jY8NZJ*^>mC7MOvuf{{g(Y2Y3Jg literal 0 HcmV?d00001 diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/group-icon.png b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/img/group-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ac34c1b2aff02bbc390f0c188acfeb7400cc4cce GIT binary patch literal 6097 zcmXY#2{hF2_s5@E7{)Th*!L}D4cYgxWf@rtS;msGi|k?uP1%|vR6=C3t7J=z$d)a9 zB`G5fDP&7_zv+Me=W{;ic|P~K=Q;Ot&-1yT*L~lzwJ~Es@*x2LEEeV%I{+ZGDFiUk z(+1bDXTG$7-pkSq1CI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*9+^ zTsvXQ-3F(LTxeFO63J^ySSks!Cc{Z-!{}B+Gz@8CU3?egskRh;8}uKgG1=ut^GEQtG}VdjoIQp>8Vp81N&X$^_($A4$j8A6VhAecqE>KiLv zLbkh0knUB+8N?{}(qf{hm}L$$7AT8PHc%X8^>u;RI+P1!m~Qp+o0lKyEv}BkM7~)v z9o-wi!VH`UeN5fsddqZp-c>DQ;1$O+3dPYGT%Z)~(O7pOi{{%H2cdmPE>AXS^U65r zU%(9Ci+OGG9THU_1fHuH70RmqOTUQ!O=vb4L~J`($Cg1vei~e{PqhhaMX> + +
+ +
+
+

Loading...

+
+
+ +
+ +
+ +
+
+

You don't have any Groups registered at the moment.

+

+ + + + + + Add New Group + +

+
+
+ +
+ +
+
+
+
+

Do you really want to remove this group from your Group List?

+ +
+
+
+
+ +
+
+
+
+

Group was successfully removed.

+ +
+
+
+
+ +
+
+
+
+

Please enter new name for the group?

+
+
+ +
+ +
+
+
+
+ +
+
+
+
+

Group was successfully updated.

+ +
+
+
+
+ +
+
+
+
+

Exception at backend. Try Later.

+ +
+
+
+
+ +
+
+
+
+

Action not permitted.

+ +
+
+
+
+ +
+
+
+
+

Group does not exist.

+ +
+
+
+
+ +
+
+
+
+

Group does not exist.

+ +
+
+
+
+{{/zone}} +{{#zone "bottomJs"}} + + +{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js new file mode 100644 index 00000000..96820097 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js @@ -0,0 +1,12 @@ +function onRequest(context){ + //var userModule = require("/modules/user.js").userModule; + var permissions = []; + //if(userModule.isAuthorized("/permission/device-mgt/admin/devices/list")){ + // permissions.push("LIST_GROUPS"); + //}else if(userModule.isAuthorized("/permission/device-mgt/user/devices/list")){ + // permissions.push("LIST_OWN_GROUPS"); + //} + permissions.push("LIST_GROUPS"); + context.permissions = stringify(permissions); + return context; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.json new file mode 100644 index 00000000..3dbff381 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.json @@ -0,0 +1,3 @@ +{ + "predicate": "false" +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/images/group-icon.png b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/images/group-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ac34c1b2aff02bbc390f0c188acfeb7400cc4cce GIT binary patch literal 6097 zcmXY#2{hF2_s5@E7{)Th*!L}D4cYgxWf@rtS;msGi|k?uP1%|vR6=C3t7J=z$d)a9 zB`G5fDP&7_zv+Me=W{;ic|P~K=Q;Ot&-1yT*L~lzwJ~Es@*x2LEEeV%I{+ZGDFiUk z(+1bDXTG$7-pkSq1CIY)#cxRWXcop$bLVgXm^l935b)p;56y_UW?^lDm__g~sEVZd zO1=Sr+uZ_V=ny@<;&$%J`QFAOsqdnwm_B2njXO78%|%l=-pQ6wj1xg{a&n6CJhL@4EJ>ng=5hM#nH}^b z@hI^)Zu0B#y0?75AkWqv z6oR9mV=wIw^l>=%5`^tjP9oW!iokOLl^K&*fQf{K z3L6wH7Og)e%us{JU?M;5kJdqsFc{|Xe$Y~?3NW$M5SWr+-{LY)~ku2Bf_!;j2w^HWfL8hUBsnUcLns{V zF@~}~AUm}OhYm-rAD|RfzhVSiGQ^2~6f1Rlj)~n_jJ8v}El(Qv*~>TGpJO3~ILbIKZn5oWR)=<+dQ;Rky24x+I@ zPx@FS*F%t&WZ0U~?nB6o+36DxM|<7bTdethKyr4=zP@CaEQSFYG+Mk<-$mg?>zh><3HK=UF8junk8=f0+jCIb`*$3ei(x0bg+;EMpD<+fjq0g z*13{jE=)StLSHh#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itm#h597iA4TpPAXIwHH_DXbpRV@;A zgLpO4)bg?;i$R&@bV6@~aM1-=DXpc;bS!6Sg&$D#=D6?|iLP&5xrm9{2m9U>hCrYZ zl;Ia~zPr=A@kD>~Lu zOGrQS@WO#T(Zvsy-!?ezezgmni`FEEzSRDQR39!CAl9Un)B`OrwOR-J$`UIzgaM7q z8GexmytF#i{c50LhfQQupyu=IUlMY${q}mZ3CN^~>afbwK@AAN-oixj7r7tpj&ap_ z;7uu`s^&M|t8i1I!|4JA)^zjsSt2QdQJPBKTGhHcaiya23+33MgxVIN5``l3D%?Efs1ZdV&PY}8}ikBnvQ)RvmBXB zemo^i2%&1}ya%Q6bSU}t#M^y}ydArT*NTMLoY!*Y6{Co+wYN`Cb63N5x=vuTdes)Sqn_(Dq!@aFuvj|W3rEOa8 z$ocgltjk2yt?YLlL#;}#^U#3i$I@(i8RvsgvxjQsaAOd{j1S?)Uh0*?f5}R9g6raq zauV|g>au*nqB%?#|Ke04)7=IS^-q0tvs!vRVm}~ka6{M~7{&+IZ_H^VY^ig|3*9+^ zTsvXQ-3F(LTxeFO63J^ySSks!Cc{Z-!{}B+Gz@8CU3?egskRh;8}uKgG1=ut^GEQtG}VdjoIQp>8Vp81N&X$^_($A4$j8A6VhAecqE>KiLv zLbkh0knUB+8N?{}(qf{hm}L$$7AT8PHc%X8^>u;RI+P1!m~Qp+o0lKyEv}BkM7~)v z9o-wi!VH`UeN5fsddqZp-c>DQ;1$O+3dPYGT%Z)~(O7pOi{{%H2cdmPE>AXS^U65r zU%(9Ci+OGG9THU_1fHuH70RmqOTUQ!O=vb4L~J`($Cg1vei~e{PqhhaMX> +
+ +
+ + + +{{/each}} + +
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css index 1f361a96..beed45c6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css @@ -250,23 +250,23 @@ a.ast-type-item:hover { } @media (min-width: 768px){ - .ctrl-wr-asset { width: 24%; } + .ctrl-wr-asset { width: 30%; } } @media (min-width: 992px){ - .ctrl-wr-asset { width: 19%; } + .ctrl-wr-asset { width: 25%; } } @media (min-width:1300px){ - .ctrl-wr-asset { width: 13%; } + .ctrl-wr-asset { width: 19%; } } @media (min-width:1500px){ - .ctrl-wr-asset { width: 11.5%; } + .ctrl-wr-asset { width: 17.5%; } } @media (min-width:1800px){ - .ctrl-wr-asset { width: 9%; } + .ctrl-wr-asset { width: 15%; } } .ctrl-wr-asset.selected { From b59a2e22dece732c0dd4511c41e8c9f092e032aa Mon Sep 17 00:00:00 2001 From: charithag Date: Sat, 25 Jul 2015 10:25:52 +0530 Subject: [PATCH 5/8] Group module completed without sharing --- .../jaggeryapps/iotserver/api/group-api.jag | 52 ++++--- .../jaggeryapps/iotserver/api/user-api.jag | 2 +- .../jaggeryapps/iotserver/pages/group.hbs | 19 +-- .../iotserver/pages/groups/index.hbs | 23 +++ .../iotserver/units/appbar/appbar.hbs | 5 +- .../iotserver/units/appbar/appbar.js | 3 +- .../units/device-detail/device-detail.js | 1 + .../units/device-listing/device-listing.js | 2 + .../units/group-detail/group-detail.hbs | 10 +- .../units/group-detail/group-detail.js | 56 ++----- .../group-detail/public/js/group-detail.js | 39 ----- .../units/group-listing/group-listing.hbs | 89 +++++++++-- .../group-listing/public/js/group-listing.js | 147 ++++++++++++++---- .../public/templates/group-listing.hbs | 17 +- .../units/operation-bar/operation-bar.js | 1 - .../units/operation-mod/operation-mod.js | 3 + .../units/theme/public/css/custom-desktop.css | 2 +- .../units/theme/public/css/fontwso2.css | 4 + .../iotserver/units/theme/public/css/main.css | 16 ++ 19 files changed, 310 insertions(+), 181 deletions(-) create mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag index fb9535c1..6014b482 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag @@ -42,47 +42,48 @@ var groupId; if (uriMatcher.match("/{context}/api/group/add")) { - var name = request.getParameter("name"); - var description = request.getParameter("description"); - - //URL: POST https://localhost:9443/devicecloud/group_manager/group/add - endPoint = deviceCloudService + "/group/add"; + var group = request.getContent(); + var name = group["name"]; + var description = group["description"]; + //URL: POST https://localhost:9443/devicecloud/group_manager/group + endPoint = deviceCloudService + "/group"; data = {"name": name, "username": user.username, "description": description}; result = post(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) { groupId = uriMatcher.elements().groupId; - name = request.getParameter("name"); - description = request.getParameter("description"); + group = request.getContent(); + name = group["name"]; + description = group["description"]; //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId} - endPoint = deviceCloudService + "id/" + groupId; + endPoint = deviceCloudService + "/group/id/" + groupId; data = {"name": name, "username": user.username, "description": description}; result = put(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/remove")) { groupId = uriMatcher.elements().groupId; - + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId} - endPoint = deviceCloudService + "id/" + groupId; + endPoint = deviceCloudService + "/group/id/" + groupId; data = {"username": user.username}; result = del(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) { - groupId = uriMatcher.elements().groupId; - + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId} - endPoint = deviceCloudService + "id/" + groupId; + endPoint = deviceCloudService + "/group/id/" + groupId; + log.info(endPoint); data = {"username": user.username}; result = get(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) { //URL: GET https://localhost:9443/devicecloud/group_manager/group/name/{name} - endPoint = deviceCloudService + "name/" + uriMatcher.elements().groupName; + endPoint = deviceCloudService + "/group/name/" + uriMatcher.elements().groupName; data = {"username": user.username}; result = get(endPoint, data, "json"); @@ -103,8 +104,8 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { groupId = uriMatcher.elements().groupId; - var shareUser = request.getParameter("shareUser"); - role = request.getParameter("role"); + var shareUser = request.getContent()["shareUser"]; + role = request.getContent()["role"]; //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; @@ -114,8 +115,8 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { groupId = uriMatcher.elements().groupId; - var unShareUser = request.getParameter("unShareUser"); - role = request.getParameter("role"); + var unShareUser = request.getContent()["unShareUser"]; + role = request.getContent()["role"]; //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; @@ -125,8 +126,8 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) { groupId = uriMatcher.elements().groupId; - var permissions = request.getParameter("permissions"); - role = request.getParameter("role"); + var permissions = request.getContent()["permissions"]; + role = request.getContent()["role"]; //URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; @@ -136,7 +137,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) { groupId = uriMatcher.elements().groupId; - role = request.getParameter("role"); + role = request.getContent()["role"]; //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; @@ -146,7 +147,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) { groupId = uriMatcher.elements().groupId; - + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role/all endPoint = deviceCloudService + "/group/id/" + groupId + "/role/all"; data = {"username": user.username}; @@ -183,8 +184,8 @@ if (uriMatcher.match("/{context}/api/group/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) { groupId = uriMatcher.elements().groupId; - var deviceId = request.getParameter("deviceId"); - var deviceType = request.getParameter("deviceType"); + var deviceId = request.getContent()["deviceId"]; + var deviceType = request.getContent()["deviceType"]; //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/assign endPoint = deviceCloudService + "/group/id/" + groupId + "/device/assign"; @@ -195,6 +196,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { // returning the result. if (result) { - print(result); + response.status = result.xhr.status; + print(false); } %> diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag index 39f046cc..7a16d385 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag @@ -79,7 +79,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) { } else { userRoles = String(addUserFormData.userRoles).split(","); } - userRoles="deviceRole, deviceUser" + try { result = userModule.registerUser(username, firstname, lastname, emailAddress, password, userRoles); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs index 3246f4c5..77007027 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/group.hbs @@ -1,23 +1,12 @@ {{authorized}} {{layout "fluid"}} {{#zone "title"}} - Groups + Group Management {{/zone}} {{#zone "body"}} - {{unit "appbar" link="group-mgt" title="My Groups"}} - {{unit "extended-search-box" item="Group"}} {{unit "operation-mod"}} -
-
+ {{unit "appbar" enableBack=true title="Group"}} + + {{unit "group-detail"}} -
-
- -
- {{unit "operation-bar"}} - {{unit "group-listing"}} -
- -
-
{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs new file mode 100644 index 00000000..3246f4c5 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs @@ -0,0 +1,23 @@ +{{authorized}} +{{layout "fluid"}} +{{#zone "title"}} + Groups +{{/zone}} +{{#zone "body"}} + {{unit "appbar" link="group-mgt" title="My Groups"}} + {{unit "extended-search-box" item="Group"}} + {{unit "operation-mod"}} +
+
+ +
+
+ +
+ {{unit "operation-bar"}} + {{unit "group-listing"}} +
+ +
+
+{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs index 20489738..20b965e6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs @@ -12,7 +12,7 @@ {{title}} - {{#each currentActions}} + {{#each currentActions}} @@ -41,7 +41,8 @@
    -
  • My Devices
  • +
  • My Devices
  • +
  • My Groups
  • {{#if permissions.ADD_USER}}
  • User Management
  • {{/if}} 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 56288fb8..73313ec2 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js @@ -80,7 +80,8 @@ function onRequest(context) { links["group-mgt"].push({ title: "Add Group", icon: "fw-add", - url: "/iotserver/group#add-device" + url: "#", + class: "add-group-link" }); } }// end-if-user diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.js index 769d3041..7c2f88b2 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.js @@ -1,3 +1,4 @@ +var log = new Log("modules/device-detail.js"); function onRequest(context) { var uri = request.getRequestURI(); var uriMatcher = new URIMatcher(String(uri)); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js index 3a5fc9b6..3760f748 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js @@ -1,3 +1,5 @@ +var log = new Log("modules/device-listing.js"); + function onRequest(context){ var userModule = require("/modules/user.js").userModule; var permissions = []; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs index 92c4f7e4..4031ac65 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs @@ -1,7 +1,7 @@ {{#zone "main"}}
    -
    -
    Owner: {{group.ownerId}}
    -
    Date of Enrollment:
    {{group.enrollment}}
    +
    No. of Devices: {{group.deviceCount}}
    +
    Users: {{group.users}}
    +
    Created on:
    {{group.dateOfCreation}}
    +
    Modified on:
    {{group.dateOfLastUpdate}}
@@ -107,7 +109,7 @@ diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js index ac6935bd..9b3738ee 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js @@ -1,53 +1,23 @@ +var log = new Log("modules/group-detail.js"); + function onRequest(context) { var uri = request.getRequestURI(); var uriMatcher = new URIMatcher(String(uri)); - var isMatched = uriMatcher.match("/{context}/group/id/{groupId}"); + var isMatched = uriMatcher.match("/{context}/group/{groupId}"); if (isMatched) { + var carbon = require('carbon'); + var carbonHttpsServletTransport = carbon.server.address('https'); + var matchedElements = uriMatcher.elements(); var groupId = matchedElements.groupId; - context.groupId = groupId; - //var group = deviceModule.viewDevice(deviceType, deviceId); - //if (device){ - // var viewModel = {}; - // var deviceInfo = device.properties.DEVICE_INFO; - // if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0){ - // deviceInfo = JSON.parse(deviceInfo); - // if (device.type == "ios"){ - // viewModel.imei = device.properties.IMEI; - // viewModel.phoneNumber = deviceInfo.PhoneNumber; - // viewModel.udid = deviceInfo.UDID; - // viewModel.BatteryLevel = Math.round(deviceInfo.BatteryLevel * 100); - // viewModel.DeviceCapacity = Math.round(deviceInfo.DeviceCapacity * 100) / 100; - // viewModel.AvailableDeviceCapacity = Math.round(deviceInfo.AvailableDeviceCapacity * 100) / 100; - // viewModel.DeviceCapacityUsed = Math.round((viewModel.DeviceCapacity - // - viewModel.AvailableDeviceCapacity) * 100) / 100; - // viewModel.DeviceCapacityPercentage = Math.round(viewModel.DeviceCapacityUsed - // / viewModel.DeviceCapacity * 10000) /100; - // }else if(device.type == "android"){ - // viewModel.imei = device.properties.IMEI; - // viewModel.model = device.properties.DEVICE_MODEL; - // viewModel.vendor = device.properties.VENDOR; - // viewModel.internal_memory = {}; - // viewModel.external_memory = {}; - // viewModel.location = { - // latitude: device.properties.LATITUDE, - // longitude: device.properties.LONGITUDE - // }; - // viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL; - // viewModel.internal_memory.FreeCapacity = Math.round((deviceInfo.INTERNAL_TOTAL_MEMORY - - // deviceInfo.INTERNAL_AVAILABLE_MEMORY) * 100) / 100; - // viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY - // / deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100; - // viewModel.external_memory.FreeCapacity = Math.round((deviceInfo.EXTERNAL_TOTAL_MEMORY - - // deviceInfo.EXTERNAL_AVAILABLE_MEMORY) * 100) / 100; - // viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY - // /deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) /100; - // } - // viewModel.enrollment = device.enrollment; - // device.viewModel = viewModel; - // } + var endpoint = carbonHttpsServletTransport + "/" + matchedElements.context + "/api/group/id/" + groupId; + log.info(endpoint); + //var result = get(endpoint, {}, "json"); + //if (result){ + // context.group = result.data; + //}else{ + // response.sendError(503); //} - context.group = groupId; } else { response.sendError(404); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/js/group-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/js/group-detail.js index c453c889..18462e9d 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/js/group-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/public/js/group-detail.js @@ -24,46 +24,7 @@ function formatDates(){ } (function () { - var deviceId = $(".device-id"); - var deviceIdentifier = deviceId.data("deviceid"); - var deviceType = deviceId.data("type"); - var payload = [deviceIdentifier]; - if (deviceType == "ios") { - var serviceUrl = "/ios/operation/deviceinfo"; - } else if (deviceType == "android") { - var serviceUrl = "/mdm-android-agent/operation/device-info"; - } - invokerUtil.post(serviceUrl, payload, - function(message){ - console.log(message); - }, function (message) { - console.log(message); - }); $(document).ready(function(){ - loadOperationBar(deviceType); - loadMap(); formatDates(); }); - function loadMap(){ - var map; - function initialize() { - var mapOptions = { - zoom: 18 - }; - var lat = 6.9098591; - var long = 79.8523753; - map = new google.maps.Map(document.getElementById('device-location'), - mapOptions); - - var pos = new google.maps.LatLng(lat, - long); - var marker = new google.maps.Marker({ - position: pos, - map: map - }); - - map.setCenter(pos); - } - google.maps.event.addDomListener(window, 'load', initialize); - } }()); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs index 18d3f6a3..54bcd732 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs @@ -12,22 +12,22 @@
- +

You don't have any Groups registered at the moment.

- + - Add New Group - + Add New Group +

- +
@@ -35,6 +35,7 @@

Do you really want to remove this group from your Group List?

+
    Yes     @@ -54,6 +55,7 @@
+ + +
+
+
+
+

Group successfully added.

+ + +
+
+
+
+
-

Please enter new name for the group?

+

Please enter new name and description for the group

+
+ +
+ +

+
- +
-     Rename     +     Update        @@ -92,6 +149,7 @@

Group was successfully updated.

+
    Ok     @@ -107,8 +165,9 @@

Exception at backend. Try Later.

+
@@ -122,8 +181,9 @@

Action not permitted.

+ @@ -137,8 +197,9 @@

Group does not exist.

+ @@ -152,8 +213,9 @@

Group does not exist.

+ @@ -163,6 +225,7 @@
{{/zone}} {{#zone "bottomJs"}} - + {{/zone}} \ No newline at end of file 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 bcf97385..d6e7ba65 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 @@ -144,9 +144,9 @@ function loadGroups(searchType, searchParam) { var successCallback = function (data) { data = JSON.parse(data); var viewModel = {}; - viewModel.groups = data.data; + viewModel.groups = data; viewModel.imageLocation = imageResource; - if(!data.data || data.data.length <= 0){ + if (!data || data.length <= 0) { $("#ast-container").html($("#no-groups-div-content").html()); } else { var content = template(viewModel); @@ -160,6 +160,7 @@ function loadGroups(searchType, searchParam) { attachEvents(); formatDates(); } + attachGroupAdding(); }; invokerUtil.get(serviceURL, successCallback, function (message) { @@ -171,8 +172,8 @@ $(document).ready(function () { loadGroups(); }); -function formatDates(){ - $(".formatDate").each(function(){ +function formatDates() { + $(".formatDate").each(function () { var timeStamp = $(this).html(); $(this).html(new Date(parseInt(timeStamp)).toUTCString()); }); @@ -222,6 +223,71 @@ function hidePopup() { $(modalPopup).hide(); } +function attachGroupAdding() { + /** + * Following click function would execute + * when a user clicks on "Remove" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.add-group-link").click(function () { + var addGroupApi = "/iotserver/api/group/add"; + $(modalPopupContent).html($('#add-group-modal-content').html()); + showPopup(); + + $("a#add-group-yes-link").click(function () { + var newGroupName = $('#add-group-name').val(); + var newGroupDescription = $('#add-group-description').val(); + var group = {"name": newGroupName, "description": newGroupDescription}; + invokerUtil.post( + addGroupApi, + group, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + if (data != "false") { + $(modalPopupContent).html($('#add-group-200-content').html()); + $("a#add-group-200-link").click(function () { + hidePopup(); + location.reload(); + }); + } else { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } + } else if (status == 400) { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#agroup-403-content').html()); + $("a#group-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } + }, + function () { + $(modalPopupContent).html($('#add-group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#add-group-cancel-link").click(function () { + hidePopup(); + }); + + }); +} /** * Following functions should be triggered after AJAX request is made. @@ -230,7 +296,7 @@ function attachEvents() { /** * Following click function would execute * when a user clicks on "Remove" link - * on Device Management page in WSO2 MDM Console. + * on Group Management page in WSO2 IoT Server Console. */ $("a.remove-group-link").click(function () { var groupId = $(this).data("groupid"); @@ -240,35 +306,43 @@ function attachEvents() { showPopup(); $("a#remove-group-yes-link").click(function () { - invokerUtil.get( + invokerUtil.delete( removeGroupApi, - function (data,txtStatus,jqxhr) { + function (data, txtStatus, jqxhr) { var status = jqxhr.status; if (status == 200) { - $(modalPopupContent).html($('#remove-group-200-content').html()); - $('div[data-group="' + groupId + '"]').remove(); - $("a#remove-group-200-link").click(function () { - hidePopup(); - }); + if (data != "false") { + $(modalPopupContent).html($('#remove-group-200-content').html()); + $('div[data-group="' + groupId + '"]').remove(); + $("a#remove-group-200-link").click(function () { + hidePopup(); + location.reload(); + }); + } else { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } } else if (status == 400) { - $(modalPopupContent).html($('#remove-group-400-content').html()); + $(modalPopupContent).html($('#group-400-content').html()); $("a#remove-group-400-link").click(function () { hidePopup(); }); } else if (status == 403) { - $(modalPopupContent).html($('#remove-group-403-content').html()); + $(modalPopupContent).html($('#group-403-content').html()); $("a#remove-group-403-link").click(function () { hidePopup(); }); } else if (status == 409) { - $(modalPopupContent).html($('#remove-group-409-content').html()); + $(modalPopupContent).html($('#group-409-content').html()); $("a#remove-group-409-link").click(function () { hidePopup(); }); } }, function () { - $(modalPopupContent).html($('#remove-group-unexpected-error-content').html()); + $(modalPopupContent).html($('#group-unexpected-error-content').html()); $("a#remove-group-unexpected-error-link").click(function () { hidePopup(); }); @@ -290,46 +364,57 @@ function attachEvents() { $("a.edit-group-link").click(function () { var groupId = $(this).data("groupid"); var groupName = $(this).data("groupname"); + var groupDescription = $(this).data("groupdescription"); var editGroupApi = "/iotserver/api/group/id/" + groupId + "/update"; $(modalPopupContent).html($('#edit-group-modal-content').html()); $('#edit-group-name').val(groupName); + $('#edit-group-description').val(groupDescription); showPopup(); $("a#edit-group-yes-link").click(function () { var newGroupName = $('#edit-group-name').val(); - var group={"group":{"name" : newGroupName}}; + var newGroupDescription = $('#edit-group-description').val(); + var group = {"name": newGroupName, "description": newGroupDescription}; invokerUtil.post( editGroupApi, group, - function (data,txtStatus,jqxhr) { + function (data, txtStatus, jqxhr) { var status = jqxhr.status; if (status == 200) { - $(modalPopupContent).html($('#edit-group-200-content').html()); - $("div[data-groupid='"+groupId+"'] .ast-name").html(newGroupName); - $("a#edit-group-200-link").click(function () { - hidePopup(); - }); + 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 () { + hidePopup(); + location.reload(); + }); + } else { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } } else if (status == 400) { - $(modalPopupContent).html($('#edit-group-400-content').html()); - $("a#edit-group-400-link").click(function () { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { hidePopup(); }); } else if (status == 403) { - $(modalPopupContent).html($('#edit-group-403-content').html()); - $("a#edit-group-403-link").click(function () { + $(modalPopupContent).html($('#group-403-content').html()); + $("a#group-403-link").click(function () { hidePopup(); }); } else if (status == 409) { - $(modalPopupContent).html($('#edit-group-409-content').html()); - $("a#edit-group-409-link").click(function () { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { hidePopup(); }); } }, function () { - $(modalPopupContent).html($('#edit-group-unexpected-error-content').html()); - $("a#edit-group-unexpected-error-link").click(function () { + $(modalPopupContent).html($('#group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { hidePopup(); }); } 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 9bba907c..14080028 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 @@ -1,6 +1,6 @@ {{#each groups}} {{groupMap this}} -
+
- +
@@ -20,21 +20,28 @@ Shared with: {{users}}
- + View - + + Edit - + diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-bar/operation-bar.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-bar/operation-bar.js index f063bc0a..e99497b9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-bar/operation-bar.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-bar/operation-bar.js @@ -1,4 +1,3 @@ function onRequest(context){ - var log = new Log(); return context; } \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-mod/operation-mod.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-mod/operation-mod.js index e69de29b..e99497b9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-mod/operation-mod.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/operation-mod/operation-mod.js @@ -0,0 +1,3 @@ +function onRequest(context){ + return context; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css index beed45c6..102e5041 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/custom-desktop.css @@ -358,7 +358,7 @@ a.ast-type-item:hover { } .ast-title { - height: 70px; + /*height: 70px;*/ overflow: hidden; } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/fontwso2.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/fontwso2.css index 463b22ec..8451e883 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/fontwso2.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/fontwso2.css @@ -67,6 +67,10 @@ content: "\e656"; } +.fw-group:before { + content: "\e611"; +} + .fw-dots:before { content: "\e615"; } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css index a1a5c3aa..23f3461e 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css @@ -595,4 +595,20 @@ header{background-color: #2a2a2a;} .wiz-lbl > span { padding-top:0px; display:inline-block; +} + +::-webkit-input-placeholder { /* WebKit browsers */ + color: #b2b2b2; +} +:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ + color: #b2b2b2; + opacity: 1; +} + +::-moz-placeholder { /* Mozilla Firefox 19+ */ + color: #b2b2b2; + opacity: 1; +} +:-ms-input-placeholder { /* Internet Explorer 10+ */ + color: #b2b2b2; } \ No newline at end of file From e473946547edbc6b0ed9967f96fcb909e85ca6b0 Mon Sep 17 00:00:00 2001 From: charithag Date: Sat, 25 Jul 2015 21:37:43 +0530 Subject: [PATCH 6/8] Add group details page --- .../jaggeryapps/iotserver/api/group-api.jag | 4 +- .../jaggeryapps/iotserver/api/user-api.jag | 2 + .../jaggeryapps/iotserver/modules/utility.js | 4 + .../units/group-detail/group-detail.hbs | 116 ++++---------- .../units/group-detail/group-detail.js | 22 ++- .../units/group-listing/group-listing.hbs | 32 ++++ .../units/group-listing/group-listing.js | 13 +- .../group-listing/public/js/group-listing.js | 143 +++++++++++++----- .../public/templates/group-listing.hbs | 62 ++++---- .../units/select2/public/css/select2.min.css | 0 .../select2/public/js/select2.full.min.js | 0 .../iotserver/units/select2/select2.hbs | 0 .../iotserver/units/select2/select2.json | 0 13 files changed, 227 insertions(+), 171 deletions(-) mode change 100755 => 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/css/select2.min.css mode change 100755 => 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/js/select2.full.min.js mode change 100755 => 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.hbs mode change 100755 => 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.json diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag index 6014b482..de7e65f6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag @@ -112,7 +112,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { data = {"username": user.username, "shareUser":shareUser, "role":role}; result = post(endPoint, data, "json"); -} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/unshare")) { groupId = uriMatcher.elements().groupId; var unShareUser = request.getContent()["unShareUser"]; @@ -197,6 +197,6 @@ if (uriMatcher.match("/{context}/api/group/add")) { // returning the result. if (result) { response.status = result.xhr.status; - print(false); + print(result.data); } %> diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag index 1bf40351..637c3fdd 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag @@ -135,6 +135,8 @@ if (uriMatcher.match("/{context}/api/user/login/")) { result = 403; } +} else if (uriMatcher.match("/{context}/api/users")) { + result = userModule.getUsers(); } // returning the result. diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js index 75683235..175031a0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js @@ -119,6 +119,10 @@ utility = function () { key: "groups/operation", name: "Perform Device Operation" }], "device-mgt/user", type); + userModule.addPermissions([{ + key: "groups/list", + name: "List Groups of User" + }], "device-mgt/user", type); }; return publicMethods; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs index 4031ac65..c15cf4f9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs @@ -1,13 +1,8 @@ {{#zone "main"}} -
+
@@ -16,7 +11,7 @@
- {{unit "operation-bar"}} + {{unit "operation-bar"}}
@@ -25,13 +20,21 @@
- +
+
+
+
Description
{{group.description}} +
+
+
No. of Devices: {{group.deviceCount}}
Users: {{group.users}}
-
Created on:
{{group.dateOfCreation}}
-
Modified on:
{{group.dateOfLastUpdate}}
+
Created on: {{group.dateOfCreation}}
+
Modified on: {{group.dateOfLastUpdate}}
@@ -42,51 +45,6 @@
- {{#if group.viewModel.BatteryLevel}} -
-
-
BATTERY
-
-
-
{{group.viewModel.BatteryLevel}}%
-
-
-
- {{/if}} - - {{#if group.viewModel.DeviceCapacity}} -
-
-
STORAGE
-
-
-
{{group.viewModel.DeviceCapacityPercentage}}%{{group.viewModel.DeviceCapacityUsed}} GB Free
-
-
-
- {{/if}} - {{#if group.viewModel.internal_memory.FreeCapacity}} -
-
-
LOCAL STORAGE
-
-
-
{{group.viewModel.internal_memory.DeviceCapacityPercentage}}%{{group.viewModel.internal_memory.FreeCapacity}} GB Free
-
-
-
- {{/if}} - {{#if group.viewModel.external_memory.FreeCapacity}} -
-
-
EXTERNAL STORAGE
-
-
-
{{group.viewModel.external_memory.DeviceCapacityPercentage}}%{{group.viewModel.external_memory.FreeCapacity}} GB Free
-
-
-
- {{/if}}
@@ -98,7 +56,8 @@
- - +
-
+
- Not available yet + Show Devices + in Group
- - - - - - - - - - - - - - - - - - - - - - -
@@ -171,6 +112,5 @@ {{/zone}} {{#zone "bottomJs"}} - {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js index 9b3738ee..6781cd38 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.js @@ -5,19 +5,15 @@ function onRequest(context) { var uriMatcher = new URIMatcher(String(uri)); var isMatched = uriMatcher.match("/{context}/group/{groupId}"); if (isMatched) { - var carbon = require('carbon'); - var carbonHttpsServletTransport = carbon.server.address('https'); - - var matchedElements = uriMatcher.elements(); - var groupId = matchedElements.groupId; - var endpoint = carbonHttpsServletTransport + "/" + matchedElements.context + "/api/group/id/" + groupId; - log.info(endpoint); - //var result = get(endpoint, {}, "json"); - //if (result){ - // context.group = result.data; - //}else{ - // response.sendError(503); - //} + var group = {}; + group.id = uriMatcher.elements().groupId; + group.name = request.getParameter("name"); + group.deviceCount = request.getParameter("deviceCount"); + group.dateOfCreation = request.getParameter("dateOfCreation"); + group.dateOfLastUpdate = request.getParameter("dateOfLastUpdate"); + group.description = request.getParameter("description"); + group.users = request.getParameter("users"); + context.group =group; } else { response.sendError(404); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs index 54bcd732..8b091435 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs @@ -30,6 +30,38 @@
+
+
+
+
+

Share group with others

+ + +
+
+
+
+ +
+
+
+
+

Group sharing updated successfully.

+ + +
+
+
+
+
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js index 96820097..6906a242 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js @@ -1,12 +1,17 @@ function onRequest(context){ - //var userModule = require("/modules/user.js").userModule; var permissions = []; - //if(userModule.isAuthorized("/permission/device-mgt/admin/devices/list")){ + //var userModule = require("/modules/user.js").userModule; + //if(userModule.isAuthorized("/permission/device-mgt/admin/groups/list")){ // permissions.push("LIST_GROUPS"); - //}else if(userModule.isAuthorized("/permission/device-mgt/user/devices/list")){ - // permissions.push("LIST_OWN_GROUPS"); + //}else if(userModule.isAuthorized("/permission/device-mgt/groups/remove")){ + // permissions.push("REMOVE_GROUPS"); + //}else if(userModule.isAuthorized("/permission/device-mgt/groups/share")){ + // permissions.push("SHARE_GROUPS"); //} permissions.push("LIST_GROUPS"); + permissions.push("ADD_GROUPS"); + permissions.push("SHARE_GROUPS"); context.permissions = stringify(permissions); + context.SHARE_GROUPS = true; return context; } \ No newline at end of file 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 d6e7ba65..70414fd8 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 @@ -245,11 +245,11 @@ function attachGroupAdding() { var status = jqxhr.status; if (status == 200) { if (data != "false") { - $(modalPopupContent).html($('#add-group-200-content').html()); - $("a#add-group-200-link").click(function () { - hidePopup(); - location.reload(); - }); + $(modalPopupContent).html($('#add-group-200-content').html()); + $("a#add-group-200-link").click(function () { + hidePopup(); + location.reload(); + }); } else { $(modalPopupContent).html($('#group-400-content').html()); $("a#group-400-link").click(function () { @@ -293,6 +293,83 @@ function attachGroupAdding() { * Following functions should be triggered after AJAX request is made. */ function attachEvents() { + /** + * Following click function would execute + * when a user clicks on "Share" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.view-group-link").click(function () { + $("#group_data").closest('form').submit(); + }); + + /** + * Following click function would execute + * when a user clicks on "Share" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.share-group-link").click(function () { + var groupId = $(this).data("groupid"); + var shareGroupApi = "/iotserver/api/group/id/" + groupId + "/share"; + var unShareGroupApi = "/iotserver/api/group/id/" + groupId + "/unshare"; + + $(modalPopupContent).html($('#share-group-modal-content').html()); + showPopup(); + + $("a#share-group-share-link").click(function () { + var data = {"shareUser":"", "role":""}; + invokerUtil.post( + shareGroupApi, + data, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + + } else { + displayErrors(status); + } + }, + function () { + $(modalPopupContent).html($('#group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#share-group-unshare-link").click(function () { + var data = {"shareUser":"", "role":""}; + invokerUtil.post( + unShareGroupApi, + data, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + + } else { + displayErrors(status); + } + }, + function () { + $(modalPopupContent).html($('#group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#share-group-yes-link").click(function () { + hidePopup(); + location.reload(); + }); + + $("a#share-group-cancel-link").click(function () { + hidePopup(); + }); + + }); + /** * Following click function would execute * when a user clicks on "Remove" link @@ -324,26 +401,13 @@ function attachEvents() { hidePopup(); }); } - } else if (status == 400) { - $(modalPopupContent).html($('#group-400-content').html()); - $("a#remove-group-400-link").click(function () { - hidePopup(); - }); - } else if (status == 403) { - $(modalPopupContent).html($('#group-403-content').html()); - $("a#remove-group-403-link").click(function () { - hidePopup(); - }); - } else if (status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); - $("a#remove-group-409-link").click(function () { - hidePopup(); - }); + } else { + displayErrors(status); } }, function () { $(modalPopupContent).html($('#group-unexpected-error-content').html()); - $("a#remove-group-unexpected-error-link").click(function () { + $("a#group-unexpected-error-link").click(function () { hidePopup(); }); } @@ -387,7 +451,6 @@ function attachEvents() { $("div[data-groupid='" + groupId + "'] .ast-name").html(newGroupName); $("a#edit-group-200-link").click(function () { hidePopup(); - location.reload(); }); } else { $(modalPopupContent).html($('#group-409-content').html()); @@ -395,21 +458,8 @@ function attachEvents() { hidePopup(); }); } - } else if (status == 400) { - $(modalPopupContent).html($('#group-400-content').html()); - $("a#group-400-link").click(function () { - hidePopup(); - }); - } else if (status == 403) { - $(modalPopupContent).html($('#group-403-content').html()); - $("a#group-403-link").click(function () { - hidePopup(); - }); - } else if (status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); - $("a#group-409-link").click(function () { - hidePopup(); - }); + } else { + displayErrors(status); } }, function () { @@ -426,3 +476,22 @@ function attachEvents() { }); }); } + +function displayErrors(status){ + if (status == 400) { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#group-403-content').html()); + $("a#group-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } +} 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 14080028..844645b9 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 @@ -1,5 +1,14 @@ {{#each groups}} - {{groupMap this}} + {{groupMap this}} +
+ + + + + + +
+
- -
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/css/select2.min.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/css/select2.min.css old mode 100755 new mode 100644 diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/js/select2.full.min.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/public/js/select2.full.min.js old mode 100755 new mode 100644 diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.hbs old mode 100755 new mode 100644 diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/select2/select2.json old mode 100755 new mode 100644 From 665e88acfbe2db99a6c49ee5d20c364a15a6fea3 Mon Sep 17 00:00:00 2001 From: charithag Date: Sun, 26 Jul 2015 09:05:21 +0530 Subject: [PATCH 7/8] Completed group sharing --- .../jaggeryapps/iotserver/api/group-api.jag | 68 ++++++-- .../units/group-listing/group-listing.hbs | 32 +++- .../units/group-listing/group-listing.js | 4 + .../group-listing/public/js/group-listing.js | 149 +++++++++++------- .../iotserver/units/theme/public/css/main.css | 19 +++ 5 files changed, 202 insertions(+), 70 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag index de7e65f6..924a53d6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag @@ -109,7 +109,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; - data = {"username": user.username, "shareUser":shareUser, "role":role}; + data = {"username": user.username, "shareUser": shareUser, "role": role}; result = post(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/unshare")) { @@ -118,10 +118,10 @@ if (uriMatcher.match("/{context}/api/group/add")) { var unShareUser = request.getContent()["unShareUser"]; role = request.getContent()["role"]; - //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share - endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; - data = {"username": user.username, "unShareUser":unShareUser, "role":role}; - result = del(endPoint, data, "json"); + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/unshare + endPoint = deviceCloudService + "/group/id/" + groupId + "/unshare"; + data = {"username": user.username, "unShareUser": unShareUser, "role": role}; + result = post(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) { @@ -131,7 +131,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { //URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; - data = {"username": user.username, "permissions":permissions, "role":role}; + data = {"username": user.username, "permissions": permissions, "role": role}; result = post(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) { @@ -141,7 +141,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; - data = {"username": user.username, "role":role}; + data = {"username": user.username, "role": role}; result = del(endPoint, data, "json"); } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) { @@ -159,10 +159,60 @@ if (uriMatcher.match("/{context}/api/group/add")) { var userId = uriMatcher.elements().userId; //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/{user}/role/all - endPoint = deviceCloudService + "/group/id/" + groupId + "/" + userId +"/role/all"; + endPoint = deviceCloudService + "/group/id/" + groupId + "/" + userId + "/role/all"; data = {"username": user.username}; result = get(endPoint, data, "json"); +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/rolemapping")) { + + groupId = uriMatcher.elements().groupId; + userId = uriMatcher.elements().userId; + + data = {"username": user.username}; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/role/all"; + var allRoles = get(endPoint, data, "json").data; + + //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/{user}/role/all + endPoint = deviceCloudService + "/group/id/" + groupId + "/" + userId + "/role/all"; + var userRolesObj = get(endPoint, data, "json"); + var userRoles = userRolesObj.data; + var roleMap = []; + for (var role in allRoles) { + var objRole = {"role": allRoles[role], "assigned": false}; + for (var usrRole in userRoles) { + if (allRoles[role] == userRoles[usrRole]) { + objRole.assigned = true; + break; + } + } + roleMap.push(objRole); + } + result = {}; + result.data = roleMap; + result.xhr = userRolesObj.xhr; + +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/{userId}/roleupdate")) { + + groupId = uriMatcher.elements().groupId; + userId = uriMatcher.elements().userId; + roleMap = request.getContent(); + + for (role in roleMap) { + if (roleMap[role].assigned == true) { + //URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share + endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; + data = {"username": user.username, "shareUser": userId, "role": roleMap[role].role}; + result = post(endPoint, data, "json"); + } else { + //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/unshare + endPoint = deviceCloudService + "/group/id/" + groupId + "/unshare"; + data = {"username": user.username, "unShareUser": userId, "role": roleMap[role].role}; + result = post(endPoint, data, "json"); + } + } + } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/user/all")) { groupId = uriMatcher.elements().groupId; @@ -189,7 +239,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/assign endPoint = deviceCloudService + "/group/id/" + groupId + "/device/assign"; - data = {"username": user.username, "deviceId":deviceId, "deviceType":deviceType}; + data = {"username": user.username, "deviceId": deviceId, "deviceType": deviceType}; result = put(endPoint, data, "json"); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs index 8b091435..e4fe30c4 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs @@ -1,5 +1,6 @@ {{#zone "main"}} +
@@ -30,13 +31,38 @@
-
+
-

Share group with others

+

Select user to manage group sharing

+
Loading...
+ +
+
+
+
+
+
+
+
+

Select sharing roles

+
+
Loading...
+ +     Cancel     + +        OK     @@ -53,7 +79,7 @@

Group sharing updated successfully.

diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js index 6906a242..fc048f66 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.js @@ -1,4 +1,7 @@ +var log = new Log("modules/group-listing.js"); + function onRequest(context){ + var constants = require("/modules/constants.js"); var permissions = []; //var userModule = require("/modules/user.js").userModule; //if(userModule.isAuthorized("/permission/device-mgt/admin/groups/list")){ @@ -13,5 +16,6 @@ function onRequest(context){ permissions.push("SHARE_GROUPS"); context.permissions = stringify(permissions); context.SHARE_GROUPS = true; + context.user = session.get(constants.USER_SESSION_KEY); return context; } \ No newline at end of file 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 70414fd8..d46d9bd0 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 @@ -223,6 +223,13 @@ function hidePopup() { $(modalPopup).hide(); } +var errorHandler = function () { + $(modalPopupContent).html($('#add-group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); +}; + function attachGroupAdding() { /** * Following click function would execute @@ -272,13 +279,7 @@ function attachGroupAdding() { hidePopup(); }); } - }, - function () { - $(modalPopupContent).html($('#add-group-unexpected-error-content').html()); - $("a#group-unexpected-error-link").click(function () { - hidePopup(); - }); - } + }, errorHandler ); }); @@ -309,62 +310,94 @@ function attachEvents() { */ $("a.share-group-link").click(function () { var groupId = $(this).data("groupid"); - var shareGroupApi = "/iotserver/api/group/id/" + groupId + "/share"; - var unShareGroupApi = "/iotserver/api/group/id/" + groupId + "/unshare"; - - $(modalPopupContent).html($('#share-group-modal-content').html()); + var username = $("#user-details").data("username"); + $(modalPopupContent).html($('#share-group-w1-modal-content').html()); + $('#user-names').html('Loading...'); showPopup(); - - $("a#share-group-share-link").click(function () { - var data = {"shareUser":"", "role":""}; - invokerUtil.post( - shareGroupApi, - data, - function (data, txtStatus, jqxhr) { - var status = jqxhr.status; - if (status == 200) { - - } else { - displayErrors(status); + $("a#share-group-next-link").hide(); + invokerUtil.get("/iotserver/api/users", + function (data, txtStatus, jqxhr) { + var users = JSON.parse(data); + var status = jqxhr.status; + if (status == 200) { + var str = '
'; + if (!hasUsers) { + str = "There is no any other users registered"; + return; } - }, - function () { - $(modalPopupContent).html($('#group-unexpected-error-content').html()); - $("a#group-unexpected-error-link").click(function () { - hidePopup(); + $('#user-names').html(str); + $("a#share-group-next-link").show(); + $("a#share-group-next-link").click(function () { + var selectedUser = $('#share-user-selector').val(); + $(modalPopupContent).html($('#share-group-w2-modal-content').html()); + $('#user-roles').html('Loading...'); + $("a#share-group-yes-link").hide(); + invokerUtil.get("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/rolemapping", + function (data, txtStatus, jqxhr) { + var roleMap = JSON.parse(data); + var status = jqxhr.status; + if (status == 200) { + var str = ''; + var isChecked = ''; + var hasRoles = false; + for (var role in roleMap) { + if (roleMap[role].assigned == true) { + isChecked = 'checked'; + } + str += '    '; + hasRoles = true; + } + if (!hasRoles) { + str = "There is no any roles for this group"; + return; + } + $('#user-roles').html(str); + $("a#share-group-yes-link").show(); + $("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){ + roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked'); + updatedRoleMap.push(roleMap[role]); + } + } + invokerUtil.post("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/roleupdate", + updatedRoleMap, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + $(modalPopupContent).html($('#share-group-200-content').html()); + $("a#share-group-200-link").click(function () { + hidePopup(); + }); + }else { + displayErrors(status); + } + }, errorHandler); + }); + } else { + displayErrors(status); + } + }, errorHandler); + $("a#share-group-w2-cancel-link").click(function () { + hidePopup(); + }); }); + } else { + displayErrors(status); } - ); - }); - - $("a#share-group-yes-link").click(function () { - hidePopup(); - location.reload(); - }); + }, errorHandler); - $("a#share-group-cancel-link").click(function () { + $("a#share-group-w1-cancel-link").click(function () { hidePopup(); }); @@ -477,7 +510,7 @@ function attachEvents() { }); } -function displayErrors(status){ +function displayErrors(status) { if (status == 400) { $(modalPopupContent).html($('#group-400-content').html()); $("a#group-400-link").click(function () { diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css index 23f3461e..b6f92077 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css @@ -611,4 +611,23 @@ header{background-color: #2a2a2a;} } :-ms-input-placeholder { /* Internet Explorer 10+ */ color: #b2b2b2; +} + +input[type=checkbox] { + width: 13px; + height: 13px; + padding: 0; + margin:0; + vertical-align: bottom; + position: relative; + top: -1px; + *overflow: hidden; +} + +.checkbox-text +{ + /* Checkbox text */ + display: inline; + padding-left: 15px; + text-indent: -15px; } \ No newline at end of file From ef3b196674e3e7ab7f9a8dbeca920caff9306447 Mon Sep 17 00:00:00 2001 From: charithag Date: Sun, 26 Jul 2015 11:08:02 +0530 Subject: [PATCH 8/8] Completed device association with groups --- .../jaggeryapps/iotserver/api/group-api.jag | 2 +- .../units/device-listing/device-listing.hbs | 90 ++++++++++- .../units/device-listing/device-listing.js | 8 + .../public/js/device-listing.js | 147 +++++++++++++++--- .../public/templates/device-listing.hbs | 7 + .../units/group-detail/group-detail.hbs | 4 +- .../group-listing/public/js/group-listing.js | 1 + 7 files changed, 230 insertions(+), 29 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag index 924a53d6..abb5b499 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/group-api.jag @@ -231,7 +231,7 @@ if (uriMatcher.match("/{context}/api/group/add")) { data = {"username": user.username}; result = get(endPoint, data, "json"); -} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) { +} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/assign")) { groupId = uriMatcher.elements().groupId; var deviceId = request.getContent()["deviceId"]; 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 17444875..e2633391 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 @@ -1,5 +1,6 @@ {{#zone "main"}} +
@@ -16,6 +17,7 @@

You don't have any Devices registered at the moment.

+

@@ -30,11 +32,32 @@

+ +

Do you really want to remove this device from your Devices List?

+
    Yes     @@ -54,6 +77,7 @@

Device was successfully removed.

+
    Ok     @@ -70,8 +94,10 @@

Please enter new name for the device?


+
- +
@@ -92,6 +118,7 @@
+ + +
+
+
+
+

Device was successfully associated with group.

+ + +
+
+
+
+ +
+
+
+
+

Device was successfully removed from group.

+ + +
+
+
+
+

Exception at backend. Try Later.

+
    Ok     @@ -122,6 +204,7 @@

Action not permitted.

+
    Ok     @@ -137,6 +220,7 @@

Device does not exist.

+
    Ok     @@ -152,6 +236,7 @@

Device does not exist.

+
{{/zone}} {{#zone "bottomJs"}} - + {{/zone}} diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js index 3760f748..3db7b52b 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js @@ -12,5 +12,13 @@ function onRequest(context){ } permissions.push("LIST_OWN_DEVICES"); context.permissions = stringify(permissions); + + var groupId = request.getParameter("groupId"); + if (groupId){ + context.groupId = groupId; + }else{ + context.groupId = 0; + } + return context; } \ No newline at end of file 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 0116b272..acc0984c 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 @@ -53,6 +53,7 @@ var assetContainer = "#ast-container"; /* * DOM ready functions. */ +var groupId; $(document).ready(function () { /* Adding selected class for selected devices */ $(deviceCheckbox).each(function () { @@ -72,6 +73,9 @@ $(document).ready(function () { return $("#content-filter-types").html(); } }); + + groupId = $("#request-group-id").data("groupid"); + loadDevices(); }); /* @@ -134,10 +138,18 @@ function loadDevices(searchType, searchParam) { $.template("device-listing", deviceListingSrc, function (template) { var serviceURL; if ($.hasPermission("LIST_DEVICES")) { - serviceURL = "/iotserver/api/devices/all"; + if (groupId && groupId != "0") { + serviceURL = "/iotserver/api/group/id/" + groupId + "/device/all"; + } else { + serviceURL = "/iotserver/api/devices/all"; + } } else if ($.hasPermission("LIST_OWN_DEVICES")) { //Get authenticated users devices - serviceURL = "/iotserver/api/devices/all"; + if (groupId && groupId != "0") { + serviceURL = "/iotserver/api/group/id/" + groupId + "/device/all"; + } else { + serviceURL = "/iotserver/api/devices/all"; + } } else { $("#ast-container").html("Permission denied"); return; @@ -154,10 +166,17 @@ function loadDevices(searchType, searchParam) { var successCallback = function (data) { data = JSON.parse(data); var viewModel = {}; + if (groupId && groupId != "0") { + data.data = data; + } viewModel.devices = data.data; viewModel.imageLocation = imageResource; - if(!data.data || data.data.length <= 0){ - $("#ast-container").html($("#no-devices-div-content").html()); + if (!data.data || data.data.length <= 0) { + if (groupId && groupId != "0") { + $("#ast-container").html($("#no-grouped-devices-div-content").html()); + } else { + $("#ast-container").html($("#no-devices-div-content").html()); + } } else { var content = template(viewModel); $("#ast-container").html(content); @@ -177,12 +196,9 @@ function loadDevices(searchType, searchParam) { }); }); } -$(document).ready(function () { - loadDevices(); -}); -function formatDates(){ - $(".formatDate").each(function(){ +function formatDates() { + $(".formatDate").each(function () { var timeStamp = $(this).html(); $(this).html(new Date(parseInt(timeStamp)).toUTCString()); }); @@ -253,12 +269,12 @@ function attachEvents() { $("a#remove-device-yes-link").click(function () { invokerUtil.get( removeDeviceAPI, - function (data,txtStatus,jqxhr) { - var status = jqxhr.status; + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; if (status == 200) { $(modalPopupContent).html($('#remove-device-200-content').html()); - $('div[data-deviceid="' + deviceId + '"]').remove(); - $("a#remove-device-200-link").click(function () { + $('div[data-deviceid="' + deviceId + '"]').remove(); + $("a#remove-device-200-link").click(function () { hidePopup(); }); } else if (status == 400) { @@ -310,38 +326,38 @@ function attachEvents() { $("a#edit-device-yes-link").click(function () { var newDeviceName = $('#edit-device-name').val(); - var device={"device":{"name" : newDeviceName}}; + var device = {"device": {"name": newDeviceName}}; invokerUtil.post( editDeviceAPI, device, - function (data,txtStatus,jqxhr) { + function (data, txtStatus, jqxhr) { var status = jqxhr.status; if (status == 200) { $(modalPopupContent).html($('#edit-device-200-content').html()); - $("div[data-deviceid='"+deviceId+"'] .ast-name").html(newDeviceName); + $("div[data-deviceid='" + deviceId + "'] .ast-name").html(newDeviceName); $("a#edit-device-200-link").click(function () { hidePopup(); }); } else if (status == 400) { - $(modalPopupContent).html($('#edit-device-400-content').html()); - $("a#edit-device-400-link").click(function () { + $(modalPopupContent).html($('#device-400-content').html()); + $("a#device-400-link").click(function () { hidePopup(); }); } else if (status == 403) { - $(modalPopupContent).html($('#edit-device-403-content').html()); - $("a#edit-device-403-link").click(function () { + $(modalPopupContent).html($('#device-403-content').html()); + $("a#device-403-link").click(function () { hidePopup(); }); } else if (status == 409) { - $(modalPopupContent).html($('#edit-device-409-content').html()); - $("a#edit-device-409-link").click(function () { + $(modalPopupContent).html($('#device-409-content').html()); + $("a#device-409-link").click(function () { hidePopup(); }); } }, function () { - $(modalPopupContent).html($('#edit-device-unexpected-error-content').html()); - $("a#edit-device-unexpected-error-link").click(function () { + $(modalPopupContent).html($('#device-unexpected-error-content').html()); + $("a#device-unexpected-error-link").click(function () { hidePopup(); }); } @@ -352,4 +368,87 @@ function attachEvents() { hidePopup(); }); }); + + /** + * Following click function would execute + * when a user clicks on "Group" link + * on Device Management page in WSO2 MDM Console. + */ + $("a.group-device-link").click(function () { + var deviceId = $(this).data("deviceid"); + var deviceType = $(this).data("devicetype"); + var endPoint = "/iotserver/api/group/all"; + + $(modalPopupContent).html($('#group-device-modal-content').html()); + $('#user-groups').html("Loading..."); + $("a#group-device-yes-link").hide(); + showPopup(); + + invokerUtil.get(endPoint, + function (data, txtStatus, jqxhr) { + var groups = JSON.parse(data); + var status = jqxhr.status; + if (status == 200) { + if (groups.length <= 0) { + $('#user-groups').html("There is no any groups available"); + return; + } + var str = '
'; + $('#user-groups').html(str); + $("a#group-device-yes-link").show(); + $("a#group-device-yes-link").click(function () { + var selectedGroupId = $('#assign-group-selector').val(); + endPoint = "/iotserver/api/group/id/" + selectedGroupId + "/assign"; + var device = {"deviceId": deviceId, "deviceType": deviceType}; + invokerUtil.post( + endPoint, + device, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + $(modalPopupContent).html($('#group-associate-device-200-content').html()); + $("a#group-associate-device-200-link").click(function () { + hidePopup(); + }); + } else if (status == 400) { + $(modalPopupContent).html($('#device-400-content').html()); + $("a#device-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#device-403-content').html()); + $("a#device-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#device-409-content').html()); + $("a#device-409-link").click(function () { + hidePopup(); + }); + } + }, + function () { + $(modalPopupContent).html($('#device-unexpected-error-content').html()); + $("a#device-unexpected-error-link").click(function () { + hidePopup(); + }); + }); + }); + } + }, + function () { + $(modalPopupContent).html($('#device-unexpected-error-content').html()); + $("a#device-unexpected-error-link").click(function () { + hidePopup(); + }); + }); + + $("a#group-device-cancel-link").click(function () { + hidePopup(); + }); + }); } 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 0ffc884e..f1fe2032 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 @@ -28,6 +28,13 @@ View
+ + + + + + Group + diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs index c15cf4f9..272963e1 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs @@ -69,7 +69,7 @@ @@ -92,7 +92,7 @@ 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 d46d9bd0..c84285b5 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 @@ -331,6 +331,7 @@ function attachEvents() { str += ''; if (!hasUsers) { str = "There is no any other users registered"; + $('#user-names').html(str); return; } $('#user-names').html(str);