Group module completed without sharing

merge-requests/1/head
charithag 9 years ago
parent 00122dc921
commit b59a2e22de

@ -42,22 +42,23 @@ var groupId;
if (uriMatcher.match("/{context}/api/group/add")) {
var name = request.getParameter("name");
var description = request.getParameter("description");
//URL: POST https://localhost:9443/devicecloud/group_manager/group/add
endPoint = deviceCloudService + "/group/add";
var group = request.getContent();
var name = group["name"];
var description = group["description"];
//URL: POST https://localhost:9443/devicecloud/group_manager/group
endPoint = deviceCloudService + "/group";
data = {"name": name, "username": user.username, "description": description};
result = post(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/update")) {
groupId = uriMatcher.elements().groupId;
name = request.getParameter("name");
description = request.getParameter("description");
group = request.getContent();
name = group["name"];
description = group["description"];
//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};
result = put(endPoint, data, "json");
@ -66,23 +67,23 @@ if (uriMatcher.match("/{context}/api/group/add")) {
groupId = uriMatcher.elements().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};
result = del(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}")) {
groupId = uriMatcher.elements().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};
result = get(endPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/group/name/{groupName}")) {
//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};
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")) {
groupId = uriMatcher.elements().groupId;
var shareUser = request.getParameter("shareUser");
role = request.getParameter("role");
var shareUser = request.getContent()["shareUser"];
role = request.getContent()["role"];
//URL: PUT https://localhost:9443/devicecloud/group_manager/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")) {
groupId = uriMatcher.elements().groupId;
var unShareUser = request.getParameter("unShareUser");
role = request.getParameter("role");
var unShareUser = request.getContent()["unShareUser"];
role = request.getContent()["role"];
//URL: DELETE https://localhost:9443/devicecloud/group_manager/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")) {
groupId = uriMatcher.elements().groupId;
var permissions = request.getParameter("permissions");
role = request.getParameter("role");
var permissions = request.getContent()["permissions"];
role = request.getContent()["role"];
//URL: POST https://localhost:9443/devicecloud/group_manager/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")) {
groupId = uriMatcher.elements().groupId;
role = request.getParameter("role");
role = request.getContent()["role"];
//URL: DELETE https://localhost:9443/devicecloud/group_manager/group/id/{groupId}/role
endPoint = deviceCloudService + "/group/id/" + groupId + "/role";
@ -183,8 +184,8 @@ if (uriMatcher.match("/{context}/api/group/add")) {
} else if (uriMatcher.match("/{context}/api/group/id/{groupId}/device/assign")) {
groupId = uriMatcher.elements().groupId;
var deviceId = request.getParameter("deviceId");
var deviceType = request.getParameter("deviceType");
var deviceId = request.getContent()["deviceId"];
var deviceType = request.getContent()["deviceType"];
//URL: GET https://localhost:9443/devicecloud/group_manager/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.
if (result) {
print(result);
response.status = result.xhr.status;
print(false);
}
%>

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

@ -1,23 +1,12 @@
{{authorized}}
{{layout "fluid"}}
{{#zone "title"}}
Groups
Group Management
{{/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">
{{unit "appbar" enableBack=true title="Group"}}
{{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}}

@ -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();'>
<span class="fw-stack"></span>
{{title}}
</a>{{#each currentActions}}<a href="{{url}}" class="cu-btn">
</a>{{#each currentActions}}<a href="{{url}}" class="cu-btn {{class}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw {{icon}} fw-stack-1x"></i>
@ -41,7 +41,8 @@
<!-- common navigation -->
<div id="hiddenNav" class="wr-hidden-nav">
<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}}
<li><a href="/iotserver/users"><i class="fw fw-user"></i>User Management</a></li>
{{/if}}

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

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

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

@ -1,7 +1,7 @@
{{#zone "main"}}
<div class="row wr-group-board">
<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}}
<span class="lbl-device">
{{#if group.viewModel.vendor}}
@ -28,8 +28,10 @@
<img src="{{self.publicURL}}/img/group-icon.png" style="width:200px" />
</div>
<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>Date of Enrollment:</b><br/> <span class="formatDate">{{group.enrollment}}</span></div>
<div class="ast-group-desc"><b>No. of Devices:</b> {{group.deviceCount}}</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>
@ -107,7 +109,7 @@
</div>
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
<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>

@ -1,53 +1,23 @@
var log = new Log("modules/group-detail.js");
function onRequest(context) {
var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
var isMatched = uriMatcher.match("/{context}/group/id/{groupId}");
var isMatched = uriMatcher.match("/{context}/group/{groupId}");
if (isMatched) {
var carbon = require('carbon');
var carbonHttpsServletTransport = carbon.server.address('https');
var matchedElements = uriMatcher.elements();
var groupId = matchedElements.groupId;
context.groupId = groupId;
//var group = deviceModule.viewDevice(deviceType, deviceId);
//if (device){
// var viewModel = {};
// var deviceInfo = device.properties.DEVICE_INFO;
// if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0){
// deviceInfo = JSON.parse(deviceInfo);
// 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;
// }
var endpoint = carbonHttpsServletTransport + "/" + matchedElements.context + "/api/group/id/" + groupId;
log.info(endpoint);
//var result = get(endpoint, {}, "json");
//if (result){
// context.group = result.data;
//}else{
// response.sendError(503);
//}
context.group = groupId;
} else {
response.sendError(404);
}

@ -24,46 +24,7 @@ function formatDates(){
}
(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(){
loadOperationBar(deviceType);
loadMap();
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 id="no-groups-div-content" class="hide">
<!-- no devices found -->
<!-- no groups found -->
<div class="container-fluid wr-content-alt">
<div class="ctrl-info-panel col-md-6 col-centered">
<h2>You don't have any Groups registered at the moment.</h2>
<p>
</a><a href="#" class="cu-btn">
<a href="#" class="cu-btn add-group-link">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add New Group
</a>
Add New Group
</a>
</p>
</div>
</div>
<!-- /no devices found -->
<!-- /no groups found -->
</div>
<div id="remove-group-modal-content" class="hide">
@ -35,6 +35,7 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this group from your Group List?</h3>
<div class="buttons">
<a href="#" id="remove-group-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Yes&nbsp;&nbsp;&nbsp;&nbsp;
@ -54,6 +55,7 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-group-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
@ -64,18 +66,73 @@
</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 class="content">
<div class="row">
<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/>
<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 class="buttons">
<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>
&nbsp;&nbsp;
<a href="#" id="edit-group-cancel-link" class="btn-operations">
@ -92,6 +149,7 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully updated.</h3>
<div class="buttons">
<a href="#" id="edit-group-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
@ -107,8 +165,9 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Exception at backend. Try Later.</h3>
<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;
</a>
</div>
@ -122,8 +181,9 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Action not permitted.</h3>
<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;
</a>
</div>
@ -137,8 +197,9 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group does not exist.</h3>
<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;
</a>
</div>
@ -152,8 +213,9 @@
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group does not exist.</h3>
<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;
</a>
</div>
@ -163,6 +225,7 @@
</div>
{{/zone}}
{{#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>
{{/zone}}

@ -144,9 +144,9 @@ function loadGroups(searchType, searchParam) {
var successCallback = function (data) {
data = JSON.parse(data);
var viewModel = {};
viewModel.groups = data.data;
viewModel.groups = data;
viewModel.imageLocation = imageResource;
if(!data.data || data.data.length <= 0){
if (!data || data.length <= 0) {
$("#ast-container").html($("#no-groups-div-content").html());
} else {
var content = template(viewModel);
@ -160,6 +160,7 @@ function loadGroups(searchType, searchParam) {
attachEvents();
formatDates();
}
attachGroupAdding();
};
invokerUtil.get(serviceURL,
successCallback, function (message) {
@ -171,8 +172,8 @@ $(document).ready(function () {
loadGroups();
});
function formatDates(){
$(".formatDate").each(function(){
function formatDates() {
$(".formatDate").each(function () {
var timeStamp = $(this).html();
$(this).html(new Date(parseInt(timeStamp)).toUTCString());
});
@ -222,6 +223,71 @@ function hidePopup() {
$(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.
@ -230,7 +296,7 @@ function attachEvents() {
/**
* Following click function would execute
* 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 () {
var groupId = $(this).data("groupid");
@ -240,35 +306,43 @@ function attachEvents() {
showPopup();
$("a#remove-group-yes-link").click(function () {
invokerUtil.get(
invokerUtil.delete(
removeGroupApi,
function (data,txtStatus,jqxhr) {
function (data, txtStatus, jqxhr) {
var status = jqxhr.status;
if (status == 200) {
$(modalPopupContent).html($('#remove-group-200-content').html());
$('div[data-group="' + groupId + '"]').remove();
$("a#remove-group-200-link").click(function () {
hidePopup();
});
if (data != "false") {
$(modalPopupContent).html($('#remove-group-200-content').html());
$('div[data-group="' + groupId + '"]').remove();
$("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) {
$(modalPopupContent).html($('#remove-group-400-content').html());
$(modalPopupContent).html($('#group-400-content').html());
$("a#remove-group-400-link").click(function () {
hidePopup();
});
} else if (status == 403) {
$(modalPopupContent).html($('#remove-group-403-content').html());
$(modalPopupContent).html($('#group-403-content').html());
$("a#remove-group-403-link").click(function () {
hidePopup();
});
} else if (status == 409) {
$(modalPopupContent).html($('#remove-group-409-content').html());
$(modalPopupContent).html($('#group-409-content').html());
$("a#remove-group-409-link").click(function () {
hidePopup();
});
}
},
function () {
$(modalPopupContent).html($('#remove-group-unexpected-error-content').html());
$(modalPopupContent).html($('#group-unexpected-error-content').html());
$("a#remove-group-unexpected-error-link").click(function () {
hidePopup();
});
@ -290,46 +364,57 @@ function attachEvents() {
$("a.edit-group-link").click(function () {
var groupId = $(this).data("groupid");
var groupName = $(this).data("groupname");
var groupDescription = $(this).data("groupdescription");
var editGroupApi = "/iotserver/api/group/id/" + groupId + "/update";
$(modalPopupContent).html($('#edit-group-modal-content').html());
$('#edit-group-name').val(groupName);
$('#edit-group-description').val(groupDescription);
showPopup();
$("a#edit-group-yes-link").click(function () {
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(
editGroupApi,
group,
function (data,txtStatus,jqxhr) {
function (data, txtStatus, jqxhr) {
var status = jqxhr.status;
if (status == 200) {
$(modalPopupContent).html($('#edit-group-200-content').html());
$("div[data-groupid='"+groupId+"'] .ast-name").html(newGroupName);
$("a#edit-group-200-link").click(function () {
hidePopup();
});
if (data != "false") {
$(modalPopupContent).html($('#edit-group-200-content').html());
$("div[data-groupid='" + groupId + "'] .ast-name").html(newGroupName);
$("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) {
$(modalPopupContent).html($('#edit-group-400-content').html());
$("a#edit-group-400-link").click(function () {
$(modalPopupContent).html($('#group-400-content').html());
$("a#group-400-link").click(function () {
hidePopup();
});
} else if (status == 403) {
$(modalPopupContent).html($('#edit-group-403-content').html());
$("a#edit-group-403-link").click(function () {
$(modalPopupContent).html($('#group-403-content').html());
$("a#group-403-link").click(function () {
hidePopup();
});
} else if (status == 409) {
$(modalPopupContent).html($('#edit-group-409-content').html());
$("a#edit-group-409-link").click(function () {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
hidePopup();
});
}
},
function () {
$(modalPopupContent).html($('#edit-group-unexpected-error-content').html());
$("a#edit-group-unexpected-error-link").click(function () {
$(modalPopupContent).html($('#group-unexpected-error-content').html());
$("a#group-unexpected-error-link").click(function () {
hidePopup();
});
}

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

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

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

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

@ -596,3 +596,19 @@ header{background-color: #2a2a2a;}
padding-top:0px;
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