diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag index 1a102757..65c0b5f6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag @@ -152,6 +152,49 @@ if (uriMatcher.match("/{context}/api/device/sketch/download/{downloadId}")) { allDevices.push({id: 0, devices: unsharedDevices}); result.data = allDevices; +} else if (uriMatcher.match("/{context}/api/devices/count")) { + + var user = session.get(constants.USER_SESSION_KEY); + if (!user) { + response.sendRedirect(dcProps.appContext + "login?#login-required"); + exit();//stop execution + } + + //URL: https://localhost:9443/devicecloud/manager/devices/username/{username} + deviceCloudService = carbonHttpsServletTransport + "/devicecloud/device_manager"; + listAllDevicesEndPoint = deviceCloudService + "/devices/username/" + user.username; + result = get(listAllDevicesEndPoint, {}, "json"); + var ownDevices = result.data; + + var allDevices = []; + deviceCloudService = carbonHttpsServletTransport + "/devicecloud/group_manager"; + var endPoint = deviceCloudService + "/group/all"; + var data = {"username": user.username}; + var groups = get(endPoint, data, "json").data; + + var count = 0; + for (var g in groups) { + endPoint = deviceCloudService + "/group/id/" + groups[g].id + "/device/all"; + data = {"username": user.username}; + var deviceInGroup = get(endPoint, data, "json").data; + groups[g].devices = deviceInGroup; + allDevices.push(groups[g]); + for (var od in ownDevices) { + for (var gd in deviceInGroup) { + if (deviceInGroup[gd].deviceIdentifier == ownDevices[od].deviceIdentifier) { + ownDevices[od].deviceIdentifier = -1; + } + } + } + count += deviceInGroup.length; + } + for (var od in ownDevices) { + if (ownDevices[od].deviceIdentifier != -1){ + count++; + } + } + result.data = count; + } else if (uriMatcher.match("/{context}/api/devices/types")) { result = deviceModule.listDeviceTypes(); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/policy-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/policy-api.jag index fadc4869..d0bc221a 100755 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/policy-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/policy-api.jag @@ -58,6 +58,9 @@ if (uriMatcher.match("/{context}/api/policies/update")) { // http status code 500 refers to - Internal Server Error. result = 500; } +} else if (uriMatcher.match("/{context}/api/policies/count")) { + result = {} + result.data = policyModule.getPolicies().length; } // returning the result. 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 e965c1be..7c7f2171 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag @@ -139,6 +139,10 @@ if (uriMatcher.match("/{context}/api/user/login/")) { } else if (uriMatcher.match("/{context}/api/users")) { result = userModule.getUsers(); + +} else if (uriMatcher.match("/{context}/api/users/count")) { + result = {}; + result.data = userModule.getUsers().length; } // returning the result. diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs index d11adeca..3a282d01 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs @@ -4,6 +4,6 @@ WSO2 DC | Device Cloud {{/zone}} {{#zone "body"}} - {{unit "appbar"}} + {{unit "appbar" title="Dashboard"}} {{unit "dashboard"}} {{/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 20b965e6..90eea9cf 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.hbs @@ -41,13 +41,13 @@
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs index 07e7116b..4cbb2e22 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs @@ -18,6 +18,13 @@ View + + + + + + Add + @@ -60,14 +67,14 @@