Merge pull request #708 from Kamidu/master

Fixing the notification validation issue.
revert-dabc3590
inoshperera 8 years ago committed by GitHub
commit 06b5801948

@ -51,6 +51,7 @@
<div class="operation" data-operation-code="{{operation}}">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
@ -65,6 +66,11 @@
{{description}}
<br>
</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">
<form action="{{params.0.uri}}" method="{{params.0.method}}"
style="padding-bottom: 20px;"

@ -27,6 +27,11 @@ function operationSelect(selection) {
showPopup();
}
var resetLoader = function () {
$("#btnSend").removeClass("hidden");
$('#lbl-execution').addClass("hidden");
};
function submitForm(formId) {
$("#btnSend").addClass("hidden");
$("#lbl-execution").removeClass("hidden");
@ -58,6 +63,9 @@ function submitForm(formId) {
uri += uriencodedQueryStr;
var httpMethod = form.attr("method").toUpperCase();
//var contentType = form.attr("enctype");
var validaterString = validatePayload(operationCode, payload);
if (validaterString == "OK") {
if (contentType == undefined || contentType == "") {
contentType = "application/x-www-form-urlencoded";
@ -72,11 +80,6 @@ function submitForm(formId) {
var description = content.find("#description");
description.html("");
var resetLoader = function () {
$("#btnSend").removeClass("hidden");
$('#lbl-execution').addClass("hidden");
};
var successCallBack = function (response) {
var res = response;
try {
@ -124,6 +127,11 @@ function submitForm(formId) {
resetLoader();
$(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) {
@ -161,6 +169,21 @@ var operationTypeConstants = {
"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 payload;
@ -228,8 +251,8 @@ var generatePayload = function (operationCode, operationData, deviceList) {
payload = {
"operation": {
//"message" : operationData["message"]
"messageText": operationData["messageText"],
"messageTitle": operationData["messageTitle"]
"messageTitle": operationData["messageTitle"],
"messageText": operationData["messageText"]
}
};
break;

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

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

Loading…
Cancel
Save