Merge branch 'release-3.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

revert-70aa11f8
Hasunie 8 years ago
commit 1d6bf23d67

@ -37,7 +37,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -106,8 +105,13 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_ID, registrationProfile.getConsumerKey()); jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_ID, registrationProfile.getConsumerKey());
jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_SECRET, jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_SECRET,
registrationProfile.getConsumerSecret()); registrationProfile.getConsumerSecret());
jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG, if (registrationProfile.getValidityPeriod() == 0) {
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG,
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD);
} else {
jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG,
registrationProfile.getValidityPeriod());
}
apiManagementProviderService.registerExistingOAuthApplicationToAPIApplication( apiManagementProviderService.registerExistingOAuthApplicationToAPIApplication(
jsonStringObject.toJSONString(), registrationProfile.getApplicationName(), jsonStringObject.toJSONString(), registrationProfile.getApplicationName(),
registrationProfile.getConsumerKey(), username, registrationProfile.isAllowedToAllDomains(), registrationProfile.getConsumerKey(), username, registrationProfile.isAllowedToAllDomains(),

@ -41,6 +41,8 @@ public class RegistrationProfile {
private boolean isMappingAnExistingOAuthApp; private boolean isMappingAnExistingOAuthApp;
private String consumerKey; private String consumerKey;
private String consumerSecret; private String consumerSecret;
@XmlElement(required = false)
private int validityPeriod;
public String getApplicationName() { public String getApplicationName() {
return applicationName; return applicationName;
@ -89,4 +91,12 @@ public class RegistrationProfile {
public void setConsumerSecret(String consumerSecret) { public void setConsumerSecret(String consumerSecret) {
this.consumerSecret = consumerSecret; this.consumerSecret = consumerSecret;
} }
public int getValidityPeriod() {
return validityPeriod;
}
public void setValidityPeriod(int validityPeriod) {
this.validityPeriod = validityPeriod;
}
} }

@ -105,6 +105,11 @@ public class GroupDAOImpl implements GroupDAO {
stmt.setInt(1, groupId); stmt.setInt(1, groupId);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
sql = "DELETE FROM DM_DEVICE_GROUP_POLICY WHERE DEVICE_GROUP_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, groupId);
stmt.setInt(2, tenantId);
stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while removing mappings for group.'", e); throw new GroupManagementDAOException("Error occurred while removing mappings for group.'", e);
} finally { } finally {

@ -1903,6 +1903,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
defaultGroup = new DeviceGroup(groupName); defaultGroup = new DeviceGroup(groupName);
// Setting system level user (wso2.system.user) as the owner // Setting system level user (wso2.system.user) as the owner
defaultGroup.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME); defaultGroup.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
defaultGroup.setDescription("Default system group for devices with " + groupName + " ownership.");
try { try {
service.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE, service.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE,
DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS); DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS);

@ -500,10 +500,11 @@ var userModule = function () {
publicMethods.getUIPermissions = function () { publicMethods.getUIPermissions = function () {
var permissions = {}; var permissions = {};
if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/list")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/any-device")) {
permissions["LIST_DEVICES"] = true; permissions["LIST_DEVICES"] = true;
permissions["LIST_OWN_DEVICES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/owning-device")) {
permissions["LIST_OWN_DEVICES"] = true; permissions["LIST_OWN_DEVICES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) {
@ -524,10 +525,10 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) {
permissions["LIST_POLICIES"] = true; permissions["LIST_POLICIES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/add")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/add")) {
permissions["ADD_DEVICE"] = true; permissions["ADD_DEVICE"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/add")) {
permissions["ADD_GROUP"] = true; permissions["ADD_GROUP"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/add")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/add")) {
@ -542,9 +543,6 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/view")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/view")) {
permissions["VIEW_GROUP_DEVICES"] = true; permissions["VIEW_GROUP_DEVICES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/create")) {
permissions["CREATE_GROUP_ROLES"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/view")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/view")) {
permissions["VIEW_GROUP_ROLES"] = true; permissions["VIEW_GROUP_ROLES"] = true;
} }

@ -60,6 +60,8 @@ var WEB_SERVICE_ADDRESSING_VERSION = 1.0;
var TOKEN_PAIR = "tokenPair"; var TOKEN_PAIR = "tokenPair";
var ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS = "encodedTenantBasedClientAppCredentials"; var ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS = "encodedTenantBasedClientAppCredentials";
var CONTENT_TYPE_IDENTIFIER = "Content-Type"; var CONTENT_TYPE_IDENTIFIER = "Content-Type";
var ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS = "encodedTenantBasedWebSocketClientCredentials";
var CONTENT_DISPOSITION_IDENTIFIER = "Content-Disposition"; var CONTENT_DISPOSITION_IDENTIFIER = "Content-Disposition";
var APPLICATION_JSON = "application/json"; var APPLICATION_JSON = "application/json";
var APPLICATION_ZIP = "application/zip"; var APPLICATION_ZIP = "application/zip";
@ -76,4 +78,6 @@ var HTTP_CONFLICT = 409;
var HTTP_CREATED = 201; var HTTP_CREATED = 201;
var CACHED_CREDENTIALS = "tenantBasedCredentials"; var CACHED_CREDENTIALS = "tenantBasedCredentials";
var CACHED_CREDENTIALS_FOR_WEBSOCKET_APP = "tenantBasedWebSocketClientCredentials";
var ALLOWED_SCOPES = "scopes"; var ALLOWED_SCOPES = "scopes";

@ -29,7 +29,9 @@ var carbonServer = new carbonModule.server.Server({
application.put("carbonServer", carbonServer); application.put("carbonServer", carbonServer);
var permissions = { var permissions = {
"/permission/admin/device-mgt/devices": ["ui.execute"], "/permission/admin/device-mgt/devices/enroll": ["ui.execute"],
"/permission/admin/device-mgt/devices/disenroll": ["ui.execute"],
"/permission/admin/device-mgt/devices/owning-device": ["ui.execute"],
"/permission/admin/device-mgt/groups": ["ui.execute"], "/permission/admin/device-mgt/groups": ["ui.execute"],
"/permission/admin/device-mgt/notifications": ["ui.execute"], "/permission/admin/device-mgt/notifications": ["ui.execute"],
"/permission/admin/device-mgt/policies": ["ui.execute"], "/permission/admin/device-mgt/policies": ["ui.execute"],

@ -138,6 +138,63 @@ var utils = function () {
} }
}; };
publicMethods["getTenantBasedWebSocketClientAppCredentials"] = function (username) {
if (!username) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
"based client app credentials. No username " +
"as input - getTenantBasedWebSocketClientAppCredentials(x)");
return null;
} else {
//noinspection JSUnresolvedFunction, JSUnresolvedVariable
var tenantDomain = carbon.server.tenantDomain({username: username});
if (!tenantDomain) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
"based client application credentials. Unable to obtain a valid tenant domain for provided " +
"username - getTenantBasedWebSocketClientAppCredentials(x, y)");
return null;
} else {
var cachedBasedWebsocketClientAppCredentials = privateMethods.
getCachedBasedWebSocketClientAppCredentials(tenantDomain);
if (cachedBasedWebsocketClientAppCredentials) {
return cachedBasedWebsocketClientAppCredentials;
} else {
var adminUsername = deviceMgtProps["adminUser"];
var adminUserTenantId = deviceMgtProps["adminUserTenantId"];
//claims required for jwtAuthenticator.
var claims = {"http://wso2.org/claims/enduserTenantId": adminUserTenantId,
"http://wso2.org/claims/enduser": adminUsername};
var jwtToken = publicMethods.getJwtToken(adminUsername, claims);
// register a tenant based app at API Manager
var applicationName = "websocket_webapp_" + tenantDomain;
var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"]
["apiManagerClientAppRegistrationServiceURL"] +
"?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName;
var xhr = new XMLHttpRequest();
xhr.open("POST", requestURL, false);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-JWT-Assertion", "" + jwtToken);
xhr.send();
if (xhr["status"] == 201 && xhr["responseText"]) {
var responsePayload = parse(xhr["responseText"]);
var tenantTenantBasedWebsocketClientAppCredentials = {};
tenantTenantBasedWebsocketClientAppCredentials["clientId"] = responsePayload["client_id"];
tenantTenantBasedWebsocketClientAppCredentials["clientSecret"] =
responsePayload["client_secret"];
privateMethods.setCachedBasedWebSocketClientAppCredentials(tenantDomain,
tenantTenantBasedWebsocketClientAppCredentials);
return tenantTenantBasedWebsocketClientAppCredentials;
} else {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
"based client application credentials from API " +
"Manager - getTenantBasedWebSocketClientAppCredentials(x, y)");
return null;
}
}
}
}
};
privateMethods["setCachedTenantBasedClientAppCredentials"] = function (tenantDomain, clientAppCredentials) { privateMethods["setCachedTenantBasedClientAppCredentials"] = function (tenantDomain, clientAppCredentials) {
var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]); var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]);
if (!cachedTenantBasedClientAppCredentialsMap) { if (!cachedTenantBasedClientAppCredentialsMap) {
@ -159,7 +216,32 @@ var utils = function () {
} }
}; };
publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { privateMethods["getCachedBasedWebSocketClientAppCredentials"] = function (tenantDomain) {
var cachedBasedWebSocketClientAppCredentialsMap
= application.get(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]);
if (!cachedBasedWebSocketClientAppCredentialsMap ||
!cachedBasedWebSocketClientAppCredentialsMap[tenantDomain]) {
return null;
} else {
return cachedBasedWebSocketClientAppCredentialsMap[tenantDomain];
}
};
privateMethods["setCachedBasedWebSocketClientAppCredentials"] = function (tenantDomain, clientAppCredentials) {
var cachedBasedWebSocketClientAppCredentialsMap
= application.get(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]);
if (!cachedBasedWebSocketClientAppCredentialsMap) {
cachedBasedWebSocketClientAppCredentialsMap = {};
cachedBasedWebSocketClientAppCredentialsMap[tenantDomain] = clientAppCredentials;
application.put(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]
, cachedBasedWebSocketClientAppCredentialsMap);
} else if (!cachedBasedWebSocketClientAppCredentialsMap[tenantDomain]) {
cachedBasedWebSocketClientAppCredentialsMap[tenantDomain] = clientAppCredentials;
}
};
publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password
, encodedClientAppCredentials, scopes) {
if (!username || !password || !encodedClientAppCredentials || !scopes) { if (!username || !password || !encodedClientAppCredentials || !scopes) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " + log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " +
"grant type. No username, password, encoded client app credentials or scopes are " + "grant type. No username, password, encoded client app credentials or scopes are " +

@ -39,6 +39,7 @@ var handlers = function () {
"as input - setupTokenPairByPasswordGrantType(x, y)"); "as input - setupTokenPairByPasswordGrantType(x, y)");
} else { } else {
privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (!encodedClientAppCredentials) { if (!encodedClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " +
@ -81,6 +82,7 @@ var handlers = function () {
"as input - setupTokenPairByPasswordGrantType(x, y)"); "as input - setupTokenPairByPasswordGrantType(x, y)");
} else { } else {
privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (!encodedClientAppCredentials) { if (!encodedClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair " +
@ -168,5 +170,44 @@ var handlers = function () {
} }
}; };
privateMethods["setUpEncodedTenantBasedWebSocketClientAppCredentials"] = function (username) {
if (!username) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context. No username of logged in user is found as " +
"input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
} else {
if (devicemgtProps["apimgt-gateway"]) {
var tenantBasedWebSocketClientAppCredentials
= tokenUtil.getTenantBasedWebSocketClientAppCredentials(username);
if (!tenantBasedWebSocketClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " +
"based client credentials to session context as the server is unable " +
"to obtain such credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
} else {
var encodedTenantBasedWebSocketClientAppCredentials =
tokenUtil.encode(tenantBasedWebSocketClientAppCredentials["clientId"] + ":" +
tenantBasedWebSocketClientAppCredentials["clientSecret"]);
// setting up encoded tenant based client credentials to session context.
session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"],
encodedTenantBasedWebSocketClientAppCredentials);
}
} else {
var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials();
if (!dynamicClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context as the server is unable to obtain " +
"dynamic client credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
}
var encodedTenantBasedWebSocketClientAppCredentials =
tokenUtil.encode(dynamicClientAppCredentials["clientId"] + ":" +
dynamicClientAppCredentials["clientSecret"]);
// setting up encoded tenant based client credentials to session context.
session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"],
encodedTenantBasedWebSocketClientAppCredentials);
}
}
};
return publicMethods; return publicMethods;
}(); }();

