Fixing Notification validation issue

;
revert-dabc3590
kamidu 8 years ago
parent 08992be99d
commit e39c2a1d8d

@ -51,6 +51,7 @@
<div class="operation" data-operation-code="{{operation}}"> <div class="operation" data-operation-code="{{operation}}">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3> <h3>
@ -65,6 +66,11 @@
{{description}} {{description}}
<br> <br>
</h4> </h4>
<div id="operation-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div id="operation-form"> <div id="operation-form">
<form action="{{params.0.uri}}" method="{{params.0.method}}" <form action="{{params.0.uri}}" method="{{params.0.method}}"
style="padding-bottom: 20px;" style="padding-bottom: 20px;"

@ -27,6 +27,11 @@ function operationSelect(selection) {
showPopup(); showPopup();
} }
var resetLoader = function () {
$("#btnSend").removeClass("hidden");
$('#lbl-execution').addClass("hidden");
};
function submitForm(formId) { function submitForm(formId) {
$("#btnSend").addClass("hidden"); $("#btnSend").addClass("hidden");
$("#lbl-execution").removeClass("hidden"); $("#lbl-execution").removeClass("hidden");
@ -48,9 +53,9 @@ function submitForm(formId) {
} else if (input.data("param-type") == "form") { } else if (input.data("param-type") == "form") {
var prefix = (uriencodedFormStr == "") ? "" : "&"; var prefix = (uriencodedFormStr == "") ? "" : "&";
uriencodedFormStr += prefix + input.attr("id") + "=" + input.val(); uriencodedFormStr += prefix + input.attr("id") + "=" + input.val();
if(input.attr("type") == "text"){ if (input.attr("type") == "text") {
payload[input.attr("id")] = input.val(); payload[input.attr("id")] = input.val();
} else if(input.attr("type") == "checkbox"){ } else if (input.attr("type") == "checkbox") {
payload[input.attr("id")] = input.is(":checked"); payload[input.attr("id")] = input.is(":checked");
} }
} }
@ -58,6 +63,9 @@ function submitForm(formId) {
uri += uriencodedQueryStr; uri += uriencodedQueryStr;
var httpMethod = form.attr("method").toUpperCase(); var httpMethod = form.attr("method").toUpperCase();
//var contentType = form.attr("enctype"); //var contentType = form.attr("enctype");
var validaterString = validatePayload(operationCode, payload);
if (validaterString == "OK") {
if (contentType == undefined || contentType == "") { if (contentType == undefined || contentType == "") {
contentType = "application/x-www-form-urlencoded"; contentType = "application/x-www-form-urlencoded";
@ -72,11 +80,6 @@ function submitForm(formId) {
var description = content.find("#description"); var description = content.find("#description");
description.html(""); description.html("");
var resetLoader = function () {
$("#btnSend").removeClass("hidden");
$('#lbl-execution').addClass("hidden");
};
var successCallBack = function (response) { var successCallBack = function (response) {
var res = response; var res = response;
try { try {
@ -95,7 +98,7 @@ function submitForm(formId) {
// console.log(response); // console.log(response);
title.html("An Error Occurred!"); title.html("An Error Occurred!");
statusIcon.attr("class", defaultStatusClasses + " fw-error"); statusIcon.attr("class", defaultStatusClasses + " fw-error");
var reason = (response.responseText == "null")?response.statusText:response.responseText; var reason = (response.responseText == "null") ? response.statusText : response.responseText;
try { try {
reason = JSON.parse(reason).message; reason = JSON.parse(reason).message;
} catch (err) { } catch (err) {
@ -124,6 +127,11 @@ function submitForm(formId) {
resetLoader(); resetLoader();
$(modalPopupContent).html(content.html()); $(modalPopupContent).html(content.html());
} }
} else {
resetLoader();
$(".modal #operation-error-msg span").text(validaterString);
$(".modal #operation-error-msg").removeClass("hidden");
}
} }
$(document).on('submit', 'form', function (e) { $(document).on('submit', 'form', function (e) {
@ -161,6 +169,21 @@ var operationTypeConstants = {
"COMMAND": "command" "COMMAND": "command"
}; };
function validatePayload(operationCode, payload) {
console.log(payload);
var returnVal = "OK";
switch (operationCode) {
case "NOTIFICATION":
if (!payload.messageText) {
returnVal = "Message Body Can't be empty !";
}
break;
default:
break;
}
return returnVal;
}
var generatePayload = function (operationCode, operationData, deviceList) { var generatePayload = function (operationCode, operationData, deviceList) {
var payload; var payload;
@ -170,40 +193,40 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"CAMERA" : operationData["cameraEnabled"], "CAMERA": operationData["cameraEnabled"],
"DISALLOW_ADJUST_VOLUME" : operationData["disallowAdjustVolumeEnabled"], "DISALLOW_ADJUST_VOLUME": operationData["disallowAdjustVolumeEnabled"],
"DISALLOW_CONFIG_BLUETOOTH" : operationData["disallowConfigBluetooth"], "DISALLOW_CONFIG_BLUETOOTH": operationData["disallowConfigBluetooth"],
"DISALLOW_CONFIG_CELL_BROADCASTS" : operationData["disallowConfigCellBroadcasts"], "DISALLOW_CONFIG_CELL_BROADCASTS": operationData["disallowConfigCellBroadcasts"],
"DISALLOW_CONFIG_CREDENTIALS" : operationData["disallowConfigCredentials"], "DISALLOW_CONFIG_CREDENTIALS": operationData["disallowConfigCredentials"],
"DISALLOW_CONFIG_MOBILE_NETWORKS" : operationData["disallowConfigMobileNetworks"], "DISALLOW_CONFIG_MOBILE_NETWORKS": operationData["disallowConfigMobileNetworks"],
"DISALLOW_CONFIG_TETHERING" : operationData["disallowConfigTethering"], "DISALLOW_CONFIG_TETHERING": operationData["disallowConfigTethering"],
"DISALLOW_CONFIG_VPN" : operationData["disallowConfigVpn"], "DISALLOW_CONFIG_VPN": operationData["disallowConfigVpn"],
"DISALLOW_CONFIG_WIFI" : operationData["disallowConfigWifi"], "DISALLOW_CONFIG_WIFI": operationData["disallowConfigWifi"],
"DISALLOW_APPS_CONTROL" : operationData["disallowAppControl"], "DISALLOW_APPS_CONTROL": operationData["disallowAppControl"],
"DISALLOW_CREATE_WINDOWS" : operationData["disallowCreateWindows"], "DISALLOW_CREATE_WINDOWS": operationData["disallowCreateWindows"],
"DISALLOW_CROSS_PROFILE_COPY_PASTE" : operationData["disallowCrossProfileCopyPaste"], "DISALLOW_CROSS_PROFILE_COPY_PASTE": operationData["disallowCrossProfileCopyPaste"],
"DISALLOW_DEBUGGING_FEATURES" : operationData["disallowDebugging"], "DISALLOW_DEBUGGING_FEATURES": operationData["disallowDebugging"],
"DISALLOW_FACTORY_RESET" : operationData["disallowFactoryReset"], "DISALLOW_FACTORY_RESET": operationData["disallowFactoryReset"],
"DISALLOW_ADD_USER" : operationData["disallowAddUser"], "DISALLOW_ADD_USER": operationData["disallowAddUser"],
"DISALLOW_INSTALL_APPS" : operationData["disallowInstallApps"], "DISALLOW_INSTALL_APPS": operationData["disallowInstallApps"],
"DISALLOW_INSTALL_UNKNOWN_SOURCES" : operationData["disallowInstallUnknownSources"], "DISALLOW_INSTALL_UNKNOWN_SOURCES": operationData["disallowInstallUnknownSources"],
"DISALLOW_MODIFY_ACCOUNTS" : operationData["disallowModifyAccounts"], "DISALLOW_MODIFY_ACCOUNTS": operationData["disallowModifyAccounts"],
"DISALLOW_MOUNT_PHYSICAL_MEDIA" : operationData["disallowMountPhysicalMedia"], "DISALLOW_MOUNT_PHYSICAL_MEDIA": operationData["disallowMountPhysicalMedia"],
"DISALLOW_NETWORK_RESET" : operationData["disallowNetworkReset"], "DISALLOW_NETWORK_RESET": operationData["disallowNetworkReset"],
"DISALLOW_OUTGOING_BEAM" : operationData["disallowOutgoingBeam"], "DISALLOW_OUTGOING_BEAM": operationData["disallowOutgoingBeam"],
"DISALLOW_OUTGOING_CALLS" : operationData["disallowOutgoingCalls"], "DISALLOW_OUTGOING_CALLS": operationData["disallowOutgoingCalls"],
"DISALLOW_REMOVE_USER" : operationData["disallowRemoveUser"], "DISALLOW_REMOVE_USER": operationData["disallowRemoveUser"],
"DISALLOW_SAFE_BOOT" : operationData["disallowSafeBoot"], "DISALLOW_SAFE_BOOT": operationData["disallowSafeBoot"],
"DISALLOW_SHARE_LOCATION" : operationData["disallowLocationSharing"], "DISALLOW_SHARE_LOCATION": operationData["disallowLocationSharing"],
"DISALLOW_SMS" : operationData["disallowSMS"], "DISALLOW_SMS": operationData["disallowSMS"],
"DISALLOW_UNINSTALL_APPS" : operationData["disallowUninstallApps"], "DISALLOW_UNINSTALL_APPS": operationData["disallowUninstallApps"],
"DISALLOW_UNMUTE_MICROPHONE" : operationData["disallowUnmuteMicrophone"], "DISALLOW_UNMUTE_MICROPHONE": operationData["disallowUnmuteMicrophone"],
"DISALLOW_USB_FILE_TRANSFER" : operationData["disallowUSBFileTransfer"], "DISALLOW_USB_FILE_TRANSFER": operationData["disallowUSBFileTransfer"],
"ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"], "ALLOW_PARENT_PROFILE_APP_LINKING": operationData["disallowParentProfileAppLinking"],
"ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"], "ENSURE_VERIFY_APPS": operationData["ensureVerifyApps"],
"AUTO_TIME" : operationData["enableAutoTime"], "AUTO_TIME": operationData["enableAutoTime"],
"SET_SCREEN_CAPTURE_DISABLED" : operationData["disableScreenCapture"], "SET_SCREEN_CAPTURE_DISABLED": operationData["disableScreenCapture"],
"SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"] "SET_STATUS_BAR_DISABLED": operationData["disableStatusBar"]
} }
}; };
break; break;
@ -211,7 +234,7 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"lockCode" : operationData["lockCode"] "lockCode": operationData["lockCode"]
} }
}; };
break; break;
@ -219,7 +242,7 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"encrypted" : operationData["encryptStorageEnabled"] "encrypted": operationData["encryptStorageEnabled"]
} }
}; };
break; break;
@ -228,8 +251,8 @@ var generatePayload = function (operationCode, operationData, deviceList) {
payload = { payload = {
"operation": { "operation": {
//"message" : operationData["message"] //"message" : operationData["message"]
"messageText": operationData["messageText"], "messageTitle": operationData["messageTitle"],
"messageTitle": operationData["messageTitle"] "messageText": operationData["messageText"]
} }
}; };
break; break;
@ -237,8 +260,8 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"schedule" : operationData["schedule"], "schedule": operationData["schedule"],
"server" : operationData["server"] "server": operationData["server"]
} }
}; };
break; break;
@ -246,7 +269,7 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"pin" : operationData["pin"] "pin": operationData["pin"]
} }
}; };
break; break;
@ -256,14 +279,14 @@ var generatePayload = function (operationCode, operationData, deviceList) {
"operation": { "operation": {
"ssid": operationData["wifiSSID"], "ssid": operationData["wifiSSID"],
"type": operationData["wifiType"], "type": operationData["wifiType"],
"password" : operationData["wifiPassword"], "password": operationData["wifiPassword"],
"eap" : operationData["wifiEAP"], "eap": operationData["wifiEAP"],
"phase2" : operationData["wifiPhase2"], "phase2": operationData["wifiPhase2"],
"provisioning" : operationData["wifiProvisioning"], "provisioning": operationData["wifiProvisioning"],
"identity" : operationData["wifiIdentity"], "identity": operationData["wifiIdentity"],
"anonymousIdentity" : operationData["wifiAnoIdentity"], "anonymousIdentity": operationData["wifiAnoIdentity"],
"cacert" : operationData["wifiCaCert"], "cacert": operationData["wifiCaCert"],
"cacertName" : operationData["wifiCaCertName"] "cacertName": operationData["wifiCaCertName"]
} }
}; };
break; break;
@ -282,8 +305,8 @@ var generatePayload = function (operationCode, operationData, deviceList) {
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = { payload = {
"operation": { "operation": {
"message" : operationData["lock-message"], "message": operationData["lock-message"],
"isHardLockEnabled" : operationData["hard-lock"] "isHardLockEnabled": operationData["hard-lock"]
} }
}; };
break; break;
@ -375,39 +398,39 @@ var androidOperationConstants = {
"LOCK_OPERATION_CODE": "DEVICE_LOCK", "LOCK_OPERATION_CODE": "DEVICE_LOCK",
"UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE", "UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE",
"DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME", "DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME",
"DISALLOW_CONFIG_BLUETOOTH" : "DISALLOW_CONFIG_BLUETOOTH", "DISALLOW_CONFIG_BLUETOOTH": "DISALLOW_CONFIG_BLUETOOTH",
"DISALLOW_CONFIG_CELL_BROADCASTS" : "DISALLOW_CONFIG_CELL_BROADCASTS", "DISALLOW_CONFIG_CELL_BROADCASTS": "DISALLOW_CONFIG_CELL_BROADCASTS",
"DISALLOW_CONFIG_CREDENTIALS" : "DISALLOW_CONFIG_CREDENTIALS", "DISALLOW_CONFIG_CREDENTIALS": "DISALLOW_CONFIG_CREDENTIALS",
"DISALLOW_CONFIG_MOBILE_NETWORKS" : "DISALLOW_CONFIG_MOBILE_NETWORKS", "DISALLOW_CONFIG_MOBILE_NETWORKS": "DISALLOW_CONFIG_MOBILE_NETWORKS",
"DISALLOW_CONFIG_TETHERING" : "DISALLOW_CONFIG_TETHERING", "DISALLOW_CONFIG_TETHERING": "DISALLOW_CONFIG_TETHERING",
"DISALLOW_CONFIG_VPN" : "DISALLOW_CONFIG_VPN", "DISALLOW_CONFIG_VPN": "DISALLOW_CONFIG_VPN",
"DISALLOW_CONFIG_WIFI" : "DISALLOW_CONFIG_WIFI", "DISALLOW_CONFIG_WIFI": "DISALLOW_CONFIG_WIFI",
"DISALLOW_APPS_CONTROL" : "DISALLOW_APPS_CONTROL", "DISALLOW_APPS_CONTROL": "DISALLOW_APPS_CONTROL",
"DISALLOW_CREATE_WINDOWS" : "DISALLOW_CREATE_WINDOWS", "DISALLOW_CREATE_WINDOWS": "DISALLOW_CREATE_WINDOWS",
"DISALLOW_CROSS_PROFILE_COPY_PASTE" : "DISALLOW_CROSS_PROFILE_COPY_PASTE", "DISALLOW_CROSS_PROFILE_COPY_PASTE": "DISALLOW_CROSS_PROFILE_COPY_PASTE",
"DISALLOW_DEBUGGING_FEATURES" : "DISALLOW_DEBUGGING_FEATURES", "DISALLOW_DEBUGGING_FEATURES": "DISALLOW_DEBUGGING_FEATURES",
"DISALLOW_FACTORY_RESET" : "DISALLOW_FACTORY_RESET", "DISALLOW_FACTORY_RESET": "DISALLOW_FACTORY_RESET",
"DISALLOW_ADD_USER" : "DISALLOW_ADD_USER", "DISALLOW_ADD_USER": "DISALLOW_ADD_USER",
"DISALLOW_INSTALL_APPS" : "DISALLOW_INSTALL_APPS", "DISALLOW_INSTALL_APPS": "DISALLOW_INSTALL_APPS",
"DISALLOW_INSTALL_UNKNOWN_SOURCES" : "DISALLOW_INSTALL_UNKNOWN_SOURCES", "DISALLOW_INSTALL_UNKNOWN_SOURCES": "DISALLOW_INSTALL_UNKNOWN_SOURCES",
"DISALLOW_MODIFY_ACCOUNTS" : "DISALLOW_MODIFY_ACCOUNTS", "DISALLOW_MODIFY_ACCOUNTS": "DISALLOW_MODIFY_ACCOUNTS",
"DISALLOW_MOUNT_PHYSICAL_MEDIA" : "DISALLOW_MOUNT_PHYSICAL_MEDIA", "DISALLOW_MOUNT_PHYSICAL_MEDIA": "DISALLOW_MOUNT_PHYSICAL_MEDIA",
"DISALLOW_NETWORK_RESET" : "DISALLOW_NETWORK_RESET", "DISALLOW_NETWORK_RESET": "DISALLOW_NETWORK_RESET",
"DISALLOW_OUTGOING_BEAM" : "DISALLOW_OUTGOING_BEAM", "DISALLOW_OUTGOING_BEAM": "DISALLOW_OUTGOING_BEAM",
"DISALLOW_OUTGOING_CALLS" : "DISALLOW_OUTGOING_CALLS", "DISALLOW_OUTGOING_CALLS": "DISALLOW_OUTGOING_CALLS",
"DISALLOW_REMOVE_USER" : "DISALLOW_REMOVE_USER", "DISALLOW_REMOVE_USER": "DISALLOW_REMOVE_USER",
"DISALLOW_SAFE_BOOT" : "DISALLOW_SAFE_BOOT", "DISALLOW_SAFE_BOOT": "DISALLOW_SAFE_BOOT",
"DISALLOW_SHARE_LOCATION" : "DISALLOW_SHARE_LOCATION", "DISALLOW_SHARE_LOCATION": "DISALLOW_SHARE_LOCATION",
"DISALLOW_SMS" : "DISALLOW_SMS", "DISALLOW_SMS": "DISALLOW_SMS",
"DISALLOW_UNINSTALL_APPS" : "DISALLOW_UNINSTALL_APPS", "DISALLOW_UNINSTALL_APPS": "DISALLOW_UNINSTALL_APPS",
"DISALLOW_UNMUTE_MICROPHONE" : "DISALLOW_UNMUTE_MICROPHONE", "DISALLOW_UNMUTE_MICROPHONE": "DISALLOW_UNMUTE_MICROPHONE",
"DISALLOW_USB_FILE_TRANSFER" : "DISALLOW_USB_FILE_TRANSFER", "DISALLOW_USB_FILE_TRANSFER": "DISALLOW_USB_FILE_TRANSFER",
"ALLOW_PARENT_PROFILE_APP_LINKING" : "ALLOW_PARENT_PROFILE_APP_LINKING", "ALLOW_PARENT_PROFILE_APP_LINKING": "ALLOW_PARENT_PROFILE_APP_LINKING",
"ENSURE_VERIFY_APPS" : "ENSURE_VERIFY_APPS", "ENSURE_VERIFY_APPS": "ENSURE_VERIFY_APPS",
"AUTO_TIME" : "AUTO_TIME", "AUTO_TIME": "AUTO_TIME",
"SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED", "SET_SCREEN_CAPTURE_DISABLED": "SET_SCREEN_CAPTURE_DISABLED",
"SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED", "SET_STATUS_BAR_DISABLED": "SET_STATUS_BAR_DISABLED",
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION", "APPLICATION_OPERATION_CODE": "APP-RESTRICTION",
"SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY", "SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY",
"KIOSK_APPS_CODE": "KIOSK_APPS" "KIOSK_APPS_CODE": "KIOSK_APPS"
}; };

@ -106,13 +106,13 @@
"formParams": [ "formParams": [
{ {
"type": "text", "type": "text",
"id": "messageText", "id": "messageTitle",
"optional": false, "optional": false,
"label": "Title Here..." "label": "Title Here..."
}, },
{ {
"type": "text", "type": "text",
"id": "messageTitle", "id": "messageText",
"optional": false, "optional": false,
"label": "Message Here..." "label": "Message Here..."
} }

@ -1142,7 +1142,7 @@
<javax.ws.rs.version>1.1.1</javax.ws.rs.version> <javax.ws.rs.version>1.1.1</javax.ws.rs.version>
<!-- Carbon Device Management --> <!-- Carbon Device Management -->
<carbon.devicemgt.version>3.0.6</carbon.devicemgt.version> <carbon.devicemgt.version>3.0.8-SNAPSHOT</carbon.devicemgt.version>
<carbon.devicemgt.version.range>[3.0.0, 4.0.0)</carbon.devicemgt.version.range> <carbon.devicemgt.version.range>[3.0.0, 4.0.0)</carbon.devicemgt.version.range>
<!-- Carbon App Management --> <!-- Carbon App Management -->

Loading…
Cancel
Save