Fix the device view related issues

merge-requests/1/head
kamidu 8 years ago
parent fe2b861932
commit 04d1a3912a

@ -0,0 +1,44 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Device Details"}}
{{unit "cdmf.unit.lib.service-invoker-utility"}}
{{unit "cdmf.unit.lib.handlebars"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/devices">
Devices
</a>
</li>
<li>
<a href="#">
Device Details
</a>
</li>
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.lib.data-table"}}
{{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.device.view"}}
{{/zone}}

@ -0,0 +1,33 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context){
var utility = require("/app/modules/utility.js").utility;
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlebars Helper equal needs 2 parameters");
if( lvalue!=rvalue ) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
var deviceType = context.uriParams.deviceType;
return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")};
}

@ -204,7 +204,7 @@ function loadDevices(searchType, searchParam){
var deviceIdentifier = row.deviceIdentifier; var deviceIdentifier = row.deviceIdentifier;
var url = "#"; var url = "#";
if (status != 'REMOVED') { if (status != 'REMOVED') {
url = "devices/view?type=" + deviceType + "&id=" + deviceIdentifier; url = "device/" + deviceType + "?id=" + deviceIdentifier;
} }
return '<div onclick="javascript:InitiateViewOption(\'' + url + '\')" class="thumbnail icon"><i class="square-element text fw fw-mobile"></i></div>' return '<div onclick="javascript:InitiateViewOption(\'' + url + '\')" class="thumbnail icon"><i class="square-element text fw fw-mobile"></i></div>'
} }

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -10,8 +10,8 @@
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* KIND, either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
@ -37,12 +37,50 @@ var operationModule = function () {
// Constants to define Android Operation Constants // Constants to define Android Operation Constants
var androidOperationConstants = { var androidOperationConstants = {
"PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY",
"VPN_OPERATION_CODE": "VPN",
"CAMERA_OPERATION_CODE": "CAMERA", "CAMERA_OPERATION_CODE": "CAMERA",
"ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE",
"WIFI_OPERATION_CODE": "WIFI", "WIFI_OPERATION_CODE": "WIFI",
"WIPE_OPERATION_CODE": "WIPE_DATA", "WIPE_OPERATION_CODE": "WIPE_DATA",
"NOTIFICATION_OPERATION_CODE": "NOTIFICATION", "NOTIFICATION_OPERATION_CODE": "NOTIFICATION",
"CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE" "WORK_PROFILE_CODE": "WORK_PROFILE",
"CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE",
"LOCK_OPERATION_CODE": "DEVICE_LOCK",
"UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE",
"DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME",
"DISALLOW_CONFIG_BLUETOOTH" : "DISALLOW_CONFIG_BLUETOOTH",
"DISALLOW_CONFIG_CELL_BROADCASTS" : "DISALLOW_CONFIG_CELL_BROADCASTS",
"DISALLOW_CONFIG_CREDENTIALS" : "DISALLOW_CONFIG_CREDENTIALS",
"DISALLOW_CONFIG_MOBILE_NETWORKS" : "DISALLOW_CONFIG_MOBILE_NETWORKS",
"DISALLOW_CONFIG_TETHERING" : "DISALLOW_CONFIG_TETHERING",
"DISALLOW_CONFIG_VPN" : "DISALLOW_CONFIG_VPN",
"DISALLOW_CONFIG_WIFI" : "DISALLOW_CONFIG_WIFI",
"DISALLOW_APPS_CONTROL" : "DISALLOW_APPS_CONTROL",
"DISALLOW_CREATE_WINDOWS" : "DISALLOW_CREATE_WINDOWS",
"DISALLOW_CROSS_PROFILE_COPY_PASTE" : "DISALLOW_CROSS_PROFILE_COPY_PASTE",
"DISALLOW_DEBUGGING_FEATURES" : "DISALLOW_DEBUGGING_FEATURES",
"DISALLOW_FACTORY_RESET" : "DISALLOW_FACTORY_RESET",
"DISALLOW_ADD_USER" : "DISALLOW_ADD_USER",
"DISALLOW_INSTALL_APPS" : "DISALLOW_INSTALL_APPS",
"DISALLOW_INSTALL_UNKNOWN_SOURCES" : "DISALLOW_INSTALL_UNKNOWN_SOURCES",
"DISALLOW_MODIFY_ACCOUNTS" : "DISALLOW_MODIFY_ACCOUNTS",
"DISALLOW_MOUNT_PHYSICAL_MEDIA" : "DISALLOW_MOUNT_PHYSICAL_MEDIA",
"DISALLOW_NETWORK_RESET" : "DISALLOW_NETWORK_RESET",
"DISALLOW_OUTGOING_BEAM" : "DISALLOW_OUTGOING_BEAM",
"DISALLOW_OUTGOING_CALLS" : "DISALLOW_OUTGOING_CALLS",
"DISALLOW_REMOVE_USER" : "DISALLOW_REMOVE_USER",
"DISALLOW_SAFE_BOOT" : "DISALLOW_SAFE_BOOT",
"DISALLOW_SHARE_LOCATION" : "DISALLOW_SHARE_LOCATION",
"DISALLOW_SMS" : "DISALLOW_SMS",
"DISALLOW_UNINSTALL_APPS" : "DISALLOW_UNINSTALL_APPS",
"DISALLOW_UNMUTE_MICROPHONE" : "DISALLOW_UNMUTE_MICROPHONE",
"DISALLOW_USB_FILE_TRANSFER" : "DISALLOW_USB_FILE_TRANSFER",
"ALLOW_PARENT_PROFILE_APP_LINKING" : "ALLOW_PARENT_PROFILE_APP_LINKING",
"ENSURE_VERIFY_APPS" : "ENSURE_VERIFY_APPS",
"AUTO_TIME" : "AUTO_TIME",
"SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED",
"SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED",
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION"
}; };
// Constants to define Windows Operation Constants // Constants to define Windows Operation Constants
@ -58,6 +96,7 @@ var operationModule = function () {
var iosOperationConstants = { var iosOperationConstants = {
"PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY",
"RESTRICTIONS_OPERATION_CODE": "RESTRICTION", "RESTRICTIONS_OPERATION_CODE": "RESTRICTION",
"VPN_OPERATION_CODE": "VPN",
"WIFI_OPERATION_CODE": "WIFI", "WIFI_OPERATION_CODE": "WIFI",
"EMAIL_OPERATION_CODE": "EMAIL", "EMAIL_OPERATION_CODE": "EMAIL",
"AIRPLAY_OPERATION_CODE": "AIR_PLAY", "AIRPLAY_OPERATION_CODE": "AIR_PLAY",
@ -66,13 +105,19 @@ var operationModule = function () {
"NOTIFICATION_OPERATION_CODE": "NOTIFICATION", "NOTIFICATION_OPERATION_CODE": "NOTIFICATION",
"CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION",
"APN_OPERATION_CODE": "APN", "APN_OPERATION_CODE": "APN",
"CELLULAR_OPERATION_CODE": "CELLULAR" "DOMAIN_CODE": "DOMAIN",
"CELLULAR_OPERATION_CODE": "CELLULAR",
"PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN",
"APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING"
}; };
publicMethods.getIOSServiceEndpoint = function (operationCode) { publicMethods.getIOSServiceEndpoint = function (operationCode) {
var featureMap = { var featureMap = {
"DEVICE_LOCK": "lock", "DEVICE_LOCK": "lock",
"ALARM": "alarm", "VPN": "vpn",
"PER_APP_VPN": "perappvpn",
"APP_TO_PER_APP_VPN_MAPPING": "apptoperappvpnmapping",
"RING": "ring",
"LOCATION": "location", "LOCATION": "location",
"NOTIFICATION": "notification", "NOTIFICATION": "notification",
"AIR_PLAY": "airplay", "AIR_PLAY": "airplay",
@ -182,6 +227,76 @@ var operationModule = function () {
"restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"] "restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"]
}; };
break; break;
case iosOperationConstants["VPN_OPERATION_CODE"]:
var pptp = false;
var l2tp = false;
if (operationPayload["vpnType"] == "PPTP") {
pptp = true;
} else if (operationPayload["vpnType"] == "L2TP") {
l2tp = true;
}
payload = {
"userDefinedName": operationPayload["userDefinedName"],
"overridePrimary": operationPayload["overridePrimary"],
"onDemandEnabled": operationPayload["onDemandEnabled"],
"onDemandMatchDomainsAlways": operationPayload["onDemandMatchDomainsAlways"],
"onDemandMatchDomainsNever": operationPayload["onDemandMatchDomainsNever"],
"onDemandMatchDomainsOnRetry": operationPayload["onDemandMatchDomainsOnRetry"],
"onDemandRules": operationPayload["onDemandRules"],
"vendorConfigs": operationPayload["vendorConfigs"],
"vpnType": operationPayload["vpnType"],
"pptpAuthName": pptp ? operationPayload.ppp["authName"] : "",
"pptpTokenCard": pptp ? operationPayload.ppp["tokenCard"] : "",
"pptpAuthPassword": pptp ? operationPayload.ppp["authPassword"] : "",
"pptpCommRemoteAddress": pptp ? operationPayload.ppp["commRemoteAddress"] : "",
"pptpRSASecureID": pptp ? operationPayload.ppp["RSASecureID"] : "",
"pptpCCPEnabled": pptp ? operationPayload.ppp["CCPEnabled"] : "",
"pptpCCPMPPE40Enabled": pptp ? operationPayload.ppp["CCPMPPE40Enabled"] : "",
"pptpCCPMPPE128Enabled": pptp ? operationPayload.ppp["CCPMPPE128Enabled"] : "",
"l2tpAuthName": l2tp ? operationPayload.ppp["authName"] : "",
"l2tpTokenCard": l2tp ? operationPayload.ppp["tokenCard"] : "",
"l2tpAuthPassword": l2tp ? operationPayload.ppp["authPassword"] : "",
"l2tpCommRemoteAddress": l2tp ? operationPayload.ppp["commRemoteAddress"] : "",
"l2tpRSASecureID": l2tp ? operationPayload.ppp["RSASecureID"] : "",
"ipsecRemoteAddress": operationPayload.ipSec["remoteAddress"],
"ipsecAuthenticationMethod": operationPayload.ipSec["authenticationMethod"],
"ipsecLocalIdentifier": operationPayload.ipSec["localIdentifier"],
"ipsecSharedSecret": operationPayload.ipSec["sharedSecret"],
"ipsecPayloadCertificateUUID": operationPayload.ipSec["payloadCertificateUUID"],
"ipsecXAuthEnabled": operationPayload.ipSec["XAuthEnabled"],
"ipsecXAuthName": operationPayload.ipSec["XAuthName"],
"ipsecPromptForVPNPIN": operationPayload.ipSec["promptForVPNPIN"],
"ikev2RemoteAddress": operationPayload.ikEv2["remoteAddress"],
"ikev2LocalIdentifier": operationPayload.ikEv2["localIdentifier"],
"ikev2RemoteIdentifier": operationPayload.ikEv2["remoteIdentifier"],
"ikev2AuthenticationMethod": operationPayload.ikEv2["authenticationMethod"],
"ikev2SharedSecret": operationPayload.ikEv2["sharedSecret"],
"ikev2PayloadCertificateUUID": operationPayload.ikEv2["payloadCertificateUUID"],
"ikev2ExtendedAuthEnabled": operationPayload.ikEv2["extendedAuthEnabled"],
"ikev2AuthName": operationPayload.ikEv2["authName"],
"ikev2AuthPassword": operationPayload.ikEv2["authPassword"],
"ikev2DeadPeerDetectionInterval": operationPayload.ikEv2["deadPeerDetectionInterval"],
"ikev2ServerCertificateIssuerCommonName": operationPayload.ikEv2["serverCertificateIssuerCommonName"],
"ikev2ServerCertificateCommonName": operationPayload.ikEv2["serverCertificateCommonName"]
};
break;
case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]:
payload = {
"operation": {
"VPNUUID": operationPayload["PER-APP-VPNUUID"],
"safariDomains": operationPayload["safariDomains"],
"onDemandMatchAppEnabled": operationPayload["onDemandMatchAppEnabled"]
}
};
break;
case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]:
payload = {
"operation": {
"appLayerVPNMappings": operationPayload["appLayerVPNMappings"]
}
};
break;
case iosOperationConstants["WIFI_OPERATION_CODE"]: case iosOperationConstants["WIFI_OPERATION_CODE"]:
payload = { payload = {
"wifiHiddenNetwork": operationPayload["hiddenNetwork"], "wifiHiddenNetwork": operationPayload["hiddenNetwork"],
@ -367,6 +482,112 @@ var operationModule = function () {
} }
}; };
break; break;
case iosOperationConstants["VPN_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
var ppp = {};
var ipSec = {};
var ikev2 = {};
if (operationData["vpnType"] == "PPTP") {
ppp = {
"authName": operationData["pptpAuthName"],
"tokenCard": operationData["pptpTokenCard"],
"authPassword": operationData["pptpAuthPassword"],
"commRemoteAddress": operationData["pptpCommRemoteAddress"],
"RSASecureID": operationData["pptpRSASecureID"],
"CCPEnabled": operationData["pptpCCPEnabled"],
"CCPMPPE40Enabled": operationData["pptpCCPMPPE40Enabled"],
"CCPMPPE128Enabled": operationData["pptpCCPMPPE128Enabled"]
};
} else if (operationData["vpnType"] == "L2TP") {
ppp = {
"authName": operationData["l2tpAuthName"],
"tokenCard": operationData["l2tpTokenCard"],
"authPassword": operationData["l2tpAuthPassword"],
"commRemoteAddress": operationData["l2tpCommRemoteAddress"],
"RSASecureID": operationData["l2tpRSASecureID"]
};
} else if (operationData["vpnType"] == "IPSec") {
ipSec = {
"remoteAddress" : operationData["ipsecRemoteAddress"],
"authenticationMethod" : operationData["ipsecAuthenticationMethod"],
"localIdentifier" : operationData["ipsecLocalIdentifier"],
"sharedSecret" : operationData["ipsecSharedSecret"],
"payloadCertificateUUID" : operationData["ipsecPayloadCertificateUUID"],
"XAuthEnabled" : operationData["ipsecXAuthEnabled"],
"XAuthName" : operationData["ipsecXAuthName"],
"promptForVPNPIN" : operationData["ipsecPromptForVPNPIN"]
};
} else if (operationData["vpnType"] == "IKEv2") {
ikev2 = {
"remoteAddress" : operationData["ikev2RemoteAddress"],
"localIdentifier" : operationData["ikev2LocalIdentifier"],
"remoteIdentifier" : operationData["ikev2RemoteIdentifier"],
"authenticationMethod" : operationData["ikev2AuthenticationMethod"],
"sharedSecret" : operationData["ikev2SharedSecret"],
"payloadCertificateUUID" : operationData["ikev2PayloadCertificateUUID"],
"extendedAuthEnabled" : operationData["ikev2ExtendedAuthEnabled"],
"authName" : operationData["ikev2AuthName"],
"authPassword" : operationData["ikev2AuthPassword"],
"deadPeerDetectionInterval" : operationData["ikev2DeadPeerDetectionInterval"],
"serverCertificateIssuerCommonName" : operationData["ikev2ServerCertificateIssuerCommonName"],
"serverCertificateCommonName" : operationData["ikev2ServerCertificateCommonName"]
};
}
var domainsAlways = new Array();
for (var i = 0; i < operationData["onDemandMatchDomainsAlways"].length; i++) {
domainsAlways.push(operationData["onDemandMatchDomainsAlways"][i].domain);
}
var domainsNever = new Array();
for (var i = 0; i < operationData["onDemandMatchDomainsNever"].length; i++) {
domainsNever.push(operationData["onDemandMatchDomainsNever"][i].domain);
}
var domainsRetry = new Array();
for (var i = 0; i < operationData["onDemandMatchDomainsOnRetry"].length; i++) {
domainsRetry.push(operationData["onDemandMatchDomainsOnRetry"][i].domain);
}
payload = {
"operation": {
"userDefinedName": operationData["userDefinedName"],
"overridePrimary": operationData["overridePrimary"],
"onDemandEnabled": operationData["onDemandEnabled"],
"onDemandMatchDomainsAlways": domainsAlways,
"onDemandMatchDomainsNever": domainsNever,
"onDemandMatchDomainsOnRetry": domainsRetry,
"onDemandRules" : operationData["onDemandRules"],
"vendorConfigs" : operationData["vendorConfigs"],
"vpnType" : operationData["vpnType"],
"ppp": ppp,
"ipSec": ipSec,
"ikEv2": ikev2
}
};
break;
case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
var domains = new Array();
for (var i = 0; i < operationData["safariDomains"].length; i++) {
domains.push(operationData["safariDomains"][i].domain);
}
payload = {
"operation": {
"VPNUUID": operationData["VPNUUID"],
"safariDomains": domains,
"onDemandMatchAppEnabled": operationData["onDemandMatchAppEnabled"]
}
};
break;
case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"appLayerVPNMappings": operationData["appLayerVPNMappings"]
}
};
break;
case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
@ -528,6 +749,15 @@ var operationModule = function () {
} }
}; };
break; break;
case iosOperationConstants["DOMAIN_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"emailDomains": operationData["emailDomains"],
"webDomains": operationData["webDomains"]
}
};
break;
case iosOperationConstants["CELLULAR_OPERATION_CODE"]: case iosOperationConstants["CELLULAR_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
@ -544,7 +774,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"message": operationData["message"] "message" : operationData["message"]
} }
}; };
break; break;
@ -584,9 +814,7 @@ var operationModule = function () {
}; };
break; break;
case androidOperationConstants["CAMERA_OPERATION_CODE"]: case androidOperationConstants["CAMERA_OPERATION_CODE"]:
payload = { payload = operationPayload;
"cameraEnabled": operationPayload["enabled"]
};
break; break;
case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]:
payload = { payload = {
@ -596,7 +824,29 @@ var operationModule = function () {
case androidOperationConstants["WIFI_OPERATION_CODE"]: case androidOperationConstants["WIFI_OPERATION_CODE"]:
payload = { payload = {
"wifiSSID": operationPayload["ssid"], "wifiSSID": operationPayload["ssid"],
"wifiPassword": operationPayload["password"] "wifiPassword": operationPayload["password"],
"wifiType": operationPayload["type"],
"wifiEAP": operationPayload["eap"],
"wifiPhase2": operationPayload["phase2"],
"wifiProvisioning": operationPayload["provisioning"],
"wifiIdentity": operationPayload["identity"],
"wifiAnoIdentity": operationPayload["anonymousIdentity"],
"wifiCaCert" : operationPayload["cacert"],
"wifiCaCertName" : operationPayload["cacertName"]
};
break;
case androidOperationConstants["VPN_OPERATION_CODE"]:
payload = {
"serverAddress": operationPayload["serverAddress"],
"serverPort": operationPayload["serverPort"],
"sharedSecret": operationPayload["sharedSecret"],
"dnsServer": operationPayload["dnsServer"]
};
break;
case androidOperationConstants["APPLICATION_OPERATION_CODE"]:
payload = {
"restrictionType": operationPayload["restriction-type"],
"restrictedApplications": operationPayload["restricted-applications"]
}; };
break; break;
} }
@ -611,7 +861,40 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"enabled": operationData["cameraEnabled"] "CAMERA" : operationData["cameraEnabled"],
"DISALLOW_ADJUST_VOLUME" : operationData["disallowAdjustVolumeEnabled"],
"DISALLOW_CONFIG_BLUETOOTH" : operationData["disallowConfigBluetooth"],
"DISALLOW_CONFIG_CELL_BROADCASTS" : operationData["disallowConfigCellBroadcasts"],
"DISALLOW_CONFIG_CREDENTIALS" : operationData["disallowConfigCredentials"],
"DISALLOW_CONFIG_MOBILE_NETWORKS" : operationData["disallowConfigMobileNetworks"],
"DISALLOW_CONFIG_TETHERING" : operationData["disallowConfigTethering"],
"DISALLOW_CONFIG_VPN" : operationData["disallowConfigVpn"],
"DISALLOW_CONFIG_WIFI" : operationData["disallowConfigWifi"],
"DISALLOW_APPS_CONTROL" : operationData["disallowAppControl"],
"DISALLOW_CREATE_WINDOWS" : operationData["disallowCreateWindows"],
"DISALLOW_CROSS_PROFILE_COPY_PASTE" : operationData["disallowCrossProfileCopyPaste"],
"DISALLOW_DEBUGGING_FEATURES" : operationData["disallowDebugging"],
"DISALLOW_FACTORY_RESET" : operationData["disallowFactoryReset"],
"DISALLOW_ADD_USER" : operationData["disallowAddUser"],
"DISALLOW_INSTALL_APPS" : operationData["disallowInstallApps"],
"DISALLOW_INSTALL_UNKNOWN_SOURCES" : operationData["disallowInstallUnknownSources"],
"DISALLOW_MODIFY_ACCOUNTS" : operationData["disallowModifyAccounts"],
"DISALLOW_MOUNT_PHYSICAL_MEDIA" : operationData["disallowMountPhysicalMedia"],
"DISALLOW_NETWORK_RESET" : operationData["disallowNetworkReset"],
"DISALLOW_OUTGOING_BEAM" : operationData["disallowOutgoingBeam"],
"DISALLOW_OUTGOING_CALLS" : operationData["disallowOutgoingCalls"],
"DISALLOW_REMOVE_USER" : operationData["disallowRemoveUser"],
"DISALLOW_SAFE_BOOT" : operationData["disallowSafeBoot"],
"DISALLOW_SHARE_LOCATION" : operationData["disallowLocationSharing"],
"DISALLOW_SMS" : operationData["disallowSMS"],
"DISALLOW_UNINSTALL_APPS" : operationData["disallowUninstallApps"],
"DISALLOW_UNMUTE_MICROPHONE" : operationData["disallowUnmuteMicrophone"],
"DISALLOW_USB_FILE_TRANSFER" : operationData["disallowUSBFileTransfer"],
"ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"],
"ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"],
"AUTO_TIME" : operationData["enableAutoTime"],
"SET_SCREEN_CAPTURE_DISABLED" : operationData["diableScreenCapture"],
"SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"]
} }
}; };
break; break;
@ -619,7 +902,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"lockCode": operationData["lockCode"] "lockCode" : operationData["lockCode"]
} }
}; };
break; break;
@ -627,7 +910,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"encrypted": operationData["encryptStorageEnabled"] "encrypted" : operationData["encryptStorageEnabled"]
} }
}; };
break; break;
@ -635,7 +918,18 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"message": operationData["message"] //"message" : operationData["message"]
"messageText": operationData["messageText"],
"messageTitle": operationData["messageTitle"]
}
};
break;
case androidOperationConstants["UPGRADE_FIRMWARE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"schedule" : operationData["schedule"],
"server" : operationData["server"]
} }
}; };
break; break;
@ -643,7 +937,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"pin": operationData["pin"] "pin" : operationData["pin"]
} }
}; };
break; break;
@ -652,7 +946,47 @@ var operationModule = function () {
payload = { payload = {
"operation": { "operation": {
"ssid": operationData["wifiSSID"], "ssid": operationData["wifiSSID"],
"password": operationData["wifiPassword"] "type": operationData["wifiType"],
"password" : operationData["wifiPassword"],
"eap" : operationData["wifiEAP"],
"phase2" : operationData["wifiPhase2"],
"provisioning" : operationData["wifiProvisioning"],
"identity" : operationData["wifiIdentity"],
"anonymousIdentity" : operationData["wifiAnoIdentity"],
"cacert" : operationData["wifiCaCert"],
"cacertName" : operationData["wifiCaCertName"]
}
};
break;
case androidOperationConstants["VPN_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"serverAddress": operationData["serverAddress"],
"serverPort": operationData["serverPort"],
"sharedSecret": operationData["sharedSecret"],
"dnsServer": operationData["dnsServer"]
}
};
break;
case androidOperationConstants["LOCK_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"message" : operationData["lock-message"],
"isHardLockEnabled" : operationData["hard-lock"]
}
};
break;
case androidOperationConstants["WORK_PROFILE_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"profileName": operationData["workProfilePolicyProfileName"],
"enableSystemApps": operationData["workProfilePolicyEnableSystemApps"],
"hideSystemApps": operationData["workProfilePolicyHideSystemApps"],
"unhideSystemApps": operationData["workProfilePolicyUnhideSystemApps"],
"enablePlaystoreApps": operationData["workProfilePolicyEnablePlaystoreApps"]
} }
}; };
break; break;
@ -670,6 +1004,14 @@ var operationModule = function () {
} }
}; };
break; break;
case androidOperationConstants["APPLICATION_OPERATION_CODE"]:
payload = {
"operation": {
"restriction-type": operationData["restrictionType"],
"restricted-applications": operationData["restrictedApplications"]
}
};
break;
default: default:
// If the operation is neither of above, it is a command operation // If the operation is neither of above, it is a command operation
operationType = operationTypeConstants["COMMAND"]; operationType = operationTypeConstants["COMMAND"];
@ -686,28 +1028,31 @@ var operationModule = function () {
publicMethods.getAndroidServiceEndpoint = function (operationCode) { publicMethods.getAndroidServiceEndpoint = function (operationCode) {
var featureMap = { var featureMap = {
"WIFI": "wifi", "WIFI": "configure-wifi",
"CAMERA": "camera", "CAMERA": "control-camera",
"DEVICE_LOCK": "lock", "VPN": "configure-vpn",
"DEVICE_LOCK": "lock-devices",
"DEVICE_UNLOCK": "unlock-devices",
"DEVICE_LOCATION": "location", "DEVICE_LOCATION": "location",
"CLEAR_PASSWORD": "clear-password", "CLEAR_PASSWORD": "clear-password",
"APPLICATION_LIST": "get-application-list", "APPLICATION_LIST": "get-application-list",
"DEVICE_RING": "ring-device", "DEVICE_RING": "ring",
"DEVICE_REBOOT": "reboot-device", "DEVICE_REBOOT": "reboot",
"UPGRADE_FIRMWARE": "upgrade-firmware", "UPGRADE_FIRMWARE": "upgrade-firmware",
"DEVICE_MUTE": "mute", "DEVICE_MUTE": "mute",
"NOTIFICATION": "notification", "NOTIFICATION": "send-notification",
"ENCRYPT_STORAGE": "encrypt", "ENCRYPT_STORAGE": "encrypt-storage",
"CHANGE_LOCK_CODE": "change-lock-code", "CHANGE_LOCK_CODE": "change-lock-code",
"WEBCLIP": "webclip", "WEBCLIP": "set-webclip",
"INSTALL_APPLICATION": "install-application", "INSTALL_APPLICATION": "install-application",
"UNINSTALL_APPLICATION": "uninstall-application", "UNINSTALL_APPLICATION": "uninstall-application",
"BLACKLIST_APPLICATIONS": "blacklist-applications", "BLACKLIST_APPLICATIONS": "blacklist-applications",
"PASSCODE_POLICY": "password-policy", "PASSCODE_POLICY": "set-password-policy",
"ENTERPRISE_WIPE": "enterprise-wipe", "ENTERPRISE_WIPE": "enterprise-wipe",
"WIPE_DATA": "wipe-data" "WIPE_DATA": "wipe"
}; };
return "/mdm-android-agent/operation/" + featureMap[operationCode]; //return "/mdm-android-agent/operation/" + featureMap[operationCode];
return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode];
}; };
/** /**
@ -754,7 +1099,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"enabled": operationData["cameraEnabled"] "enabled" : operationData["cameraEnabled"]
} }
}; };
break; break;
@ -762,7 +1107,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"lockCode": operationData["lockCode"] "lockCode" : operationData["lockCode"]
} }
}; };
break; break;
@ -770,7 +1115,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"encrypted": operationData["encryptStorageEnabled"] "encrypted" : operationData["encryptStorageEnabled"]
} }
}; };
break; break;
@ -778,7 +1123,7 @@ var operationModule = function () {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"message": operationData["message"] "message" : operationData["message"]
} }
}; };
break; break;
@ -852,9 +1197,10 @@ var operationModule = function () {
"DEVICE_RING": "fw-dial-up", "DEVICE_RING": "fw-dial-up",
"DEVICE_REBOOT": "fw-refresh", "DEVICE_REBOOT": "fw-refresh",
"UPGRADE_FIRMWARE": "fw-up-arrow", "UPGRADE_FIRMWARE": "fw-up-arrow",
"DEVICE_MUTE": "fw-incoming-call", "DEVICE_MUTE": "fw-mute",
"NOTIFICATION": "fw-message", "NOTIFICATION": "fw-message",
"CHANGE_LOCK_CODE": "fw-security" "CHANGE_LOCK_CODE": "fw-security",
"DEVICE_UNLOCK": "fw-lock"
}; };
return featureMap[operationCode]; return featureMap[operationCode];
}; };
@ -891,7 +1237,7 @@ var operationModule = function () {
"LOCATION": "fw-map-location", "LOCATION": "fw-map-location",
"ENTERPRISE_WIPE": "fw-clear", "ENTERPRISE_WIPE": "fw-clear",
"NOTIFICATION": "fw-message", "NOTIFICATION": "fw-message",
"ALARM": "fw-dial-up" "RING": "fw-dial-up"
}; };
return featureMap[operationCode]; return featureMap[operationCode];
}; };
@ -904,9 +1250,7 @@ var operationModule = function () {
*/ */
$.fn.filterByData = function (prop, val) { $.fn.filterByData = function (prop, val) {
return this.filter( return this.filter(
function () { function () {return $(this).data(prop) == val;}
return $(this).data(prop) == val;
}
); );
}; };
@ -928,7 +1272,7 @@ var operationModule = function () {
var key = operationDataObj.data("key"); var key = operationDataObj.data("key");
var value; var value;
if (operationDataObj.is(":text") || operationDataObj.is("textarea") || if (operationDataObj.is(":text") || operationDataObj.is("textarea") ||
operationDataObj.is(":password")) { operationDataObj.is(":password") || operationDataObj.is(":hidden")) {
value = operationDataObj.val(); value = operationDataObj.val();
} else if (operationDataObj.is(":checkbox")) { } else if (operationDataObj.is(":checkbox")) {
value = operationDataObj.is(":checked"); value = operationDataObj.is(":checked");
@ -941,7 +1285,8 @@ var operationModule = function () {
if (operationDataObj.hasClass("one-column-input-array")) { if (operationDataObj.hasClass("one-column-input-array")) {
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -967,7 +1312,8 @@ var operationModule = function () {
var joinedInput; var joinedInput;
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -998,7 +1344,8 @@ var operationModule = function () {
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
childInputKey = childInput.data("child-key"); childInputKey = childInput.data("child-key");
if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")
|| childInput.is(":hidden")) {
childInputValue = childInput.val(); childInputValue = childInput.val();
} else if (childInput.is(":checkbox")) { } else if (childInput.is(":checkbox")) {
childInputValue = childInput.is(":checked"); childInputValue = childInput.is(":checked");
@ -1026,6 +1373,7 @@ var operationModule = function () {
operationData[key] = value; operationData[key] = value;
} }
); );
switch (platformType) { switch (platformType) {
case platformTypeConstants["ANDROID"]: case platformTypeConstants["ANDROID"]:
payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList);
@ -1089,6 +1437,7 @@ var operationModule = function () {
// var childInputValue; // var childInputValue;
if (operationDataObj.hasClass("one-column-input-array")) { if (operationDataObj.hasClass("one-column-input-array")) {
// generating input fields to populate complex value // generating input fields to populate complex value
if (value) {
for (i = 0; i < value.length; ++i) { for (i = 0; i < value.length; ++i) {
operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); operationDataObj.parent().find("a").filterByData("click-event", "add-form").click();
} }
@ -1098,6 +1447,7 @@ var operationModule = function () {
var childInputValue = value[childInputIndex]; var childInputValue = value[childInputIndex];
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("select")) { childInput.is("select")) {
@ -1108,18 +1458,22 @@ var operationModule = function () {
// incrementing childInputIndex // incrementing childInputIndex
childInputIndex++; childInputIndex++;
}); });
}
} else if (operationDataObj.hasClass("valued-check-box-array")) { } else if (operationDataObj.hasClass("valued-check-box-array")) {
// traversing through each child input // traversing through each child input
$(".child-input", this).each(function () { $(".child-input", this).each(function () {
childInput = $(this); childInput = $(this);
// check if corresponding value of current checkbox exists in the array of values // check if corresponding value of current checkbox exists in the array of values
if (value) {
if (value.indexOf(childInput.data("value")) != -1) { if (value.indexOf(childInput.data("value")) != -1) {
// if YES, set checkbox as checked // if YES, set checkbox as checked
childInput.prop("checked", true); childInput.prop("checked", true);
} }
}
}); });
} else if (operationDataObj.hasClass("multi-column-joined-input-array")) { } else if (operationDataObj.hasClass("multi-column-joined-input-array")) {
// generating input fields to populate complex value // generating input fields to populate complex value
if (value) {
for (i = 0; i < value.length; ++i) { for (i = 0; i < value.length; ++i) {
operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); operationDataObj.parent().find("a").filterByData("click-event", "add-form").click();
} }
@ -1141,6 +1495,7 @@ var operationModule = function () {
} }
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("select")) { childInput.is("select")) {
@ -1152,8 +1507,10 @@ var operationModule = function () {
childInputIndex++; childInputIndex++;
}); });
} }
}
} else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) { } else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) {
// generating input fields to populate complex value // generating input fields to populate complex value
if (value) {
for (i = 0; i < value.length; ++i) { for (i = 0; i < value.length; ++i) {
operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); operationDataObj.parent().find("a").filterByData("click-event", "add-form").click();
} }
@ -1167,6 +1524,7 @@ var operationModule = function () {
var childInputValue = multiColumnKeyValuePair[childInputKey]; var childInputValue = multiColumnKeyValuePair[childInputKey];
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is(":hidden") ||
childInput.is("textarea") || childInput.is("textarea") ||
childInput.is(":password") || childInput.is(":password") ||
childInput.is("select")) { childInput.is("select")) {
@ -1184,6 +1542,7 @@ var operationModule = function () {
} }
} }
} }
}
); );
}; };
@ -1199,8 +1558,29 @@ var operationModule = function () {
for (var i = 0; i < operationCodes.length; ++i) { for (var i = 0; i < operationCodes.length; ++i) {
var operationCode = operationCodes[i]; var operationCode = operationCodes[i];
var payload = publicMethods.generatePayload(platformType, operationCode, null); var payload = publicMethods.generatePayload(platformType, operationCode, null);
if(platformType == platformTypeConstants["ANDROID"] &&
operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]){
var operations = payload["operation"];
for (var key in operations){
operationCode = key;
var restriction = false;
if(operations[key]){
restriction = true;
}
var payloadResult = {
"operation": {
"enabled" : restriction
}
};
generatedProfile[operationCode] = payloadResult["operation"];
}
} else {
generatedProfile[operationCode] = payload["operation"]; generatedProfile[operationCode] = payload["operation"];
} }
}
console.log(generatedProfile);
return generatedProfile; return generatedProfile;
}; };
@ -1213,14 +1593,125 @@ var operationModule = function () {
*/ */
publicMethods.populateProfile = function (platformType, payload) { publicMethods.populateProfile = function (platformType, payload) {
var i, configuredOperations = []; var i, configuredOperations = [];
var restrictions = {};
for (i = 0; i < payload.length; ++i) { for (i = 0; i < payload.length; ++i) {
var configuredFeature = payload[i]; var configuredFeature = payload[i];
var featureCode = configuredFeature["featureCode"]; var featureCode = configuredFeature["featureCode"];
var operationPayload = configuredFeature["content"]; var operationPayload = configuredFeature["content"];
if(platformType == platformTypeConstants["ANDROID"]){
var restriction = JSON.parse(operationPayload);
if(featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]){
restrictions["cameraEnabled"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]){
restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]){
restrictions["disallowConfigBluetooth"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]){
restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]){
restrictions["disallowConfigCredentials"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]){
restrictions["disallowConfigMobileNetworks"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]){
restrictions["disallowConfigTethering"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]){
restrictions["disallowConfigVpn"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]){
restrictions["disallowConfigWifi"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]){
restrictions["disallowAppControl"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]){
restrictions["disallowCreateWindows"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]){
restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]){
restrictions["disallowDebugging"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]){
restrictions["disallowFactoryReset"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]){
restrictions["disallowAddUser"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]){
restrictions["disallowInstallApps"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]){
restrictions["disallowInstallUnknownSources"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]){
restrictions["disallowModifyAccounts"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]){
restrictions["disallowMountPhysicalMedia"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]){
restrictions["disallowNetworkReset"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]){
restrictions["disallowOutgoingBeam"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]){
restrictions["disallowOutgoingCalls"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]){
restrictions["disallowRemoveUser"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]){
restrictions["disallowSafeBoot"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]){
restrictions["disallowLocationSharing"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_SMS"]){
restrictions["disallowSMS"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]){
restrictions["disallowUninstallApps"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]){
restrictions["disallowUnmuteMicrophone"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]){
restrictions["disallowUSBFileTransfer"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]){
restrictions["disallowParentProfileAppLinking"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]){
restrictions["ensureVerifyApps"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["AUTO_TIME"]){
restrictions["enableAutoTime"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]){
restrictions["diableScreenCapture"] = restriction["enabled"];
continue;
} else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]){
restrictions["disableStatusBar"] = restriction["enabled"];
continue;
}
}
//push the feature-code to the configuration array //push the feature-code to the configuration array
configuredOperations.push(featureCode); configuredOperations.push(featureCode);
publicMethods.populateUI(platformType, featureCode, operationPayload); publicMethods.populateUI(platformType, featureCode, operationPayload);
} }
if (typeof restrictions.cameraEnabled !== 'undefined') {
configuredOperations.push(androidOperationConstants["CAMERA_OPERATION_CODE"]);
publicMethods.populateUI(platformType, androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions));
}
return configuredOperations; return configuredOperations;
}; };