@ -36,9 +36,11 @@
<div class="form-login-box"> <div class="form-login-box">
<label class="wr-input-label">Group Name</label> <label class="wr-input-label">Group Name</label>
<div class="wr-input-control"> <div class="form-group wr-input-control">
<input type="text right" id="name" placeholder="Group Name" data-regex="{{groupNameJSRegEx}}" <input type="text right" id="name" placeholder="Group Name" data-regex="{{groupNameJSRegEx}}"
data-errormsg="{{groupNameRegExViolationErrorMsg}}"> data-errormsg="{{groupNameRegExViolationErrorMsg}}" class="form-control">
<span class="groupNameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error groupNameEmpty hidden" for="summary"></label>
</div> </div>
<label class="wr-input-label">Description</label> <label class="wr-input-label">Description</label>

@ -35,12 +35,10 @@ $(function () {
var description = $("input#description").val(); var description = $("input#description").val();
if (!name) { if (!name) {
$('.wr-validation-summary strong').text("Group Name is a required field. It cannot be empty."); triggerError($("input#name"),"Group Name is a required field. It cannot be empty.");
$('.wr-validation-summary').removeClass("hidden");
return false; return false;
} else if (!inputIsValid($("input#name").data("regex"), name)) { } else if (!inputIsValid($("input#name").data("regex"), name)) {
$('.wr-validation-summary strong').text($("input#name").data("errormsg")); triggerError($("input#name"),$("input#name").data("errormsg"));
$('.wr-validation-summary').removeClass("hidden");
return false; return false;
} else { } else {
var group = {"name": name, "description": description}; var group = {"name": name, "description": description};
@ -69,6 +67,61 @@ $(function () {
}); });
}); });
/**
* @param el
* @param errorMsg
*
* Triggers validation error for provided element.
* Note : the basic jQuery validation elements should be present in the markup
*
*/
function triggerError(el,errorMsg){
var parent = el.parents('.form-group'),
errorSpan = parent.find('span'),
errorMsgContainer = parent.find('label');
errorSpan.on('click',function(event){
event.stopPropagation();
removeErrorStyling($(this));
el.unbind('.errorspace');
});
el.bind('focusin.errorspace',function(){
removeErrorStyling($(this))
}).bind('focusout.errorspace',function(){
addErrorStyling($(this));
}).bind('keypress.errorspace',function(){
$(this).unbind('.errorspace');
removeErrorStyling($(this));
});
errorMsgContainer.text(errorMsg);
parent.addClass('has-error has-feedback');
errorSpan.removeClass('hidden');
errorMsgContainer.removeClass('hidden');
function removeErrorStyling(el){
var parent = el.parents('.form-group'),
errorSpan = parent.find('span'),
errorMsgContainer = parent.find('label');
parent.removeClass('has-error has-feedback');
errorSpan.addClass('hidden');
errorMsgContainer.addClass('hidden');
}
function addErrorStyling(el){
var parent = el.parents('.form-group'),
errorSpan = parent.find('span'),
errorMsgContainer = parent.find('label');
parent.addClass('has-error has-feedback');
errorSpan.removeClass('hidden');
errorMsgContainer.removeClass('hidden');
}
}
function displayErrors(message) { function displayErrors(message) {
$('#error-msg').html(message.responseText); $('#error-msg').html(message.responseText);
modalDialog.header('Unexpected error occurred!'); modalDialog.header('Unexpected error occurred!');

@ -93,7 +93,7 @@ function loadGroups() {
var currentUser = groupListing.data("currentUser"); var currentUser = groupListing.data("currentUser");
var serviceURL; var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) { if ($.hasPermission("LIST_ALL_GROUPS")) {
serviceURL = "/api/device-mgt/v1.0/groups"; serviceURL = "/api/device-mgt/v1.0/admin/groups";
} else if ($.hasPermission("LIST_GROUPS")) { } else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups //Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser; serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser;
@ -113,8 +113,7 @@ function loadGroups() {
groupId: data.deviceGroups[index].id, groupId: data.deviceGroups[index].id,
name: data.deviceGroups[index].name, name: data.deviceGroups[index].name,
description: data.deviceGroups[index].description, description: data.deviceGroups[index].description,
owner: data.deviceGroups[index].owner, owner: data.deviceGroups[index].owner
dateOfCreation: data.deviceGroups[index].dateOfCreation
}) })
}); });
var json = { var json = {
@ -153,7 +152,7 @@ function loadGroups() {
data: 'id', data: 'id',
class: 'text-right content-fill text-left-on-grid-view no-wrap', class: 'text-right content-fill text-left-on-grid-view no-wrap',
render: function (id, type, row, meta) { render: function (id, type, row, meta) {
var html; var html = '';
if ($.hasPermission("VIEW_GROUP_DEVICES")) { if ($.hasPermission("VIEW_GROUP_DEVICES")) {
html = '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name html = '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name
+ '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' + + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
@ -166,46 +165,39 @@ function loadGroups() {
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>'
+ +
'<span class="hidden-xs hidden-on-grid-view">Analytics</span></a>'; '<span class="hidden-xs hidden-on-grid-view">Analytics</span></a>';
} else {
html = '';
}
if ($.hasPermission("SHARE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view share-group-link" data-group-id="'
+ row.groupId + '" ' +
'data-group-owner="' + row.owner
+ '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-share fw-stack-1x"></i></span>'
+
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
} else {
html += '';
}
if ($.hasPermission("UPDATE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="'
+ row.name + '" ' +
'data-group-owner="' + row.owner + '" data-group-description="' + row.description
+ '" data-group-id="' + row.groupId
+ '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
} else {
html += '';
} }
if ($.hasPermission("REMOVE_GROUP")) { if (row.owner != "wso2.system.user") {
html += if ($.hasPermission("SHARE_GROUP")) {
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-id="' html +=
+ row.groupId + '" ' + '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view share-group-link" data-group-id="'
'data-group-owner="' + row.owner + row.groupId + '" ' +
+ '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>' 'data-group-owner="' + row.owner
+ + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-share fw-stack-1x"></i></span>'
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>'; +
} else { '<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
html += ''; }
if ($.hasPermission("UPDATE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="'
+ row.name + '" ' +
'data-group-owner="' + row.owner + '" data-group-description="' + row.description
+ '" data-group-id="' + row.groupId
+ '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
}
if ($.hasPermission("REMOVE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-id="'
+ row.groupId + '" ' +
'data-group-owner="' + row.owner
+ '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>'
+
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
}
} }
return html; return html;
} }
} }
]; ];
var fnCreatedRow = function (row, data) { var fnCreatedRow = function (row, data) {

@ -20,6 +20,7 @@
var deviceId = $(".device-id"); var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid"); var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
var deviceOwner = deviceId.data("owner");
$(document).ready(function () { $(document).ready(function () {
$(".panel-body").removeClass("hidden"); $(".panel-body").removeClass("hidden");
@ -54,76 +55,78 @@
return; return;
} }
operationTable = $(operationsLogTable).datatables_extended({ operationTable = $(operationsLogTable).datatables_extended({
serverSide: true, serverSide: true,
processing: false, processing: false,
searching: false, searching: false,
ordering: false, ordering: false,
pageLength : 10, pageLength : 10,
order: [], order: [],
ajax: { ajax: {
url: context + "/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType}, url: "/devicemgt/api/operation/paginate",
dataSrc: function (json) { data: {deviceId : deviceIdentifier, deviceType: deviceType, owner: deviceOwner},
$("#operations-spinner").addClass("hidden"); dataSrc: function (json) {
$("#operations-log-container").empty(); $("#operations-spinner").addClass("hidden");
return json.data; $("#operations-log-container").empty();
} return json.data;
}, }
columnDefs: [ },
{targets: 0, data: "code" }, columnDefs: [
{targets: 1, data: "status", render: {targets: 0, data: "code" },
function (status) { {targets: 1, data: "status", render:
var html; function (status) {
switch (status) { var html;
case "COMPLETED" : switch (status) {
html = "<span><i class='fw fw-ok icon-success'></i> Completed</span>"; case "COMPLETED" :
break; html = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
case "PENDING" : break;
html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>"; case "PENDING" :
break; html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
case "ERROR" : break;
html = "<span><i class='fw fw-error icon-danger'></i> Error</span>"; case "ERROR" :
break; html = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
case "IN_PROGRESS" : break;
html = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>"; case "IN_PROGRESS" :
break; html = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
case "REPEATED" : break;
html = "<span><i class='fw fw-ok icon-warning'></i> Repeated</span>"; case "REPEATED" :
break; html = "<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
} break;
return html; }
} return html;
}, }
{targets: 2, data: "createdTimeStamp", render: },
function (date) { {targets: 2, data: "createdTimeStamp", render:
var value = String(date); function (date) {
return value.slice(0, 16); var value = String(date);
} return value.slice(0, 16);
} }
], }
"createdRow": function(row, data) { ],
$(row).attr("data-type", "selectable"); "createdRow": function(row, data) {
$(row).attr("data-id", data["id"]);
$.each($("td", row), $(row).attr("data-type", "selectable");
function(colIndex) { $(row).attr("data-id", data["id"]);
switch(colIndex) { $.each($("td", row),
case 1: function(colIndex) {
$(this).attr("data-grid-label", "Code"); switch(colIndex) {
$(this).attr("data-display", data["code"]); case 1:
break; $(this).attr("data-grid-label", "Code");
case 2: $(this).attr("data-display", data["code"]);
$(this).attr("data-grid-label", "Status"); break;
$(this).attr("data-display", data["status"]); case 2:
break; $(this).attr("data-grid-label", "Status");
case 3: $(this).attr("data-display", data["status"]);
$(this).attr("data-grid-label", "Created Timestamp"); break;
$(this).attr("data-display", data["createdTimeStamp"]); case 3:
break; $(this).attr("data-grid-label", "Created Timestamp");
} $(this).attr("data-display", data["createdTimeStamp"]);
} break;
); }
} }
}); );
}
});
} }
function loadPolicyCompliance() { function loadPolicyCompliance() {
@ -175,7 +178,7 @@
} else { } else {
$("#policy-list-container"). $("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> This device " + html("<div class='panel-body'><br><p class='fw-warning'> This device " +
"has no policy applied.<p></div>"); "has no policy applied.<p></div>");
} }
} }
}, },
@ -183,7 +186,7 @@
function () { function () {
$("#policy-list-container"). $("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " + html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>"); "was not successful. please try refreshing data in a while.<p></div>");
} }
); );
} }
@ -193,7 +196,7 @@
function () { function () {
$("#policy-list-container"). $("#policy-list-container").
html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " + html("<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " +
"was not successful. please try refreshing data in a while.<p></div>"); "was not successful. please try refreshing data in a while.<p></div>");
} }
); );
} }

