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

merge-requests/7/head
Milan Perera 8 years ago
commit f3409adc21

@ -269,7 +269,7 @@ public class APIPublisherUtil {
log.debug("'managed-api-transports' attribute is not configured. Therefore using the default, " + log.debug("'managed-api-transports' attribute is not configured. Therefore using the default, " +
"which is 'https'"); "which is 'https'");
} }
transports = "https"; transports = "https,http";
} }
apiConfig.setTransports(transports); apiConfig.setTransports(transports);

@ -105,4 +105,33 @@ var groupModule = {};
); );
}; };
groupModule.getGroup = function (groupId) {
return serviceInvokers.XMLHttp.get(
deviceServiceEndpoint + "/groups/id/" + groupId, function (responsePayload) {
return JSON.parse(responsePayload.responseText);
},
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
groupModule.getRolesOfGroup = function (groupId) {
return serviceInvokers.XMLHttp.get(
deviceServiceEndpoint + "/groups/id/" + groupId + "/roles", function (responsePayload) {
var data = JSON.parse(responsePayload.responseText);
if(data) {
return data.roles;
} else {
return [];
}
},
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
}(groupModule)); }(groupModule));

@ -171,7 +171,7 @@
</a> </a>
{{/if}} {{/if}}
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles/add-role"> <a href="{{@app.context}}/role/add">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>

