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

4.x.x
Hasunie 8 years ago
commit 1d6bf23d67

@ -37,7 +37,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
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_SECRET,
registrationProfile.getConsumerSecret());
if (registrationProfile.getValidityPeriod() == 0) {
jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG,
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD);
} else {
jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG,
registrationProfile.getValidityPeriod());
}
apiManagementProviderService.registerExistingOAuthApplicationToAPIApplication(
jsonStringObject.toJSONString(), registrationProfile.getApplicationName(),
registrationProfile.getConsumerKey(), username, registrationProfile.isAllowedToAllDomains(),

@ -41,6 +41,8 @@ public class RegistrationProfile {
private boolean isMappingAnExistingOAuthApp;
private String consumerKey;
private String consumerSecret;
@XmlElement(required = false)
private int validityPeriod;
public String getApplicationName() {
return applicationName;
@ -89,4 +91,12 @@ public class RegistrationProfile {
public void setConsumerSecret(String 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(2, tenantId);
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) {
throw new GroupManagementDAOException("Error occurred while removing mappings for group.'", e);
} finally {

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

@ -500,10 +500,11 @@ var userModule = function () {
publicMethods.getUIPermissions = function () {
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_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;
}
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")) {
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;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/add")) {
permissions["ADD_GROUP"] = true;
}
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")) {
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")) {
permissions["VIEW_GROUP_ROLES"] = true;
}

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

@ -29,7 +29,9 @@ var carbonServer = new carbonModule.server.Server({
application.put("carbonServer", carbonServer);
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/notifications": ["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) {
var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]);
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) {
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 " +

@ -39,6 +39,7 @@ var handlers = function () {
"as input - setupTokenPairByPasswordGrantType(x, y)");
} else {
privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (!encodedClientAppCredentials) {
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)");
} else {
privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (!encodedClientAppCredentials) {
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;
}();

@ -36,9 +36,11 @@
<div class="form-login-box">
<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}}"
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>
<label class="wr-input-label">Description</label>

@ -35,12 +35,10 @@ $(function () {
var description = $("input#description").val();
if (!name) {
$('.wr-validation-summary strong').text("Group Name is a required field. It cannot be empty.");
$('.wr-validation-summary').removeClass("hidden");
triggerError($("input#name"),"Group Name is a required field. It cannot be empty.");
return false;
} else if (!inputIsValid($("input#name").data("regex"), name)) {
$('.wr-validation-summary strong').text($("input#name").data("errormsg"));
$('.wr-validation-summary').removeClass("hidden");
triggerError($("input#name"),$("input#name").data("errormsg"));
return false;
} else {
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) {
$('#error-msg').html(message.responseText);
modalDialog.header('Unexpected error occurred!');

@ -93,7 +93,7 @@ function loadGroups() {
var currentUser = groupListing.data("currentUser");
var serviceURL;
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")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser;
@ -113,8 +113,7 @@ function loadGroups() {
groupId: data.deviceGroups[index].id,
name: data.deviceGroups[index].name,
description: data.deviceGroups[index].description,
owner: data.deviceGroups[index].owner,
dateOfCreation: data.deviceGroups[index].dateOfCreation
owner: data.deviceGroups[index].owner
})
});
var json = {
@ -153,7 +152,7 @@ function loadGroups() {
data: 'id',
class: 'text-right content-fill text-left-on-grid-view no-wrap',
render: function (id, type, row, meta) {
var html;
var html = '';
if ($.hasPermission("VIEW_GROUP_DEVICES")) {
html = '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name
+ '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
@ -166,9 +165,8 @@ 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="hidden-xs hidden-on-grid-view">Analytics</span></a>';
} else {
html = '';
}
if (row.owner != "wso2.system.user") {
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="'
@ -177,8 +175,6 @@ function loadGroups() {
+ '"><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 +=
@ -188,8 +184,6 @@ function loadGroups() {
+ '" 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")) {
html +=
@ -199,13 +193,11 @@ function loadGroups() {
+ '"><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>';
} else {
html += '';
}
}
return html;
}
}
];
var fnCreatedRow = function (row, data) {

@ -20,6 +20,7 @@
var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type");
var deviceOwner = deviceId.data("owner");
$(document).ready(function () {
$(".panel-body").removeClass("hidden");
@ -61,8 +62,9 @@
pageLength : 10,
order: [],
ajax: {
url: context + "/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType},
url: "/devicemgt/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType, owner: deviceOwner},
dataSrc: function (json) {
$("#operations-spinner").addClass("hidden");
$("#operations-log-container").empty();
@ -102,6 +104,7 @@
}
],
"createdRow": function(row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),

@ -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,142 +59,109 @@
</div>
</div>
{{#defineZone "device-detail-properties"}}
<div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist">
<li class="active"><a class="list-group-item"
href="#device_details"
role="tab" data-toggle="tab"
aria-controls="device_details">Device
Details</a>
</li>
<li><a class="list-group-item" href="#policies"
role="tab"
data-toggle="tab" aria-controls="policies">Policies</a>
</li>
<li><a class="list-group-item" href="#policy_compliance"
role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy
Compliance</a>
<div class="media tab-responsive">
<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">
{{#defineZone "device-view-tabs"}}
{{#defineZone "device-details-tab"}}
<li role="presentation" class="list-group-item active">
<a href="#device_details_tab" role="tab" data-toggle="tab"
aria-controls="device_details_tab">
<i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span>
</a>
</li>
<li><a class="list-group-item" href="#device_location"
role="tab"
data-toggle="tab" aria-controls="device_location">Device
Location</a>
{{/defineZone}}
{{#defineZone "device-details-tab-injected"}}
{{/defineZone}}
{{#defineZone "device-details-tab-operations"}}
<li role="presentation" class="list-group-item">
<a href="#event_log_tab" role="tab" data-toggle="tab" aria-controls="event_log_tab">
<i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
</a>
</li>
<li><a class="list-group-item" href="#event_log" role="tab"
data-toggle="tab" aria-controls="event_log">Operations
Log</a></li>
{{/defineZone}}
{{/defineZone}}
</ul>
</div>
<div class="media-body add-padding-left-5x remove-padding-xs">
<div class="panel-group tab-content remove-padding" id="tabs" role="tablist"
data-status="{{device.isNotRemoved}}" aria-multiselectable="true">
<div class="arrow-left hidden-xs"></div>
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
<div class="panel panel-default tab-pane active"
id="device_details" role="tabpanel"
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>
<a class="padding-left"
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>
{{#defineZone "device-view-tab-contents"}}
{{#defineZone "device-details-tab-contents"}}
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
No Device details avaialbe yet.
</h4>
</div>
{{/defineZone}}
<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 . . .
<br>
<br>
{{#defineZone "device-view-tab-operations-log-conents"}}
<div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab">
<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 class="panel-heading display-none-xs">
Operations Log
<span>
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div id="policy-list-container">
<div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
<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 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
<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>
<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>
{{/defineZone}}
{{/defineZone}}
Loading Operations Log . . .
<br>
<br>
</div>
<div id="operations-log-container">
<div class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
</div>
</div>
</div>
</div>
{{/defineZone}}
</div>
{{else}}
<h1 class="page-sub-title">
Permission Denied
@ -206,6 +173,7 @@
<h1 class="page-sub-title">
Device not found
</h1>
</h1>
<br>
You have tried to access either a removed or non-existing device.
{{/if}}
@ -221,7 +189,4 @@
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
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}}

@ -196,7 +196,7 @@ function onRequest(context) {
viewModel["deviceInfoAvailable"] = false;
}
deviceViewData["deviceView"] = viewModel;
deviceViewData["device"] = viewModel;
} else if (response["status"] == "unauthorized") {
deviceViewData["deviceFound"] = true;
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) {
invokerUtil.get(
"/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 groupObjects = [];
loadGroups(function (deviceGroups) {
@ -136,7 +147,6 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
var content = template();
$("#device-type-policy-operations").html(content).removeClass("hidden");
// $("#device-type-policy-operations").removeClass("hidden");
$(".policy-platform").addClass("hidden");
});

@ -63,7 +63,7 @@
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div>
<div class="clearfix">
<label class="wr-input-label">
Set a name * to your policy<br>
( 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) {
invokerUtil.get(
"/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 groupObjects = [];
loadGroups(function (deviceGroups) {
var tenantId = $("#logged-in-user").data("tenant-id");
for (var index in deviceGroups) {
if(deviceGroups.hasOwnProperty(index)) {
if (deviceGroups.hasOwnProperty(index)) {
var deviceGroupWrapper = {};
if (selectedGroups.indexOf(deviceGroups[index].name) > -1) {
deviceGroupWrapper.id = deviceGroups[index].id;
@ -132,7 +143,18 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
currentlyEffected["roles"] = policyPayloadObj.roles;
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) {
$("#user-roles-radio-btn").prop("checked", true);
@ -146,7 +168,7 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
userInput.val(currentlyEffected["users"]).trigger("change");
}
if(currentlyEffected["groups"].length > 0) {
if (currentlyEffected["groups"].length > 0) {
groupsInput.val(currentlyEffected["groups"]).trigger("change");
}
@ -178,8 +200,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
script.type = 'text/javascript';
script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script);
var configuredOperations = operationModule.
populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]);
var configuredOperations = operationModule.populateProfile(policy["platform"],
policyPayloadObj["profile"]["profileFeaturesList"]);
polulateProfileOperations(configuredOperations);
}
});
@ -222,7 +244,7 @@ stepForwardFrom["policy-criteria"] = function () {
}
});
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"]);
}
@ -422,7 +444,7 @@ var updatePolicy = function (policy, state) {
payload["roles"] = [];
}
if(policy["selectedGroups"]) {
if (policy["selectedGroups"]) {
payload["deviceGroups"] = policy["selectedGroups"];
}

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

@ -6511,3 +6511,13 @@ select > option:hover {
.required:before {
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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.mdm</groupId>
<artifactId>dynamic-client-web-proxy</artifactId>
<version>2.0.2-SNAPSHOT</version>
<name>WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web Proxy</description>
<packaging>war</packaging>

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

@ -22,8 +22,12 @@ package org.wso2.carbon.policy.mgt.common;
import io.swagger.annotations.ApiModel;
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.")
public class DeviceGroupWrapper {
public class DeviceGroupWrapper implements Serializable {
private static final long serialVersionUID = 1998101722L;
@ApiModelProperty(name = "id", value = "Id of the group", required = true)
private int id;

@ -18,7 +18,8 @@
~ 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>
<groupId>org.wso2.carbon.devicemgt</groupId>
@ -96,7 +97,7 @@
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wso2.mdm</groupId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-web</artifactId>
<version>${carbon.device.mgt.version}</version>
<type>war</type>

@ -17,7 +17,8 @@
~ 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>
<groupId>org.wso2.carbon.devicemgt</groupId>
@ -246,7 +247,7 @@
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.mdm</groupId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-web</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
@ -920,6 +921,10 @@
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

Loading…
Cancel
Save