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

4.x.x
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, " +
"which is 'https'");
}
transports = "https";
transports = "https,http";
}
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));

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

@ -26,7 +26,7 @@
<i class="icon fw fw-home"></i>
</a>
</li>
{{#if groupName}}
{{#if group}}
<li>
<a href="{{@app.context}}/groups">
Groups
@ -34,7 +34,7 @@
</li>
<li>
<a href="#">
{{groupName}}
{{group.name}}
</a>
</li>
{{else}}
@ -47,7 +47,7 @@
{{/zone}}
{{#zone "navbarActions"}}
{{#if groupName}}
{{#if group}}
<li>
<a href="{{@app.context}}/devices" class="cu-btn">
<span class="icon fw-stack">
@ -57,6 +57,15 @@
Assign from My Devices
</a>
</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}}
{{#if permissions.enroll}}
<li>
@ -73,6 +82,55 @@
{{/zone}}
{{#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-hidden-operations wr-advance-operations"></div>
<div class="col-md-12 wr-page-content">
@ -82,7 +140,6 @@
{{#if deviceCount}}
<div id="loading-content" class="col-centered">
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading devices . . .
<br>
</div>
@ -157,7 +214,7 @@
</h3>
<h3 class="text-muted">
You don't have any device
{{#if groupName}}
{{#if group}}
assigned to this group
{{else}}
enrolled
@ -165,7 +222,7 @@
at the moment.
</h3>
<h3>
{{#if groupName}}
{{#if group}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices" class="btn-operations btn-default">
<span class="fw-stack">
@ -208,20 +265,16 @@
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div>
<h4>
Please select group
<br>
<div id="user-groups">Loading...</div>
</h4>
</div>
</div>
<div class="modal-footer">
<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">
Assign
Update assignment
</a>
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
Cancel
</a>

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

@ -51,7 +51,7 @@ function InitiateViewOption(url) {
var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container";
var deviceListing, currentUser, groupName, groupId;
var deviceListing, currentUser, groupId;
/*
* DOM ready functions.
@ -70,7 +70,6 @@ $(document).ready(function () {
deviceListing = $("#device-listing");
currentUser = deviceListing.data("current-user");
groupName = getParameterByName("groupName");
groupId = getParameterByName("groupId");
/* Adding selected class for selected devices */
@ -161,7 +160,7 @@ function toTitleCase(str) {
function loadDevices(searchType, searchParam) {
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";
} else if ($.hasPermission("LIST_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>';
}
if ((!groupName || !groupId) && groupingEnabled(row.deviceType)) {
if (!groupId && groupingEnabled(row.deviceType)) {
html +=
'<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) {
var groups = JSON.parse(data);
var html = '<br />';
var html = '';
var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' +
'<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' +
'<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name +
'</span></label></div>';
hasGroups = true;
}
}
$('#user-groups').html(html);
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);
$("a#group-device-yes-link").click(function () {
var deviceIdentifier = {"id": deviceId, "type": deviceType};
var deviceGroupIds = [];
@ -683,7 +692,7 @@ function attachDeviceEvents() {
showPopup();
$("a#remove-device-yes-link").click(function () {
if (groupId && groupName) {
if (groupId) {
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {

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

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

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

@ -16,18 +16,41 @@
* 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.
*/
var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
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.
*
@ -118,9 +141,9 @@ function loadGroups() {
});
var json = {
"recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects
}
};
return JSON.stringify(json);
};
@ -129,7 +152,14 @@ function loadGroups() {
data: 'id',
class: 'remove-padding icon-only content-fill',
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) {
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">' +
'<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
html += '<a href="group/' + row.groupId
+ '/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>'
+
@ -224,7 +248,6 @@ function loadGroups() {
});
};
$('#group-grid').datatables_extended_serverside_paging(
null,
serviceURL,
@ -234,11 +257,14 @@ function loadGroups() {
function (oSettings) {
$(".icon .text").res_text(0.2);
attachEvents();
var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
thisTable.removeClass("table-selectable");
},
{
"placeholder": "Search By Group Name",
"searchKey": "name"
});
}
);
$(groupCheckbox).click(function () {
addGroupSelectedClass(this);
});
@ -257,6 +283,11 @@ function openCollapsedNav() {
* DOM ready functions.
*/
$(document).ready(function () {
/* Adding selected class for selected devices */
$(groupCheckbox).each(function () {
addGroupSelectedClass(this);
});
var permissionSet = {};
//This method is used to setup permission for device listing
@ -278,11 +309,6 @@ $(document).ready(function () {
loadGroups();
//$('#device-grid').datatables_extended();
/* Adding selected class for selected devices */
$(groupCheckbox).each(function () {
addGroupSelectedClass(this);
});
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover(
{

Loading…
Cancel
Save