diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java index 4212f65ceb..2da0537b6b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.jaxrs.service.api.admin; +package org.wso2.carbon.device.mgt.jaxrs.service.api; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; @API(name = "Device Type Management", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/device-types", tags = {"devicemgt_admin"}) -@Path("/admin/device-types") +@Path("/device-types") @Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " + "type management") @Produces(MediaType.APPLICATION_JSON) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java similarity index 92% rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java index fdda3bdd88..e38f02a027 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java @@ -16,14 +16,14 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin; +package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; -import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypeManagementService; +import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceTypeManagementService; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import javax.ws.rs.GET; @@ -32,7 +32,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.Response; import java.util.List; -@Path("/admin/device-types") +@Path("/device-types") public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementService { private static Log log = LogFactory.getLog(DeviceTypeManagementServiceImpl.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index dd3d26f070..8405fb99fc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -79,7 +79,7 @@ - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index c12327a912..21360452c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -40,6 +40,32 @@ deviceModule = function () { // var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager"; +/** + * Only GET method is implemented for now since there are no other type of methods used this method. + * @param url - URL to call the backend without the host + * @param method - HTTP Method (GET, POST) + * @returns An object with 'status': 'success'|'error', 'content': {} + */ + privateMethods.callBackend = function (url, method) { + if (constants["HTTP_GET"] == method) { + return serviceInvokers.XMLHttp.get(url, + function (backendResponse) { + var response = {}; + response.content = backendResponse.responseText; + if (backendResponse.status == 200) { + response.status = "success"; + } else if (backendResponse.status == 400 || backendResponse.status == 401 || + backendResponse.status == 404 || backendResponse.status == 500) { + response.status = "error"; + } + return response; + } + ); + } else { + log.error("Runtime error : This method only support HTTP GET requests."); + } + }; + privateMethods.validateAndReturn = function (value) { return (value == undefined || value == null) ? constants.UNSPECIFIED : value; }; @@ -292,16 +318,12 @@ deviceModule = function () { }; publicMethods.getDeviceTypes = function () { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types"; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types"; + var response = privateMethods.callBackend(url, constants["HTTP_GET"]); + if (response.status == "success") { + response.content = parse(response.content); + } + return response; }; //Old methods @@ -309,24 +331,24 @@ deviceModule = function () { /* @Updated */ - publicMethods.getLicense = function (deviceType) { - var url; - var license; - if (deviceType == "windows") { - url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license"; - } else if (deviceType == "ios") { - url = mdmProps["httpsURL"] + "/ios-enrollment/license/"; - } + // publicMethods.getLicense = function (deviceType) { + // var url; + // var license; + // if (deviceType == "windows") { + // url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license"; + // } else if (deviceType == "ios") { + // url = mdmProps["httpsURL"] + "/ios-enrollment/license/"; + // } - if (url != null && url != undefined) { - serviceInvokers.XMLHttp.get(url, function (responsePayload) { - license = responsePayload.text; - }, function (responsePayload) { - return null; - }); - } - return license; - }; + // if (url != null && url != undefined) { + // serviceInvokers.XMLHttp.get(url, function (responsePayload) { + // license = responsePayload.text; + // }, function (responsePayload) { + // return null; + // }); + // } + // return license; + // }; publicMethods.getDevices = function (userName) { var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index bc5c727bcb..0590605891 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -268,6 +268,7 @@ var userModule = function () { /** * Get Platforms. + * @deprecated moved this device module under getDeviceTypes. */ //TODO Move this piece of logic out of user.js to somewhere else appropriate. publicMethods.getPlatforms = function () { @@ -279,7 +280,7 @@ var userModule = function () { } try { utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/admin/device-types"; + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types"; var response = privateMethods.callBackend(url, constants["HTTP_GET"]); if (response.status == "success") { response.content = parse(response.content); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js index 38a3075064..79aa46e5de 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js @@ -18,7 +18,7 @@ var WEB_APP_TITLE = "WSO2 CDM"; var WEB_APP_CONTEXT = "/devicemgt"; -var ADMIN_SERVICE_CONTEXT = "/devicemgt_admin"; +var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0"; var USER_SESSION_KEY = "_UUF_USER"; var UNSPECIFIED = "Unspecified"; var httpURL = "httpURL"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs new file mode 100644 index 0000000000..b2411eac33 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs @@ -0,0 +1,101 @@ +{{! + 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"}} +
  • + + + +
  • +
  • + + + + + + Add Certificate + +
  • +{{/zone}} + +{{#zone "content"}} + +
    +
    + +
    +
    +

    Add Certificate

    +

    Please note that * sign represents required fields of data.

    +
    +
    +
    + + + +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    + +{{/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"}} +
  • + + + +
  • +
  • + + + + + + Add Certificate + +
  • +{{/zone}} + +{{#zone "content"}} + {{unit "cdmf.unit.data-tables-extended"}} + + +
    + {{#if removePermitted}} + + {{/if}} + {{#if viewPermitted}} + + {{/if}} + + Loading Certificates . . . +
    +
    + + + +
    + + + + + + + + + + + + + + + + +
    + +
    By Serial Number
    + + + + +
    +
    +
    + + +
    +
    +
    +
    +

    Do you really want to remove this certificate ?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Certificate was successfully removed.

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + + + + + Unauthorized action! +

    +
    +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + + + {{js "/js/certificate-listing.js"}} +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js new file mode 100644 index 0000000000..8aeb02353e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js @@ -0,0 +1,15 @@ +function onRequest(context) { + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + + context["permissions"] = userModule.getUIPermissions(); + + if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { + context["removePermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { + context["viewPermitted"] = true; + } + context["adminUser"] = mdmProps.adminUser; + 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.certificates/certificates.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.json new file mode 100644 index 0000000000..39fb7ff01b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.json @@ -0,0 +1,5 @@ +{ + "version": "1.0.0", + "uri": "/certificates", + "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.certificates/public/js/certificate-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js new file mode 100644 index 0000000000..d911d7fb45 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js @@ -0,0 +1,171 @@ +/* + * Sorting function of certificates + * listed on Certificate Management page in WSO2 MDM Console. + */ +$(function () { + var sortableElem = '.wr-sortable'; + $(sortableElem).sortable({ + beforeStop: function () { + var sortedIDs = $(this).sortable('toArray'); + } + }); + $(sortableElem).disableSelection(); +}); + +var modalPopup = ".wr-modalpopup"; +var modalPopupContainer = modalPopup + " .modalpopup-container"; +var modalPopupContent = modalPopup + " .modalpopup-content"; +var body = "body"; +var isInit = true; + +var base_api_url = "/api/certificate-mgt/v1.0"; + +$(".icon .text").res_text(0.2); + +/* + * set popup maximum height function. + */ +function setPopupMaxHeight() { + $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); + $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); +} + +/* + * show popup function. + */ +function showPopup() { + $(modalPopup).show(); + setPopupMaxHeight(); +} + +/* + * hide popup function. + */ +function hidePopup() { + $(modalPopupContent).html(''); + $(modalPopup).hide(); +} + +/** + * Following click function would execute + * when a user clicks on "Remove" link + * on Certificate Listing page in WSO2 MDM Console. + */ +function removeCertificate(serialNumber) { + var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber; + $(modalPopupContent).html($('#remove-certificate-modal-content').html()); + showPopup(); + + $("a#remove-certificate-yes-link").click(function () { + invokerUtil.delete( + serviceUrl, + function () { + $("#" + serialNumber).remove(); + var newCertificateListCount = $(".user-list > span").length; + $("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount); + $(modalPopupContent).html($('#remove-certificate-success-content').html()); + $("a#remove-certificate-success-link").click(function () { + hidePopup(); + }); + }, + function () { + $(modalPopupContent).html($('#remove-certificate-error-content').html()); + $("a#remove-certificate-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#remove-certificate-cancel-link").click(function () { + hidePopup(); + }); +} + +/** + * Following on click function would execute + * when a user type on the search field on certificate Listing page in + * WSO2 MDM Console then click on the search button. + */ +$("#search-btn").click(function () { + var searchQuery = $("#search-by-certificate").val(); + $("#ast-container").empty(); + loadCertificates(searchQuery); +}); + +/** + * Following function would execute + * when a user clicks on the list item + * initial mode and with out select mode. + */ +function InitiateViewOption() { + if ($("#can-view").val()) { + $(location).attr('href', $(this).data("url")); + } else { + $(modalPopupContent).html($('#errorCertificateView').html()); + showPopup(); + } +} + +function loadCertificates(searchParam) { + $("#loading-content").show(); + var certificateListing = $("#certificate-listing"); + var certificateListingSrc = certificateListing.attr("src"); + $.template("certificate-listing", certificateListingSrc, function (template) { + var serviceURL = base_api_url + "/admin/certificates"; + + if (searchParam != null && searchParam != undefined && searchParam.trim() != '') { + serviceURL = base_api_url + "/admin/certificates?" + searchParam; + } + + var successCallback = function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + + var viewModel = {}; + viewModel.certificates = data.certificates; + + for (var i = 0; i < viewModel.certificates.length; i++) { + viewModel.certificates[i].removePermitted = true; + viewModel.certificates[i].viewPermitted = true; + } + + if (viewModel.certificates.length > 0) { + $('#ast-container').removeClass('hidden'); + $('#certificate-listing-status-msg').text(""); + var content = template(viewModel); + $("#ast-container").html(content); + } else { + $('#ast-container').addClass('hidden'); + $('#certificate-listing-status-msg').text('No certificate is available to be displayed.'); + $('#certificate-listing-status').removeClass('hidden'); + } + + $("#loading-content").hide(); + + if (isInit) { + $('#certificate-grid').datatables_extended(); + isInit = false; + } + + $(".icon .text").res_text(0.2); + } + }; + invokerUtil.get(serviceURL, + successCallback, + function (message) { + $('#ast-container').addClass('hidden'); + $('#certificate-listing-status-msg'). + text('Invalid search query. Try again with a valid search query'); + } + ); + }); +} + +$(document).ready(function () { + loadCertificates(); + + $(".viewEnabledIcon").click(function () { + InitiateViewOption(); + }); +}); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs new file mode 100644 index 0000000000..c492e4f800 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs @@ -0,0 +1,30 @@ +{{#each certificates}} + + + +
    + +
    + + {{serialNumber}} + {{subject}} + + {{#unequal adminUser serialNumber }} + {{#if removePermitted}} + + + + + + + + {{/if}} + {{/unequal}} + + + +{{/each}} \ 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.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.hbs index 2b6be8fd6d..1a58360409 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.view/view.hbs @@ -19,7 +19,6 @@ {{unit "cdmf.unit.lib.service-invoker-utility"}} {{unit "cdmf.unit.lib.handlebars"}} -{{unit deviceViewUnitName}} {{#zone "breadcrumbs"}}
  • @@ -40,6 +39,7 @@ {{/zone}} {{#zone "content"}} + {{unit deviceViewUnitName}} {{unit "cdmf.unit.lib.data-table"}} {{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.view"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js index 15c9b131f7..d7a19da36b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js @@ -50,21 +50,24 @@ function onRequest(context) { if (deviceCount > 0) { page.deviceCount = deviceCount; var utility = require("/app/modules/utility.js").utility; - var data = deviceModule.getDeviceTypes(); + var typesListResponse = deviceModule.getDeviceTypes(); var deviceTypes = []; - if (data) { - for (var i = 0; i < data.length; i++) { - var config = utility.getDeviceTypeConfig(data[i].name); - if (!config){ - continue; + if (typesListResponse["status"] == "success") { + var data = typesListResponse["content"]; + if (data) { + for (var i = 0; i < data.length; i++) { + var config = utility.getDeviceTypeConfig(data[i].name); + if (!config) { + continue; + } + var deviceType = config.deviceType; + deviceTypes.push({ + "type": data[i].name, + "category": deviceType.category, + "label": deviceType.label, + "thumb": utility.getDeviceThumb(data[i].name) + }); } - var deviceType = config.deviceType; - deviceTypes.push({ - "type": data[i].name, - "category": deviceType.category, - "label": deviceType.label, - "thumb": utility.getDeviceThumb(data[i].name) - }); } } page.deviceTypes = stringify(deviceTypes); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js index 0ae0ed8a48..e9c68c6452 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js @@ -25,47 +25,49 @@ function onRequest(context) { var viewModel = {}; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var utility = require("/app/modules/utility.js").utility; - var deviceTypes = deviceModule.getDeviceTypes(); + var typesListResponse = deviceModule.getDeviceTypes(); + if (typesListResponse["status"] == "success") { + var deviceTypes = typesListResponse["content"]; + if (deviceTypes) { + var deviceTypesList = [], virtualDeviceTypesList = []; + for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes) { - var deviceTypesList = [], virtualDeviceTypesList = []; - for (var i = 0; i < deviceTypes.length; i++) { - - var deviceTypeLabel = deviceTypes[i].name; - var configs = utility.getDeviceTypeConfig(deviceTypeLabel); - var deviceCategory = "device"; - if (configs) { - if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]) { - deviceCategory = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]; + var deviceTypeLabel = deviceTypes[i].name; + var configs = utility.getDeviceTypeConfig(deviceTypeLabel); + var deviceCategory = "device"; + if (configs) { + if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]) { + deviceCategory = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]; + } + if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) { + deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]; + } } - if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) { - deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]; + if (deviceCategory == 'virtual') { + virtualDeviceTypesList.push({ + "hasCustTemplate": false, + "deviceTypeLabel": deviceTypeLabel, + "deviceTypeName": deviceTypes[i].name, + "deviceCategory": deviceCategory, + "deviceTypeId": deviceTypes[i].id, + "thumb": utility.getDeviceThumb(deviceTypes[i].name) + }); + } else { + deviceTypesList.push({ + "hasCustTemplate": false, + "deviceTypeLabel": deviceTypeLabel, + "deviceTypeName": deviceTypes[i].name, + "deviceCategory": deviceCategory, + "deviceTypeId": deviceTypes[i].id, + "thumb": utility.getDeviceThumb(deviceTypes[i].name) + }); } } - if (deviceCategory == 'virtual') { - virtualDeviceTypesList.push({ - "hasCustTemplate": false, - "deviceTypeLabel": deviceTypeLabel, - "deviceTypeName": deviceTypes[i].name, - "deviceCategory": deviceCategory, - "deviceTypeId": deviceTypes[i].id, - "thumb": utility.getDeviceThumb(deviceTypes[i].name) - }); - } else { - deviceTypesList.push({ - "hasCustTemplate": false, - "deviceTypeLabel": deviceTypeLabel, - "deviceTypeName": deviceTypes[i].name, - "deviceCategory": deviceCategory, - "deviceTypeId": deviceTypes[i].id, - "thumb": utility.getDeviceThumb(deviceTypes[i].name) - }); + if (virtualDeviceTypesList.length > 0) { + viewModel.virtualDeviceTypesList = virtualDeviceTypesList; } + viewModel.deviceTypesList = stringify(deviceTypesList); } - if (virtualDeviceTypesList.length > 0) { - viewModel.virtualDeviceTypesList = virtualDeviceTypesList; - } - viewModel.deviceTypesList = stringify(deviceTypesList); } else { log.error("Unable to fetch device types data"); throw new Error("Unable to fetch device types!"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs index 3663b0c6e9..83b6f72333 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs @@ -15,6 +15,7 @@ specific language governing permissions and limitations under the License. }} + {{#zone "contentTitle"}}
    @@ -32,6 +33,7 @@
    {{/zone}} +{{#zone "content"}}
    @@ -193,7 +195,7 @@
    {{/defineZone}}
    - +{{/zone}} {{#zone "bottomJs"}} {{js "js/device-view.js"}} {{js "js/notification-listing.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/units/cdmf.unit.notification.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js index 0086ba8e3e..3512296bda 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js @@ -16,15 +16,16 @@ * under the License. */ -function onRequest(context){ +function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require("/app/modules/constants.js"); + var viewModel = {}; var permissions = []; - if(userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/list")){ + if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/list")) { permissions.push("LIST_NOTIFICATIONS"); } var currentUser = session.get(constants.USER_SESSION_KEY); - context.permissions = stringify(permissions); - context.currentUser = currentUser; - return context; + viewModel.permissions = stringify(permissions); + viewModel.currentUser = currentUser; + return viewModel; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 52fd96af33..f7f7db822f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -91,8 +91,8 @@ function loadNotifications(){ var successCallback = function (data) { var viewModel = {}; data = JSON.parse(data); - viewModel.notifications = data; - if(data.length > 0){ + viewModel.notifications = data.notifications; + if(data.count > 0){ var content = template(viewModel); $("#ast-container").html(content); $('#unread-notifications').datatables_extended(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs index d59fc831db..418bef892b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs @@ -16,10 +16,10 @@ {{#each notifications}} {{#equal "NEW" status }} - + {{description}} - + @@ -54,10 +54,10 @@ {{#each notifications}} - + {{description}} - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs index abdf6fd598..e4d27bc01d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs @@ -15,107 +15,109 @@ specific language governing permissions and limitations under the License. }} -
    -
    - -
    -
    +{{#zone "content"}} +
    +
    + +
    +
    -

    - Platform Configurations -

    -
    - General and Platform Specific Server Settings for the Tenant -
    -
    +

    + Platform Configurations +

    +
    + General and Platform Specific Server Settings for the Tenant +
    +
    -
    -
    -
    - - - - - General Configurations - - {{#each deviceTypes}} - - - - - {{label}} Configurations +
    +
    + + {{#each deviceTypes}} + + + + + {{label}} Configurations + + {{/each}} +
    -
    - -
    -
    - -
    - -
    - - +
    + +
    +
    + -
    - +
    + +
    + + +
    +
    + +
    -
    - - {{#each deviceTypes}} - - {{/each}} + + {{#each deviceTypes}} + + {{/each}} +
    -
    - -
    +{{/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"}}
  • - Logout + Change password
  • +
  • + Sign out +
  • + +
    + +
    +
    +
    +

    + + + + + Change Password +

    +

    + +

    + Enter old password * +

    +
    + +
    +
    + Enter new password * +

    +
    + +
    +
    + Retype new password * +

    +
    + +
    +
    +

    +
    + Update + Cancel +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    Password change is successful.

    +
    + Ok +
    +
    +
    +
    +
    +{{/zone}} +{{#zone "bottomJs"}} + {{/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/units/cdmf.unit.ui.header.user-menu/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/user-menu.js new file mode 100644 index 0000000000..e0ebe26b0a --- /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/user-menu.js @@ -0,0 +1,4 @@ +function onRequest() { + var constants = require("/app/modules/constants.js"); + return session.get(constants["USER_SESSION_KEY"]); +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf index 8397121567..dec7a25f8c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/jaggery.conf @@ -50,6 +50,10 @@ { "url": "/api/data-tables/invoker", "path": "/api/data-tables-invoker-api.jag" + }, + { + "url": "/api/operation/*", + "path": "/api/operation-api.jag" } ] } \ No newline at end of file