Merge pull request #354 from rasika/iots-ga

Merge iot-ga branch
merge-requests/1/head
Rasika Perera 8 years ago committed by GitHub
commit 2517b7b385

@ -24,15 +24,15 @@ function onRequest(context) {
if (devices) { if (devices) {
return { return {
"devices": stringify(devices), "devices": stringify(devices),
"backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/stats/" "backendApiUri": "/android_sense/stats/"
}; };
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUrl": devicemgtProps["httpsURL"] + "/android_sense/stats/" + deviceId + "/sensors/" "backendApiUrl": "/android_sense/stats/" + deviceId + "/sensors/"
}; };
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -29,7 +29,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/", "backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/",
"autoCompleteParams": autoCompleteParams "autoCompleteParams": autoCompleteParams
}; };

@ -18,7 +18,7 @@
$(document).ready(function () { $(document).ready(function () {
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/configuration", "/api/device-mgt/android_sense/v1.0/configuration",
function (data) { function (data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data && data.configuration) { if (data && data.configuration) {
@ -52,7 +52,7 @@ var addConfiguration = function () {
var errorMsgWrapper = "#android_sense-config-error-msg"; var errorMsgWrapper = "#android_sense-config-error-msg";
var errorMsg = "#android_sense-config-error-msg span"; var errorMsg = "#android_sense-config-error-msg span";
var addConfigFormData = {}; var addConfigFormData = {};
var configList = new Array(); var configList = [];
var mqttEp = $("input#mqtt-endpoint").val(); var mqttEp = $("input#mqtt-endpoint").val();
var mqttConfig = { var mqttConfig = {
"name": "ANDROID_SENSE_MQTT_EP", "name": "ANDROID_SENSE_MQTT_EP",
@ -61,10 +61,10 @@ var addConfiguration = function () {
}; };
configList.push(mqttConfig); configList.push(mqttConfig);
addConfigFormData.type = "android_sense" addConfigFormData.type = "android_sense";
addConfigFormData.configuration = configList; addConfigFormData.configuration = configList;
var addConfigAPI = "/devicemgt_admin/configuration"; var addConfigAPI = "/api/device-mgt/android_sense/v1.0/configuration";
invokerUtil.post( invokerUtil.post(
addConfigAPI, addConfigAPI,
addConfigFormData, addConfigFormData,

@ -16,9 +16,9 @@
* under the License. * under the License.
*/ */
var modalPopup = ".wr-modalpopup"; var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modal-content";
var body = "body"; var body = "body";
/* /*

@ -26,15 +26,15 @@ function onRequest(context) {
if (devices) { if (devices) {
return { return {
"devices": stringify(devices), "devices": stringify(devices),
"backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" "backendApiUri": "/arduino/device/stats/"
}; };
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" + deviceId "backendApiUri": "/arduino/device/stats/" + deviceId
}; };
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -28,7 +28,7 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams}; return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams};
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit(); exit();

@ -18,7 +18,7 @@
$(document).ready(function () { $(document).ready(function () {
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/configuration", "/api/device-mgt/arduino/v1.0/configuration",
function (data) { function (data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data && data.configuration) { if (data && data.configuration) {
@ -69,10 +69,10 @@ var addConfiguration = function () {
configList.push(httpConfig); configList.push(httpConfig);
configList.push(httpsConfig); configList.push(httpsConfig);
addConfigFormData.type = "arduino" addConfigFormData.type = "arduino";
addConfigFormData.configuration = configList; addConfigFormData.configuration = configList;
var addConfigAPI = "/devicemgt_admin/configuration"; var addConfigAPI = "/api/device-mgt/arduino/v1.0/configuration";
invokerUtil.post( invokerUtil.post(
addConfigAPI, addConfigAPI,
addConfigFormData, addConfigFormData,

@ -16,9 +16,9 @@
* under the License. * under the License.
*/ */
var modalPopup = ".wr-modalpopup"; var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modal-content";
var body = "body"; var body = "body";
/* /*

@ -75,6 +75,10 @@
<groupId>org.wso2.carbon.identity</groupId> <groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId> <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
</dependency> </dependency>
<dependency>
<groupId>commons-pool.wso2</groupId>
<artifactId>commons-pool</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -248,7 +248,7 @@ var updatePolicy = function (policy, state) {
payload["roles"] = []; payload["roles"] = [];
} }
var serviceURL = "/devicemgt_admin/policies/" + getParameterByName("id"); var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id");
invokerUtil.put( invokerUtil.put(
serviceURL, serviceURL,
payload, payload,
@ -257,7 +257,7 @@ var updatePolicy = function (policy, state) {
if (state == "save"){ if (state == "save"){
var policyList = []; var policyList = [];
policyList.push(getParameterByName("id")); policyList.push(getParameterByName("id"));
serviceURL = "/devicemgt_admin/policies/inactivate"; serviceURL = "/api/device-mgt/v1.0/policies/inactivate";
invokerUtil.put( invokerUtil.put(
serviceURL, serviceURL,
policyList, policyList,
@ -274,7 +274,7 @@ var updatePolicy = function (policy, state) {
}else if(state == "publish"){ }else if(state == "publish"){
var policyList = []; var policyList = [];
policyList.push(getParameterByName("id")); policyList.push(getParameterByName("id"));
serviceURL = "/devicemgt_admin/policies/activate"; serviceURL = "/api/device-mgt/v1.0/policies/activate";
invokerUtil.put( invokerUtil.put(
serviceURL, serviceURL,
policyList, policyList,
@ -451,7 +451,7 @@ $(document).ready(function () {
data: function (params) { data: function (params) {
var postData = {}; var postData = {};
postData.actionMethod = "GET"; postData.actionMethod = "GET";
postData.actionUrl = "/devicemgt_admin/users?q=ad"; postData.actionUrl = "/api/device-mgt/v1.0/users?q=ad";
postData.actionPayload = JSON.stringify({ postData.actionPayload = JSON.stringify({
q: params.term, // search term q: params.term, // search term
page: params.page page: params.page
@ -479,7 +479,7 @@ $(document).ready(function () {
var policyPayloadObj; var policyPayloadObj;
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/policies/" + getParameterByName("id"), "/api/device-mgt/v1.0/policies/" + getParameterByName("id"),
// on success // on success
function (data) { function (data) {
data = JSON.parse(data); data = JSON.parse(data);

@ -111,7 +111,7 @@ $(document).ready(function () {
var policyPayloadObj; var policyPayloadObj;
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/policies/" + getParameterByName("id"), "/api/device-mgt/v1.0/policies/" + getParameterByName("id"),
// on success // on success
function (data) { function (data) {
// console.log("success: " + JSON.stringify(data)); // console.log("success: " + JSON.stringify(data));

@ -241,9 +241,9 @@ var savePolicy = function (policy, state) {
var serviceURL; var serviceURL;
if (state == "save") { if (state == "save") {
serviceURL = "/devicemgt_admin/policies/inactive-policy" serviceURL = "/api/device-mgt/v1.0/policies/inactive-policy"
} else if (state == "publish") { } else if (state == "publish") {
serviceURL = "/devicemgt_admin/policies/active-policy" serviceURL = "/api/device-mgt/v1.0/policies/active-policy"
} }
invokerUtil.post( invokerUtil.post(
serviceURL, serviceURL,
@ -414,7 +414,7 @@ $(document).ready(function () {
data: function (params) { data: function (params) {
var postData = {}; var postData = {};
postData.actionMethod = "GET"; postData.actionMethod = "GET";
postData.actionUrl = "/devicemgt_admin/users"; postData.actionUrl = "/api/device-mgt/v1.0/users";
postData.actionPayload = JSON.stringify({ postData.actionPayload = JSON.stringify({
q: params.term, // search term q: params.term, // search term
page: params.page page: params.page
@ -457,7 +457,7 @@ $(document).ready(function () {
var postData = {}; var postData = {};
postData.actionMethod = "GET"; postData.actionMethod = "GET";
var username = $("#platform").data("username"); var username = $("#platform").data("username");
postData.actionUrl = "/devicemgt_admin/groups/user/" + username + postData.actionUrl = "/api/device-mgt/v1.0/groups/user/" + username +
"/search?groupName=" + params.term; "/search?groupName=" + params.term;
return JSON.stringify(postData); return JSON.stringify(postData);
}, },

@ -72,7 +72,7 @@
org.wso2.carbon.utils, org.wso2.carbon.utils,
javax.xml.bind, javax.xml.bind,
javax.xml.bind.annotation, javax.xml.bind.annotation,
javax.xml.parsers, javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
org.w3c.dom org.w3c.dom
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>

@ -26,15 +26,15 @@ function onRequest(context) {
if (devices) { if (devices) {
return { return {
"devices": stringify(devices), "devices": stringify(devices),
"backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" "backendApiUri": "/raspberrypi/device/stats/"
}; };
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" + deviceId "backendApiUri": "/raspberrypi/device/stats/" + deviceId
}; };
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -28,7 +28,7 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams}; return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams};
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit(); exit();

@ -18,7 +18,7 @@
$(document).ready(function () { $(document).ready(function () {
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/configuration", "/api/device-mgt/raspberrypi/v1.0/configuration",
function (data) { function (data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data && data.configuration) { if (data && data.configuration) {
@ -79,10 +79,10 @@ var addConfiguration = function () {
configList.push(httpConfig); configList.push(httpConfig);
configList.push(httpsConfig); configList.push(httpsConfig);
configList.push(mqttConfig); configList.push(mqttConfig);
addConfigFormData.type = "raspberrypi" addConfigFormData.type = "raspberrypi";
addConfigFormData.configuration = configList; addConfigFormData.configuration = configList;
var addConfigAPI = "/devicemgt_admin/configuration"; var addConfigAPI = "/api/device-mgt/raspberrypi/v1.0/configuration";
invokerUtil.post( invokerUtil.post(
addConfigAPI, addConfigAPI,
addConfigFormData, addConfigFormData,

@ -16,9 +16,9 @@
* under the License. * under the License.
*/ */
var modalPopup = ".wr-modalpopup"; var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modal-content";
var body = "body"; var body = "body";
/* /*

@ -26,15 +26,15 @@ function onRequest(context) {
if (devices) { if (devices) {
return { return {
"devices": stringify(devices), "devices": stringify(devices),
"backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" "backendApiUri": "/virtual_firealarm/device/stats/"
}; };
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" + deviceId "backendApiUri": "/virtual_firealarm/device/stats/" + deviceId
}; };
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -28,7 +28,7 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/virtual_firealarm/", "autoCompleteParams" : autoCompleteParams}; return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/virtual_firealarm/", "autoCompleteParams" : autoCompleteParams};
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit(); exit();

@ -18,7 +18,7 @@
$(document).ready(function () { $(document).ready(function () {
invokerUtil.get( invokerUtil.get(
"/devicemgt_admin/configuration", "/api/device-mgt/virtual_firealarm/v1.0/configuration",
function (data) { function (data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data && data.configuration) { if (data && data.configuration) {
@ -69,10 +69,10 @@ var addConfiguration = function () {
configList.push(httpConfig); configList.push(httpConfig);
configList.push(httpsConfig); configList.push(httpsConfig);
configList.push(mqttConfig); configList.push(mqttConfig);
addConfigFormData.type = "virtual_firealarm" addConfigFormData.type = "virtual_firealarm";
addConfigFormData.configuration = configList; addConfigFormData.configuration = configList;
var addConfigAPI = "/devicemgt_admin/configuration"; var addConfigAPI = "/api/device-mgt/virtual_firealarm/v1.0/configuration";
invokerUtil.post( invokerUtil.post(
addConfigAPI, addConfigAPI,
addConfigFormData, addConfigFormData,

@ -18,21 +18,24 @@
function onRequest(context) { function onRequest(context) {
var log = new Log("stats.js"); var log = new Log("stats.js");
var carbonServer = require("carbon").server;
var device = context.unit.params.device; var device = context.unit.params.device;
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var jwtService = carbon.server.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient(); var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants.ENCODED_CLIENT_KEYS_IDENTIFIER); var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (encodedClientKeys) { if (encodedClientKeys) {
var tokenUtil = require("/app/modules/util.js").util; var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(","); var resp = tokenUtil.decode(encodedClientKeys).split(":");
var user = session.get(constants.USER_SESSION_KEY); var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier
var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\""+device.deviceIdentifier+" \", \"type\":\""+device.type+"\"}]}"; + "\", \"type\":\"" + device.type + "\"}]}";
var encodedScope = tokenUtil.encode(deviceParam); var encodedScope = tokenUtil.encode(deviceParam);
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], user.username, null, var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default",
"{\"device\": \"" +encodedScope+"\"}"); {"device": encodedScope});
var token = ""; var token = "";
if (tokenPair) { if (tokenPair) {
token = tokenPair.accessToken; token = tokenPair.accessToken;

@ -16,9 +16,9 @@
* under the License. * under the License.
*/ */
var modalPopup = ".wr-modalpopup"; var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modal-content";
var body = "body"; var body = "body";
/* /*

@ -23,7 +23,7 @@ function onRequest(context) {
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId)["content"];
if (device) { if (device) {
var viewModel = {}; var viewModel = {};

@ -21,57 +21,265 @@
var deviceIdentifier = deviceId.data("deviceid"); var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
var payload = [deviceIdentifier]; var payload = [deviceIdentifier];
var serviceUrl = "/mdm-android-agent/operation/device-info"; var operationTable;
if (deviceType == "ios") {
serviceUrl = "/ios/operation/deviceinfo";
} else if (deviceType == "android") {
//var serviceUrl = "/mdm-android-agent/operation/device-info";
serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info";
}
if (serviceUrl) {
invokerUtil.post(serviceUrl, payload, invokerUtil.post(serviceUrl, payload,
function (message) { function (message) {
console.log(message); console.log(message);
}, function (message) { }, function (message) {
console.log(message); console.log(message);
}); });
}
$(document).ready(function () { $(document).ready(function () {
$(".panel-body").removeClass("hidden"); $(".panel-body").removeClass("hidden");
$("#loading-content").remove(); $("#loading-content").remove();
loadOperationsLog();
loadApplicationsList(); loadApplicationsList();
loadPolicyCompliance();
$("#refresh-policy").click(function () {
$('#policy-spinner').removeClass('hidden');
loadPolicyCompliance();
});
$("#refresh-apps").click(function () { $("#refresh-apps").click(function () {
$('#apps-spinner').removeClass('hidden'); $('#apps-spinner').removeClass('hidden');
loadApplicationsList(); loadApplicationsList();
}); });
$("#refresh-operations").click(function () {
$('#operations-spinner').removeClass('hidden');
loadOperationsLog(true);
});
loadOperationBar(deviceType); loadOperationBar(deviceType);
}); });
function loadOperationsLog(update) {
var operationsLogTable = "#operations-log-table";
if (update) {
operationTable = $(operationsLogTable).DataTable();
operationTable.ajax.reload(false);
return;
}
operationTable = $(operationsLogTable)
.datatables_extended({
serverSide: true,
processing: false,
searching: false,
ordering: false,
pageLength: 10,
order: [],
ajax: {
url: context + "/api/operation/paginate",
data: {
deviceId: deviceIdentifier,
deviceType: deviceType
},
dataSrc: function (json) {
$("#operations-spinner").addClass(
"hidden");
$("#operations-log-container").empty();
return json.data;
}
},
columnDefs: [
{targets: 0, data: "code"},
{
targets: 1,
data: "status",
render: function (status) {
var html;
switch (status) {
case "COMPLETED" :
html =
"<span><i class='fw fw-ok icon-success'></i> Completed</span>";
break;
case "PENDING" :
html =
"<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break;
case "ERROR" :
html =
"<span><i class='fw fw-error icon-danger'></i> Error</span>";
break;
case "IN_PROGRESS" :
html =
"<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
break;
case "REPEATED" :
html =
"<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
break;
}
return html;
}
},
{
targets: 2,
data: "createdTimeStamp",
render: function (date) {
var value = String(date);
return value.slice(0, 16);
}
}
],
"createdRow": function (row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),
function (colIndex) {
switch (colIndex) {
case 1:
$(this).attr(
"data-grid-label",
"Code");
$(this).attr(
"data-display",
data["code"]);
break;
case 2:
$(this).attr(
"data-grid-label",
"Status");
$(this).attr(
"data-display",
data["status"]);
break;
case 3:
$(this).attr(
"data-grid-label",
"Created Timestamp");
$(this).attr(
"data-display",
data["createdTimeStamp"]);
break;
}
}
);
}
});
}
function loadApplicationsList() { function loadApplicationsList() {
var applicationsList = $("#applications-list"); var applicationsList = $("#applications-list");
var deviceListingSrc = applicationsList.attr("src"); var applicationListingTemplate = applicationsList.attr("src");
var deviceId = applicationsList.data("device-id"); var deviceId = applicationsList.data("device-id");
var deviceType = applicationsList.data("device-type"); var deviceType = applicationsList.data("device-type");
$.template("application-list", deviceListingSrc, function (template) { $.template("application-list", applicationListingTemplate, function (template) {
var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications";
invokerUtil.get(
var successCallback = function (data) { serviceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data); data = JSON.parse(data);
$('#apps-spinner').addClass('hidden'); $("#apps-spinner").addClass("hidden");
var viewModel = {}; if (data.length > 0) {
if (data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); data[i]["name"] = decodeURIComponent(data[i]["name"]);
data[i].name = data[i].name.replace(/[0-9]/g, ' '); data[i]["platform"] = deviceType;
} }
}
viewModel.applications = data; var viewModel = {};
viewModel.deviceType = deviceType; viewModel["applications"] = data;
if (data.length > 0) { viewModel["deviceType"] = deviceType;
var content = template(viewModel); var content = template(viewModel);
$("#applications-list-container").html(content); $("#applications-list-container").html(content);
} else {
$("#applications-list-container").
html("<div class='message message-info'><h4><i class='icon fw fw-info'></i>No applications found.</h4>" +
"<p>Please try refreshing the list in a while.</p></div>");
} }
}
}; },
invokerUtil.get(serviceURL, // error-callback
successCallback, function (message) { function () {
console.log(message); $("#applications-list-container").
html("<div class='panel-body'><br><p class='fw-warning'>&nbsp;Loading application list " +
"was not successful. please try refreshing the list in a while.<p></div>");
}); });
}); });
} }
function loadPolicyCompliance() {
var policyCompliance = $("#policy-view");
var policyComplianceTemplate = policyCompliance.attr("src");
var deviceId = policyCompliance.data("device-id");
var deviceType = policyCompliance.data("device-type");
var activePolicy = null;
$.template(
"policy-view",
policyComplianceTemplate,
function (template) {
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
invokerUtil.get(
getEffectivePolicyURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data);
$("#policy-spinner").addClass("hidden");
if (data["active"] == true) {
activePolicy = data;
invokerUtil.get(
getDeviceComplianceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
var viewModel = {};
viewModel["policy"] = activePolicy;
viewModel["deviceType"] = deviceType;
data = JSON.parse(data);
var content;
if (data["complianceData"]) {
if (data["complianceData"]["complianceFeatures"] &&
data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["compliance"] = "NON-COMPLIANT";
viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
content = template(viewModel);
$("#policy-list-container").html(content);
} else {
viewModel["compliance"] = "COMPLIANT";
content = template(viewModel);
$("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden");
}
} else {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> This device " +
"has no policy applied.<p></div>");
}
}
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
}
}
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
}
);
}
}()); }());

@ -50,7 +50,7 @@
{{/if}} {{/if}}
{{#if permissions.ADVANCED_SEARCH}} {{#if permissions.ADVANCED_SEARCH}}
<li id="advanced-search-btn" class="hidden"> <li id="advanced-search-btn" class="hidden">
<a href="{{appContext}}devices/search"> <a href="{{@app.context}}/devices/search">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stroke fw-stack-2x"></i> <i class="fw fw-ring fw-stroke fw-stack-2x"></i>
<i class="fw fw-search fw-stack-1x"></i> <i class="fw fw-search fw-stack-1x"></i>

@ -21,8 +21,8 @@
*/ */
var operations = '.wr-operations', var operations = '.wr-operations',
modalPopup = '.wr-modalpopup', modalPopup = '.modal',
modalPopupContent = modalPopup + ' .modalpopup-content', modalPopupContent = modalPopup + ' .modal-content',
navHeight = $('#nav').height(), navHeight = $('#nav').height(),
headerHeight = $('header').height(), headerHeight = $('header').height(),
offset = (headerHeight + navHeight), offset = (headerHeight + navHeight),
@ -208,14 +208,16 @@ function runOperation(operationName) {
var payload, serviceEndPoint; var payload, serviceEndPoint;
if (list[platformTypeConstants.IOS]) { if (list[platformTypeConstants.IOS]) {
payload = operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); payload =
operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]);
serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName);
} else if (list[platformTypeConstants.ANDROID]) { } else if (list[platformTypeConstants.ANDROID]) {
payload = operationModule payload = operationModule
.generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]); .generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]);
serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName);
} else if (list[platformTypeConstants.WINDOWS]) { } else if (list[platformTypeConstants.WINDOWS]) {
payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, list[platformTypeConstants.WINDOWS]); payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName,
list[platformTypeConstants.WINDOWS]);
serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName);
} }
if (operationName == "NOTIFICATION") { if (operationName == "NOTIFICATION") {

@ -1822,13 +1822,13 @@ stepForwardFrom["policy-naming-publish"] = function () {
policy["policyName"] = $("#policy-name-input").val(); policy["policyName"] = $("#policy-name-input").val();
policy["description"] = $("#policy-description-input").val(); policy["description"] = $("#policy-description-input").val();
//All data is collected. Policy can now be updated. //All data is collected. Policy can now be updated.
savePolicy(policy, "/devicemgt_admin/policies/active-policy"); savePolicy(policy, "/api/device-mgt/v1.0/policies/active-policy");
}; };
stepForwardFrom["policy-naming"] = function () { stepForwardFrom["policy-naming"] = function () {
policy["policyName"] = $("#policy-name-input").val(); policy["policyName"] = $("#policy-name-input").val();
policy["description"] = $("#policy-description-input").val(); policy["description"] = $("#policy-description-input").val();
//All data is collected. Policy can now be updated. //All data is collected. Policy can now be updated.
savePolicy(policy, "/devicemgt_admin/policies/inactive-policy"); savePolicy(policy, "/api/device-mgt/v1.0/policies/inactive-policy");
}; };
var savePolicy = function (policy, serviceURL) { var savePolicy = function (policy, serviceURL) {
@ -2058,9 +2058,9 @@ $(document).ready(function () {
data: function (params) { data: function (params) {
var postData = {}; var postData = {};
postData.actionMethod = "GET"; postData.actionMethod = "GET";
postData.actionUrl = "/devicemgt_admin/users"; postData.actionUrl = "/api/device-mgt/v1.0/users/search/usernames";
postData.actionPayload = JSON.stringify({ postData.actionPayload = JSON.stringify({
q: params.term, // search term filter: params.term, // search term
page: params.page page: params.page
}); });

@ -79,7 +79,7 @@
{{#zone "navbarCollapsableRightItems"}} {{#zone "navbarCollapsableRightItems"}}
<ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right"> <ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right">
<li class="visible-inline-block"> <li class="visible-inline-block">
<!--<a href="{{appContext}}notification-listing" title="Failures of operations on the device side will be listed here">--> <!--<a href="{{@app.context}}notification-listing" title="Failures of operations on the device side will be listed here">-->
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content" <a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
aria-expanded="false" rel="notifications-sidebar"> aria-expanded="false" rel="notifications-sidebar">
<span id="notification-bubble" class="badge notifications hidden"></span> <span id="notification-bubble" class="badge notifications hidden"></span>
@ -100,7 +100,7 @@
<ul class="sidebar-messages"></ul> <ul class="sidebar-messages"></ul>
<br> <br>
<div class="text-center"> <div class="text-center">
<a href="{{appContext}}notification-listing" class="btn-operations btn-default"> <a href="{{@app.context}}/notification-listing" class="btn-operations btn-default">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stroke fw-stack-2x"></i> <i class="fw fw-ring fw-stroke fw-stack-2x"></i>
<i class="fw fw-notification fw-stack-1x"></i> <i class="fw fw-notification fw-stack-1x"></i>
@ -112,7 +112,7 @@
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script id="notifications" data-current-user="{{currentUser.username}}" <script id="notifications" data-current-user="{{@user.username}}"
data-image-resource="{{@unit.publicUri}}/images/" src="{{@unit.publicUri}}/templates/notifications.hbs" data-image-resource="{{@unit.publicUri}}/images/" src="{{@unit.publicUri}}/templates/notifications.hbs"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/nav-menu.js"}} {{js "js/nav-menu.js"}}

@ -18,7 +18,7 @@
var WEB_APP_TITLE = "WSO2 CDM"; var WEB_APP_TITLE = "WSO2 CDM";
var WEB_APP_CONTEXT = "/devicemgt"; var WEB_APP_CONTEXT = "/devicemgt";
var ADMIN_SERVICE_CONTEXT = "/devicemgt_admin"; var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0";
var USER_SESSION_KEY = "_UUF_USER"; var USER_SESSION_KEY = "_UUF_USER";
var UNSPECIFIED = "Unspecified"; var UNSPECIFIED = "Unspecified";
var httpURL = "httpURL"; var httpURL = "httpURL";

@ -87,7 +87,7 @@
{{#zone "navbarCollapsableRightItems"}} {{#zone "navbarCollapsableRightItems"}}
<ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right"> <ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right">
<li class="visible-inline-block"> <li class="visible-inline-block">
<!--<a href="{{appContext}}notification-listing" title="Failures of operations on the device side will be listed here">--> <!--<a href="{{@app.context}}notification-listing" title="Failures of operations on the device side will be listed here">-->
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content" <a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
aria-expanded="false" rel="notifications-sidebar"> aria-expanded="false" rel="notifications-sidebar">
<span class="icon fw-stack"> <span class="icon fw-stack">
@ -105,13 +105,13 @@
data-offset-top="80"> data-offset-top="80">
<ul class="sidebar-messages"> <ul class="sidebar-messages">
</ul> </ul>
<h4 class="text-center"><a href="{{appContext}}notification-listing" class="text-center">Show all notifications</a> <h4 class="text-center"><a href="{{@app.context}}notification-listing" class="text-center">Show all notifications</a>
</h4> </h4>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script id="notifications" data-current-user="{{currentUser.username}}" <script id="notifications" data-current-user="{{@user.username}}"
data-image-resource="{{self.publicURL}}/images/" src="{{self.publicURL}}/templates/notifications.hbs" data-image-resource="{{@unit.publicUri}}/images/" src="{{@unit.publicUri}}/templates/notifications.hbs"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/nav-menu.js"}} {{js "js/nav-menu.js"}}
{{/zone}} {{/zone}}

@ -16,9 +16,10 @@
* under the License. * under the License.
*/ */
var modalPopup = ".wr-modalpopup", var modalPopup = ".modal";
modalPopupContainer = modalPopup + " .modalpopup-container", var modalPopupContainer = modalPopup + " .modal-content";
modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
var emmAdminBasePath = "/api/device-mgt/v1.0"; var emmAdminBasePath = "/api/device-mgt/v1.0";

@ -23,9 +23,10 @@
var payload = [deviceIdentifier]; var payload = [deviceIdentifier];
var operationTable; var operationTable;
if (deviceType == "ios") { if (deviceType == "ios") {
var serviceUrl = "/ios/operation/deviceinfo"; serviceUrl = "/ios/operation/deviceinfo";
} else if (deviceType == "android") { } else if (deviceType == "android") {
var serviceUrl = "/mdm-android-agent/operation/device-info"; //var serviceUrl = "/mdm-android-agent/operation/device-info";
serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info";
} }
if (serviceUrl) { if (serviceUrl) {
invokerUtil.post(serviceUrl, payload, invokerUtil.post(serviceUrl, payload,
@ -61,137 +62,224 @@
}); });
function loadOperationsLog(update) { function loadOperationsLog(update) {
var operationsLog = $("#operations-log"); var operationsLogTable = "#operations-log-table";
var deviceListingSrc = operationsLog.attr("src"); if (update) {
var deviceId = operationsLog.data("device-id"); operationTable = $(operationsLogTable).DataTable();
var deviceType = operationsLog.data("device-type"); operationTable.ajax.reload(false);
return;
$.template("operations-log", deviceListingSrc, function (template) {
var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId;
var successCallback = function (data) {
data = JSON.parse(data);
$('#operations-spinner').addClass('hidden');
var viewModel = {};
viewModel.operations = data;
if (data.length > 0) {
var content = template(viewModel);
if (!update) {
$("#operations-log-container").html(content);
operationTable = $('#operations-log-table').datatables_extended();
} else {
$('#operations-log-table').dataTable().fnClearTable();
for (var i = 0; i < data.length; i++) {
var status;
if (data[i].status == "COMPLETED") {
status = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
} else if (data[i].status == "PENDING") {
status = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
} else if (data[i].status == "ERROR") {
status = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
} else if (data[i].status == "IN_PROGRESS") {
status = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
} }
operationTable = $(operationsLogTable)
$('#operations-log-table').dataTable().fnAddData([ .datatables_extended({
data[i].code, serverSide: true,
status, processing: false,
data[i].createdTimeStamp searching: false,
]); ordering: false,
pageLength: 10,
order: [],
ajax: {
url: context + "/api/operation/paginate",
data: {
deviceId: deviceIdentifier,
deviceType: deviceType
},
dataSrc: function (json) {
$("#operations-spinner").addClass(
"hidden");
$("#operations-log-container").empty();
return json.data;
} }
},
columnDefs: [
{targets: 0, data: "code"},
{
targets: 1,
data: "status",
render: function (status) {
var html;
switch (status) {
case "COMPLETED" :
html =
"<span><i class='fw fw-ok icon-success'></i> Completed</span>";
break;
case "PENDING" :
html =
"<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break;
case "ERROR" :
html =
"<span><i class='fw fw-error icon-danger'></i> Error</span>";
break;
case "IN_PROGRESS" :
html =
"<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
break;
case "REPEATED" :
html =
"<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
break;
} }
return html;
}
},
{
targets: 2,
data: "createdTimeStamp",
render: function (date) {
var value = String(date);
return value.slice(0, 16);
}
}
],
"createdRow": function (row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),
function (colIndex) {
switch (colIndex) {
case 1:
$(this).attr(
"data-grid-label",
"Code");
$(this).attr(
"data-display",
data["code"]);
break;
case 2:
$(this).attr(
"data-grid-label",
"Status");
$(this).attr(
"data-display",
data["status"]);
break;
case 3:
$(this).attr(
"data-grid-label",
"Created Timestamp");
$(this).attr(
"data-display",
data["createdTimeStamp"]);
break;
}
}
);
} }
};
invokerUtil.get(serviceURL,
successCallback, function (message) {
console.log(message);
});
}); });
} }
function loadApplicationsList() { function loadApplicationsList() {
var applicationsList = $("#applications-list"); var applicationsList = $("#applications-list");
var deviceListingSrc = applicationsList.attr("src"); var applicationListingTemplate = applicationsList.attr("src");
var deviceId = applicationsList.data("device-id"); var deviceId = applicationsList.data("device-id");
var deviceType = applicationsList.data("device-type"); var deviceType = applicationsList.data("device-type");
$.template("application-list", deviceListingSrc, function (template) { $.template("application-list", applicationListingTemplate, function (template) {
var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications";
invokerUtil.get(
var successCallback = function (data) { serviceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data); data = JSON.parse(data);
$('#apps-spinner').addClass('hidden'); $("#apps-spinner").addClass("hidden");
var viewModel = {}; if (data.length > 0) {
if (data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); data[i]["name"] = decodeURIComponent(data[i]["name"]);
data[i].name = data[i].name.replace(/[0-9]/g, ' '); data[i]["platform"] = deviceType;
} }
}
viewModel.applications = data; var viewModel = {};
viewModel.deviceType = deviceType; viewModel["applications"] = data;
if (data.length > 0) { viewModel["deviceType"] = deviceType;
var content = template(viewModel); var content = template(viewModel);
$("#applications-list-container").html(content); $("#applications-list-container").html(content);
} else {
$("#applications-list-container").
html("<div class='message message-info'><h4><i class='icon fw fw-info'></i>No applications found.</h4>" +
"<p>Please try refreshing the list in a while.</p></div>");
} }
}
}; },
invokerUtil.get(serviceURL, // error-callback
successCallback, function (message) { function () {
console.log(message); $("#applications-list-container").
html("<div class='panel-body'><br><p class='fw-warning'>&nbsp;Loading application list " +
"was not successful. please try refreshing the list in a while.<p></div>");
}); });
}); });
} }
function loadPolicyCompliance() { function loadPolicyCompliance() {
var policyCompliance = $("#policy-view"); var policyCompliance = $("#policy-view");
var policySrc = policyCompliance.attr("src"); var policyComplianceTemplate = policyCompliance.attr("src");
var deviceId = policyCompliance.data("device-id"); var deviceId = policyCompliance.data("device-id");
var deviceType = policyCompliance.data("device-type"); var deviceType = policyCompliance.data("device-type");
var activePolicy = null; var activePolicy = null;
$.template("policy-view", policySrc, function (template) { $.template(
var serviceURLPolicy = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId + "/active-policy" "policy-view",
var serviceURLCompliance = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId; policyComplianceTemplate,
function (template) {
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
var successCallbackCompliance = function (data) { invokerUtil.get(
getEffectivePolicyURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data);
$("#policy-spinner").addClass("hidden");
if (data["active"] == true) {
activePolicy = data;
invokerUtil.get(
getDeviceComplianceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
var viewModel = {}; var viewModel = {};
viewModel.policy = activePolicy; viewModel["policy"] = activePolicy;
viewModel.deviceType = deviceType; viewModel["deviceType"] = deviceType;
if (data != null && data.complianceFeatures != null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) { data = JSON.parse(data);
viewModel.compliance = "NON-COMPLIANT"; var content;
viewModel.complianceFeatures = data.complianceFeatures; if (data["complianceData"]) {
var content = template(viewModel); if (data["complianceData"]["complianceFeatures"] &&
data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["compliance"] = "NON-COMPLIANT";
viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
content = template(viewModel);
$("#policy-list-container").html(content); $("#policy-list-container").html(content);
} else { } else {
viewModel.compliance = "COMPLIANT"; viewModel["compliance"] = "COMPLIANT";
var content = template(viewModel); content = template(viewModel);
$("#policy-list-container").html(content); $("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden"); $("#policy-compliance-table").addClass("hidden");
} }
} else {
}; $("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> This device " +
var successCallbackPolicy = function (data) { "has no policy applied.<p></div>");
data = JSON.parse(data);
$('#policy-spinner').addClass('hidden');
if (data != null && data.active == true) {
activePolicy = data;
invokerUtil.get(serviceURLCompliance,
successCallbackCompliance, function (message) {
console.log(message);
});
} }
};
invokerUtil.get(serviceURLPolicy,
successCallbackPolicy, function (message) {
console.log(message);
});
});
} }
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
}
}
},
// error-callback
function () {
$("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>");
}
);
}
);
}
}()); }());

