Configure default operations loading

When loading device details page, default operatios are loaded always. With this improvement, default operations will be loaded if API paths are defined in the config.json
revert-dabc3590
lasanthaDLPDS 6 years ago
parent c20492eb1c
commit fdd1ef9ba1

@ -12,11 +12,13 @@
{{#zone "device-details-header"}} {{#zone "device-details-header"}}
<h1 class="device-id" <h1 class="device-id"
data-deviceid="{{device.deviceIdentifier}}" data-deviceid="{{device.deviceIdentifier}}"
data-type="{{device.type}}" data-type="{{device.type}}"
data-ownership="{{device.ownership}}" data-ownership="{{device.ownership}}"
data-owner="{{device.owner}}" data-owner="{{device.owner}}"
data-status="{{device.status}}"> data-status="{{device.status}}"
data-deviceinfoservice="{{device.deviceInfoServiceAPI}}"
data-devicelocationservice="{{device.deviceLocationServiceAPI}}">
{{device.owner}}'s {{device.name}} {{device.owner}}'s {{device.name}}
<a id="device-info-tooltip" href="#" data-toggle="tooltip" title="Device Identifier: {{device.deviceIdentifier}} <a id="device-info-tooltip" href="#" data-toggle="tooltip" title="Device Identifier: {{device.deviceIdentifier}}
Firmware Build Date: {{device.osBuildDate}} Firmware Build Date: {{device.osBuildDate}}

@ -24,19 +24,28 @@ function onRequest(context) {
var deviceViewData = {}; var deviceViewData = {};
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var carbonServer = require("carbon").server; var carbonServer = require("carbon").server;
var constants = require("/app/modules/constants.js") var constants = require("/app/modules/constants.js");
if (deviceType && deviceId) { if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId, owner); var response = deviceModule.viewDevice(deviceType, deviceId, owner);
if (response["status"] == "success") { if (response["status"] === "success") {
deviceViewData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = true; deviceViewData["isAuthorized"] = true;
var filteredDeviceData = response["content"]; var filteredDeviceData = response["content"];
// creating deviceView information model from filtered device data // creating deviceView information model from filtered device data
var viewModel = {}; var viewModel = {};
var deviceInfoServiceAPI = devicemgtProps["deviceInfoServiceAPI"];
var deviceLocationServiceAPI = devicemgtProps["deviceLocationServiceAPI"];
if (deviceInfoServiceAPI){
viewModel["deviceInfoServiceAPI"] = deviceInfoServiceAPI.replace("%device-type%", deviceType)
}
if (deviceLocationServiceAPI){
viewModel['deviceLocationServiceAPI'] = deviceLocationServiceAPI.replace("%device-type%", deviceType)
}
if (filteredDeviceData["type"]) { if (filteredDeviceData["type"]) {
viewModel["type"] = filteredDeviceData["type"]; viewModel["type"] = filteredDeviceData["type"];
viewModel.isNotWindows = true; viewModel.isNotWindows = true;

@ -26,46 +26,42 @@ var InitiateViewOption = null;
var devStatus = deviceId.data("status"); var devStatus = deviceId.data("status");
var payload = [deviceIdentifier]; var payload = [deviceIdentifier];
var operationTable; var operationTable;
var serviceUrl;
var serviceUrlLocal = "/api/device-mgt/android/v1.0/admin/devices/location"; if ("REMOVED" !== devStatus) {
var deviceInfoServiceAPI = deviceId.data("deviceinfoservice");
if (deviceType == "ios") { var deviceLocationServiceAPI = deviceId.data("devicelocationservice");
serviceUrl = "/ios/operation/deviceinfo"; if (deviceInfoServiceAPI) {
} else if (deviceType == "android") {
//var serviceUrl = "/mdm-android-agent/operation/device-info";
serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info";
serviceUrlLocal = "/api/device-mgt/android/v1.0/admin/devices/location";
}
if (serviceUrl && ("REMOVED" !== devStatus)) {
invokerUtil.post( invokerUtil.post(
serviceUrl, deviceInfoServiceAPI,
payload, payload,
// success-callback // success-callback
function () { function () {
$(".panel-body").show(); $(".panel-body").show();
}, },
// error-callback // error-callback
function () { function () {
var defaultInnerHTML = var defaultInnerHTML =
"<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>"; "<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>";
$(".panel-body").append(defaultInnerHTML); $(".panel-body").append(defaultInnerHTML);
} }
); );
}
if (deviceLocationServiceAPI) {
invokerUtil.post( invokerUtil.post(
serviceUrlLocal, deviceLocationServiceAPI,
payload, payload,
// success-callback // success-callback
function () { function () {
$(".panel-body").show(); $(".panel-body").show();
}, },
// error-callback // error-callback
function () { function () {
var defaultInnerHTML = var defaultInnerHTML =
"<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>"; "<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>";
$(".panel-body").append(defaultInnerHTML); $(".panel-body").append(defaultInnerHTML);
} }
); );
}
} }
$(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) { $(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) {

@ -11,11 +11,13 @@
{{#zone "device-details-header"}} {{#zone "device-details-header"}}
<h1 class="device-id" <h1 class="device-id"
data-deviceid="{{device.deviceIdentifier}}" data-deviceid="{{device.deviceIdentifier}}"
data-type="{{device.type}}" data-type="{{device.type}}"
data-ownership="{{device.ownership}}" data-ownership="{{device.ownership}}"
data-owner="{{device.owner}}" data-owner="{{device.owner}}"
data-status="{{device.status}}"> data-status="{{device.status}}"
data-deviceinfoservice="{{device.deviceInfoServiceAPI}}"
data-devicelocationservice="{{device.deviceLocationServiceAPI}}">
{{device.owner}}'s {{device.name}} {{device.owner}}'s {{device.name}}
</h1> </h1>
<a id="device-info-tooltip" href="#" data-toggle="tooltip" title="Device Identifier: {{device.deviceIdentifier}} <a id="device-info-tooltip" href="#" data-toggle="tooltip" title="Device Identifier: {{device.deviceIdentifier}}

@ -26,7 +26,7 @@ function onRequest(context) {
if (deviceType && deviceId) { if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId, owner); var response = deviceModule.viewDevice(deviceType, deviceId, owner);
if (response["status"] == "success") { if (response["status"] === "success") {
deviceViewData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = true; deviceViewData["isAuthorized"] = true;
@ -34,6 +34,15 @@ function onRequest(context) {
// creating deviceView information model from filtered device data // creating deviceView information model from filtered device data
var viewModel = {}; var viewModel = {};
var deviceInfoServiceAPI = devicemgtProps["deviceInfoServiceAPI"];
var deviceLocationServiceAPI = devicemgtProps["deviceLocationServiceAPI"];
if (deviceInfoServiceAPI){
viewModel["deviceInfoServiceAPI"] = deviceInfoServiceAPI.replace("%device-type%", deviceType)
}
if (deviceLocationServiceAPI){
viewModel['deviceLocationServiceAPI'] = deviceLocationServiceAPI.replace("%device-type%", deviceType)
}
if (filteredDeviceData["type"]) { if (filteredDeviceData["type"]) {
viewModel["type"] = filteredDeviceData["type"]; viewModel["type"] = filteredDeviceData["type"];
viewModel.isNotWindows = true; viewModel.isNotWindows = true;

@ -26,30 +26,42 @@ var InitiateViewOption = null;
var devStatus = deviceId.data("status"); var devStatus = deviceId.data("status");
var payload = [deviceIdentifier]; var payload = [deviceIdentifier];
var operationTable; var operationTable;
var serviceUrl;
if (deviceType == "ios") { if ("REMOVED" !== devStatus) {
serviceUrl = "/ios/operation/deviceinfo"; var deviceInfoServiceAPI = deviceId.data("deviceinfoservice");
} else if (deviceType == "android") { var deviceLocationServiceAPI = deviceId.data("devicelocationservice");
//var serviceUrl = "/mdm-android-agent/operation/device-info"; if (deviceInfoServiceAPI) {
serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info";
}
if (serviceUrl && ("REMOVED" !== devStatus)) {
invokerUtil.post( invokerUtil.post(
serviceUrl, deviceInfoServiceAPI,
payload, payload,
// success-callback // success-callback
function () { function () {
$(".panel-body").show(); $(".panel-body").show();
}, },
// error-callback // error-callback
function () { function () {
var defaultInnerHTML = var defaultInnerHTML =
"<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>"; "<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>";
$(".panel-body").append(defaultInnerHTML); $(".panel-body").append(defaultInnerHTML);
} }
);
}
if (deviceLocationServiceAPI) {
invokerUtil.post(
deviceLocationServiceAPI,
payload,
// success-callback
function () {
$(".panel-body").show();
},
// error-callback
function () {
var defaultInnerHTML =
"<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>";
$(".panel-body").append(defaultInnerHTML);
}
); );
}
} }

Loading…
Cancel
Save