@ -0,0 +1,318 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var InitiateViewOption = null;
(function () {
var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type");
var payload = [deviceIdentifier];
var operationTable;
var serviceUrl;
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,
// 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);
}
);
}
$(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) {
var activeTabPane = $(e.target).attr("href"),
activeCollapsePane = $(activeTabPane).find("[data-toggle=collapse]").data("target"),
activeCollapsePaneSiblings = $(activeTabPane).siblings().find("[data-toggle=collapse]").data("target"),
activeListGroupItem = $(".media .list-group-item.active");
$(activeCollapsePaneSiblings).collapse("hide");
$(activeCollapsePane).collapse("show");
positionArrow(activeListGroupItem);
$(".panel-heading .caret-updown").removeClass("fw-sort-down");
$(".panel-heading.collapsed .caret-updown").addClass("fw-sort-up");
});
$(".media.tab-responsive .tab-content").on("shown.bs.collapse", function (e) {
var activeTabPane = $(e.target).parent().attr("id");
$(".media.tab-responsive [data-toggle=tab][href=#" + activeTabPane + "]").tab("show");
$(".panel-heading .caret-updown").removeClass("fw-sort-up");
$(".panel-heading.collapsed .caret-updown").addClass("fw-sort-down");
});
function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).outerHeight();
var arrowPosition = 0;
var totalHeight = 0;
var arrow = $(".media .panel-group.tab-content .arrow-left");
var parentHeight = $(arrow).parent().outerHeight();
// if($(selectedTab).prev().length){
// $(selectedTab).prevAll().each(function() {
// totalHeight += $(this).outerHeight();
// });
// arrowPosition = totalHeight + (selectedTabHeight / 2);
// }else{
// arrowPosition = selectedTabHeight / 2;
// }
if(arrowPosition >= parentHeight){
parentHeight = arrowPosition + 10;
$(arrow).parent().height(parentHeight);
}else{
$(arrow).parent().removeAttr("style");
}
$(arrow).css("top", arrowPosition - 10);
}
$(document).ready(function() {
$(".device-detail-body").removeClass("hidden");
$("#loading-content").remove();
loadOperationBar(deviceType);
loadOperationsLog(false);
loadApplicationsList();
loadPolicyCompliance();
$("#refresh-policy").click(function () {
$("#policy-spinner").removeClass("hidden");
loadPolicyCompliance();
});
$("#refresh-apps").click(function () {
$("#apps-spinner").removeClass("hidden");
loadApplicationsList();
});
$("#refresh-operations").click(function () {
$("#operations-spinner").removeClass("hidden");
loadOperationsLog(true);
});
});
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: "/emm/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() {
var applicationsList = $("#applications-list");
var applicationListingTemplate = applicationsList.attr("src");
var deviceId = applicationsList.data("device-id");
var deviceType = applicationsList.data("device-type");
$.template("application-list", applicationListingTemplate, function (template) {
var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications";
invokerUtil.get(
serviceURL,
// success-callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data);
$("#apps-spinner").addClass("hidden");
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
data[i]["name"] = decodeURIComponent(data[i]["name"]);
data[i]["platform"] = deviceType;
}
var viewModel = {};
viewModel["applications"] = data;
viewModel["deviceType"] = deviceType;
var content = template(viewModel);
$("#applications-list-container").html(content);
} else {
$("#applications-list-container").
html("<div class='panel-body'><br><p class='fw-warning'>&nbsp;No applications found. " +
"please try refreshing the list in a while.<p></div>");
}
}
},
// error-callback
function () {
$("#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>");
}
);
}
);
}
}());

