aboutsummaryrefslogtreecommitdiffstats
path: root/openo-portal/portal-auth/src/main/webapp/user/js
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2017-01-20 17:43:08 +0530
committerseshukm <seshu.kumar.m@huawei.com>2017-01-20 17:43:08 +0530
commitf0b211f269df2b0bb10d5552d14aeb8991a750ed (patch)
tree1bd6ccf7503f8dad0785e03ce52937a55ae9555b /openo-portal/portal-auth/src/main/webapp/user/js
parent68036a69f0dd0dad6b6a715d9850997d21f82940 (diff)
GUI Code refactor
GUI Code refactor for the sun release code. Issue-Id : CLIENT-11 Change-Id: I771cc25ff3c8ff7a4e939ce7baef7dd94a67974b Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'openo-portal/portal-auth/src/main/webapp/user/js')
-rw-r--r--openo-portal/portal-auth/src/main/webapp/user/js/changePassword.js386
-rw-r--r--openo-portal/portal-auth/src/main/webapp/user/js/createUser.js378
-rw-r--r--openo-portal/portal-auth/src/main/webapp/user/js/modifyUser.js154
-rw-r--r--openo-portal/portal-auth/src/main/webapp/user/js/user.js218
-rw-r--r--openo-portal/portal-auth/src/main/webapp/user/js/userTools.js176
5 files changed, 656 insertions, 656 deletions
diff --git a/openo-portal/portal-auth/src/main/webapp/user/js/changePassword.js b/openo-portal/portal-auth/src/main/webapp/user/js/changePassword.js
index f499bfc2..068ea561 100644
--- a/openo-portal/portal-auth/src/main/webapp/user/js/changePassword.js
+++ b/openo-portal/portal-auth/src/main/webapp/user/js/changePassword.js
@@ -1,193 +1,193 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed 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.
- */
-$(document).ready(function() {
- var USER_SERVICE = "/openoapi/auth/v1/users";
- var userId;
- var $userName = $("#userName");
- var $oldPassword = $("#oldPassword");
- var $oldPasswordError = $("#oldPasswordError");
- var $password = $("#password");
- var $passwordError = $("#passwordError")
-
- var $cfPsdError = $("#cfPsdError");
-
- function initialPage() {
- userId = getId();
- getUserDetails(userId).done(function(data) {
- listUserDetails(data);
- });
-
- /*initial the event*/
- $("#confirm").click(function(e) {
- if (!checkPassword()) {
- return;
- }
- var data = getModifyUser();
- changePsd(data).done(function() {
- top.bootbox.alert("Password change successfully.", function(e) {
- Rest.turn2URI("/openoui/user/user.html");
- })
- }).fail(function(e) {
- if (e.statusText == "Unauthorized") {
- showError($oldPasswordError, "The old password is wrong.");
- } else {
- showError($oldPasswordError, e.statusText);
- }
- })
- })
- $("#cancel").click(function(e) {
- window.document.location = "/openoui/user/user.html";
- })
- }
-
- function checkPassword() {
- if (!checkMandatory()) {
- return false;
- }
-
- if (!checkCfPassword()) {
- showError($cfPsdError, "The password is not the same.");
- return false;
- }
-
- if (!checkPasswordRule()) {
- return false;
- }
- return true;
- }
-
- function checkMandatory() {
- if ($password.val() == "") {
- showError($passwordError, "Mandatory.");
- return false;
- }
-
- if ($oldPassword.val() == "") {
- showError($oldPasswordError, "Mandatory.");
- return false;
- }
- return true;
- }
-
- function checkCfPassword() {
- return $("#password").val() == $("#cfPassword").val();
- }
-
- function checkPasswordRule() {
- var password = $password.val();
-
- if (!checkLength(8, 32, password)) {
- showError($passwordError, "The password length should between 8 and 32.");
- return false
- }
-
- if (!checkCotainSpecial(password)) {
- showError($passwordError, "At least contain: one uppercase letter, one lowercase letter, and one digit, one special character;");
- return false
- }
-
- if (!checkNoContainAndReverse(password, $userName.val())) {
- showError($passwordError, "The password should not contain the user name or reverse.");
- return false
- }
-
- if (!checkNoSpace(password)) {
- showError($passwordError, "The password should not contain space.");
- return false
- }
- return true
- }
-
- function checkLength(min, max, str) {
- return str.length >= min && str.length <= max;
- }
-
- function checkOnlySpecials(str, reg) {
- return str.match(reg) && str.match(reg).length == str.length
- }
-
- function checkCotainSpecial(password) {
- return password.match(/\~|\`|\@|\#|\$|\%|\^|\&|\*|\-|\_|\=|\+|\||\?|\/|\(|\)|\<|\>|\[|\]|\{|\}|\"|\,|\.|\;|\'|\!/g) != null
- && password.match(/[0-9]/g) != null && password.match(/[a-z]/g) != null && password.match(/[A-Z]/g) != null;
- }
-
- function checkUderScore(str) {
- return str.indexOf("_") != 0 && str.lastIndexOf("_") != str.length - 1;
- }
-
- function checkNoSpace(str) {
- return str.indexOf(" ") == -1;
- }
-
- function checkNoContainAndReverse(str, str2) {
- return str.indexOf(str2) == -1 && str.indexOf(str2.split("").reverse().join("")) == -1;
- }
-
- function getModifyUser() {
- var data = {};
- data["original_password"] = $("#oldPassword").val();
- data.password = $("#password").val();
- return data;
- }
-
- function getUserDetails(id) {
- return Rest.http({
- url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
- type: "GET",
- async: false,
- contentType: 'application/json',
- dataType: "json"
- })
- }
-
- function listUserDetails(data) {
- $("#userName").val(data.name);
- }
-
-
- function changePsd(data) {
- return Rest.http({
- url: USER_SERVICE + "/" + userId + "/password" + "?=" + new Date().getTime(),
- type: "POST",
- async: false,
- contentType: 'application/json',
- dataType: "json",
- data: JSON.stringify(data)
- })
- }
-
- function getId() {
- var qs = location.search;
- qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
- var start = qs.indexOf("id=") + 3;
- var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
- return qs.substr(start, end);
- }
-
- function showError($Obj, message) {
- $Obj.text(message);
- $Obj.css("visibility", "visible");
- setTimeout(function() {
- hideError($Obj);
- }, 5000)
- }
-
- function hideError($Obj) {
- $Obj.css("visibility", "hidden");
- }
-
- initialPage();
-})
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * Licensed 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.
+ */
+$(document).ready(function() {
+ var USER_SERVICE = "/openoapi/auth/v1/users";
+ var userId;
+ var $userName = $("#userName");
+ var $oldPassword = $("#oldPassword");
+ var $oldPasswordError = $("#oldPasswordError");
+ var $password = $("#password");
+ var $passwordError = $("#passwordError")
+
+ var $cfPsdError = $("#cfPsdError");
+
+ function initialPage() {
+ userId = getId();
+ getUserDetails(userId).done(function(data) {
+ listUserDetails(data);
+ });
+
+ /*initial the event*/
+ $("#confirm").click(function(e) {
+ if (!checkPassword()) {
+ return;
+ }
+ var data = getModifyUser();
+ changePsd(data).done(function() {
+ top.bootbox.alert("Password change successfully.", function(e) {
+ Rest.turn2URI("/openoui/user/user.html");
+ })
+ }).fail(function(e) {
+ if (e.statusText == "Unauthorized") {
+ showError($oldPasswordError, "The old password is wrong.");
+ } else {
+ showError($oldPasswordError, e.statusText);
+ }
+ })
+ })
+ $("#cancel").click(function(e) {
+ window.document.location = "/openoui/user/user.html";
+ })
+ }
+
+ function checkPassword() {
+ if (!checkMandatory()) {
+ return false;
+ }
+
+ if (!checkCfPassword()) {
+ showError($cfPsdError, "The password is not the same.");
+ return false;
+ }
+
+ if (!checkPasswordRule()) {
+ return false;
+ }
+ return true;
+ }
+
+ function checkMandatory() {
+ if ($password.val() == "") {
+ showError($passwordError, "Mandatory.");
+ return false;
+ }
+
+ if ($oldPassword.val() == "") {
+ showError($oldPasswordError, "Mandatory.");
+ return false;
+ }
+ return true;
+ }
+
+ function checkCfPassword() {
+ return $("#password").val() == $("#cfPassword").val();
+ }
+
+ function checkPasswordRule() {
+ var password = $password.val();
+
+ if (!checkLength(8, 32, password)) {
+ showError($passwordError, "The password length should between 8 and 32.");
+ return false
+ }
+
+ if (!checkCotainSpecial(password)) {
+ showError($passwordError, "At least contain: one uppercase letter, one lowercase letter, and one digit, one special character;");
+ return false
+ }
+
+ if (!checkNoContainAndReverse(password, $userName.val())) {
+ showError($passwordError, "The password should not contain the user name or reverse.");
+ return false
+ }
+
+ if (!checkNoSpace(password)) {
+ showError($passwordError, "The password should not contain space.");
+ return false
+ }
+ return true
+ }
+
+ function checkLength(min, max, str) {
+ return str.length >= min && str.length <= max;
+ }
+
+ function checkOnlySpecials(str, reg) {
+ return str.match(reg) && str.match(reg).length == str.length
+ }
+
+ function checkCotainSpecial(password) {
+ return password.match(/\~|\`|\@|\#|\$|\%|\^|\&|\*|\-|\_|\=|\+|\||\?|\/|\(|\)|\<|\>|\[|\]|\{|\}|\"|\,|\.|\;|\'|\!/g) != null
+ && password.match(/[0-9]/g) != null && password.match(/[a-z]/g) != null && password.match(/[A-Z]/g) != null;
+ }
+
+ function checkUderScore(str) {
+ return str.indexOf("_") != 0 && str.lastIndexOf("_") != str.length - 1;
+ }
+
+ function checkNoSpace(str) {
+ return str.indexOf(" ") == -1;
+ }
+
+ function checkNoContainAndReverse(str, str2) {
+ return str.indexOf(str2) == -1 && str.indexOf(str2.split("").reverse().join("")) == -1;
+ }
+
+ function getModifyUser() {
+ var data = {};
+ data["original_password"] = $("#oldPassword").val();
+ data.password = $("#password").val();
+ return data;
+ }
+
+ function getUserDetails(id) {
+ return Rest.http({
+ url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
+ type: "GET",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json"
+ })
+ }
+
+ function listUserDetails(data) {
+ $("#userName").val(data.name);
+ }
+
+
+ function changePsd(data) {
+ return Rest.http({
+ url: USER_SERVICE + "/" + userId + "/password" + "?=" + new Date().getTime(),
+ type: "POST",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json",
+ data: JSON.stringify(data)
+ })
+ }
+
+ function getId() {
+ var qs = location.search;
+ qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
+ var start = qs.indexOf("id=") + 3;
+ var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
+ return qs.substr(start, end);
+ }
+
+ function showError($Obj, message) {
+ $Obj.text(message);
+ $Obj.css("visibility", "visible");
+ setTimeout(function() {
+ hideError($Obj);
+ }, 5000)
+ }
+
+ function hideError($Obj) {
+ $Obj.css("visibility", "hidden");
+ }
+
+ initialPage();
+})
diff --git a/openo-portal/portal-auth/src/main/webapp/user/js/createUser.js b/openo-portal/portal-auth/src/main/webapp/user/js/createUser.js
index f27214a6..5c780ab8 100644
--- a/openo-portal/portal-auth/src/main/webapp/user/js/createUser.js
+++ b/openo-portal/portal-auth/src/main/webapp/user/js/createUser.js
@@ -1,189 +1,189 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed 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.
- */
-$(document).ready(function() {
-
- var USER_SERVICE = "/openoapi/auth/v1/users";
- var $userName = $("#userName");
- var $password = $("#password");
- var $cfPsdError = $("#cfPsdError");
- var $userNameError = $("#userNameError");
- var $passwordError = $("#passwordError");
-
- function initialPage() {
- /*initial the event*/
- $("#confirm").click(function(e) {
- if (!checkUserRules()) {
- return;
- }
- var data = getCreateUser();
- createUser(data).done(function() {
- window.document.location = "/openoui/user/user.html";
- })
- })
- $("#cancel").click(function(e) {
- window.document.location = "/openoui/user/user.html";
- })
- }
-
- function getCreateUser() {
- var data = {};
- data.userName = $userName.val();
- data.password = $password.val();
- data.description = $("#description").val();
- data.email = "xxxx@xxxx.com";
- return data;
- }
-
- function createUser(data) {
- return Rest.http({
- url: USER_SERVICE + "?=" + new Date().getTime(),
- type: "POST",
- async: false,
- contentType: 'application/json',
- dataType: "json",
- data: JSON.stringify(data)
- })
- }
-
- function checkUserRules() {
- if (!checkMandatory()) {
- return false;
- }
-
- if (!checkCfPassword()) {
- return false;
- }
-
- if (!checkUserNameRule()) {
- return false;
- }
-
- if (!checkPasswordRule()) {
- return false;
- }
- return true;
- }
-
- function checkMandatory() {
- if ($userName.val() == "") {
- showError($userNameError, "Mandatory.");
- return false;
- }
-
- if ($password.val() == "") {
- showError($passwordError, "Mandatory.");
- return false;
- }
- return true;
- }
-
- function checkUserNameRule() {
- var username = $userName.val();
- if (!checkLength(5, 30, username)) {
- showError($userNameError, "The user name length should between 5 and 30.");
- return false
- }
-
- if (!checkOnlySpecials(username, /[0-9]|[a-z]|[A-Z]|_/g)) {
- showError($userNameError, "Only Character(a-z\,A-Z\,0-9,_) is allowed.");
- return false
- }
-
- if(!checkUderScore(username)) {
- showError($userNameError, 'The character "_" is only allowed in the middle of the user name.');
- return false
- }
-
- if (!checkNoSpace(username)) {
- showError($userNameError, "The user name should not contain space.");
- return false
- }
-
- return true
- }
-
- function checkPasswordRule() {
- var password = $password.val();
-
- if (!checkLength(8, 32, password)) {
- showError($passwordError, "The password length should between 8 and 32.");
- return false
- }
-
- if (!checkCotainSpecial(password)) {
- showError($passwordError, "At least contain: one uppercase letter, one lowercase letter, and one digit, one special character;");
- return false
- }
-
- if (!checkNoContainAndReverse(password, $userName.val())) {
- showError($passwordError, "The password should not contain the user name or reverse.");
- return false
- }
-
- if (!checkNoSpace(password)) {
- showError($passwordError, "The password should not contain space.");
- return false
- }
- return true
- }
-
- function checkLength(min, max, str) {
- return str.length >= min && str.length <= max;
- }
-
- function checkOnlySpecials(str, reg) {
- return str.match(reg) && str.match(reg).length == str.length
- }
-
- function checkCotainSpecial(password) {
- return password.match(/\~|\`|\@|\#|\$|\%|\^|\&|\*|\-|\_|\=|\+|\||\?|\/|\(|\)|\<|\>|\[|\]|\{|\}|\"|\,|\.|\;|\'|\!/g) != null
- && password.match(/[0-9]/g) != null && password.match(/[a-z]/g) != null && password.match(/[A-Z]/g) != null;
- }
-
- function checkUderScore(str) {
- return str.indexOf("_") != 0 && str.lastIndexOf("_") != str.length - 1;
- }
-
- function checkNoContainAndReverse(str, str2) {
- return str.indexOf(str2) == -1 && str.indexOf(str2.split("").reverse().join("")) == -1;
- }
-
- function checkNoSpace(str) {
- return str.indexOf(" ") == -1;
- }
-
- function checkCfPassword() {
- if ($password.val() == $("#cfPassword").val()) {
- return true;
- }
- showError($cfPsdError, "The password is not the same.");
- return false;
- }
-
- function showError($Obj, message) {
- $Obj.text(message);
- $Obj.css("visibility", "visible");
- setTimeout(function() {
- hideError($Obj);
- }, 5000)
- }
-
- function hideError($Obj) {
- $Obj.css("visibility", "hidden");
- }
-
- initialPage();
-})
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * Licensed 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.
+ */
+$(document).ready(function() {
+
+ var USER_SERVICE = "/openoapi/auth/v1/users";
+ var $userName = $("#userName");
+ var $password = $("#password");
+ var $cfPsdError = $("#cfPsdError");
+ var $userNameError = $("#userNameError");
+ var $passwordError = $("#passwordError");
+
+ function initialPage() {
+ /*initial the event*/
+ $("#confirm").click(function(e) {
+ if (!checkUserRules()) {
+ return;
+ }
+ var data = getCreateUser();
+ createUser(data).done(function() {
+ window.document.location = "/openoui/user/user.html";
+ })
+ })
+ $("#cancel").click(function(e) {
+ window.document.location = "/openoui/user/user.html";
+ })
+ }
+
+ function getCreateUser() {
+ var data = {};
+ data.userName = $userName.val();
+ data.password = $password.val();
+ data.description = $("#description").val();
+ data.email = "xxxx@xxxx.com";
+ return data;
+ }
+
+ function createUser(data) {
+ return Rest.http({
+ url: USER_SERVICE + "?=" + new Date().getTime(),
+ type: "POST",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json",
+ data: JSON.stringify(data)
+ })
+ }
+
+ function checkUserRules() {
+ if (!checkMandatory()) {
+ return false;
+ }
+
+ if (!checkCfPassword()) {
+ return false;
+ }
+
+ if (!checkUserNameRule()) {
+ return false;
+ }
+
+ if (!checkPasswordRule()) {
+ return false;
+ }
+ return true;
+ }
+
+ function checkMandatory() {
+ if ($userName.val() == "") {
+ showError($userNameError, "Mandatory.");
+ return false;
+ }
+
+ if ($password.val() == "") {
+ showError($passwordError, "Mandatory.");
+ return false;
+ }
+ return true;
+ }
+
+ function checkUserNameRule() {
+ var username = $userName.val();
+ if (!checkLength(5, 30, username)) {
+ showError($userNameError, "The user name length should between 5 and 30.");
+ return false
+ }
+
+ if (!checkOnlySpecials(username, /[0-9]|[a-z]|[A-Z]|_/g)) {
+ showError($userNameError, "Only Character(a-z\,A-Z\,0-9,_) is allowed.");
+ return false
+ }
+
+ if(!checkUderScore(username)) {
+ showError($userNameError, 'The character "_" is only allowed in the middle of the user name.');
+ return false
+ }
+
+ if (!checkNoSpace(username)) {
+ showError($userNameError, "The user name should not contain space.");
+ return false
+ }
+
+ return true
+ }
+
+ function checkPasswordRule() {
+ var password = $password.val();
+
+ if (!checkLength(8, 32, password)) {
+ showError($passwordError, "The password length should between 8 and 32.");
+ return false
+ }
+
+ if (!checkCotainSpecial(password)) {
+ showError($passwordError, "At least contain: one uppercase letter, one lowercase letter, and one digit, one special character;");
+ return false
+ }
+
+ if (!checkNoContainAndReverse(password, $userName.val())) {
+ showError($passwordError, "The password should not contain the user name or reverse.");
+ return false
+ }
+
+ if (!checkNoSpace(password)) {
+ showError($passwordError, "The password should not contain space.");
+ return false
+ }
+ return true
+ }
+
+ function checkLength(min, max, str) {
+ return str.length >= min && str.length <= max;
+ }
+
+ function checkOnlySpecials(str, reg) {
+ return str.match(reg) && str.match(reg).length == str.length
+ }
+
+ function checkCotainSpecial(password) {
+ return password.match(/\~|\`|\@|\#|\$|\%|\^|\&|\*|\-|\_|\=|\+|\||\?|\/|\(|\)|\<|\>|\[|\]|\{|\}|\"|\,|\.|\;|\'|\!/g) != null
+ && password.match(/[0-9]/g) != null && password.match(/[a-z]/g) != null && password.match(/[A-Z]/g) != null;
+ }
+
+ function checkUderScore(str) {
+ return str.indexOf("_") != 0 && str.lastIndexOf("_") != str.length - 1;
+ }
+
+ function checkNoContainAndReverse(str, str2) {
+ return str.indexOf(str2) == -1 && str.indexOf(str2.split("").reverse().join("")) == -1;
+ }
+
+ function checkNoSpace(str) {
+ return str.indexOf(" ") == -1;
+ }
+
+ function checkCfPassword() {
+ if ($password.val() == $("#cfPassword").val()) {
+ return true;
+ }
+ showError($cfPsdError, "The password is not the same.");
+ return false;
+ }
+
+ function showError($Obj, message) {
+ $Obj.text(message);
+ $Obj.css("visibility", "visible");
+ setTimeout(function() {
+ hideError($Obj);
+ }, 5000)
+ }
+
+ function hideError($Obj) {
+ $Obj.css("visibility", "hidden");
+ }
+
+ initialPage();
+})
diff --git a/openo-portal/portal-auth/src/main/webapp/user/js/modifyUser.js b/openo-portal/portal-auth/src/main/webapp/user/js/modifyUser.js
index e75e9779..7e571448 100644
--- a/openo-portal/portal-auth/src/main/webapp/user/js/modifyUser.js
+++ b/openo-portal/portal-auth/src/main/webapp/user/js/modifyUser.js
@@ -1,78 +1,78 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed 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.
- */
-$(document).ready(function() {
- var USER_SERVICE = "/openoapi/auth/v1/users";
- var userId;
- function initialPage() {
- userId = getId();
- getUserDetails(userId).done(function(data) {
- listUserDetails(data);
- });
-
- /*initial the event*/
- $("#confirm").click(function(e) {
- var data = getModifyUser();
- modifyUser(data).done(function() {
- window.document.location = "/openoui/user/user.html";
- })
- })
- $("#cancel").click(function(e) {
- window.document.location = "/openoui/user/user.html";
- })
- }
-
- function getModifyUser() {
- var data = {};
- data.description = $("#description").val();
- data.email = "xxxx@xxxx.com";
- return data;
- }
- function getUserDetails(id) {
- return Rest.http({
- url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
- type: "GET",
- async: false,
- contentType: 'application/json',
- dataType: "json"
- })
- }
-
- function listUserDetails(data) {
- $("#userName").val(data.name);
- $("#description").val(data.description);
- }
-
- function modifyUser(data) {
- return Rest.http({
- url: USER_SERVICE + "/" + userId + "?=" + new Date().getTime(),
- type: "PATCH",
- async: false,
- contentType: 'application/json',
- dataType: "json",
- data: JSON.stringify(data)
- })
- }
-
- function getId() {
- var qs = location.search;
- qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
- var start = qs.indexOf("id=") + 3;
- var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
- return qs.substr(start, end);
- }
-
- initialPage();
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * Licensed 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.
+ */
+$(document).ready(function() {
+ var USER_SERVICE = "/openoapi/auth/v1/users";
+ var userId;
+ function initialPage() {
+ userId = getId();
+ getUserDetails(userId).done(function(data) {
+ listUserDetails(data);
+ });
+
+ /*initial the event*/
+ $("#confirm").click(function(e) {
+ var data = getModifyUser();
+ modifyUser(data).done(function() {
+ window.document.location = "/openoui/user/user.html";
+ })
+ })
+ $("#cancel").click(function(e) {
+ window.document.location = "/openoui/user/user.html";
+ })
+ }
+
+ function getModifyUser() {
+ var data = {};
+ data.description = $("#description").val();
+ data.email = "xxxx@xxxx.com";
+ return data;
+ }
+ function getUserDetails(id) {
+ return Rest.http({
+ url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
+ type: "GET",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json"
+ })
+ }
+
+ function listUserDetails(data) {
+ $("#userName").val(data.name);
+ $("#description").val(data.description);
+ }
+
+ function modifyUser(data) {
+ return Rest.http({
+ url: USER_SERVICE + "/" + userId + "?=" + new Date().getTime(),
+ type: "PATCH",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json",
+ data: JSON.stringify(data)
+ })
+ }
+
+ function getId() {
+ var qs = location.search;
+ qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
+ var start = qs.indexOf("id=") + 3;
+ var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
+ return qs.substr(start, end);
+ }
+
+ initialPage();
}) \ No newline at end of file
diff --git a/openo-portal/portal-auth/src/main/webapp/user/js/user.js b/openo-portal/portal-auth/src/main/webapp/user/js/user.js
index 11f2326c..7be00a3d 100644
--- a/openo-portal/portal-auth/src/main/webapp/user/js/user.js
+++ b/openo-portal/portal-auth/src/main/webapp/user/js/user.js
@@ -1,109 +1,109 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed 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.
- */
-$(document).ready(function() {
- var USER_SERVICE = "/openoapi/auth/v1/users";
- var deleteEditOpt = "<img class='edit' title='edit' src='/openoui/user/images/edit.png'><img class='changePsd' title='Change Password' src='/openoui/user/images/reset.png'><img class='delete' title='delete' src='/openoui/user/images/delete.png'>";
- var editOpt = "<img class='edit' title='edit' src='/openoui/user/images/edit.png'><img class='changePsd' title='Change Password' src='/openoui/user/images/reset.png'>";
-
- var userListHeader = [
- { title: "User", data: "User",width: "20%"},
- { title: "Description", data: "Description",width: "60%"},
- { title: "Operations", data: "Operations",width: "20%"}
- ];
- function initialPage() {
- /*get the user list data;*/
- getUserList().done(function(data) {
- var data = formatUsers(data);
- Table.create(data, "table_id", userListHeader);
- $(".hw_body").css("visibility", "visible");
- }).error(function(data) {
- if (data.status == 403) {
- $(".hw_body").html("<span style='font-size:20px;'>" + JSON.parse(data.responseText).error.message + "</span>");
- }
- });
-
- /*add the listener*/
- $("#table_id tbody").on("click", "td", function(e) {
- var classname = e.target.className;
- var id = $("#table_id").DataTable().row(this).data().rowid;
- if (classname == "delete") {
- top.bootbox.confirm("Are you sure to delete this user?", function(result) {
- if (result) {
- deleteUser(id).done(function() {
- getUserList().done(function(data) {
- var data = formatUsers(data);
- var datatable = $("#table_id").dataTable().api();
- datatable.clear();
- datatable.rows.add(data);
- datatable.draw();
- })
- })
- }
- })
- } else if (classname == "edit") {
- window.document.location = "/openoui/user/modifyUser.html" + "?id=" + id;
- } else if (classname == "changePsd") {
- window.document.location = "/openoui/user/changePassword.html" + "?id=" + id;
- }
- })
-
- $("#create").click(function(e) {
- window.document.location = "/openoui/user/createUser.html";
- })
- }
-
- function getUserList() {
- return Rest.http({
- url: USER_SERVICE + "?=" + new Date().getTime(),
- type: "GET",
- async: false,
- contentType: 'application/json',
- dataType: "json"
- })
- }
-
- function deleteUser(id) {
- return Rest.http({
- url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
- type: "DELETE",
- async: false,
- contentType: 'application/json',
- dataType: "json"
- })
- }
-
- function formatUsers(data) {
- var tableData = [];
- for (var i = 0; i < data.length; i++) {
- var temp = {};
- temp.rowid = data[i].id;
- temp.User = data[i].name;
- temp.Description = data[i].description;
- if (data[i].name == "admin") {
- temp.Operations = editOpt;
- } else {
- temp.Operations = deleteEditOpt;
- }
- tableData.push(temp);
- }
- return tableData;
- }
- initialPage();
-
- setTimeout(function() {
- Table.enableToolTips("table_id");
- }, 0)
-});
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * Licensed 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.
+ */
+$(document).ready(function() {
+ var USER_SERVICE = "/openoapi/auth/v1/users";
+ var deleteEditOpt = "<img class='edit' title='edit' src='/openoui/user/images/edit.png'><img class='changePsd' title='Change Password' src='/openoui/user/images/reset.png'><img class='delete' title='delete' src='/openoui/user/images/delete.png'>";
+ var editOpt = "<img class='edit' title='edit' src='/openoui/user/images/edit.png'><img class='changePsd' title='Change Password' src='/openoui/user/images/reset.png'>";
+
+ var userListHeader = [
+ { title: "User", data: "User",width: "20%"},
+ { title: "Description", data: "Description",width: "60%"},
+ { title: "Operations", data: "Operations",width: "20%"}
+ ];
+ function initialPage() {
+ /*get the user list data;*/
+ getUserList().done(function(data) {
+ var data = formatUsers(data);
+ Table.create(data, "table_id", userListHeader);
+ $(".hw_body").css("visibility", "visible");
+ }).error(function(data) {
+ if (data.status == 403) {
+ $(".hw_body").html("<span style='font-size:20px;'>" + JSON.parse(data.responseText).error.message + "</span>");
+ }
+ });
+
+ /*add the listener*/
+ $("#table_id tbody").on("click", "td", function(e) {
+ var classname = e.target.className;
+ var id = $("#table_id").DataTable().row(this).data().rowid;
+ if (classname == "delete") {
+ top.bootbox.confirm("Are you sure to delete this user?", function(result) {
+ if (result) {
+ deleteUser(id).done(function() {
+ getUserList().done(function(data) {
+ var data = formatUsers(data);
+ var datatable = $("#table_id").dataTable().api();
+ datatable.clear();
+ datatable.rows.add(data);
+ datatable.draw();
+ })
+ })
+ }
+ })
+ } else if (classname == "edit") {
+ window.document.location = "/openoui/user/modifyUser.html" + "?id=" + id;
+ } else if (classname == "changePsd") {
+ window.document.location = "/openoui/user/changePassword.html" + "?id=" + id;
+ }
+ })
+
+ $("#create").click(function(e) {
+ window.document.location = "/openoui/user/createUser.html";
+ })
+ }
+
+ function getUserList() {
+ return Rest.http({
+ url: USER_SERVICE + "?=" + new Date().getTime(),
+ type: "GET",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json"
+ })
+ }
+
+ function deleteUser(id) {
+ return Rest.http({
+ url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
+ type: "DELETE",
+ async: false,
+ contentType: 'application/json',
+ dataType: "json"
+ })
+ }
+
+ function formatUsers(data) {
+ var tableData = [];
+ for (var i = 0; i < data.length; i++) {
+ var temp = {};
+ temp.rowid = data[i].id;
+ temp.User = data[i].name;
+ temp.Description = data[i].description;
+ if (data[i].name == "admin") {
+ temp.Operations = editOpt;
+ } else {
+ temp.Operations = deleteEditOpt;
+ }
+ tableData.push(temp);
+ }
+ return tableData;
+ }
+ initialPage();
+
+ setTimeout(function() {
+ Table.enableToolTips("table_id");
+ }, 0)
+});
diff --git a/openo-portal/portal-auth/src/main/webapp/user/js/userTools.js b/openo-portal/portal-auth/src/main/webapp/user/js/userTools.js
index d9157a9a..f6aa84ff 100644
--- a/openo-portal/portal-auth/src/main/webapp/user/js/userTools.js
+++ b/openo-portal/portal-auth/src/main/webapp/user/js/userTools.js
@@ -1,88 +1,88 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed 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 Table = {};
-Table.create = function(data, id, columns) {
- $('#' + id).DataTable({
- data: data,
- bSort: false,
- "sDom": "<t<'left'li><'right'p>>",
- columns: columns
- });
- }
- /**
- * update the table data, the cloumns must be same with the create one.
- * data: the update data. as the create structure
- * id: the table id.
- */
-Table.updata = function(data, id) {
- var datatable = $('#' + id).dataTable().api();
- datatable.clear();
- datatable.rows.add(data);
- datatable.draw();
-}
-
-Table.enableToolTips = function(id) {
- $("#" + id + " tr th").each(function(index, sdom){
- sdom.title = sdom.textContent;
- })
- $("#" + id + " tbody tr td").each(function(index, sdom){
- sdom.title = sdom.textContent;
- })
-}
-
-var Rest = {};
-
-Rest.http = function(setting) {
- var ret = $.ajax(setting);
- ret.fail(function(data) {
- try {
- if (data.responseText.indexOf("login") != -1) {
- top.window.document.location.reload()
- }
- var result = JSON.parse(data.responseText);
- if (result.error && result.error.message) {
- top.bootbox.alert(result.error.message, function() {});
- }
- } catch (e) {
- }
-
- })
- return ret;
-}
-
-Rest.turn2URI = function(url) {
- var cookies = document.cookie.split(";");
- var cookie = "";
- for (var i = 0; i < cookies.length; i++) {
- if (cookies[i].split("=")[0] == "X-Auth-Token") {
- cookie = cookies[i].split("=")[1];
- break;
- }
- }
- $.ajax({
- url: "/openoapi/auth/v1/tokens",
- type: "HEAD",
- headers: {
- "X-Auth-Token": cookie
- },
- success: function(data) {
- window.document.location = url;
- },
- error: function(data) {
- top.window.document.location.reload();
- }
- })
-}
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * Licensed 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 Table = {};
+Table.create = function(data, id, columns) {
+ $('#' + id).DataTable({
+ data: data,
+ bSort: false,
+ "sDom": "<t<'left'li><'right'p>>",
+ columns: columns
+ });
+ }
+ /**
+ * update the table data, the cloumns must be same with the create one.
+ * data: the update data. as the create structure
+ * id: the table id.
+ */
+Table.updata = function(data, id) {
+ var datatable = $('#' + id).dataTable().api();
+ datatable.clear();
+ datatable.rows.add(data);
+ datatable.draw();
+}
+
+Table.enableToolTips = function(id) {
+ $("#" + id + " tr th").each(function(index, sdom){
+ sdom.title = sdom.textContent;
+ })
+ $("#" + id + " tbody tr td").each(function(index, sdom){
+ sdom.title = sdom.textContent;
+ })
+}
+
+var Rest = {};
+
+Rest.http = function(setting) {
+ var ret = $.ajax(setting);
+ ret.fail(function(data) {
+ try {
+ if (data.responseText.indexOf("login") != -1) {
+ top.window.document.location.reload()
+ }
+ var result = JSON.parse(data.responseText);
+ if (result.error && result.error.message) {
+ top.bootbox.alert(result.error.message, function() {});
+ }
+ } catch (e) {
+ }
+
+ })
+ return ret;
+}
+
+Rest.turn2URI = function(url) {
+ var cookies = document.cookie.split(";");
+ var cookie = "";
+ for (var i = 0; i < cookies.length; i++) {
+ if (cookies[i].split("=")[0] == "X-Auth-Token") {
+ cookie = cookies[i].split("=")[1];
+ break;
+ }
+ }
+ $.ajax({
+ url: "/openoapi/auth/v1/tokens",
+ type: "HEAD",
+ headers: {
+ "X-Auth-Token": cookie
+ },
+ success: function(data) {
+ window.document.location = url;
+ },
+ error: function(data) {
+ top.window.document.location.reload();
+ }
+ })
+}