Please note that * sign represents required fields of data.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Certificate was added successfully.
+
+ Please click "Add Another Certificate", if you wish to add another certificate or
+ click
+ "View Certificate List" to complete the process and go back to the certificate list.
+
+
+
+
+
+
+
+ Add Another Certificate
+
+
+
+
+
+
+
+{{/zone}}
+
+{{#zone "bottomJs"}}
+ {{js "/js/certificate-create.js"}}
+{{/zone}}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js
new file mode 100644
index 0000000000..4e7585163a
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js
@@ -0,0 +1,45 @@
+/*
+ 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 log = new Log("units/user-create/create.js");
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
+ var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
+
+ var response = userModule.getRolesByUserStore();
+ if (response["status"] == "success") {
+ context["roles"] = response["content"];
+ }
+
+ context["charLimit"] = mdmProps["usernameLength"];
+ context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
+ context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
+ context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
+ context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"];
+ context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"];
+ context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"];
+ context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"];
+
+ return context;
+}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.json
new file mode 100644
index 0000000000..db293d5ab1
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.json
@@ -0,0 +1,5 @@
+{
+ "version": "1.0.0",
+ "uri": "/certificates/add",
+ "layout": "cdmf.layout.default"
+}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js
new file mode 100644
index 0000000000..4ccd72a11f
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js
@@ -0,0 +1,129 @@
+/*
+ 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.
+ */
+var pemContent = "";
+var errorMsgWrapper = "#certificate-create-error-msg";
+var errorMsg = "#certificate-create-error-msg span";
+var validateInline = {};
+var clearInline = {};
+
+var base_api_url = "/api/certificate-mgt/v1.0";
+
+var enableInlineError = function (inputField, errorMsg, errorSign) {
+ var fieldIdentifier = "#" + inputField;
+ var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
+ var errorSignIdentifier = "#" + inputField + " ." + errorSign;
+
+ if (inputField) {
+ $(fieldIdentifier).addClass(" has-error has-feedback");
+ }
+
+ if (errorMsg) {
+ $(errorMsgIdentifier).removeClass(" hidden");
+ }
+
+ if (errorSign) {
+ $(errorSignIdentifier).removeClass(" hidden");
+ }
+};
+
+var disableInlineError = function (inputField, errorMsg, errorSign) {
+ var fieldIdentifier = "#" + inputField;
+ var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
+ var errorSignIdentifier = "#" + inputField + " ." + errorSign;
+
+ if (inputField) {
+ $(fieldIdentifier).removeClass(" has-error has-feedback");
+ }
+
+ if (errorMsg) {
+ $(errorMsgIdentifier).addClass(" hidden");
+ }
+
+ if (errorSign) {
+ $(errorSignIdentifier).addClass(" hidden");
+ }
+};
+
+function readSingleFile(evt) {
+ var f = evt.target.files[0];
+ if (f) {
+ var r = new FileReader();
+ r.onload = function (e) {
+ var contents = e.target.result;
+ if (f.type == "application/x-x509-ca-cert") {
+ pemContent = contents;
+ console.log(contents);
+ console.log(pemContent);
+ pemContent = pemContent.substring(28, pemContent.length - 27);
+ console.log(pemContent);
+ $(errorMsgWrapper).addClass("hidden");
+ } else {
+ $(errorMsg).text("Certificate must be a .pem file containing a valid certificate data.");
+ $(errorMsgWrapper).removeClass("hidden");
+ }
+ }
+ r.readAsText(f);
+ } else {
+ //inline error
+ }
+}
+
+$(document).ready(function () {
+ pemContent = "";
+ document.getElementById('certificate').addEventListener('change', readSingleFile, false);
+
+ /**
+ * Following click function would execute
+ * when a user clicks on "Add Certificate" button.
+ */
+ $("button#add-certificate-btn").click(function () {
+ var serialNoInput = $("input#serialNo");
+ var serialNo = serialNoInput.val();
+ if (!serialNo) {
+ $(errorMsg).text("Serial Number is a required field. It cannot be empty.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else if (!pemContent) {
+ $(errorMsg).text(" .pem file must contains certificate information.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else {
+ var addCertificateFormData = {};
+ addCertificateFormData.serial = serialNo;
+ addCertificateFormData.pem = pemContent;
+ var certificateList = [];
+ certificateList.push(addCertificateFormData);
+
+ var serviceUrl = base_api_url + "/admin/certificates";
+ invokerUtil.post(
+ serviceUrl,
+ certificateList,
+ function (data) {
+ // Refreshing with success message
+ $("#certificate-create-form").addClass("hidden");
+ $("#certificate-created-msg").removeClass("hidden");
+ }, function (data) {
+ if (data["status"] == 500) {
+ $(errorMsg).text("An unexpected error occurred at backend server. Please try again later.");
+ } else {
+ $(errorMsg).text(data);
+ }
+ $(errorMsgWrapper).removeClass("hidden");
+ }
+ );
+ }
+ });
+});
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs
new file mode 100644
index 0000000000..86f161ae35
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs
@@ -0,0 +1,177 @@
+{{!
+ 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="Add Certificate"}}
+
+{{#zone "breadcrumbs"}}
+
-
- Please click "Go back to configurations", if you wish to save another
- configuration or click
- "Exit" to complete the process and go back to the dashboard.
-
-
-
+
+
+
Configuration was saved successfully.
+
+ Please click "Go back to configurations", if you wish to save another
+ configuration or click
+ "Exit" to complete the process and go back to the dashboard.
+
+
+
+
+
-
-
+{{/zone}}
{{#zone "bottomJs"}}
{{js "js/platform-configuration.js"}}
{{/zone}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
index e34720df7b..ce96d0d1a0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
@@ -20,15 +20,26 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js").utility;
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
//get all device types
- var data = deviceModule.getDeviceTypes();
var deviceTypesArray = [];
- if (data) {
- for (var i = 0; i < data.length; i++) {
- var deviceTypeName = data[i].name;
- var configUnitName = utility.getTenantedDeviceUnitName(deviceTypeName, "platform.configuration");
- if(configUnitName) {
- var deviceTypeConfig = utility.getDeviceTypeConfig(deviceTypeName);
- deviceTypesArray.push({name: deviceTypeName, label:deviceTypeConfig.deviceType.label, unitName : configUnitName});
+ var typesListResponse = deviceModule.getDeviceTypes();
+ if (typesListResponse["status"] == "success") {
+ var data = typesListResponse["content"].deviceTypes;
+ if (data) {
+ for (var i = 0; i < data.length; i++) {
+ var deviceTypeName = data[i];
+ var configUnitName = utility.getTenantedDeviceUnitName(deviceTypeName, "platform.configuration");
+ if (configUnitName) {
+ var deviceTypeConfig = utility.getDeviceTypeConfig(deviceTypeName);
+ var deviceTypeLabel = deviceTypeName;
+ if (deviceTypeConfig) {
+ deviceTypeLabel = deviceTypeConfig.deviceType.label;
+ }
+ deviceTypesArray.push({
+ name: deviceTypeName,
+ label: deviceTypeLabel,
+ unitName: configUnitName
+ });
+ }
}
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
index f2704873a4..2f739d228a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
@@ -41,7 +41,7 @@ $(document).ready(function () {
}
invokerUtil.get(
- "/devicemgt_admin/configuration",
+ "/api/device-mgt/v1.0/configuration",
function (data) {
data = JSON.parse(data);
if (data && data.configuration) {
@@ -85,13 +85,13 @@ $(document).ready(function () {
configList.push(monitorFrequency);
addConfigFormData.configuration = configList;
- var addConfigAPI = "/devicemgt_admin/configuration";
- invokerUtil.post(
+ var addConfigAPI = "/api/device-mgt/v1.0/configuration";
+ invokerUtil.put(
addConfigAPI,
addConfigFormData,
- function (data) {
- data = JSON.parse(data);
- if (data.statusCode == responseCodes["SUCCESS"]) {
+ function (data, textStatus, jqXHR) {
+ data = jqXHR.status;
+ if (data == 200) {
$("#config-save-form").addClass("hidden");
$("#record-created-msg").removeClass("hidden");
} else if (data == 500) {
@@ -118,3 +118,12 @@ $(document).ready(function () {
}
});
});
+
+// Start of HTML embedded invoke methods
+var showAdvanceOperation = function (operation, button) {
+ $(button).addClass('selected');
+ $(button).siblings().removeClass('selected');
+ var hiddenOperation = ".wr-hidden-operations-content > div";
+ $(hiddenOperation + '[data-operation="' + operation + '"]').show();
+ $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
+};
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
index 28142c13eb..79d41eab85 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
@@ -25,7 +25,7 @@ function onRequest(context) {
var types = {};
types["types"] = [];
- var typesListResponse = userModule.getPlatforms();
+ var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
for (var type in typesListResponse["content"]) {
var content = {};
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js
new file mode 100644
index 0000000000..9547a1e50d
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js
@@ -0,0 +1,83 @@
+/**
+ * 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);
+}
+
+$(document).ready(function () {
+ var modalPopup = ".wr-modalpopup";
+ // var modalPopupContainer = modalPopup + " .modalpopup-container";
+ var modalPopupContent = modalPopup + " .modalpopup-content";
+
+ $("#change-password").click(function () {
+
+ $(modalPopupContent).html($('#change-password-window').html());
+ showPopup();
+
+ $("a#change-password-yes-link").click(function () {
+ var oldPassword = $("#old-password").val();
+ var newPassword = $("#new-password").val();
+ var confirmedPassword = $("#confirmed-password").val();
+ var user = $("#user").val();
+
+ var errorMsgWrapper = "#notification-error-msg";
+ var errorMsg = "#notification-error-msg span";
+ if (!oldPassword) {
+ $(errorMsg).text("Old password is a required field. It cannot be empty.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else if (!newPassword) {
+ $(errorMsg).text("New password is a required field. It cannot be empty.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else if (!confirmedPassword) {
+ $(errorMsg).text("Retyping the new password is required.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else if (confirmedPassword != newPassword) {
+ $(errorMsg).text("New password doesn't match the confirmation.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) {
+ $(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else {
+ var changePasswordFormData = {};
+ //changePasswordFormData.username = user;
+ changePasswordFormData.newPassword = unescape((confirmedPassword));
+ changePasswordFormData.oldPassword = unescape((oldPassword));
+
+
+ var changePasswordAPI = "/api/device-mgt/v1.0/users" + user + "/credentials";
+
+ invokerUtil.put(
+ changePasswordAPI,
+ changePasswordFormData,
+ function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 200 && data) {
+ $(modalPopupContent).html($('#change-password-success-content').html());
+ $("#change-password-success-link").click(function () {
+ hidePopup();
+ });
+ }
+ }, function (jqXHR) {
+ if (jqXHR.status == 400) {
+ $(errorMsg).text("Old password does not match with the provided value.");
+ $(errorMsgWrapper).removeClass("hidden");
+ } else {
+ $(errorMsg).text("An unexpected error occurred. Please try again later.");
+ $(errorMsgWrapper).removeClass("hidden");
+ }
+ }
+ );
+ }
+
+ });
+
+ $("a#change-password-cancel-link").click(function () {
+ hidePopup();
+ });
+ });
+});
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs
index 5fc7ac3bca..21b7c28f3e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs
@@ -17,6 +17,70 @@
}}
{{#zone "userMenu-items"}}