diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
index b74abb7dc4c..a93d3173a04 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs
@@ -47,7 +47,7 @@
-
+
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js
index cad7431f819..5a7d7eb304a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js
@@ -31,6 +31,8 @@ function inputIsValid(regExp, inputString) {
var validateInline = {};
var clearInline = {};
+var apiBasePath = "/api/device-mgt/v1.0";
+
var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField;
var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
@@ -113,12 +115,12 @@ function formatRepoSelection (user) {
}
$(document).ready(function () {
-
+ var appContext = $("#app-context").data("app-context");
$("#users").select2({
multiple:true,
tags: false,
ajax: {
- url: window.location.origin + "/devicemgt/api/invoker/execute/",
+ url: appContext + "/api/invoker/execute/",
method: "POST",
dataType: 'json',
delay: 250,
@@ -128,15 +130,17 @@ $(document).ready(function () {
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
- postData.actionUrl = "/devicemgt_admin/users/view-users?username=" + params.term;
+ postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term;
postData.actionPayload = null;
return JSON.stringify(postData);
},
processResults: function (data, page) {
var newData = [];
- $.each(data.responseContent, function (index, value) {
- value.id = value.username;
- newData.push(value);
+ $.each(data, function (index, value) {
+ var user = {};
+ user.username = value.username;
+ user.id = value.username;
+ newData.push(user);
});
return {
results: newData
@@ -153,7 +157,7 @@ $(document).ready(function () {
/**
* Following click function would execute
* when a user clicks on "Add Role" button
- * on Add Role page in WSO2 Devicemgt Console.
+ * on Add Role page in WSO2 MDM Console.
*/
$("button#add-role-btn").click(function() {
var rolenameInput = $("input#rolename");
@@ -188,7 +192,7 @@ $(document).ready(function () {
}
addRoleFormData.users = users;
- var addRoleAPI = "/devicemgt_admin/roles";
+ var addRoleAPI = apiBasePath + "/roles";
invokerUtil.post(
addRoleAPI,
@@ -205,10 +209,10 @@ $(document).ready(function () {
//// Refreshing with success message
//$("#role-create-form").addClass("hidden");
//$("#role-created-msg").removeClass("hidden");
- window.location.href = '/devicemgt/role/edit-permission/' + roleName + '?wizard=true';
+ window.location.href = appContext + '/role/edit-permission/' + roleName;
}
}, function (data) {
- if (JSON.parse(data.responseText).errorMessage.indexOf("RoleExisting") > -1) {
+ if (JSON.parse(data).errorMessage.indexOf("RoleExisting") > -1) {
$(errorMsg).text("Role name : " + roleName + " already exists. Pick another role name.");
} else {
$(errorMsg).text(JSON.parse(data.responseText).errorMessage);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs
index ad3b495e28a..26628391df3 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.hbs
@@ -78,6 +78,20 @@
+
+
+
+
+
Can't deselect child permissions when parent permission is selected.
+
+
+
+
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js
index 6829dc21e30..5790f1b7ffa 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js
@@ -26,7 +26,7 @@ function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
- var isMatched = uriMatcher.match("/{context}/roles/edit-role-permission/{rolename}");
+ var isMatched = uriMatcher.match("/{context}/role/edit-permission/{rolename}");
if (isMatched) {
var matchedElements = uriMatcher.elements();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js
index 2989ce39242..7c778de0409 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js
@@ -31,6 +31,8 @@
var modalPopup = ".wr-modalpopup";
var modalPopupContent = modalPopup + " .modalpopup-content";
+var apiBasePath = "/api/device-mgt/v1.0";
+
/*
* hide popup function.
*/
@@ -96,29 +98,33 @@ $(document).ready(function () {
var listPartialSrc = $("#list-partial").attr("src");
var treeTemplateSrc = $("#tree-template").attr("src");
var roleName = $("#permissionList").data("currentrole");
- var serviceUrl = "/devicemgt_admin/roles/permissions?rolename=" + encodeURIComponent(roleName);
+ var serviceUrl = apiBasePath + "/roles/" +encodeURIComponent(roleName)+"/permissions";
$.registerPartial("list", listPartialSrc, function(){
$.template("treeTemplate", treeTemplateSrc, function (template) {
invokerUtil.get(serviceUrl,
function(data){
data = JSON.parse(data);
- var treeData = data.responseContent;
+ var treeData = data;
if(treeData.nodeList.length > 0){
treeData = { nodeList: treeData.nodeList };
var content = template(treeData);
$("#permissionList").html(content);
- $("#permissionList").on("click", ".permissionTree .permissionItem", function() {
+ $("#permissionList").on("click", ".permissionTree .permissionItem", function(){
var parentValue = $(this).prop('checked');
$(this).closest("li").find("li input").each(function () {
$(this).prop('checked',parentValue);
});
});
}
- $("#permissionList li input").click(function() {
+ $("#permissionList li input").click(function(){
var parentInput = $(this).parents("ul:eq(1) > li").find('input:eq(0)');
if(parentInput && parentInput.is(':checked')){
- parentInput.prop('checked', false);
- return true;
+ $(modalPopupContent).html($('#child-deselect-error-content').html());
+ showPopup();
+ $("a#child-deselect-error-link").click(function () {
+ hidePopup();
+ });
+ return false;
}
});
$('#permissionList').tree_view();
@@ -135,24 +141,25 @@ $(document).ready(function () {
*/
$("button#update-permissions-btn").click(function() {
var roleName = $("#permissionList").data("currentrole");
- var updateRolePermissionAPI = "/devicemgt_admin/roles?rolename=" + roleName;
+ var updateRolePermissionAPI = apiBasePath + "/roles/" + roleName;
var updateRolePermissionData = {};
var perms = [];
$("#permissionList li input:checked").each(function(){
perms.push($(this).data("resourcepath"));
- });
+ })
updateRolePermissionData.permissions = perms;
invokerUtil.put(
updateRolePermissionAPI,
updateRolePermissionData,
- function (jqXHR) {
- if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) {
+ function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 200) {
// Refreshing with success message
$("#role-create-form").addClass("hidden");
$("#role-created-msg").removeClass("hidden");
}
}, function (data) {
- $(errorMsg).text(JSON.parse(data.responseText).errorMessage);
+ var payload = JSON.parse(data.responseText);
+ $(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
}
);
@@ -162,4 +169,4 @@ $(document).ready(function () {
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
-}
\ 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.role.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs
index 3ed8209cf72..249e35a6e3e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs
@@ -29,7 +29,7 @@
-
+
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
index f8c42854cfb..e038c32592b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js
@@ -1,21 +1,3 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
/**
* Checks if provided input is valid against RegEx input.
*
@@ -31,6 +13,8 @@ function inputIsValid(regExp, inputString) {
var validateInline = {};
var clearInline = {};
+var apiBasePath = "/api/device-mgt/v1.0";
+
var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField;
var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
@@ -113,12 +97,12 @@ function formatRepoSelection (user) {
}
$(document).ready(function () {
-
+ var appContext = $("#app-context").data("app-context");
$("#users").select2({
multiple:true,
tags: false,
ajax: {
- url: window.location.origin + "/devicemgt/api/invoker/execute/",
+ url: appContext + "/api/invoker/execute/",
method: "POST",
dataType: 'json',
delay: 250,
@@ -128,7 +112,7 @@ $(document).ready(function () {
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
- postData.actionUrl = "/devicemgt_admin/users/view-users?username=" + params.term;
+ postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term;
postData.actionPayload = null;
return JSON.stringify(postData);
},
@@ -155,7 +139,7 @@ $(document).ready(function () {
/**
* Following click function would execute
* when a user clicks on "Add Role" button
- * on Add Role page in WSO2 Devicemgt Console.
+ * on Add Role page in WSO2 MDM Console.
*/
$("button#add-role-btn").click(function() {
var rolenameInput = $("input#rolename");
@@ -183,12 +167,12 @@ $(document).ready(function () {
addRoleFormData.roleName = domain + "/" + roleName;
}
- var addRoleAPI = "/devicemgt_admin/roles?rolename=" + encodeURIComponent(currentRoleName);
+ var addRoleAPI = apiBasePath + "/roles/" + currentRoleName;
invokerUtil.put(
addRoleAPI,
addRoleFormData,
- function (jqXHR) {
- if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) {
+ function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 200) {
// Clearing user input fields.
$("input#rolename").val("");
$("#domain").val("");
@@ -197,7 +181,8 @@ $(document).ready(function () {
$("#role-created-msg").removeClass("hidden");
}
}, function (data) {
- $(errorMsg).text(JSON.parse(data.responseText).errorMessage);
+ var payload = JSON.parse(data.responseText);
+ $(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
}
);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
index 1b0991cb0a8..afeb0a393ec 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js
@@ -16,7 +16,7 @@
* under the License.
*/
var loadRoleBasedActionURL = function (action, rolename) {
- var href = $("#ast-container").data("app-context") + "roles/" + action + "?rolename=" + rolename;
+ var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename;
$(location).attr('href', href);
};
@@ -113,13 +113,13 @@ function loadRoles(searchQuery) {
class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null,
render: function ( data, type, row, meta ) {
- return '' +
'' +
'' +
'' +
'Edit' +
- '' +
'' +
'' +
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql
index 39cfc6d1722..71de29d8338 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql
@@ -587,8 +587,4 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND
DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID
ORDER BY TENANT_ID, DEVICE_ID;
--- END OF DASHBOARD RELATED VIEWS --
-
-SELECT feom.DEVICE_IDENTIFICATION, feom.DEVICE_TYPE, or.OPERATION_RESPONSE, feom.CREATED_TIMESTAMP
-FROM DM_DEVICE_OPERATION_RESPONSE dor, (SELECT eom.OPERATION_ID, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE, fe.ENROLMENT_ID, eom.CREATED_TIMESTAMP, eom.UPDATED_TIMESTAMP, or.RECEIVED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING eom, (SELECT e.ID AS ENROLMENT_ID, fd.DEVICE_ID, fd.DEVICE_IDENTIFICATION, fd.DEVICE_TYPE FROM DM_ENROLMENT e, (SELECT DISTINCT d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = -1234) fd WHERE e.DEVICE_ID = fd.DEVICE_ID AND e.TENANT_ID = -1234) fe WHERE eom.ENROLMENT_ID = fe.ENROLMENT_ID) feom WHERE or.OPERATION_ID = or.OPERATION_ID;
-
+-- END OF DASHBOARD RELATED VIEWS --
\ No newline at end of file