Complete dashboard functionality

application-manager-new
charithag 9 years ago
parent d46e52c256
commit 7481505342

@ -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();

@ -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.

@ -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.

@ -4,6 +4,6 @@
WSO2 DC | Device Cloud
{{/zone}}
{{#zone "body"}}
{{unit "appbar"}}
{{unit "appbar" title="Dashboard"}}
{{unit "dashboard"}}
{{/zone}}

@ -41,13 +41,13 @@
<!-- common navigation -->
<div id="hiddenNav" class="wr-hidden-nav">
<ul>
<li><a href="/iotserver/dashboard"><i class="fw fw-globe"></i>Dashboard</a></li>
<li><a href="/iotserver/devices"><i class="fw fw-mobile"></i>My Devices</a></li>
<li><a href="/iotserver/groups"><i class="fw fw-group"></i>My Groups</a></li>
{{#if permissions.ADD_USER}}
<li><a href="/iotserver/users"><i class="fw fw-user"></i>User Management</a></li>
{{/if}}
<li><a href="/iotserver/policies"><i class="fw fw-policy"></i>Policy Management</a></li>
<li><a href="/iotserver/dashboard"><i class="fw fw-settings"></i>Dashboard</a></li>
</ul>
</div>
<!-- /common navigation -->

@ -18,6 +18,13 @@
</span>
View
</a>
<a href="devices/add-device">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add
</a>
</span>
</div>
</div>
@ -60,14 +67,14 @@
<div class="tile-stats">
<span id="policy-count">Loading...</span>
<span class="tile-stats-free">
<a href="policies.html">
<a href="policies">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
<a href="policy-create-wizard.html">
<a href="policies/add-policy">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>

@ -1,8 +1,8 @@
var updateStats = function (serviceURL, id) {
invokerUtil.get(
serviceURL,
function (data) {
$(id).html(data);
function (result) {
$(id).html(JSON.parse(result).data);
}, function (message) {
console.log(message);
}
@ -10,11 +10,7 @@ var updateStats = function (serviceURL, id) {
};
$(document).ready(function(){
//updateStats("/mdm-admin/devices/count", "#device-count");
//updateStats("/mdm-admin/policies/count", "#policy-count");
//updateStats("/mdm-admin/users/count/" + "carbon.super", "#user-count");
//TODO: get this value from devicecloud webservice
$("#device-count").html("0");
$("#policy-count").html("0");
$("#user-count").html("0");
updateStats("/iotserver/api/devices/count", "#device-count");
updateStats("/iotserver/api/policies/count", "#policy-count");
updateStats("/iotserver/api/users/count", "#user-count");
});
Loading…
Cancel
Save