@ -1,24 +0,0 @@
<table class="table table-striped table-hover table-bordered display data-table" id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
{{#each operations}}
<tr data-type="selectable" data-id="{{id}}">
<td data-display="{{code}}" data-grid-label="Code">{{code}}</td>
<td data-display="{{status}}" data-grid-label="Status">
{{#equal status "COMPLETED"}}<span><i class="fw fw-ok icon-success"></i> Completed</span>{{/equal}}
{{#equal status "PENDING"}}<span><i class="fw fw-warning icon-warning"></i> Pending</span>{{/equal}}
{{#equal status "ERROR"}}<span><i class="fw fw-error icon-danger"></i> Error</span>{{/equal}}
{{#equal status "IN_PROGRESS"}}<span><i class="fw fw-ok icon-warning"></i> In Progress</span>{{/equal}}
</td>
<td data-display="{{createdTimeStamp}}" data-grid-label="Created Timestamp">{{createdTimeStamp}}</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -59,141 +59,108 @@
</div> </div>
</div> </div>
{{#defineZone "device-detail-properties"}} <div class="media tab-responsive">
<div class="media"> <div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs">
<ul class="list-group nav nav-pills nav-stacked" role="tablist">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2"> {{#defineZone "device-view-tabs"}}
<ul class="list-group" role="tablist"> {{#defineZone "device-details-tab"}}
<li class="active"><a class="list-group-item" <li role="presentation" class="list-group-item active">
href="#device_details" <a href="#device_details_tab" role="tab" data-toggle="tab"
role="tab" data-toggle="tab" aria-controls="device_details_tab">
aria-controls="device_details">Device <i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span>
Details</a> </a>
</li> </li>
<li><a class="list-group-item" href="#policies" {{/defineZone}}
role="tab" {{#defineZone "device-details-tab-injected"}}
data-toggle="tab" aria-controls="policies">Policies</a> {{/defineZone}}
</li> {{#defineZone "device-details-tab-operations"}}
<li><a class="list-group-item" href="#policy_compliance" <li role="presentation" class="list-group-item">
role="tab" <a href="#event_log_tab" role="tab" data-toggle="tab" aria-controls="event_log_tab">
data-toggle="tab" aria-controls="policy_compliance">Policy <i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
Compliance</a> </a>
</li> </li>
<li><a class="list-group-item" href="#device_location" {{/defineZone}}
role="tab" {{/defineZone}}
data-toggle="tab" aria-controls="device_location">Device </ul>
Location</a> </div>
</li> <div class="media-body add-padding-left-5x remove-padding-xs">
<li><a class="list-group-item" href="#event_log" role="tab" <div class="panel-group tab-content remove-padding" id="tabs" role="tablist"
data-toggle="tab" aria-controls="event_log">Operations data-status="{{device.isNotRemoved}}" aria-multiselectable="true">
Log</a></li> <div class="arrow-left hidden-xs"></div>
</ul>
</div> {{#defineZone "device-view-tab-contents"}}
{{#defineZone "device-details-tab-contents"}}
<div class="media-body add-padding-left-5x remove-padding-xs tab-content"> <div class="message message-info">
<div class="panel-group tab-content"> <h4 class="remove-margin">
<i class="icon fw fw-info"></i>
<div class="panel panel-default tab-pane active" No Device details avaialbe yet.
id="device_details" role="tabpanel" </h4>
aria-labelledby="device_details">
{{unit "cdmf.unit.device.details" device=device}}
</div>
<div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policies">
<div class="panel-heading">Policies</div>
<div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Policies . . .
<br>
<br>
</div>
<div id="policy-list-container">
<div class="panel-body">
No policies found
</div>
<br class="c-both" />
</div>
</div> </div>
<a class="padding-left" {{/defineZone}}
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div>
<div class="panel panel-default tab-pane" id="policy_compliance"
role="tabpanel" aria-labelledby="policy_compliance">
<div class="panel-heading">Policy Compliance <span><a
href="#" id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="policy-spinner"
class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i> {{#defineZone "device-view-tab-injected-conents"}}
{{/defineZone}}
Loading Policy Compliance . . . {{#defineZone "device-view-tab-operations-log-conents"}}
<br> <div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab">
<br> <div class="panel-heading visible-xs collapsed" id="event_log">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#tabs"
href="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
<i class="fw fw-text fw-2x"></i>
Operations Log
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div> </div>
<div id="policy-list-container"> <div class="panel-heading display-none-xs">
<div class="panel-body"> Operations Log
Not available yet <span>
</div> <a href="javascript:void(0);" id="refresh-operations">
<br class="c-both" /> <i class="fw fw-refresh"></i>
</div> </a>
</div> </span>
</div>
<div class="panel panel-default tab-pane" id="device_location"
role="tabpanel" aria-labelledby="device_location">
<div class="panel-heading">Device Location</div>
<div class="panel-body">
<div id="device-location"
data-lat="{{device.viewModel.location.latitude}}"
data-long="{{device.viewModel.location.longitude}}"
style="height:450px" class="panel-body">
</div>
<div id="map-error" class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
<div class="panel panel-default tab-pane" id="event_log"
role="tabpanel" aria-labelledby="event_log">
<div class="panel-heading">Operations Log <span><a href="#"
id="refresh-operations"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="operations-spinner"
class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Operations Log . . .
<br>
<br>
</div> </div>
<div id="operations-log-container"> <div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-body"> <div class="panel-body">
Not available yet <span class="visible-xs add-padding-2x text-right">
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Operations Log...
</div>
<div id="operations-log-container">
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
There are no operations, performed yet on this device.
</h4>
</div>
</div>
<table class="table table-striped table-hover table-bordered display data-table"
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div> </div>
<br class="c-both" />
</div> </div>
</div> </div>
</div> {{/defineZone}}
</div> {{/defineZone}}
</div> </div>
</div> </div>
</div>
{{/defineZone}}
</div> </div>
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
@ -206,6 +173,7 @@
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Device not found Device not found
</h1> </h1>
</h1>
<br> <br>
You have tried to access either a removed or non-existing device. You have tried to access either a removed or non-existing device.
{{/if}} {{/if}}
@ -221,7 +189,4 @@
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
{{/zone}} {{/zone}}

@ -95,8 +95,8 @@ function onRequest(context) {
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["internalMemory"]["usage"] = Math. viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else { } else {
viewModel["internalMemory"]["usage"] = 0; viewModel["internalMemory"]["usage"] = 0;
} }
@ -107,8 +107,8 @@ function onRequest(context) {
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["externalMemory"]["usage"] = Math. viewModel["externalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else { } else {
viewModel["externalMemory"]["usage"] = 0; viewModel["externalMemory"]["usage"] = 0;
} }
@ -122,8 +122,8 @@ function onRequest(context) {
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) {
viewModel["internalMemory"]["usage"] = Math. viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100;
} else { } else {
viewModel["internalMemory"]["usage"] = 0; viewModel["internalMemory"]["usage"] = 0;
} }
@ -162,8 +162,8 @@ function onRequest(context) {
if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
viewModel["ramUsage"]["value"] = Math. viewModel["ramUsage"]["value"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] - round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] -
filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"]) filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"])
/ filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100; / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100;
} else { } else {
viewModel["ramUsage"]["value"] = 0; viewModel["ramUsage"]["value"] = 0;
} }
@ -174,8 +174,8 @@ function onRequest(context) {
if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) {
viewModel["internalMemory"]["usage"] = Math. viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] - round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] -
filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]) filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100; / filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100;
} else { } else {
viewModel["internalMemory"]["usage"] = 0; viewModel["internalMemory"]["usage"] = 0;
} }
@ -186,8 +186,8 @@ function onRequest(context) {
if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) {
viewModel["externalMemory"]["usage"] = Math. viewModel["externalMemory"]["usage"] = Math.
round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] - round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] -
filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"]) filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100; / filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100;
} else { } else {
viewModel["externalMemory"]["usage"] = 0; viewModel["externalMemory"]["usage"] = 0;
} }
@ -196,7 +196,7 @@ function onRequest(context) {
viewModel["deviceInfoAvailable"] = false; viewModel["deviceInfoAvailable"] = false;
} }
deviceViewData["deviceView"] = viewModel; deviceViewData["device"] = viewModel;
} else if (response["status"] == "unauthorized") { } else if (response["status"] == "unauthorized") {
deviceViewData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = false; deviceViewData["isAuthorized"] = false;

@ -59,6 +59,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
} }
}; };
/**
* Load all device groups.
*
* @param callback function to call on loading completion.
*/
function loadGroups(callback) { function loadGroups(callback) {
invokerUtil.get( invokerUtil.get(
"/api/device-mgt/v1.0/groups", "/api/device-mgt/v1.0/groups",
@ -68,6 +73,12 @@ function loadGroups(callback) {
}); });
} }
/**
* Creates DeviceGroupWrapper object from selected groups.
*
* @param selectedGroups
* @returns {Array} DeviceGroupWrapper list.
*/
var createDeviceGroupWrapper = function (selectedGroups) { var createDeviceGroupWrapper = function (selectedGroups) {
var groupObjects = []; var groupObjects = [];
loadGroups(function (deviceGroups) { loadGroups(function (deviceGroups) {
@ -136,7 +147,6 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) { $.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
var content = template(); var content = template();
$("#device-type-policy-operations").html(content).removeClass("hidden"); $("#device-type-policy-operations").html(content).removeClass("hidden");
// $("#device-type-policy-operations").removeClass("hidden");
$(".policy-platform").addClass("hidden"); $(".policy-platform").addClass("hidden");
}); });

@ -63,7 +63,7 @@
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert"> <div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<div> <div class="clearfix">
<label class="wr-input-label"> <label class="wr-input-label">
Set a name * to your policy<br> Set a name * to your policy<br>
( should be 1-to-30 characters long ) ( should be 1-to-30 characters long )

@ -63,6 +63,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
} }
}; };
/**
* Load all device groups.
*
* @param callback function to call on loading completion.
*/
function loadGroups(callback) { function loadGroups(callback) {
invokerUtil.get( invokerUtil.get(
"/api/device-mgt/v1.0/groups", "/api/device-mgt/v1.0/groups",
@ -72,12 +77,18 @@ function loadGroups(callback) {
}); });
} }
/**
* Creates DeviceGroupWrapper object from selected groups.
*
* @param selectedGroups
* @returns {Array} DeviceGroupWrapper list.
*/
var createDeviceGroupWrapper = function (selectedGroups) { var createDeviceGroupWrapper = function (selectedGroups) {
var groupObjects = []; var groupObjects = [];
loadGroups(function (deviceGroups) { loadGroups(function (deviceGroups) {
var tenantId = $("#logged-in-user").data("tenant-id"); var tenantId = $("#logged-in-user").data("tenant-id");
for (var index in deviceGroups) { for (var index in deviceGroups) {
if(deviceGroups.hasOwnProperty(index)) { if (deviceGroups.hasOwnProperty(index)) {
var deviceGroupWrapper = {}; var deviceGroupWrapper = {};
if (selectedGroups.indexOf(deviceGroups[index].name) > -1) { if (selectedGroups.indexOf(deviceGroups[index].name) > -1) {
deviceGroupWrapper.id = deviceGroups[index].id; deviceGroupWrapper.id = deviceGroups[index].id;
@ -132,7 +143,18 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
currentlyEffected["roles"] = policyPayloadObj.roles; currentlyEffected["roles"] = policyPayloadObj.roles;
currentlyEffected["users"] = policyPayloadObj.users; currentlyEffected["users"] = policyPayloadObj.users;
currentlyEffected["groups"] = policyPayloadObj.deviceGroups; currentlyEffected["groups"] = [];
if (policyPayloadObj.deviceGroups) {
var deviceGroups = policyPayloadObj.deviceGroups;
for (var index in deviceGroups) {
if (deviceGroups.hasOwnProperty(index)) {
currentlyEffected["groups"].push(deviceGroups[index].name);
}
}
} else {
currentlyEffected["groups"].push("NONE");
}
if (currentlyEffected["roles"].length > 0) { if (currentlyEffected["roles"].length > 0) {
$("#user-roles-radio-btn").prop("checked", true); $("#user-roles-radio-btn").prop("checked", true);
@ -146,7 +168,7 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
userInput.val(currentlyEffected["users"]).trigger("change"); userInput.val(currentlyEffected["users"]).trigger("change");
} }
if(currentlyEffected["groups"].length > 0) { if (currentlyEffected["groups"].length > 0) {
groupsInput.val(currentlyEffected["groups"]).trigger("change"); groupsInput.val(currentlyEffected["groups"]).trigger("change");
} }
@ -178,8 +200,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = policyOperationsScriptSrc; script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script); $(".wr-advance-operations").prepend(script);
var configuredOperations = operationModule. var configuredOperations = operationModule.populateProfile(policy["platform"],
populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); policyPayloadObj["profile"]["profileFeaturesList"]);
polulateProfileOperations(configuredOperations); polulateProfileOperations(configuredOperations);
} }
}); });
@ -222,7 +244,7 @@ stepForwardFrom["policy-criteria"] = function () {
} }
}); });
policy["selectedGroups"] = $("#groups-input").val(); policy["selectedGroups"] = $("#groups-input").val();
if (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE") { if (policy["selectedGroups"] && (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE")) {
policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]); policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]);
} }
@ -422,7 +444,7 @@ var updatePolicy = function (policy, state) {
payload["roles"] = []; payload["roles"] = [];
} }
if(policy["selectedGroups"]) { if (policy["selectedGroups"]) {
payload["deviceGroups"] = policy["selectedGroups"]; payload["deviceGroups"] = policy["selectedGroups"];
} }