@ -1248,8 +1248,8 @@
<swagger.version>1.5.8</swagger.version> <swagger.version>1.5.8</swagger.version>
<!-- Carbon Analytics --> <!-- Carbon Analytics -->
<carbon.analytics.common.version>5.0.11</carbon.analytics.common.version> <carbon.analytics.common.version>5.1.3</carbon.analytics.common.version>
<carbon.analytics.common.version.range>[5.0.11,6.0.0)</carbon.analytics.common.version.range> <carbon.analytics.common.version.range>[5.1.3,6.0.0)</carbon.analytics.common.version.range>
<carbon.analytics.version>1.0.6-ALPHA</carbon.analytics.version> <carbon.analytics.version>1.0.6-ALPHA</carbon.analytics.version>
<carbon.analytics.version.range>[1.0.5,2.0.0]</carbon.analytics.version.range> <carbon.analytics.version.range>[1.0.5,2.0.0]</carbon.analytics.version.range>
@ -1315,6 +1315,7 @@
<servlet-api.version>2.5</servlet-api.version> <servlet-api.version>2.5</servlet-api.version>
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version> <hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
<javax.xml.parsers.import.pkg.version>[0.0.0,1.0.0)</javax.xml.parsers.import.pkg.version>
</properties> </properties>
<scm> <scm>

Loading…
Cancel
Save