Group module completed without sharing

application-manager-new
charithag 10 years ago
parent 00122dc921
commit b59a2e22de

@ -42,47 +42,48 @@ var groupId;
if (uriMatcher.match("/{context}/api/group/add")) { if (uriMatcher.match("/{context}/api/group/add")) {
var name = request.getParameter("name"); var group = request.getContent();
var description = request.getParameter("description"); var name = group["name"];
var description = group["description"];
//URL: POST https://localhost:9443/devicecloud/group_manager/group/add //URL: POST https://localhost:9443/devicecloud/group_manager/group
endPoint = deviceCloudService + "/group/add"; endPoint = deviceCloudService + "/group";
data = {"name": name, "username": user.username, "description": description}; data = {"name": name, "username": user.username, "description": description};
result = post(endPoint, data, "json"); result = post(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
name = request.getParameter("name"); group = request.getContent();
description = request.getParameter("description"); name = group["name"];
description = group["description"];
//URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId} //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}
endPoint = deviceCloudService + "id/" + groupId; endPoint = deviceCloudService + "/group/id/" + groupId;
data = {"name": name, "username": user.username, "description": description}; data = {"name": name, "username": user.username, "description": description};
result = put(endPoint, data, "json"); result = put(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/remove")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/remove")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
//URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId} //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}
endPoint = deviceCloudService + "id/" + groupId; endPoint = deviceCloudService + "/group/id/" + groupId;
data = {"username": user.username}; data = {"username": user.username};
result = del(endPoint, data, "json"); result = del(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
//URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId} //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}
endPoint = deviceCloudService + "id/" + groupId; endPoint = deviceCloudService + "/group/id/" + groupId;
log.info(endPoint);
data = {"username": user.username}; data = {"username": user.username};
result = get(endPoint, data, "json"); result = get(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) { } else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) {
//URL: GET https://localhost:9443/devicecloud/group_manager/group/name/{name} //URL: GET https://localhost:9443/devicecloud/group_manager/group/name/{name}
endPoint = deviceCloudService + "name/" + uriMatcher.elements().groupName; endPoint = deviceCloudService + "/group/name/" + uriMatcher.elements().groupName;
data = {"username": user.username}; data = {"username": user.username};
result = get(endPoint, data, "json"); result = get(endPoint, data, "json");
@ -103,8 +104,8 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
var shareUser = request.getParameter("shareUser"); var shareUser = request.getContent()["shareUser"];
role = request.getParameter("role"); role = request.getContent()["role"];
//URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share //URL: PUT https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share
endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; endPoint = deviceCloudService + "/group/id/" + groupId + "/share";
@ -114,8 +115,8 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/share")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
var unShareUser = request.getParameter("unShareUser"); var unShareUser = request.getContent()["unShareUser"];
role = request.getParameter("role"); role = request.getContent()["role"];
//URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/share
endPoint = deviceCloudService + "/group/id/" + groupId + "/share"; endPoint = deviceCloudService + "/group/id/" + groupId + "/share";
@ -125,8 +126,8 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/add")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
var permissions = request.getParameter("permissions"); var permissions = request.getContent()["permissions"];
role = request.getParameter("role"); role = request.getContent()["role"];
//URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role //URL: POST https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role
endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; endPoint = deviceCloudService + "/group/id/" + groupId + "/role";
@ -136,7 +137,7 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/delete")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
role = request.getParameter("role"); role = request.getContent()["role"];
//URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role //URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role
endPoint = deviceCloudService + "/group/id/" + groupId + "/role"; endPoint = deviceCloudService + "/group/id/" + groupId + "/role";
@ -146,7 +147,7 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/role/all")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
//URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role/all //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role/all
endPoint = deviceCloudService + "/group/id/" + groupId + "/role/all"; endPoint = deviceCloudService + "/group/id/" + groupId + "/role/all";
data = {"username": user.username}; data = {"username": user.username};
@ -183,8 +184,8 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) { } else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) {
groupId = uriMatcher.elements().groupId; groupId = uriMatcher.elements().groupId;
var deviceId = request.getParameter("deviceId"); var deviceId = request.getContent()["deviceId"];
var deviceType = request.getParameter("deviceType"); var deviceType = request.getContent()["deviceType"];
//URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/assign //URL: GET https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/device/assign
endPoint = deviceCloudService + "/group/id/" + groupId + "/device/assign"; endPoint = deviceCloudService + "/group/id/" + groupId + "/device/assign";
@ -195,6 +196,7 @@ if (uriMatcher.match("/{context}/api/group/add")) {
// returning the result. // returning the result.
if (result) { if (result) {
print(result); response.status = result.xhr.status;
print(false);
} }
%> %>

@ -79,7 +79,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) {
} else { } else {
userRoles = String(addUserFormData.userRoles).split(","); userRoles = String(addUserFormData.userRoles).split(",");
} }
userRoles="deviceRole, deviceUser"
try { try {
result = userModule.registerUser(username, firstname, lastname, emailAddress, password, result = userModule.registerUser(username, firstname, lastname, emailAddress, password,
userRoles); userRoles);

@ -1,23 +1,12 @@
{{authorized}} {{authorized}}
{{layout "fluid"}} {{layout "fluid"}}
{{#zone "title"}} {{#zone "title"}}
Groups Group Management
{{/zone}} {{/zone}}
{{#zone "body"}} {{#zone "body"}}
{{unit "appbar" link="group-mgt" title="My Groups"}}
{{unit "extended-search-box" item="Group"}}
{{unit "operation-mod"}} {{unit "operation-mod"}}
<div class="wr-device-list row"> {{unit "appbar" enableBack=true title="Group"}}
<div class="wr-hidden-operations wr-advance-operations">
{{unit "group-detail"}}
</div>
<div class="col-md-12 wr-page-content">
<!-- content -->
<div>
{{unit "operation-bar"}}
{{unit "group-listing"}}
</div>
<!-- /content -->
</div>
</div>
{{/zone}} {{/zone}}

@ -0,0 +1,23 @@
{{authorized}}
{{layout "fluid"}}
{{#zone "title"}}
Groups
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="group-mgt" title="My Groups"}}
{{unit "extended-search-box" item="Group"}}
{{unit "operation-mod"}}
<div class="wr-device-list row">
<div class="wr-hidden-operations wr-advance-operations">
</div>
<div class="col-md-12 wr-page-content">
<!-- content -->
<div>
{{unit "operation-bar"}}
{{unit "group-listing"}}
</div>
<!-- /content -->
</div>
</div>
{{/zone}}

@ -12,7 +12,7 @@
</a><a class="cu-btn page-title" href='javascript:location.reload();'> </a><a class="cu-btn page-title" href='javascript:location.reload();'>
<span class="fw-stack"></span> <span class="fw-stack"></span>
{{title}} {{title}}
</a>{{#each currentActions}}<a href="{{url}}" class="cu-btn"> </a>{{#each currentActions}}<a href="{{url}}" class="cu-btn {{class}}">
<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 {{icon}} fw-stack-1x"></i> <i class="fw {{icon}} fw-stack-1x"></i>
@ -41,7 +41,8 @@
<!-- common navigation --> <!-- common navigation -->
<div id="hiddenNav" class="wr-hidden-nav"> <div id="hiddenNav" class="wr-hidden-nav">
<ul> <ul>
<li><a href="/iotserver/devices"><i class="fw fw-mobile"></i>My Devices</a></li> <li><a href="/iotserver/devices"><i class="fw fw-mobile"></i>My Devices</a></li>
<li><a href="/iotserver/groups"><i class="fw fw-group"></i>My Groups</a></li>
{{#if permissions.ADD_USER}} {{#if permissions.ADD_USER}}
<li><a href="/iotserver/users"><i class="fw fw-user"></i>User Management</a></li> <li><a href="/iotserver/users"><i class="fw fw-user"></i>User Management</a></li>
{{/if}} {{/if}}

@ -80,7 +80,8 @@ function onRequest(context) {
links["group-mgt"].push({ links["group-mgt"].push({
title: "Add Group", title: "Add Group",
icon: "fw-add", icon: "fw-add",
url: "/iotserver/group#add-device" url: "#",
class: "add-group-link"
}); });
} }
}// end-if-user }// end-if-user

@ -1,3 +1,4 @@
var log = new Log("modules/device-detail.js");
function onRequest(context) { function onRequest(context) {
var uri = request.getRequestURI(); var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));

@ -1,3 +1,5 @@
var log = new Log("modules/device-listing.js");
function onRequest(context){ function onRequest(context){
var userModule = require("/modules/user.js").userModule; var userModule = require("/modules/user.js").userModule;
var permissions = []; var permissions = [];

@ -1,7 +1,7 @@
{{#zone "main"}} {{#zone "main"}}
<div class="row wr-group-board"> <div class="row wr-group-board">
<div class="col-lg-12 wr-secondary-bar"> <div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-groupid="{{group.groupId}}"> <label class="device-id device-select" data-groupid="{{group.id}}">
Group {{group.name}} Group {{group.name}}
<span class="lbl-device"> <span class="lbl-device">
{{#if group.viewModel.vendor}} {{#if group.viewModel.vendor}}
@ -28,8 +28,10 @@
<img src="{{self.publicURL}}/img/group-icon.png" style="width:200px" /> <img src="{{self.publicURL}}/img/group-icon.png" style="width:200px" />
</div> </div>
<div class="col-lg-12 col-sm-4 ast-desc"> <div class="col-lg-12 col-sm-4 ast-desc">
<div class="ast-group-desc"><b>Owner:</b> {{group.ownerId}}</div> <div class="ast-group-desc"><b>No. of Devices:</b> {{group.deviceCount}}</div>
<div class="ast-group-desc"><b>Date of Enrollment:</b><br/> <span class="formatDate">{{group.enrollment}}</span></div> <div class="ast-group-desc"><b>Users:</b> {{group.users}}</div>
<div class="ast-group-desc"><b>Created on:</b><br/> <span class="formatDate">{{group.dateOfCreation}}</span></div>
<div class="ast-group-desc"><b>Modified on:</b><br/> <span class="formatDate">{{group.dateOfLastUpdate}}</span></div>
</div> </div>
</div> </div>
</div> </div>
@ -107,7 +109,7 @@
</div> </div>
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour"> <div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
<div class="panel-body"> <div class="panel-body">
<a href="../../groups/analytics?groupId={{groupId}}" ><i class="fw fw-charts"></i> Show Statistics</a> <a href="../../groups/analytics?id={{id}}" ><i class="fw fw-charts"></i> Show Statistics</a>
</div> </div>
</div> </div>
</div> </div>

@ -1,53 +1,23 @@
var log = new Log("modules/group-detail.js");
function onRequest(context) { function onRequest(context) {
var uri = request.getRequestURI(); var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));
var isMatched = uriMatcher.match("/{context}/group/id/{groupId}"); var isMatched = uriMatcher.match("/{context}/group/{groupId}");
if (isMatched) { if (isMatched) {
var carbon = require('carbon');
var carbonHttpsServletTransport = carbon.server.address('https');
var matchedElements = uriMatcher.elements(); var matchedElements = uriMatcher.elements();
var groupId = matchedElements.groupId; var groupId = matchedElements.groupId;
context.groupId = groupId; var endpoint = carbonHttpsServletTransport + "/" + matchedElements.context + "/api/group/id/" + groupId;
//var group = deviceModule.viewDevice(deviceType, deviceId); log.info(endpoint);
//if (device){ //var result = get(endpoint, {}, "json");
// var viewModel = {}; //if (result){
// var deviceInfo = device.properties.DEVICE_INFO; // context.group = result.data;
// if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0){ //}else{
// deviceInfo = JSON.parse(deviceInfo); // response.sendError(503);
// if (device.type == "ios"){
// viewModel.imei = device.properties.IMEI;
// viewModel.phoneNumber = deviceInfo.PhoneNumber;
// viewModel.udid = deviceInfo.UDID;
// viewModel.BatteryLevel = Math.round(deviceInfo.BatteryLevel * 100);
// viewModel.DeviceCapacity = Math.round(deviceInfo.DeviceCapacity * 100) / 100;
// viewModel.AvailableDeviceCapacity = Math.round(deviceInfo.AvailableDeviceCapacity * 100) / 100;
// viewModel.DeviceCapacityUsed = Math.round((viewModel.DeviceCapacity
// - viewModel.AvailableDeviceCapacity) * 100) / 100;
// viewModel.DeviceCapacityPercentage = Math.round(viewModel.DeviceCapacityUsed
// / viewModel.DeviceCapacity * 10000) /100;
// }else if(device.type == "android"){
// viewModel.imei = device.properties.IMEI;
// viewModel.model = device.properties.DEVICE_MODEL;
// viewModel.vendor = device.properties.VENDOR;
// viewModel.internal_memory = {};
// viewModel.external_memory = {};
// viewModel.location = {
// latitude: device.properties.LATITUDE,
// longitude: device.properties.LONGITUDE
// };
// viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL;
// viewModel.internal_memory.FreeCapacity = Math.round((deviceInfo.INTERNAL_TOTAL_MEMORY -
// deviceInfo.INTERNAL_AVAILABLE_MEMORY) * 100) / 100;
// viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY
// / deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100;
// viewModel.external_memory.FreeCapacity = Math.round((deviceInfo.EXTERNAL_TOTAL_MEMORY -
// deviceInfo.EXTERNAL_AVAILABLE_MEMORY) * 100) / 100;
// viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY
// /deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) /100;
// }
// viewModel.enrollment = device.enrollment;
// device.viewModel = viewModel;
// }
//} //}
context.group = groupId;
} else { } else {
response.sendError(404); response.sendError(404);
} }

@ -24,46 +24,7 @@ function formatDates(){
} }
(function () { (function () {
var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type");
var payload = [deviceIdentifier];
if (deviceType == "ios") {
var serviceUrl = "/ios/operation/deviceinfo";
} else if (deviceType == "android") {
var serviceUrl = "/mdm-android-agent/operation/device-info";
}
invokerUtil.post(serviceUrl, payload,
function(message){
console.log(message);
}, function (message) {
console.log(message);
});
$(document).ready(function(){ $(document).ready(function(){
loadOperationBar(deviceType);
loadMap();
formatDates(); formatDates();
}); });
function loadMap(){
var map;
function initialize() {
var mapOptions = {
zoom: 18
};
var lat = 6.9098591;
var long = 79.8523753;
map = new google.maps.Map(document.getElementById('device-location'),
mapOptions);
var pos = new google.maps.LatLng(lat,
long);
var marker = new google.maps.Marker({
position: pos,
map: map
});
map.setCenter(pos);
}
google.maps.event.addDomListener(window, 'load', initialize);
}
}()); }());

@ -12,22 +12,22 @@
</div> </div>
<div id="no-groups-div-content" class="hide"> <div id="no-groups-div-content" class="hide">
<!-- no devices found --> <!-- no groups found -->
<div class="container-fluid wr-content-alt"> <div class="container-fluid wr-content-alt">
<div class="ctrl-info-panel col-md-6 col-centered"> <div class="ctrl-info-panel col-md-6 col-centered">
<h2>You don't have any Groups registered at the moment.</h2> <h2>You don't have any Groups registered at the moment.</h2>
<p> <p>
</a><a href="#" class="cu-btn"> <a href="#" class="cu-btn add-group-link">
<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>
</span> </span>
Add New Group Add New Group
</a> </a>
</p> </p>
</div> </div>
</div> </div>
<!-- /no devices found --> <!-- /no groups found -->
</div> </div>
<div id="remove-group-modal-content" class="hide"> <div id="remove-group-modal-content" class="hide">
@ -35,6 +35,7 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this group from your Group List?</h3> <h3>Do you really want to remove this group from your Group List?</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-yes-link" class="btn-operations"> <a href="#" id="remove-group-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;
@ -54,6 +55,7 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully removed.</h3> <h3>Group was successfully removed.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-200-link" class="btn-operations"> <a href="#" id="remove-group-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
@ -64,18 +66,73 @@
</div> </div>
</div> </div>
<div id="add-group-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Please enter name and description for new group</h3>
<br/>
<div>
<input id="add-group-name" style="color:#3f3f3f;padding:5px" type="text" value=""
placeholder="Group Name" size="60">
</div>
<br/>
<div>
<input id="add-group-description" style="color:#3f3f3f;padding:5px" type="text" value=""
placeholder="Group Description" size="60">
</div>
<div class="buttons">
<a href="#" id="add-group-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Add Group&nbsp;&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
<a href="#" id="add-group-cancel-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
<div id="add-group-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group successfully added.</h3>
<div class="buttons">
<a href="#" id="add-group-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
<div id="edit-group-modal-content" class="hide"> <div id="edit-group-modal-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Please enter new name for the group?</h3> <h3>Please enter new name and description for the group</h3>
<br/>
<div>
<input id="edit-group-name" style="color:#3f3f3f;padding:5px" type="text" value=""
placeholder="Group Name" size="60">
</div>
<br/> <br/>
<div> <div>
<input id="edit-device-name" style="color:#3f3f3f;padding:5px" type="text" value="" placeholder="Type here" size="60"> <input id="edit-group-description" style="color:#3f3f3f;padding:5px" type="text" value=""
placeholder="Group Description" size="60">
</div> </div>
<div class="buttons"> <div class="buttons">
<a href="#" id="edit-group-yes-link" class="btn-operations"> <a href="#" id="edit-group-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Rename&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Update&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="edit-group-cancel-link" class="btn-operations"> <a href="#" id="edit-group-cancel-link" class="btn-operations">
@ -92,6 +149,7 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully updated.</h3> <h3>Group was successfully updated.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="edit-group-200-link" class="btn-operations"> <a href="#" id="edit-group-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
@ -107,8 +165,9 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Exception at backend. Try Later.</h3> <h3>Exception at backend. Try Later.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-400-link" class="btn-operations"> <a href="#" id="group-400-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -122,8 +181,9 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Action not permitted.</h3> <h3>Action not permitted.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-403-link" class="btn-operations"> <a href="#" id="group-403-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -137,8 +197,9 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Group does not exist.</h3> <h3>Group does not exist.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-409-link" class="btn-operations"> <a href="#" id="group-409-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -152,8 +213,9 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Group does not exist.</h3> <h3>Group does not exist.</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-group-unexpected-error-link" class="btn-operations"> <a href="#" id="group-unexpected-error-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a> </a>
</div> </div>
@ -163,6 +225,7 @@
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script id="group-listing" data-image-resource="{{self.publicURL}}/images/" src="{{self.publicURL}}/templates/group-listing.hbs" type="text/x-handlebars-template" ></script> <script id="group-listing" data-image-resource="{{self.publicURL}}/images/"
src="{{self.publicURL}}/templates/group-listing.hbs" type="text/x-handlebars-template"></script>
<script src="{{self.publicURL}}/js/group-listing.js"></script> <script src="{{self.publicURL}}/js/group-listing.js"></script>
{{/zone}} {{/zone}}

@ -144,9 +144,9 @@ function loadGroups(searchType, searchParam) {
var successCallback = function (data) { var successCallback = function (data) {
data = JSON.parse(data); data = JSON.parse(data);
var viewModel = {}; var viewModel = {};
viewModel.groups = data.data; viewModel.groups = data;
viewModel.imageLocation = imageResource; viewModel.imageLocation = imageResource;
if(!data.data || data.data.length <= 0){ if (!data || data.length <= 0) {
$("#ast-container").html($("#no-groups-div-content").html()); $("#ast-container").html($("#no-groups-div-content").html());
} else { } else {
var content = template(viewModel); var content = template(viewModel);
@ -160,6 +160,7 @@ function loadGroups(searchType, searchParam) {
attachEvents(); attachEvents();
formatDates(); formatDates();
} }
attachGroupAdding();
}; };
invokerUtil.get(serviceURL, invokerUtil.get(serviceURL,
successCallback, function (message) { successCallback, function (message) {
@ -171,8 +172,8 @@ $(document).ready(function () {
loadGroups(); loadGroups();
}); });
function formatDates(){ function formatDates() {
$(".formatDate").each(function(){ $(".formatDate").each(function () {
var timeStamp = $(this).html(); var timeStamp = $(this).html();
$(this).html(new Date(parseInt(timeStamp)).toUTCString()); $(this).html(new Date(parseInt(timeStamp)).toUTCString());
}); });
@ -222,6 +223,71 @@ function hidePopup() {
$(modalPopup).hide(); $(modalPopup).hide();
} }
function attachGroupAdding() {
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on Group Management page in WSO2 IoT Server Console.
*/
$("a.add-group-link").click(function () {
var addGroupApi = "/iotserver/api/group/add";
$(modalPopupContent).html($('#add-group-modal-content').html());
showPopup();
$("a#add-group-yes-link").click(function () {
var newGroupName = $('#add-group-name').val();
var newGroupDescription = $('#add-group-description').val();
var group = {"name": newGroupName, "description": newGroupDescription};
invokerUtil.post(
addGroupApi,
group,
function (data, txtStatus, jqxhr) {
var status = jqxhr.status;
if (status == 200) {
if (data != "false") {
$(modalPopupContent).html($('#add-group-200-content').html());
$("a#add-group-200-link").click(function () {
hidePopup();
location.reload();
});
} else {
$(modalPopupContent).html($('#group-400-content').html());
$("a#group-400-link").click(function () {
hidePopup();
});
}
} else if (status == 400) {
$(modalPopupContent).html($('#group-400-content').html());
$("a#group-400-link").click(function () {
hidePopup();
});
} else if (status == 403) {
$(modalPopupContent).html($('#agroup-403-content').html());
$("a#group-403-link").click(function () {
hidePopup();
});
} else if (status == 409) {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
hidePopup();
});
}
},
function () {
$(modalPopupContent).html($('#add-group-unexpected-error-content').html());
$("a#group-unexpected-error-link").click(function () {
hidePopup();
});
}
);
});
$("a#add-group-cancel-link").click(function () {
hidePopup();
});
});
}
/** /**
* Following functions should be triggered after AJAX request is made. * Following functions should be triggered after AJAX request is made.
@ -230,7 +296,7 @@ function attachEvents() {
/** /**
* Following click function would execute * Following click function would execute
* when a user clicks on "Remove" link * when a user clicks on "Remove" link
* on Device Management page in WSO2 MDM Console. * on Group Management page in WSO2 IoT Server Console.
*/ */
$("a.remove-group-link").click(function () { $("a.remove-group-link").click(function () {
var groupId = $(this).data("groupid"); var groupId = $(this).data("groupid");
@ -240,35 +306,43 @@ function attachEvents() {
showPopup(); showPopup();
$("a#remove-group-yes-link").click(function () { $("a#remove-group-yes-link").click(function () {
invokerUtil.get( invokerUtil.delete(
removeGroupApi, removeGroupApi,
function (data,txtStatus,jqxhr) { function (data, txtStatus, jqxhr) {
var status = jqxhr.status; var status = jqxhr.status;
if (status == 200) { if (status == 200) {
$(modalPopupContent).html($('#remove-group-200-content').html()); if (data != "false") {
$('div[data-group="' + groupId + '"]').remove(); $(modalPopupContent).html($('#remove-group-200-content').html());
$("a#remove-group-200-link").click(function () { $('div[data-group="' + groupId + '"]').remove();
hidePopup(); $("a#remove-group-200-link").click(function () {
}); hidePopup();
location.reload();
});
} else {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
hidePopup();
});
}
} else if (status == 400) { } else if (status == 400) {
$(modalPopupContent).html($('#remove-group-400-content').html()); $(modalPopupContent).html($('#group-400-content').html());
$("a#remove-group-400-link").click(function () { $("a#remove-group-400-link").click(function () {
hidePopup(); hidePopup();
}); });
} else if (status == 403) { } else if (status == 403) {
$(modalPopupContent).html($('#remove-group-403-content').html()); $(modalPopupContent).html($('#group-403-content').html());
$("a#remove-group-403-link").click(function () { $("a#remove-group-403-link").click(function () {
hidePopup(); hidePopup();
}); });
} else if (status == 409) { } else if (status == 409) {
$(modalPopupContent).html($('#remove-group-409-content').html()); $(modalPopupContent).html($('#group-409-content').html());
$("a#remove-group-409-link").click(function () { $("a#remove-group-409-link").click(function () {
hidePopup(); hidePopup();
}); });
} }
}, },
function () { function () {
$(modalPopupContent).html($('#remove-group-unexpected-error-content').html()); $(modalPopupContent).html($('#group-unexpected-error-content').html());
$("a#remove-group-unexpected-error-link").click(function () { $("a#remove-group-unexpected-error-link").click(function () {
hidePopup(); hidePopup();
}); });
@ -290,46 +364,57 @@ function attachEvents() {
$("a.edit-group-link").click(function () { $("a.edit-group-link").click(function () {
var groupId = $(this).data("groupid"); var groupId = $(this).data("groupid");
var groupName = $(this).data("groupname"); var groupName = $(this).data("groupname");
var groupDescription = $(this).data("groupdescription");
var editGroupApi = "/iotserver/api/group/id/" + groupId + "/update"; var editGroupApi = "/iotserver/api/group/id/" + groupId + "/update";
$(modalPopupContent).html($('#edit-group-modal-content').html()); $(modalPopupContent).html($('#edit-group-modal-content').html());
$('#edit-group-name').val(groupName); $('#edit-group-name').val(groupName);
$('#edit-group-description').val(groupDescription);
showPopup(); showPopup();
$("a#edit-group-yes-link").click(function () { $("a#edit-group-yes-link").click(function () {
var newGroupName = $('#edit-group-name').val(); var newGroupName = $('#edit-group-name').val();
var group={"group":{"name" : newGroupName}}; var newGroupDescription = $('#edit-group-description').val();
var group = {"name": newGroupName, "description": newGroupDescription};
invokerUtil.post( invokerUtil.post(
editGroupApi, editGroupApi,
group, group,
function (data,txtStatus,jqxhr) { function (data, txtStatus, jqxhr) {
var status = jqxhr.status; var status = jqxhr.status;
if (status == 200) { if (status == 200) {
$(modalPopupContent).html($('#edit-group-200-content').html()); if (data != "false") {
$("div[data-groupid='"+groupId+"'] .ast-name").html(newGroupName); $(modalPopupContent).html($('#edit-group-200-content').html());
$("a#edit-group-200-link").click(function () { $("div[data-groupid='" + groupId + "'] .ast-name").html(newGroupName);
hidePopup(); $("a#edit-group-200-link").click(function () {
}); hidePopup();
location.reload();
});
} else {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
hidePopup();
});
}
} else if (status == 400) { } else if (status == 400) {
$(modalPopupContent).html($('#edit-group-400-content').html()); $(modalPopupContent).html($('#group-400-content').html());
$("a#edit-group-400-link").click(function () { $("a#group-400-link").click(function () {
hidePopup(); hidePopup();
}); });
} else if (status == 403) { } else if (status == 403) {
$(modalPopupContent).html($('#edit-group-403-content').html()); $(modalPopupContent).html($('#group-403-content').html());
$("a#edit-group-403-link").click(function () { $("a#group-403-link").click(function () {
hidePopup(); hidePopup();
}); });
} else if (status == 409) { } else if (status == 409) {
$(modalPopupContent).html($('#edit-group-409-content').html()); $(modalPopupContent).html($('#group-409-content').html());
$("a#edit-group-409-link").click(function () { $("a#group-409-link").click(function () {
hidePopup(); hidePopup();
}); });
} }
}, },
function () { function () {
$(modalPopupContent).html($('#edit-group-unexpected-error-content').html()); $(modalPopupContent).html($('#group-unexpected-error-content').html());
$("a#edit-group-unexpected-error-link").click(function () { $("a#group-unexpected-error-link").click(function () {
hidePopup(); hidePopup();
}); });
} }

@ -1,6 +1,6 @@
{{#each groups}} {{#each groups}}
{{groupMap this}} {{groupMap this}}
<div class="ctrl-wr-asset" data-groupid="{{groupId}}"> <div class="ctrl-wr-asset" data-groupid="{{id}}">
<div class="itm-select"> <div class="itm-select">
<label class="wr-input-control checkbox"> <label class="wr-input-control checkbox">
<input type="checkbox"/> <input type="checkbox"/>
@ -8,7 +8,7 @@
</label> </label>
</div> </div>
<div class="itm-ast"> <div class="itm-ast">
<a href="group/id/{{groupId}}"> <a href="group/{{id}}">
<div class="ast-img"><img src="{{../imageLocation}}group-icon.png"/></div> <div class="ast-img"><img src="{{../imageLocation}}group-icon.png"/></div>
<div class="ast-desc"> <div class="ast-desc">
<div class="ast-title"> <div class="ast-title">
@ -20,21 +20,28 @@
<span class="ast-ver">Shared with: {{users}}</span> <span class="ast-ver">Shared with: {{users}}</span>
<div class="ast-btn-group"> <div class="ast-btn-group">
<a href="/iotserver/group/id/{{groupId}}"> <a href="/iotserver/group/{{id}}">
<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-view fw-stack-1x"></i> <i class="fw fw-view fw-stack-1x"></i>
</span> </span>
<span class="lbl-action">View</span> <span class="lbl-action">View</span>
</a> </a>
<a href="#" class="edit-group-link" data-groupid="{{groupId}}" data-groupname="{{name}}"> <a href="#" class="share-group-link" data-groupid="{{id}}">
<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="lbl-action">Share</span>
</a>
<a href="#" class="edit-group-link" data-groupid="{{id}}" data-groupname="{{name}}" data-groupdescription="{{description}}">
<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-edit fw-stack-1x"></i> <i class="fw fw-edit fw-stack-1x"></i>
</span> </span>
<span class="lbl-action">Edit</span> <span class="lbl-action">Edit</span>
</a> </a>
<a href="#" class="remove-group-link" data-groupid="{{groupId}}"> <a href="#" class="remove-group-link" data-groupid="{{id}}">
<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-delete fw-stack-1x"></i> <i class="fw fw-delete fw-stack-1x"></i>

@ -1,4 +1,3 @@
function onRequest(context){ function onRequest(context){
var log = new Log();
return context; return context;
} }

@ -358,7 +358,7 @@ a.ast-type-item:hover {
} }
.ast-title { .ast-title {
height: 70px; /*height: 70px;*/
overflow: hidden; overflow: hidden;
} }

@ -67,6 +67,10 @@
content: "\e656"; content: "\e656";
} }
.fw-group:before {
content: "\e611";
}
.fw-dots:before { .fw-dots:before {
content: "\e615"; content: "\e615";
} }

@ -595,4 +595,20 @@ header{background-color: #2a2a2a;}
.wiz-lbl > span { .wiz-lbl > span {
padding-top:0px; padding-top:0px;
display:inline-block; display:inline-block;
}
::-webkit-input-placeholder { /* WebKit browsers */
color: #b2b2b2;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #b2b2b2;
opacity: 1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #b2b2b2;
opacity: 1;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
color: #b2b2b2;
} }
Loading…
Cancel
Save