@ -30,22 +30,13 @@
</a> </a>
</li> </li>
{{/if}} {{/if}}
{{#if permissions.LIST_DEVICES_ADMIN}} {{#if permissions.LIST_OWN_DEVICES}}
<li> <li>
<a href="{{@app.context}}/devices"> <a href="{{@app.context}}/devices">
<i class="fw fw-mobile"></i> <i class="fw fw-mobile"></i>
Device Management Device Management
</a> </a>
</li> </li>
{{else}}
{{#if permissions.LIST_OWN_DEVICES}}
<li>
<a href="{{@app.context}}/devices">
<i class="fw fw-mobile"></i>
Device Management
</a>
</li>
{{/if}}
{{/if}} {{/if}}
{{#if permissions.LIST_GROUPS}} {{#if permissions.LIST_GROUPS}}
<li> <li>

@ -6511,3 +6511,13 @@ select > option:hover {
.required:before { .required:before {
content: "*"; content: "*";
} }
.table.list-table:not(.grid-view){
margin: 0px !important;
}
.table.list-table:not(.grid-view) > thead, .table.list-table:not(.grid-view) > tbody, .table.list-table:not(.grid-view) > tfoot{
margin-bottom: 10px !important;
}
.table.list-table:not(.grid-view) tbody{
margin: 0px !important;
}

@ -26,9 +26,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.mdm</groupId>
<artifactId>dynamic-client-web-proxy</artifactId> <artifactId>dynamic-client-web-proxy</artifactId>
<version>2.0.2-SNAPSHOT</version>
<name>WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service</name> <name>WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web Proxy</description> <description>WSO2 Carbon - Dynamic Client Registration Web Proxy</description>
<packaging>war</packaging> <packaging>war</packaging>

@ -26,9 +26,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.mdm</groupId>
<artifactId>dynamic-client-web</artifactId> <artifactId>dynamic-client-web</artifactId>
<version>2.0.2-SNAPSHOT</version>
<name>WSO2 Carbon - Dynamic Client Registration Web Service</name> <name>WSO2 Carbon - Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web</description> <description>WSO2 Carbon - Dynamic Client Registration Web</description>
<packaging>war</packaging> <packaging>war</packaging>

@ -22,8 +22,12 @@ package org.wso2.carbon.policy.mgt.common;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
@ApiModel(value = "DeviceGroupWrapper", description = "This class carries information related to device groups expect users and devices.") @ApiModel(value = "DeviceGroupWrapper", description = "This class carries information related to device groups expect users and devices.")
public class DeviceGroupWrapper { public class DeviceGroupWrapper implements Serializable {
private static final long serialVersionUID = 1998101722L;
@ApiModelProperty(name = "id", value = "Id of the group", required = true) @ApiModelProperty(name = "id", value = "Id of the group", required = true)
private int id; private int id;

@ -18,7 +18,8 @@
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
@ -96,7 +97,7 @@
<configuration> <configuration>
<artifactItems> <artifactItems>
<artifactItem> <artifactItem>
<groupId>org.wso2.mdm</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-web</artifactId> <artifactId>dynamic-client-web</artifactId>
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
<type>war</type> <type>war</type>

@ -17,7 +17,8 @@
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
@ -246,7 +247,7 @@
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.mdm</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-web</artifactId> <artifactId>dynamic-client-web</artifactId>
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
@ -920,6 +921,10 @@
<groupId>xerces</groupId> <groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId> <artifactId>xercesImpl</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>

Loading…
Cancel
Save