Redirecting to respective analytics pages depending on the device type

4.x.x
GDLMadushanka 8 years ago
parent 39a7037821
commit 85d07dc9cb

@ -519,8 +519,8 @@
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script id="device-listing" data-analitics-url="{{analyticsURL}}" data-current-user="{{@user.username}}" data-device-types="{{deviceTypes}}" <script id="device-listing" data-server-url="{{serverUrl}}" data-current-user="{{@user.username}}" data-device-types="{{deviceTypes}}"
type="text/x-handlebars-template"></script> data-portal-url="{{portalUrl}}" data-user-domain="{{userDomain}}" type="text/x-handlebars-template"></script>
{{js "js/listing.js"}} {{js "js/listing.js"}}
{{/zone}} {{/zone}}

@ -60,6 +60,8 @@ function onRequest(context) {
if (data) { if (data) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
var config = utility.getDeviceTypeConfig(data[i]); var config = utility.getDeviceTypeConfig(data[i]);
var log = new Log("devices.js");
if (!config) { if (!config) {
continue; continue;
} }
@ -70,7 +72,8 @@ function onRequest(context) {
"label": deviceType.label, "label": deviceType.label,
"thumb": utility.getDeviceThumb(data[i]), "thumb": utility.getDeviceThumb(data[i]),
"analyticsEnabled": deviceType.analyticsEnabled, "analyticsEnabled": deviceType.analyticsEnabled,
"groupingEnabled": deviceType.groupingEnabled "groupingEnabled": deviceType.groupingEnabled,
"analyticsView" : deviceType.analyticsView
}); });
} }
} }
@ -80,9 +83,15 @@ function onRequest(context) {
} }
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var analyticsServer = mdmProps["dashboardServerURL"]; var serverUrl = mdmProps["httpsURL"];
var analyticsURL = analyticsServer + "/portal/t/" + context.user.userDomain + "/dashboards/android-iot/battery?owner=" + context.user.username + "&deviceId="; var portalUrl = mdmProps["portalURL"];
viewModel.analyticsURL = analyticsURL; var userDomain = context.user.domain;
//var userName = context.user.username;
viewModel.serverUrl = serverUrl;
viewModel.portalUrl = portalUrl;
viewModel.userDomain = userDomain;
//viewModel.userName = userName;
return viewModel; return viewModel;
} }

@ -224,6 +224,21 @@ function loadDevices(searchType, searchParam) {
return true; return true;
} }
function getAnalyticsView(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
var analyticsView = deviceTypes[i].analyticsView;
if (analyticsEnabled == undefined) {
// if undefined go to default analytics view
return "none";
}
return analyticsView;
}
}
return "none";
}
function groupingEnabled(type) { function groupingEnabled(type) {
var deviceTypes = deviceListing.data("deviceTypes"); var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) { for (var i = 0; i < deviceTypes.length; i++) {
@ -323,12 +338,19 @@ function loadDevices(searchType, searchParam) {
var deviceType = row.deviceType; var deviceType = row.deviceType;
var deviceIdentifier = row.deviceIdentifier; var deviceIdentifier = row.deviceIdentifier;
var html = '<span></span>'; var html = '<span></span>';
var statURL = $("#device-listing").data("analitics-url"); var portalUrl = $("#device-listing").data("portal-url");
var serverUrl = $("#device-listing").data("server-url");
var userDomain = $("#device-listing").data("userDomain");
var statURL;
if (status != 'REMOVED') { if (status != 'REMOVED') {
html = ''; html = '';
if (analyticsEnabled(row.deviceType)) { if (analyticsEnabled(row.deviceType)) {
switch (getAnalyticsView(deviceType)) {
case "DAS" : { statURL =portalUrl + "/portal/t/"+ userDomain+ "/dashboards/android-iot/battery?owner=" +currentUser+"&deviceId=";break;}
default : {statURL=context+ "/device/" + row.deviceType +"/analytics?deviceId="}
}
html += '<a href="' + statURL + html += '<a href="' + statURL +
deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' + deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' +

Loading…
Cancel
Save