forked from community/device-mgt-core
parent
4292442aa5
commit
44ac6b13b5
@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if provided input is valid against RegEx input.
|
||||||
|
*
|
||||||
|
* @param regExp Regular expression
|
||||||
|
* @param inputString Input string to check
|
||||||
|
* @returns {boolean} Returns true if input matches RegEx
|
||||||
|
*/
|
||||||
|
function inputIsValid(regExp, inputString) {
|
||||||
|
regExp = new RegExp(regExp);
|
||||||
|
return regExp.test(inputString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an email address has the valid format or not.
|
||||||
|
*
|
||||||
|
* @param email Email address
|
||||||
|
* @returns {boolean} true if email has the valid format, otherwise false.
|
||||||
|
*/
|
||||||
|
function emailIsValid(email) {
|
||||||
|
var regExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
|
||||||
|
return regExp.test(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Following click function would execute
|
||||||
|
* when a user clicks on "Add User" button
|
||||||
|
* on Add User page in WSO2 Devicemgt Console.
|
||||||
|
*/
|
||||||
|
$("button#add-user-btn").click(function () {
|
||||||
|
|
||||||
|
var usernameInput = $("input#user_name");
|
||||||
|
var firstnameInput = $("input#first_name");
|
||||||
|
var lastnameInput = $("input#last_name");
|
||||||
|
var emailInput = $("input#email");
|
||||||
|
var passwordInput = $("input#password");
|
||||||
|
var passwordConfirmationInput = $("input#password_confirmation");
|
||||||
|
|
||||||
|
var username = usernameInput.val().trim();
|
||||||
|
var firstname = firstnameInput.val();
|
||||||
|
var lastname = lastnameInput.val();
|
||||||
|
var emailAddress = emailInput.val();
|
||||||
|
var password = passwordInput.val();
|
||||||
|
var passwordConfirmation = passwordConfirmationInput.val();
|
||||||
|
var errorMsgWrapper = "#user-create-error-msg";
|
||||||
|
var errorMsg = "#user-create-error-msg span";
|
||||||
|
|
||||||
|
if (!firstname) {
|
||||||
|
$(errorMsg).text("Firstname is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!inputIsValid(firstnameInput.data("regex"), firstname)) {
|
||||||
|
$(errorMsg).text(firstnameInput.data("errormsg"));
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!lastname) {
|
||||||
|
$(errorMsg).text("Lastname is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!inputIsValid(lastnameInput.data("regex"), lastname)) {
|
||||||
|
$(errorMsg).text(lastnameInput.data("errormsg"));
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!username) {
|
||||||
|
$(errorMsg).text("Username is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!inputIsValid(usernameInput.data("regex"), username)) {
|
||||||
|
$(errorMsg).text(usernameInput.data("errormsg"));
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!emailAddress) {
|
||||||
|
$(errorMsg).text("Email is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!emailIsValid(emailAddress)) {
|
||||||
|
$(errorMsg).text(emailInput.data("errormsg"));
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (!password) {
|
||||||
|
$(errorMsg).text("Password is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (password.length < 6) {
|
||||||
|
$(errorMsg).text("Password is a required field. It cannot be empty.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else if (password != passwordConfirmation) {
|
||||||
|
$(errorMsg).text("Please enter the same password for confirmation.");
|
||||||
|
$(errorMsgWrapper).removeClass("hidden");
|
||||||
|
} else {
|
||||||
|
$(errorMsgWrapper).addClass("hidden");
|
||||||
|
$("#add-user-btn").prop('disabled', true);
|
||||||
|
|
||||||
|
var addUserFormData = {};
|
||||||
|
addUserFormData.username = username;
|
||||||
|
addUserFormData.firstname = firstname;
|
||||||
|
addUserFormData.lastname = lastname;
|
||||||
|
addUserFormData.emailAddress = emailAddress;
|
||||||
|
addUserFormData.password = $("input#password").val();
|
||||||
|
addUserFormData.userRoles = null;
|
||||||
|
|
||||||
|
var context = $(".form-login-box").data("context");
|
||||||
|
var addUserAPI = context + "/api/user/register";
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: addUserAPI,
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify(addUserFormData),
|
||||||
|
success: function (data) {
|
||||||
|
$("#add-user-btn").prop('disabled', false);
|
||||||
|
if (data == 200) {
|
||||||
|
$('.wr-validation-summary strong').html(
|
||||||
|
"<i class=\"icon fw fw-ok\"></i> Successfully Submitted.");
|
||||||
|
$('.wr-validation-summary').removeClass("alert-danger");
|
||||||
|
$('.wr-validation-summary').addClass("alert-success");
|
||||||
|
} else if (data == 201) {
|
||||||
|
$('.wr-validation-summary strong').html(
|
||||||
|
"<i class=\"icon fw fw-ok\"></i> User created succssfully. You will be " +
|
||||||
|
"redirected to login page.");
|
||||||
|
$('.wr-validation-summary').removeClass("alert-danger");
|
||||||
|
$('.wr-validation-summary').addClass("alert-success");
|
||||||
|
$("#add-user-btn").prop('disabled', true);
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location = context + "/login";
|
||||||
|
}, 2000);
|
||||||
|
} else if (data == 400) {
|
||||||
|
$('.wr-validation-summary strong').html(
|
||||||
|
"<i class=\"icon fw fw-error\"></i> Exception at backend.");
|
||||||
|
$('.wr-validation-summary').removeClass("alert-danger");
|
||||||
|
$('.wr-validation-summary').addClass("alert-warning");
|
||||||
|
} else if (data == 403) {
|
||||||
|
$('.wr-validation-summary strong').html("Action not permitted.");
|
||||||
|
} else if (data == 409) {
|
||||||
|
$('.wr-validation-summary strong').html(
|
||||||
|
"<i class=\"icon fw fw-info\"></i> User name already exists.");
|
||||||
|
$('.wr-validation-summary').removeClass("alert-default");
|
||||||
|
$('.wr-validation-summary').addClass("alert-success");
|
||||||
|
}
|
||||||
|
$('.wr-validation-summary').removeClass("hidden");
|
||||||
|
$('#password').val('');
|
||||||
|
$('#password_confirmation').val('');
|
||||||
|
},
|
||||||
|
error: function (err) {
|
||||||
|
$("#add-user-btn").prop('disabled', false);
|
||||||
|
$('.wr-validation-summary strong').html(
|
||||||
|
"<i class=\"icon fw fw-error\"></i> An unexpected error occurred.");
|
||||||
|
$('.wr-validation-summary').removeClass("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,75 @@
|
|||||||
|
{{unit "cdmf.unit.ui.title" pageTitle="Register"}}
|
||||||
|
|
||||||
|
{{#zone "content"}}
|
||||||
|
{{unit "uuf.unit.lib.form-validation"}}
|
||||||
|
|
||||||
|
<div class="container col-xs-12 col-sm-10 col-md-8 col-lg-6 col-centered wr-content wr-login col-centered sign-panel">
|
||||||
|
|
||||||
|
<p class="page-sub-title">Register</p>
|
||||||
|
|
||||||
|
<p>Create new account on WSO2 IoT (All fields are required.)</p>
|
||||||
|
<hr/>
|
||||||
|
<!-- validation -->
|
||||||
|
<div class="wr-validation-summary hidden alert alert-danger">
|
||||||
|
<strong></strong>
|
||||||
|
<button type="button" class="close" aria-label="close" data-dismiss="alert">
|
||||||
|
<span aria-hidden="true">
|
||||||
|
<i class="fw fw-cancel"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="form-login-box" id="registerForm" data-context="{{@app.context}}">
|
||||||
|
<div id="user-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||||
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="first_name" class="wr-input-label">First Name</label>
|
||||||
|
<input type="text" id="first_name" name="first_name" class="form-control" placeholder="First Name"
|
||||||
|
data-regex="{{usernameJSRegEx}}" data-lengthmsg="{{usernameHelpText}}"
|
||||||
|
data-errormsg="{{usernameRegExViolationErrorMsg}}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="last_name" class="wr-input-label">Last Name</label>
|
||||||
|
<input type="text" id="last_name" name="last_name" class="form-control" placeholder="Last Name"
|
||||||
|
data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="user_name" class="wr-input-label">Username ( {{usernameHelpText}} )</label>
|
||||||
|
<input type="text" id="user_name" name="user_name" class="form-control" placeholder="Username"
|
||||||
|
data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email" class="wr-input-label">Email</label>
|
||||||
|
<input type="text" id="email" name="email" class="form-control" placeholder="Email"
|
||||||
|
data-regex="{{emailJSRegEx}}" data-errormsg="{{emailRegExViolationErrorMsg}}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password" class="wr-input-label">Password</label>
|
||||||
|
<input type="password" id="password" name="password" class="form-control"
|
||||||
|
placeholder="Password"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password_confirmation" class="wr-input-label">Confirm Password</label>
|
||||||
|
<input type="password" id="password_confirmation" name="password_confirmation"
|
||||||
|
class="form-control" placeholder="Confirm Password"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<button class="wr-btn" id="add-user-btn">Register</button>
|
||||||
|
<button class="wr-btn" onclick="document.location.href='{{@app.context}}/login';">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{{/zone}}
|
||||||
|
|
||||||
|
{{#zone "bottomJs"}}
|
||||||
|
{{js "js/validate-register.js"}}
|
||||||
|
{{/zone}}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dynamic state to be populated by add-user page.
|
||||||
|
*
|
||||||
|
* @param context Object that gets updated with the dynamic state of this page to be presented
|
||||||
|
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
||||||
|
*/
|
||||||
|
function onRequest(context) {
|
||||||
|
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||||
|
var page = {};
|
||||||
|
page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx;
|
||||||
|
page["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg;
|
||||||
|
page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg;
|
||||||
|
page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx;
|
||||||
|
page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg;
|
||||||
|
page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx;
|
||||||
|
page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg;
|
||||||
|
page["emailJSRegEx"] = devicemgtProps.userValidationConfig.emailJSRegEx;
|
||||||
|
page["emailRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.emailRegExViolationErrorMsg;
|
||||||
|
return page;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"uri": "/register",
|
||||||
|
"isAnonymous": true,
|
||||||
|
"layout": "uuf.layout.sign-in"
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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 log = new Log("operation.js");
|
||||||
|
var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
|
||||||
|
var device = context.unit.params.device;
|
||||||
|
var autoCompleteParams = context.unit.params.autoCompleteParams;
|
||||||
|
var controlOperations = operationModule.getControlOperations(device.type);
|
||||||
|
var queryParams = [];
|
||||||
|
var formParams = [];
|
||||||
|
var pathParams = [];
|
||||||
|
for (var i = 0; i < controlOperations.length; i++) {
|
||||||
|
var currentParamList = controlOperations[i]["params"];
|
||||||
|
for (var j = 0; j < currentParamList.length; j++) {
|
||||||
|
var currentParam = currentParamList[j];
|
||||||
|
currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams);
|
||||||
|
currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams);
|
||||||
|
currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams);
|
||||||
|
}
|
||||||
|
controlOperations[i]["params"] = currentParamList;
|
||||||
|
}
|
||||||
|
return {"control_operations": controlOperations, "device": device};
|
||||||
|
}
|
||||||
|
|
||||||
|
function processParams(paramsList, autoCompleteParams) {
|
||||||
|
for (var i = 0; i < paramsList.length; i++) {
|
||||||
|
var paramName = paramsList[i];
|
||||||
|
var paramValue = "";
|
||||||
|
var paramType = "text";
|
||||||
|
for (var k = 0; k < autoCompleteParams.length; k++) {
|
||||||
|
if (paramName == autoCompleteParams[k].name) {
|
||||||
|
paramValue = autoCompleteParams[k].value;
|
||||||
|
paramType = "hidden";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paramsList[i] = {"name": paramName, "value": paramValue, "type": paramType};
|
||||||
|
}
|
||||||
|
return paramsList;
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On operation click function.
|
||||||
|
* @param selection: Selected operation
|
||||||
|
*/
|
||||||
|
function operationSelect(selection) {
|
||||||
|
$(modalPopupContent).addClass("operation-data");
|
||||||
|
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
|
||||||
|
$(modalPopupContent).data("operation-code", selection);
|
||||||
|
showPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitForm(formId) {
|
||||||
|
var form = $("#" + formId);
|
||||||
|
var uri = form.attr("action");
|
||||||
|
var uriencodedQueryStr = "";
|
||||||
|
var uriencodedFormStr = "";
|
||||||
|
var payload = {};
|
||||||
|
form.find("input").each(function () {
|
||||||
|
var input = $(this);
|
||||||
|
if (input.data("param-type") == "path") {
|
||||||
|
uri = uri.replace("{" + input.attr("id") + "}", input.val());
|
||||||
|
} else if (input.data("param-type") == "query") {
|
||||||
|
var prefix = (uriencodedQueryStr == "") ? "?" : "&";
|
||||||
|
uriencodedQueryStr += prefix + input.attr("id") + "=" + input.val();
|
||||||
|
} else if (input.data("param-type") == "form") {
|
||||||
|
var prefix = (uriencodedFormStr == "") ? "" : "&";
|
||||||
|
uriencodedFormStr += prefix + input.attr("id") + "=" + input.val();
|
||||||
|
//payload[input.attr("id")] = input.val();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
uri += uriencodedQueryStr;
|
||||||
|
var httpMethod = form.attr("method").toUpperCase();
|
||||||
|
var contentType = form.attr("enctype");
|
||||||
|
console.log(payload);
|
||||||
|
if (contentType == undefined || contentType.isEmpty()) {
|
||||||
|
contentType = "application/x-www-form-urlencoded";
|
||||||
|
payload = uriencodedFormStr;
|
||||||
|
}
|
||||||
|
//setting responses callbacks
|
||||||
|
var defaultStatusClasses = "fw fw-stack-1x";
|
||||||
|
var content = $("#operation-response-template").find(".content");
|
||||||
|
var title = content.find("#title");
|
||||||
|
var statusIcon = content.find("#status-icon");
|
||||||
|
var description = content.find("#description");
|
||||||
|
var successCallBack = function (response) {
|
||||||
|
var res = response;
|
||||||
|
try {
|
||||||
|
res = JSON.parse(response).messageFromServer;
|
||||||
|
} catch (err) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
title.html("Operation Triggered!");
|
||||||
|
statusIcon.attr("class", defaultStatusClasses + " fw-check");
|
||||||
|
description.html(res);
|
||||||
|
$(modalPopupContent).html(content.html());
|
||||||
|
};
|
||||||
|
var errorCallBack = function (response) {
|
||||||
|
console.log(response);
|
||||||
|
title.html("An Error Occurred!");
|
||||||
|
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
||||||
|
var reason = (response.responseText == "null")?response.statusText:response.responseText;
|
||||||
|
description.html(reason);
|
||||||
|
$(modalPopupContent).html(content.html());
|
||||||
|
};
|
||||||
|
//executing http request
|
||||||
|
if (httpMethod == "GET") {
|
||||||
|
invokerUtil.get(uri, successCallBack, errorCallBack, contentType);
|
||||||
|
} else if (httpMethod == "POST") {
|
||||||
|
invokerUtil.post(uri, payload, successCallBack, errorCallBack, contentType);
|
||||||
|
} else if (httpMethod == "PUT") {
|
||||||
|
invokerUtil.put(uri, payload, successCallBack, errorCallBack, contentType);
|
||||||
|
} else if (httpMethod == "DELETE") {
|
||||||
|
invokerUtil.delete(uri, successCallBack, errorCallBack, contentType);
|
||||||
|
} else {
|
||||||
|
title.html("An Error Occurred!");
|
||||||
|
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
||||||
|
description.html("This operation requires http method: " + httpMethod + " which is not supported yet!");
|
||||||
|
$(modalPopupContent).html(content.html());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('submit', 'form', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var postOperationRequest = $.ajax({
|
||||||
|
url: $(this).attr("action") + '&' + $(this).serialize(),
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
|
||||||
|
var btnSubmit = $('#btnSend', this);
|
||||||
|
btnSubmit.addClass('hidden');
|
||||||
|
|
||||||
|
var lblSending = $('#lblSending', this);
|
||||||
|
lblSending.removeClass('hidden');
|
||||||
|
|
||||||
|
var lblSent = $('#lblSent', this);
|
||||||
|
postOperationRequest.done(function (data) {
|
||||||
|
lblSending.addClass('hidden');
|
||||||
|
lblSent.removeClass('hidden');
|
||||||
|
setTimeout(function () {
|
||||||
|
hidePopup();
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
postOperationRequest.fail(function (jqXHR, textStatus) {
|
||||||
|
lblSending.addClass('hidden');
|
||||||
|
lblSent.addClass('hidden');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in new issue