@ -0,0 +1,54 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var map;
function loadLeafletMap() {
var deviceLocationID = "#device-location",
lat = $(deviceLocationID).data("lat"),
long = $(deviceLocationID).data("long"),
container = "device-location",
zoomLevel = 13,
tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
attribution = "&copy; <a href='https://openstreetmap.org/copyright'>OpenStreetMap</a> contributors";
if (lat && long) {
map = L.map(container).setView([lat, long], zoomLevel);
L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
L.marker([lat, long]).addTo(map).bindPopup("Device is here...").openPopup();
$("#map-error").hide();
$("#device-location").show();
} else {
$("#device-location").hide();
$("#map-error").show();
}
}
$(document).ready(function () {
$("a[data-toggle='tab']").on("shown.bs.tab", function() {
var url = $(this).prop("href");
var hash = url.substring(url.indexOf("#") + 1);
if (hash == "device_location") {
if (!map) {
loadLeafletMap();
}
}
});
});

@ -0,0 +1,31 @@
<div class="wr-app-listing">
<div class="wr-applist">
{{#each applications}}
<a style="text-align: center; width: 110px; height: 140px;">
{{#equal platform "android"}}<i class="icon fw fw-android"></i>{{/equal}}
{{#equal platform "ios"}}<i class="icon fw fw-apple"></i>{{/equal}}
{{#equal platform "windows"}}<i class="icon fw fw-windows"></i>{{/equal}}
{{#equal isActive true}}
<span style="word-wrap: break-word;">
<i class="fw fw-ok icon-success" style="font-size: 14px;"></i>
&nbsp;Active
</span>
<span style="word-wrap: break-word;"><b>{{name}}</b></span>
<span style="word-wrap: break-word;"><b>V:{{version}}</b></span>
{{#if memoryUsage}}
<span style="word-wrap: break-word;">
Memory Usage
</span>
<span style="word-wrap: break-word;">
( {{memoryUsage}} Bytes )
</span>
{{/if}}
{{/equal}}
{{#equal isActive false}}
<span style="word-wrap: break-word;">{{name}}</span>
<span style="word-wrap: break-word;"><b>V:{{version}}</b></span>
{{/equal}}
</a>
{{/each}}
</div>
</div>

@ -0,0 +1,24 @@
<table class="table table-striped table-hover table-bordered display data-table" id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
{{#each operations}}
<tr data-type="selectable" data-id="{{id}}">
<td data-display="{{code}}" data-grid-label="Code">{{code}}</td>
<td data-display="{{status}}" data-grid-label="Status">
{{#equal status "COMPLETED"}}<span><i class="fw fw-ok icon-success"></i> Completed</span>{{/equal}}
{{#equal status "PENDING"}}<span><i class="fw fw-warning icon-warning"></i> Pending</span>{{/equal}}
{{#equal status "ERROR"}}<span><i class="fw fw-error icon-danger"></i> Error</span>{{/equal}}
{{#equal status "IN_PROGRESS"}}<span><i class="fw fw-ok icon-warning"></i> In Progress</span>{{/equal}}
</td>
<td data-display="{{createdTimeStamp}}" data-grid-label="Created Timestamp">{{createdTimeStamp}}</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -0,0 +1,79 @@
<div class="wr-list-group wr-sortable policy-list">
<span class="list-group-item" id="{{id}}">
<div class="row">
<div class="col-lg-3 clearfix">
<span class="wr-list-icon">
{{#equal deviceType "android"}}
<i class=" fw fw-android"></i>
{{/equal}}
{{#equal deviceType "ios"}}
<i class=" fw fw-apple"></i>
{{/equal}}
{{#equal deviceType "windows"}}
<i class=" fw fw-windows"></i>
{{/equal}}
</span>
<span class="wr-list-desc">
<h3 class="wr-list-name">{{policy.policyName}}</h3>
<span class="wr-list-username">{{deviceType}}</span>
</span>
</div>
<div class="col-lg-6">
<div class="row no-gutter">
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Ownership Type : </b> {{policy.ownershipType}}
</div>
</div>
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Compliance Type :</b> {{policy.compliance}}
</div>
</div>
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Compliance :</b>
{{#equal compliance "COMPLIANT"}}
<span><i class="fw fw-ok icon-success"></i> Compliant</span>
{{/equal}}
{{#equal compliance "NON-COMPLIANT"}}
<span><i class="fw fw-warning icon-danger"></i> Not Compliant</span>
{{/equal}}
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<span class="list-group-item-actions">
<a href="/emm/policies/view?id={{policy.id}}" class="cu-btn-inner policy-view-link" data-id="{{id}}">
<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>
</span>
</div>
</div>
</span>
</div>
<table class="table table-striped table-hover table-bordered display data-table" id="policy-compliance-table">
<thead>
<tr class="sort-row">
<th>Feature</th>
<th>Compliance</th>
</tr>
</thead>
<tbody>
{{#each complianceFeatures}}
<tr data-type="selectable">
<td data-display="{{featureCode}}" data-grid-label="Feature Code">{{featureCode}}</td>
<td data-display="{{compliance}}" data-grid-label="Status">
{{#equal compliance true}}<span><i class="fw fw-ok icon-success"></i> Compliant</span>{{/equal}}
{{#equal compliance false}}<span><i class="fw fw-warning icon-danger"></i> Not Compliant</span>{{/equal}}
</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -0,0 +1,378 @@
{{#zone "content"}}
{{#defineZone "device-detail-top"}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-deviceid="{{device.deviceIdentifier}}"
data-type="{{device.type}}">
Device {{device.name}}
{{#if device.viewModel.model}}
<span class="lbl-device">
( {{device.viewModel.vendor}} {{device.viewModel.model}} )
</span>
{{/if}}
</label>
</div>
</div>
{{/defineZone}}
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
<div class="thumbnail icon"><i class="square-element text fw fw-mobile"></i></div>
</div>
<div class="media-body asset-desc add-padding-left-5x">
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Device Overview</div>
{{#defineZone "device-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 1%;">Device</td>
<td style="padding:10px 15px;">{{device.viewModel.vendor}} {{device.properties.model}}</td>
</tr>
{{#if device.viewModel.model}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">Model</td>
<td style="padding:10px 15px;">{{device.viewModel.model}}</td>
</tr>
{{/if}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">IMEI</td>
<td style="padding:10px 15px;">{{device.viewModel.imei}}</td>
</tr>
{{#if device.viewModel.udid}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">UDID</td>
<td style="padding:10px 15px;">{{device.viewModel.udid}}</td>
</tr>
{{/if}}
{{#if device.viewModel.os_build_date}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Firmware Build Date</td>
<td style="padding:10px 15px;">{{device.viewModel.os_build_date}}</td>
</tr>
{{/if}}
{{#if device.viewModel.phoneNumber}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Phone Number</td>
<td style="padding:10px 15px;">{{device.viewModel.phoneNumber}}</td>
</tr>
{{/if}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i>&nbsp;&nbsp;Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i>&nbsp;&nbsp;Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i>&nbsp;&nbsp;Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i>&nbsp;&nbsp;Removed</span>{{/equal}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Operations</div>
<div class="add-margin-top-4x">
{{unit "mdm.unit.device.operation-bar" deviceType=device.type}}
</div>
</div>
</div>
<div class="media tab-responsive">
<div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs">
<ul class="list-group nav nav-pills nav-stacked" role="tablist">
<li class="list-group-item active">
<a href="#device_details" role="tab" data-toggle="tab" aria-controls="device_details">
<i class="icon fw fw-mobile"></i>Device Details
</a>
</li>
<li class="list-group-item">
<a href="#policy_compliance" role="tab" data-toggle="tab" aria-controls="policy_compliance">
<i class="icon fw fw-policy"></i>Policy Compliance
</a>
</li>
<li class="list-group-item">
<a href="#device_location" role="tab" data-toggle="tab"
data-lat="{{device.viewModel.location.latitude}}"
data-long="{{device.viewModel.location.longitude}}"
aria-controls="device_location">
<i class="icon fw fw-map-location"></i> Device Location
</a>
</li>
<li class="list-group-item">
<a href="#installed_applications" role="tab" data-toggle="tab" aria-controls="installed_applications">
<i class="icon fw fw-application"></i> Installed Applications
</a>
</li>
<li class="list-group-item">
<a href="#event_log" role="tab" data-toggle="tab" aria-controls="event_log">
<i class="icon fw fw-text"></i> Operations Log
</a>
</li>
</ul>
</div>
<div class="media-body remove-padding-xs">
{{#defineZone "device-detail-properties"}}
<div class="media-body add-padding-left-5x remove-padding-xs">
<div class="panel-group tab-content" id="tabs">
<div class="arrow-left hidden-xs"></div>
<div class="panel panel-default tab-pane fade in active fade-in-xs visible-block"
id="device_details" role="tabpanel"
aria-labelledby="device_details">
<div class="panel-heading dropup visible-xs" role="tab" id="tab1" data-toggle="collapse"
data-target="#tabContent1" aria-expanded="false" data-parent="#tabs">
<h4 class="panel-title">
<i class="fw fw-map-location fw-2x"></i>
Device Details
<i class="caret-updown fw fw-sort-up"></i>
</h4>
</div>
<div class="panel-heading display-none-xs">Device Details</div>
<div id="loading-content" class="col-centered">
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fw fw-settings fw-spin fw-2x"></i>&nbsp;&nbsp;&nbsp;Loading Device Details . . .<br>
</div>
<div class="panel-body collapse display-block-sm display-block-md display-block-lg in"
id="tabContent1">
<div class="device-detail-body hidden">
<!-- device summary -->
{{#equal device.type "windows"}}
<div class="panel-body">
Not available yet
</div>
<br class="c-both"/>
{{/equal}}
{{#if device.viewModel.BatteryLevel}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">BATTERY</div>
<div>
<div class="tile-icon"><i class="fw fw-battery"></i></div>
<div class="tile-stats">
{{device.viewModel.BatteryLevel}} %
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if device.viewModel.DeviceCapacity}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">STORAGE</div>
<div>
<div class="tile-icon"><i class="fw fw-hdd"></i></div>
<div class="tile-stats">
{{device.viewModel.DeviceCapacityPercentage}} %
<span class="tile-stats-free">
{{device.viewModel.AvailableDeviceCapacity}} GB Free
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if device.viewModel.internal_memory.FreeCapacity}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">LOCAL STORAGE</div>
<div>
<div class="tile-icon"><i class="fw fw-hdd"></i></div>
<div class="tile-stats">
{{device.viewModel.internal_memory.DeviceCapacityPercentage}} %
<span class="tile-stats-free">
{{device.viewModel.internal_memory.FreeCapacity}} GB Free
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if device.viewModel.external_memory.FreeCapacity}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">EXTERNAL STORAGE</div>
<div>
<div class="tile-icon"><i class="fw fw-usb-drive"></i></div>
<div class="tile-stats">
{{device.viewModel.external_memory.DeviceCapacityPercentage}} %
<span class="tile-stats-free">
{{device.viewModel.external_memory.FreeCapacity}} GB Free
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
</div>
</div>
</div>
<div class="panel panel-default tab-pane fade fade-in-xs visible-block"
id="policy_compliance">
<div class="panel-heading dropdown visible-xs collapsed" role="tab" id="tab2"
data-toggle="collapse" data-target="#tabContent2" aria-expanded="false"
data-parent="#tabs">
<h4 class="panel-title"><i class="fw fw-text fw-2x"></i>
Policy Compliance
<i class="caret-updown fw fw-sort-down"></i>
</h4>
</div>
<div class="panel-heading display-none-xs">
Policy Compliance
&nbsp;&nbsp;
<span>
<a href="#" id="refresh-policy">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div id="policy-spinner" class="wr-advance-operations-init hidden">
<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . .
<br>
<br>
</div>
<div class="panel-body collapse display-block-sm display-block-md display-block-lg" id="tabContent2">
<div id="policy-list-container">
<div class="panel-body">
There is no active policy for this device.
</div>
<br class="c-both"/>
</div>
</div>
</div>
<div class="panel panel-default tab-pane fade fade-in-xs visible-block"
id="device_location">
<div class="panel-heading dropdown visible-xs collapsed" role="tab" id="tab3"
data-toggle="collapse" data-target="#tabContent3" aria-expanded="false"
data-parent="#tabs">
<h4 class="panel-title">
<i class="fw fw-text fw-2x"></i>
Device Location
<i class="caret-updown fw fw-sort-down"></i>
</h4>
</div>
<div class="panel-heading display-none-xs">Device Location</div>
<div class="panel-body collapse display-block-sm display-block-md display-block-lg"
id="tabContent3">
<div id="device-location"
data-lat="{{device.viewModel.location.latitude}}"
data-long="{{device.viewModel.location.longitude}}"
class="panel-body">
</div>
<div id="map-error" class="panel-body" style="margin: auto;">
Device location cannot be retrieved.
</div>
<br class="c-both"/>
</div>
</div>
<div class="panel panel-default tab-pane fade fade-in-xs visible-block"
id="installed_applications">
<div class="panel-heading dropdown visible-xs collapsed" role="tab" id="tab4"
data-toggle="collapse" data-target="#tabContent4" aria-expanded="false"
data-parent="#tabs">
<h4 class="panel-title">
<i class="fw fw-text fw-2x"></i>
Installed Applications
<i class="caret-updown fw fw-sort-down"></i></h4>
</div>
<div class="panel-heading display-none-xs">
Installed Applications
&nbsp;&nbsp;
<span>
<a href="#" id="refresh-apps">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div class="panel-body collapse display-block-sm display-block-md display-block-lg"
id="tabContent4">
<div id="apps-spinner" class="wr-advance-operations-init hidden">
<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;<i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp;Loading Applications List . . .<br><br>
</div>
<div id="applications-list-container">
<div class="panel-body">
<br>
<p class="fw-warning">
No applications found. please try refreshing the list in a while.
<p>
</div>
<br class="c-both"/>
</div>
</div>
</div>
<div class="panel panel-default tab-pane fade fade-in-xs visible-block" id="event_log">
<div class="panel-heading dropdown visible-xs collapsed" role="tab" id="tab5"
data-toggle="collapse" data-target="#tabContent5" aria-expanded="false"
data-parent="#tabs">
<h4 class="panel-title">
<i class="fw fw-text fw-2x"></i>
Operations Logs
<i class="caret-updown fw fw-sort-down"></i>
</h4>
</div>
<div class="panel-heading display-none-xs">
Operations Logs
&nbsp;&nbsp;
<span>
<a href="#" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div class="panel-body collapse display-block-sm display-block-md display-block-lg"
id="tabContent5">
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fw fw-settings fw-spin fw-2x"></i>&nbsp;&nbsp;&nbsp;
Loading Operations Log . . .
<br><br>
</div>
<div id="operations-log-container">
<div class="panel-body">
There are no operations, performed yet on this device.
</div>
<br class="c-both"/>
</div>
<table class="table table-striped table-hover table-bordered display data-table"
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{{/defineZone}}
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
{{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
{{js "js/load-map.js"}}
{{/zone}}

@ -0,0 +1,102 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var log = new Log("view.js");
var deviceType = context.uriParams.deviceType;
var deviceId = request.getParameter("id");
var deviceData = {};
if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId);
if (response["status"] == "success") {
var device = response["content"];
var viewModel = {};
var deviceInfo = device["properties"]["DEVICE_INFO"];
if (deviceInfo && String(deviceInfo.toString()).length > 0) {
deviceInfo = parse(stringify(deviceInfo));
if (device["type"] == "ios") {
deviceInfo = parse(deviceInfo);
viewModel["imei"] = device["properties"]["IMEI"];
viewModel["phoneNumber"] = deviceInfo["PhoneNumber"];
viewModel["udid"] = deviceInfo["UDID"];
viewModel["BatteryLevel"] = Math.round(deviceInfo["BatteryLevel"] * 100);
viewModel["DeviceCapacity"] = Math.round(deviceInfo["DeviceCapacity"] * 100) / 100;
viewModel["AvailableDeviceCapacity"] = Math.
round(deviceInfo["AvailableDeviceCapacity"] * 100) / 100;
viewModel["DeviceCapacityUsed"] = Math.
round((viewModel["DeviceCapacity"] - viewModel["AvailableDeviceCapacity"]) * 100) / 100;
viewModel["DeviceCapacityPercentage"] = Math.
round(viewModel["AvailableDeviceCapacity"] / viewModel["DeviceCapacity"] * 10000) / 100;
viewModel["location"] = {
latitude: device["properties"]["LATITUDE"],
longitude: device["properties"]["LONGITUDE"]
};
} else if (device["type"] == "android") {
viewModel["imei"] = device["properties"]["IMEI"];
viewModel["model"] = device["properties"]["DEVICE_MODEL"];
viewModel["vendor"] = device["properties"]["VENDOR"];
var osBuildDate = device["properties"]["OS_BUILD_DATE"];
if (osBuildDate != null && osBuildDate != "0") {
var formattedDate = new Date(osBuildDate * 1000);
viewModel["os_build_date"] = formattedDate;
}
viewModel["internal_memory"] = {};
viewModel["external_memory"] = {};
viewModel["location"] = {
latitude: device["properties"]["LATITUDE"],
longitude: device["properties"]["LONGITUDE"]
};
var info = {};
var infoList = parse(deviceInfo);
if (infoList != null && infoList != undefined) {
for (var j = 0; j < infoList.length; j++) {
info[infoList[j].name] = infoList[j].value;
}
}
deviceInfo = info;
viewModel["BatteryLevel"] = deviceInfo["BATTERY_LEVEL"];
viewModel["internal_memory"]["FreeCapacity"] = Math.
round(deviceInfo["INTERNAL_AVAILABLE_MEMORY"] * 100)/100;
viewModel["internal_memory"]["DeviceCapacityPercentage"] = Math.
round(deviceInfo["INTERNAL_AVAILABLE_MEMORY"]
/ deviceInfo["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
viewModel["external_memory"]["FreeCapacity"] = Math.
round(deviceInfo["EXTERNAL_AVAILABLE_MEMORY"] * 100) / 100;
viewModel["external_memory"]["DeviceCapacityPercentage"] = Math.
round(deviceInfo["EXTERNAL_AVAILABLE_MEMORY"]
/ deviceInfo["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else if (device["type"] == "windows") {
viewModel["imei"] = device["properties"]["IMEI"];
viewModel["model"] = device["properties"]["DEVICE_MODEL"];
viewModel["vendor"] = device["properties"]["VENDOR"];
viewModel["internal_memory"] = {};
viewModel["external_memory"] = {};
viewModel["location"] = {
latitude: device["properties"]["LATITUDE"],
longitude: device["properties"]["LONGITUDE"]
};
}
device["viewModel"] = viewModel;
}
deviceData["device"] = device;
}
return deviceData;
}
}
Loading…
Cancel
Save