@ -26,7 +26,7 @@
<i class="icon fw fw-home"></i> <i class="icon fw fw-home"></i>
</a> </a>
</li> </li>
{{#if groupName}} {{#if group}}
<li> <li>
<a href="{{@app.context}}/groups"> <a href="{{@app.context}}/groups">
Groups Groups
@ -34,7 +34,7 @@
</li> </li>
<li> <li>
<a href="#"> <a href="#">
{{groupName}} {{group.name}}
</a> </a>
</li> </li>
{{else}} {{else}}
@ -47,7 +47,7 @@
{{/zone}} {{/zone}}
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
{{#if groupName}} {{#if group}}
<li> <li>
<a href="{{@app.context}}/devices" class="cu-btn"> <a href="{{@app.context}}/devices" class="cu-btn">
<span class="icon fw-stack"> <span class="icon fw-stack">
@ -57,6 +57,15 @@
Assign from My Devices Assign from My Devices
</a> </a>
</li> </li>
<li>
<a href="{{@app.context}}/group/{{group.id}}/analytics" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-statistics fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i>
</span>
View Analytics
</a>
</li>
{{else}} {{else}}
{{#if permissions.enroll}} {{#if permissions.enroll}}
<li> <li>
@ -73,6 +82,55 @@
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if group}}
<h1 class="page-sub-title">
{{group.name}} group
</h1>
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div id="device_overview">
<div class="media-left col-lg-1">
<div class="icon">
<img src="/devicemgt/public/cdmf.page.groups/images/group-icon.png" style="background-color: #11375b; height: 152px;">
</div>
</div>
<div class="media-body asset-desc add-padding-left-5x">
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Overview
</div>
<table class="table table-responsive table-striped" id="members" style="margin-bottom: 0px;">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
<td style="padding:10px 15px;">{{group.owner}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Shared with roles</td>
<td style="padding:10px 15px;">
{{#each roles}}
{{this}}<br/>
{{/each}}
</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;width: 15%;">Device Count</td>
<td style="padding:10px 15px;">{{deviceCount}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;width: 15%;">Description</td>
<td style="padding:10px 15px;">{{group.description}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br/>
<h1 class="page-sub-title add-margin-top-5x">
Devices in {{group.name}} group
</h1>
{{/if}}
<div class="wr-device-list row"> <div class="wr-device-list row">
<div class="wr-hidden-operations wr-advance-operations"></div> <div class="wr-hidden-operations wr-advance-operations"></div>
<div class="col-md-12 wr-page-content"> <div class="col-md-12 wr-page-content">
@ -82,7 +140,6 @@
{{#if deviceCount}} {{#if deviceCount}}
<div id="loading-content" class="col-centered"> <div id="loading-content" class="col-centered">
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
Loading devices . . . Loading devices . . .
<br> <br>
</div> </div>
@ -157,7 +214,7 @@
</h3> </h3>
<h3 class="text-muted"> <h3 class="text-muted">
You don't have any device You don't have any device
{{#if groupName}} {{#if group}}
assigned to this group assigned to this group
{{else}} {{else}}
enrolled enrolled
@ -165,7 +222,7 @@
at the moment. at the moment.
</h3> </h3>
<h3> <h3>
{{#if groupName}} {{#if group}}
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices" class="btn-operations btn-default"> <a href="{{@app.context}}/devices" class="btn-operations btn-default">
<span class="fw-stack"> <span class="fw-stack">
@ -208,20 +265,16 @@
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert"> <div id="notification-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 id="user-groups">Loading...</div>
<h4>
Please select group
<br>
<div id="user-groups">Loading...</div>
</h4>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="{{@app.context}}/group/add" id="group-add-link" class="btn-operations">
Add device group
</a>
<a href="#" id="group-device-yes-link" class="btn-operations"> <a href="#" id="group-device-yes-link" class="btn-operations">
Assign Update assignment
</a> </a>
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default"> <a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
Cancel Cancel
</a> </a>

@ -20,15 +20,19 @@ function onRequest(context) {
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var groupName = request.getParameter("groupName");
var groupId = request.getParameter("groupId"); var groupId = request.getParameter("groupId");
var viewModel = {}; var viewModel = {};
var title = "Devices"; var title = "Devices";
if (groupName) { if (groupId) {
title = groupName + " " + title; var group = groupModule.getGroup(groupId);
viewModel.groupName = groupName; if (group) {
title = group.name + " " + title;
viewModel.roles = groupModule.getRolesOfGroup(groupId);
viewModel.group = group;
}
} }
viewModel.title = title; viewModel.title = title;
var currentUser = session.get(constants.USER_SESSION_KEY); var currentUser = session.get(constants.USER_SESSION_KEY);
@ -42,7 +46,6 @@ function onRequest(context) {
viewModel.currentUser = currentUser; viewModel.currentUser = currentUser;
var deviceCount = 0; var deviceCount = 0;
if (groupId) { if (groupId) {
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
deviceCount = groupModule.getGroupDeviceCount(groupId); deviceCount = groupModule.getGroupDeviceCount(groupId);
} else { } else {
deviceCount = deviceModule.getDevicesCount(); deviceCount = deviceModule.getDevicesCount();

@ -51,7 +51,7 @@ function InitiateViewOption(url) {
var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container"; var assetContainer = "#ast-container";
var deviceListing, currentUser, groupName, groupId; var deviceListing, currentUser, groupId;
/* /*
* DOM ready functions. * DOM ready functions.
@ -69,8 +69,7 @@ $(document).ready(function () {
deviceListing = $("#device-listing"); deviceListing = $("#device-listing");
currentUser = deviceListing.data("current-user"); currentUser = deviceListing.data("current-user");
groupName = getParameterByName("groupName");
groupId = getParameterByName("groupId"); groupId = getParameterByName("groupId");
/* Adding selected class for selected devices */ /* Adding selected class for selected devices */
@ -161,7 +160,7 @@ function toTitleCase(str) {
function loadDevices(searchType, searchParam) { function loadDevices(searchType, searchParam) {
var serviceURL; var serviceURL;
if (groupName && groupId && $.hasPermission("LIST_OWN_DEVICES")) { if (groupId && $.hasPermission("LIST_OWN_DEVICES")) {
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices"; serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices";
} else if ($.hasPermission("LIST_DEVICES")) { } else if ($.hasPermission("LIST_DEVICES")) {
serviceURL = "/api/device-mgt/v1.0/devices"; serviceURL = "/api/device-mgt/v1.0/devices";
@ -345,7 +344,7 @@ function loadDevices(searchType, searchParam) {
'<span class="hidden-xs hidden-on-grid-view">Analytics</span>'; '<span class="hidden-xs hidden-on-grid-view">Analytics</span>';
} }
if ((!groupName || !groupId) && groupingEnabled(row.deviceType)) { if (!groupId && groupingEnabled(row.deviceType)) {
html += html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" '
+ +
@ -614,18 +613,28 @@ function attachDeviceEvents() {
invokerUtil.get(serviceURL, function (data) { invokerUtil.get(serviceURL, function (data) {
var groups = JSON.parse(data); var groups = JSON.parse(data);
var html = '<br />'; var html = '';
var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) { for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") { if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' + html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' +
'<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' + '<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' +
'<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name + '<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name +
'</span></label></div>'; '</span></label></div>';
hasGroups = true;
} }
} }
if (hasGroups) {
html = '<br/><h4>Please select device group(s)</h4><br/>' + html;
markAlreadyAssignedGroups(deviceId, deviceType);
$("a#group-device-yes-link").show();
$("a#group-add-link").hide();
} else {
$("a#group-device-yes-link").hide();
$("a#group-add-link").show();
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>'
}
$('#user-groups').html(html); $('#user-groups').html(html);
markAlreadyAssignedGroups(deviceId, deviceType);
$("a#group-device-yes-link").show();
$("a#group-device-yes-link").click(function () { $("a#group-device-yes-link").click(function () {
var deviceIdentifier = {"id": deviceId, "type": deviceType}; var deviceIdentifier = {"id": deviceId, "type": deviceType};
var deviceGroupIds = []; var deviceGroupIds = [];
@ -683,7 +692,7 @@ function attachDeviceEvents() {
showPopup(); showPopup();
$("a#remove-device-yes-link").click(function () { $("a#remove-device-yes-link").click(function () {
if (groupId && groupName) { if (groupId) {
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; var deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove"; serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) { invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {

@ -37,7 +37,7 @@
</a> </a>
</li> </li>
<li> <li>
<a href="{{@app.context}}/devices?groupOwner={{groupOwner}}&groupName={{groupName}}"> <a href="{{@app.context}}/devices?groupId={{groupId}}&groupName={{groupName}}">
{{groupName}} {{groupName}}
</a> </a>
</li> </li>

@ -19,8 +19,8 @@
function onRequest(context) { function onRequest(context) {
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var groupName = context.uriParams.name;
var groupId = context.uriParams.id; var groupId = context.uriParams.id;
var group = groupModule.getGroup(groupId);
var devices = []; var devices = [];
var deviceResponse = groupModule.getGroupDevices(groupId).responseText; var deviceResponse = groupModule.getGroupDevices(groupId).responseText;
@ -29,8 +29,9 @@ function onRequest(context) {
devices = deviceResponseObj.devices; devices = deviceResponseObj.devices;
} }
var page = { var page = {
"groupName": groupName, "groupId": groupId,
"title": groupName + " Analytics" "groupName": group.name,
"title": group.name + " Analytics"
}; };
if (devices) { if (devices) {
var deviceTypes = []; var deviceTypes = [];

@ -1,5 +1,5 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"uri": "/group/{name}/{id}/analytics", "uri": "/group/{id}/analytics",
"layout": "cdmf.layout.default" "layout": "cdmf.layout.default"
} }

@ -16,18 +16,41 @@
* under the License. * under the License.
*/ */
/**
* Following function would execute
* when a user clicks on the list item
* initial mode and with out select mode.
*/
function InitiateViewOption(url) {
if ($(".select-enable-btn").text() == "Select") {
$(location).attr('href', url);
}
}
(function () {
var cache = {};
var validateAndReturn = function (value) {
return (value == undefined || value == null) ? "Unspecified" : value;
};
Handlebars.registerHelper("deviceMap", function (device) {
device.owner = validateAndReturn(device.owner);
device.ownership = validateAndReturn(device.ownership);
var arr = device.properties;
if (arr) {
device.properties = arr.reduce(function (total, current) {
total[current.name] = validateAndReturn(current.value);
return total;
}, {});
}
});
})();
/* /*
* Setting-up global variables. * Setting-up global variables.
*/ */
var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container"; var assetContainer = "#ast-container";
function InitiateViewOption() {
if ($(".select-enable-btn").text() == "Select") {
$(location).attr('href', $(this).data("url"));
}
}
/* /*
* On Select All Groups button click function. * On Select All Groups button click function.
* *
@ -118,9 +141,9 @@ function loadGroups() {
}); });
var json = { var json = {
"recordsTotal": data.count, "recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects "data": objects
} };
return JSON.stringify(json); return JSON.stringify(json);
}; };
@ -129,7 +152,14 @@ function loadGroups() {
data: 'id', data: 'id',
class: 'remove-padding icon-only content-fill', class: 'remove-padding icon-only content-fill',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>'; if ($.hasPermission("VIEW_GROUP_DEVICES")) {
return '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name
+ '"><div class="thumbnail icon"><img class="square-element text fw " '
+ 'src="public/cdmf.page.groups/images/group-icon.png"/></div></a>';
} else {
return '<div class="thumbnail icon"><img class="square-element text fw " ' +
'src="public/cdmf.page.groups/images/group-icon.png"/></div>';
}
} }
}, },
{ {
@ -154,13 +184,7 @@ function loadGroups() {
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="group/' + row.groupId
+ '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-view fw-stack-1x"></i></span>'
+
'<span class="hidden-xs hidden-on-grid-view">View Devices</span></a>';
html += '<a href="group/' + row.name + '/' + row.groupId
+ '/analytics" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' + + '/analytics" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
'<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>'
+ +
@ -224,21 +248,23 @@ function loadGroups() {
}); });
}; };
$('#group-grid').datatables_extended_serverside_paging( $('#group-grid').datatables_extended_serverside_paging(
null, null,
serviceURL, serviceURL,
dataFilter, dataFilter,
columns, columns,
fnCreatedRow, fnCreatedRow,
function (oSettings) { function (oSettings) {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
attachEvents(); attachEvents();
}, var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
{ thisTable.removeClass("table-selectable");
"placeholder": "Search By Group Name", },
"searchKey": "name" {
}); "placeholder": "Search By Group Name",
"searchKey": "name"
}
);
$(groupCheckbox).click(function () { $(groupCheckbox).click(function () {
addGroupSelectedClass(this); addGroupSelectedClass(this);
}); });
@ -257,6 +283,11 @@ function openCollapsedNav() {
* DOM ready functions. * DOM ready functions.
*/ */
$(document).ready(function () { $(document).ready(function () {
/* Adding selected class for selected devices */
$(groupCheckbox).each(function () {
addGroupSelectedClass(this);
});
var permissionSet = {}; var permissionSet = {};
//This method is used to setup permission for device listing //This method is used to setup permission for device listing
@ -278,11 +309,6 @@ $(document).ready(function () {
loadGroups(); loadGroups();
//$('#device-grid').datatables_extended(); //$('#device-grid').datatables_extended();
/* Adding selected class for selected devices */
$(groupCheckbox).each(function () {
addGroupSelectedClass(this);
});
/* for device list sorting drop down */ /* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover( $(".ctrl-filter-type-switcher").popover(
{ {

Loading…
Cancel
Save