Merge pull request #1086 from lasanthaDLPDS/application-mgt

Remove unnecessary pages and units
merge-requests/7/head
Kamidu Sachith Punchihewa 7 years ago committed by GitHub
commit 96ad19f634

@ -1,541 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Device Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.lib.ui-permissions-utility"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
{{#if group}}
<li>
<a href="{{@app.context}}/groups">
Groups
</a>
</li>
<li>
<a href="#">
{{group.name}}
</a>
</li>
{{else}}
<li>
<a href="{{@app.context}}/devices">
Devices
</a>
</li>
{{/if}}
{{/zone}}
{{#zone "navbarActions"}}
{{#if group}}
<li>
<a href="{{@app.context}}/devices" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
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-circle-outline fw-stack-2x"></i>
</span>
View Analytics
</a>
</li>-->
{{else}}
{{#if permissions.enroll}}
<li>
<a href="{{@app.context}}/device/enroll" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Enroll Device
</a>
</li>
{{/if}}
{{/if}}
{{/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-2">
<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 id="group_owner" 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">
<div>
<span id="permission" data-permission="{{permissions.list}}"></span>
{{unit "cdmf.unit.device.operation-mod"}}
{{#if deviceCount}}
<div id="loading-content" class="col-centered">
<i class="fw fw-wso2-logo fw-pulse fw-2x"></i>
Loading devices . . .
<br>
</div>
<div id="device-listing-status" class="raw hidden">
<ul style="list-style-type: none;">
<li class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
<a id="device-listing-status-msg"></a>
</h4>
</li>
</ul>
</div>
<div id="device-table">
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view hidden"
id="device-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th>By Device Name</th>
<th>By Owner</th>
<th>By Status</th>
<th>By Platform</th>
<th>By Ownership</th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th class="no-sort"></th>
<th data-for="By Device name" class="text-filter"></th>
<th data-for="By Owner" class="text-filter"></th>
<th data-for="By Status" class="select-filter"></th>
<th data-for="By Platform" class="select-filter data-platform"></th>
<th data-for="By Ownership" class="select-filter"></th>
<th class="no-sort"></th>
</tr>
<tr class="bulk-action-row hidden">
<th colspan="7">
<ul class="tiles">
{{#unless group}}
<li>
<a href="#" style="width: 100px;height: 80px;;"
data-click-event="remove-form"
class="btn square-element add-devices-to-group-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-group fw-stack-1x"></i>
</span>
Add to Group
</a>
</li>
{{/unless}}
<li>
<a href="#" style="width: 100px;height: 80px;"
data-click-event="remove-form"
class="btn square-element remove-device-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
{{#if group}}
Remove from group
{{else}}
Remove Device
{{/if}}
</a>
</li>
</ul>
</th>
</tr>
</thead>
<tbody id="ast-container">
<br class="c-both"/>
</tbody>
</table>
</div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<a href="#">By Device Name<span class="ico-sort-asc"></span></a>
<a href="#">By Owner</a>
<a href="#">By Status</a>
<a href="#">By Platform</a>
<a href="#">By Ownership</a>
</div>
</div>
{{else}}
<div id="ast-container" class="ast-container list-view">
<div class="ctrl-info-panel col-centered text-center wr-login">
<h3 class="text-muted">
<i class="fw fw-devices fw-3x"></i>
</h3>
<h3 class="text-muted">
You don't have any
{{#if group}}
devices assigned to this group. Let's add a device!
{{else}}
enrolled devices. Let's enroll a device!
{{/if}}
</h3>
<h3>
{{#if group}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices" class="btn-operations btn-default">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Assign from My Devices
</a>
{{else}}
{{#if permissions.enroll}}
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/device/enroll" class="btn-operations btn-default">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Enroll New Device
</a>
{{/if}}
{{/if}}
</h3>
</div>
</div>
{{/if}}
<div id="group-device-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
<span>
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-group fw-stack-1x"></i>
</span> Device Grouping
</span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div id="user-groups">Loading...</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-add-link" class="btn-operations">
Add devices to group
</a>
<a href="#" id="group-device-update-link" class="btn-operations">
Update assignment
</a>
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
Cancel
</a>
</div>
</div>
</div>
<div id="group-associate-device-200-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-3 col-centered">
<h3>Successfully added the device/s to the group!</h3>
</div>
</div>
</div>
</div>
<div id="remove-device-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
{{#if group}}
Do you really want to remove this device(s) from '{{group.name}}' group?
{{else}}
Do you really want to remove this device(s) from your Devices?
{{/if}}
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i>
</button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="remove-device-yes-link" class="btn-operations">
Yes
</a>
<a href="#" id="remove-device-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
<div id="remove-device-200-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
{{#if group}}
Successfully removed from '{{group.name}}' group.
{{else}}
Successfully removed.
{{/if}}
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i>
</button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
</div>
</div>
</div>
<div id="edit-device-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
Please enter a new name for the device.
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i>
</button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<input id="edit-device-name" style="color:#3f3f3f;padding:5px" type="text"
value=""
placeholder="Type here" size="60">
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="edit-device-yes-link" class="btn-operations">
Rename
</a>
<a href="#" id="edit-device-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
<div id="edit-device-200-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
Device was successfully updated.
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i>
</button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons">
<div id="edit-device-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Device was successfully updated.</h3>
</div>
</div>
</div>
</div>
<div id="device-400-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Exception at backend. Try Later.</h3>
<br/>
<div class="buttons">
<a href="#" id="device-400-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-403-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Operation not permitted.</h3>
<br/>
<div class="buttons">
<a href="#" id="device-403-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-404-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
You don't have any device group to add this device. Let's add a new
device group!</h3>
<br/>
<div class="buttons">
<a href="{{@app.context}}/group/add" class="btn-operations">
Add New Group
</a>
<a href="#" id="cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-409-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Device does not exist.</h3>
<br/>
<div class="buttons">
<a href="#" id="remove-device-409-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="no-device-selected" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Please select one or more devices in order to perform this
operation.</h3>
<br/>
<div class="buttons">
<a href="#" id="no-device-selected-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
<script id="device-listing" data-server-url="{{serverUrl}}" data-current-user="{{@user.username}}" data-device-types="{{deviceTypes}}"
data-portal-url="{{portalUrl}}" data-user-domain="{{userDomain}}" type="text/x-handlebars-template"></script>
{{js "js/listing.js"}}
{{/zone}}
{{#zone "topCss"}}
<style>
.select2-dropdown {
z-index: 999999999;
}
.wr-input-control {
color: black;
}
.select2-selection__choice {
font-size: medium;
}
</style>
{{/zone}}

@ -1,101 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
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 groupId = request.getParameter("groupId");
var viewModel = {};
var title = "Devices";
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);
if (currentUser) {
viewModel.permissions = {};
var uiPermissions = userModule.getUIPermissions();
viewModel.permissions.list = stringify(uiPermissions);
if (uiPermissions.ADD_DEVICE) {
viewModel.permissions.enroll = true;
}
viewModel.currentUser = currentUser;
var deviceCount = 0;
if (groupId) {
deviceCount = groupModule.getGroupDeviceCount(groupId);
} else {
deviceCount = deviceModule.getDevicesCount();
}
if (deviceCount > 0) {
viewModel.deviceCount = deviceCount;
var utility = require("/app/modules/utility.js").utility;
var typesListResponse = deviceModule.getDeviceTypes();
var deviceTypes = [];
if (typesListResponse["status"] == "success") {
var data = typesListResponse.content.deviceTypes;
if (data) {
for (var i = 0; i < data.length; i++) {
var config = utility.getDeviceTypeConfig(data[i]);
var category = "iot";
var label = data[i];
var analyticsEnabled = "false";
var groupingEnabled = "true";
var analyticsView = null;
if (config) {
var deviceType = config.deviceType;
category = deviceType.category;
label = deviceType.label;
analyticsEnabled = deviceType.analyticsEnabled;
groupingEnabled = deviceType.groupingEnabled;
analyticsView = deviceType.analyticsView;
}
deviceTypes.push({
"type": data[i],
"category": category,
"label": label,
"thumb": utility.getDeviceThumb(data[i]),
"analyticsEnabled": analyticsEnabled,
"groupingEnabled": groupingEnabled,
"analyticsView" : analyticsView
});
}
}
}
viewModel.deviceTypes = stringify(deviceTypes);
}
}
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var serverUrl = mdmProps["httpsURL"];
var portalUrl = mdmProps["portalURL"];
var userDomain = context.user.domain;
viewModel.serverUrl = serverUrl;
viewModel.portalUrl = portalUrl;
viewModel.userDomain = userDomain;
return viewModel;
}

@ -1,959 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* 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" && !$(this).hasClass("btn")) {
url = $(this).parent().data("url");
$(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 deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container";
var deviceListing, currentUser, groupId;
/*
* DOM ready functions.
*/
$(document).ready(function () {
var permissionSet = {};
$.setPermission = function (permission) {
permissionSet[permission] = true;
};
$.hasPermission = function (permission) {
return permissionSet[permission];
};
deviceListing = $("#device-listing");
currentUser = deviceListing.data("current-user");
groupId = getParameterByName("groupId");
/* Adding selected class for selected devices */
$(deviceCheckbox).each(function () {
addDeviceSelectedClass(this);
});
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
html: true,
content: function () {
return $("#content-filter-types").html();
}
});
});
/*
* On Select All Device button click function.
*
* @param button: Select All Device button
*/
function selectAllDevices(button) {
if (!$(button).data('select')) {
$(deviceCheckbox).each(function (index) {
$(this).prop('checked', true);
addDeviceSelectedClass(this);
});
$(button).data('select', true);
$(button).html('Deselect All Devices');
} else {
$(deviceCheckbox).each(function (index) {
$(this).prop('checked', false);
addDeviceSelectedClass(this);
});
$(button).data('select', false);
$(button).html('Select All Devices');
}
}
/*
* On listing layout toggle buttons click function.
*
* @param view: Selected view type
* @param selection: Selection button
*/
function changeDeviceView(view, selection) {
$(".view-toggle").each(function () {
$(this).removeClass("selected");
});
$(selection).addClass("selected");
if (view == "list") {
$(assetContainer).addClass("list-view");
} else {
$(assetContainer).removeClass("list-view");
}
}
/*
* Add selected style class to the parent element function.
*
* @param checkbox: Selected checkbox
*/
function addDeviceSelectedClass(checkbox) {
if ($(checkbox).is(":checked")) {
$(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select");
} else {
$(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select");
}
}
function toTitleCase(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
function loadDevices(searchType, searchParam) {
var serviceURL;
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";
} else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) {
//Get authenticated users devices
serviceURL = "/api/device-mgt/v1.0/devices?user=" + currentUser;
} else {
$("#loading-content").remove();
$('#device-table').addClass('hidden');
$('#device-listing-status-msg').text('Permission denied.');
$("#device-listing-status").removeClass(' hidden');
return;
}
function getPropertyValue(deviceProperties, propertyName) {
if (!deviceProperties) {
return;
}
var property;
for (var i = 0; i < deviceProperties.length; i++) {
property = deviceProperties[i];
if (property.name == propertyName) {
return property.value;
}
}
return {};
}
function getDeviceTypeLabel(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
return deviceTypes[i].label;
}
}
return type;
}
function getDeviceTypeCategory(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
return deviceTypes[i].category;
}
}
return type;
}
function getDeviceTypeThumb(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
return deviceTypes[i].thumb;
}
}
return type;
}
function analyticsEnabled(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
var analyticsEnabled = deviceTypes[i].analyticsEnabled;
if (analyticsEnabled == undefined) {
// By default it should be enabled
return true;
}
// In JS Boolean("false") returns TRUE => http://stackoverflow.com/a/264037/1560536
return (analyticsEnabled == "true");
}
}
return true;
}
// Read "analyticsView" from config.json and return value if exists
function getAnalyticsView(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
var analyticsView = deviceTypes[i].analyticsView;
if (analyticsEnabled == undefined) {
// if undefined go to default analytics view
return "none";
}
return analyticsView;
}
}
return "none";
}
function groupingEnabled(type) {
var deviceTypes = deviceListing.data("deviceTypes");
for (var i = 0; i < deviceTypes.length; i++) {
if (deviceTypes[i].type == type) {
var groupingEnabled = deviceTypes[i].groupingEnabled;
if (groupingEnabled == undefined) {
// By default it should be enabled
return true;
}
// In JS Boolean("false") returns TRUE => http://stackoverflow.com/a/264037/1560536
return (groupingEnabled == "true");
}
}
return true;
}
var columns = [
{
targets: 0,
data: 'name',
class: 'remove-padding icon-only content-fill viewEnabledIcon',
render: function (data, type, row, meta) {
return '<div class="thumbnail icon"><img class="square-element text fw " src="'
+ getDeviceTypeThumb(row.deviceType) + '"/></div>';
}
},
{
targets: 1,
data: 'name',
class: 'viewEnabledIcon',
render: function (name, type, row, meta) {
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
var vendor = getPropertyValue(row.properties, 'VENDOR');
var html = '<h4>' + name + '</h4>';
if (model) {
html += '<div>(' + vendor + '-' + model + ')</div>';
}
return html;
}
},
{
targets: 2,
data: 'userPattern',
class: 'remove-padding-top viewEnabledIcon'
},
{
targets: 3,
data: 'status',
class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) {
var html;
switch (status) {
case 'ACTIVE' :
html = '<span><i class="fw fw-success icon-success"></i> Active</span>';
break;
case 'INACTIVE' :
html = '<span><i class="fw fw-warning icon-warning"></i> Inactive</span>';
break;
case 'BLOCKED' :
html = '<span><i class="fw fw-remove icon-danger"></i> Blocked</span>';
break;
case 'REMOVED' :
html = '<span><i class="fw fw-delete icon-danger"></i> Removed</span>';
break;
case 'UNREACHABLE' :
html = '<span><i class="fw fw-warning icon-warning"></i> Unreachable</span>';
break;
}
return html;
}
},
{
targets: 4,
data: 'type',
class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) {
return getDeviceTypeLabel(row.deviceType);
}
},
{
targets: 5,
data: 'ownership',
class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) {
if (getDeviceTypeCategory(row.deviceType) == 'mobile') {
return row.ownership;
} else {
return null;
}
}
},
{
targets: 6,
data: 'action-buttons',
class: 'text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix',
render: function (status, type, row, meta) {
var deviceType = row.deviceType;
var deviceIdentifier = row.deviceIdentifier;
var html = '<span></span>';
var portalUrl = $("#device-listing").data("portal-url");
var serverUrl = $("#device-listing").data("server-url");
var userDomain = $("#device-listing").data("userDomain");
var statURL;
if (status != 'REMOVED') {
html = '';
if (analyticsEnabled(row.deviceType)) {
// redirecting to respective analytics view depending on device configs
switch (getAnalyticsView(deviceType)) {
case "DAS" : { statURL =portalUrl + "/portal/t/"+ userDomain+ "/dashboards/android-iot/battery?owner=" +currentUser+"&deviceId=";break;}
default : {statURL=context+ "/device/" + row.deviceType +"/analytics?deviceId="}
}
html += '<a href="' + statURL +
deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' +
' class="btn padding-reduce-on-grid-view" data-placement="top" data-toggle="tooltip" data-original-title="Analytics"><span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' +
'<span class="hidden-xs hidden-on-grid-view">Analytics</span>';
}
if (!groupId && groupingEnabled(row.deviceType)) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" '
+
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' +
row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Group"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-group fw-stack-1x"></i></span>' +
'<span class="hidden-xs hidden-on-grid-view">Group</span></a>';
}
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Edit">'
+ '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
+ '<i class="fw fw-edit fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
var groupOwner = $('#group_owner').text();
if (groupId && groupOwner != "wso2.system.user") {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Remove from group">'
+ '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
+ '<i class="fw fw-delete fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Remove from group</span>';
} else {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Delete">'
+ '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
+ '<i class="fw fw-delete fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Delete</span>';
}
}
return html;
}
}
];
var fnCreatedRow = function (row, data, dataIndex) {
if(data.status != "REMOVED"){
$(row).attr('data-type', 'selectable');
}else{
$(row).attr('data-type', 'non-selectable');
}
$(row).attr('data-deviceid', htmlspecialchars(data.deviceIdentifier));
$(row).attr('data-devicetype', htmlspecialchars(data.deviceType));
$(row).attr('data-url', context + '/device/' + htmlspecialchars(data.deviceType) + '?id=' + htmlspecialchars(data.deviceIdentifier));
var model = htmlspecialchars(getPropertyValue(data.properties, 'DEVICE_MODEL'));
var vendor = htmlspecialchars(getPropertyValue(data.properties, 'VENDOR'));
var owner = htmlspecialchars(data.userPattern);
var status = htmlspecialchars(data.status);
var ownership = htmlspecialchars(data.ownership);
var deviceType = htmlspecialchars(data.deviceType);
var category = getDeviceTypeCategory(deviceType);
$.each($('td', row), function (colIndex) {
switch (colIndex) {
case 1:
$(this).attr('data-search', model + ',' + vendor);
$(this).attr('data-display', model);
break;
case 2:
$(this).attr('data-grid-label', "Owner");
$(this).attr('data-search', owner);
$(this).attr('data-display', owner);
break;
case 3:
$(this).attr('data-grid-label', "Status");
$(this).attr('data-search', status);
$(this).attr('data-display', status);
break;
case 4:
$(this).attr('data-grid-label', "Type");
$(this).attr('data-search', deviceType);
$(this).attr('data-display', getDeviceTypeLabel(deviceType));
break;
case 5:
if (category == 'mobile') {
$(this).attr('data-grid-label', "Ownership");
$(this).attr('data-search', ownership);
$(this).attr('data-display', ownership);
}
break;
}
});
};
function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html();
}
var dataFilter = function (data) {
data = JSON.parse(data);
var objects = [];
$(data.devices).each(function (index) {
objects.push(
{
model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"),
vendor: getPropertyValue(data.devices[index].properties, "VENDOR"),
userPattern: data.devices[index].enrolmentInfo.owner,
status: data.devices[index].enrolmentInfo.status,
ownership: data.devices[index].enrolmentInfo.ownership,
deviceType: data.devices[index].type,
deviceIdentifier: data.devices[index].deviceIdentifier,
name: data.devices[index].name
}
);
});
var json = {
"recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects
};
return JSON.stringify(json);
};
$('#device-grid').datatables_extended_serverside_paging(
null,
serviceURL,
dataFilter,
columns,
fnCreatedRow,
function () {
$(".icon .text").res_text(0.2);
$('#device-grid').removeClass('hidden');
$("#loading-content").remove();
attachDeviceEvents();
// if ($('.advance-search').length < 1) {
// $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
// .after('<a href="' + context + '/devices/search"' +
// ' class="advance-search add-padding-3x">Advance Search</a>');
// }
}, {
"placeholder": "Search By Device Name",
"searchKey": "name"
}
);
$(deviceCheckbox).click(function () {
addDeviceSelectedClass(this);
});
}
function openCollapsedNav() {
$('.wr-hidden-nav-toggle-btn').addClass('active');
$('#hiddenNav').slideToggle('slideDown', function () {
if ($(this).css('display') == 'none') {
$('.wr-hidden-nav-toggle-btn').removeClass('active');
}
});
}
/*
* DOM ready functions.
*/
$(document).ready(function () {
/* Adding selected class for selected devices */
$(deviceCheckbox).each(function () {
addDeviceSelectedClass(this);
});
var permissionList = $("#permission").data("permission");
for (var key in permissionList) {
if (permissionList.hasOwnProperty(key)) {
$.setPermission(key);
}
}
loadDevices();
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
html: true,
content: function () {
return $("#content-filter-types").html();
}
});
/* for data tables*/
$('[data-toggle="tooltip"]').tooltip();
$("[data-toggle=popover]").popover();
$(".ctrl-filter-type-switcher").popover({
html: true,
content: function () {
return $('#content-filter-types').html();
}
});
$('#nav').affix({
offset: {
top: $('header').height()
}
});
});
var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).modal('show');
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html("");
$(modalPopupContent).removeClass("operation-data");
$(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove();
}
function markAlreadyAssignedGroups(deviceId, deviceType) {
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
if (xhr.status == 200) {
if (data.length > 0) {
var selectedValues = [];
for (var i = 0; i < data.length; i++) {
if (data[i].owner != "wso2.system.user") {
selectedValues.push(data[i].id);
}
}
$("#groups").val(selectedValues).trigger("change");
}
} else {
displayErrors(xhr);
}
};
invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType,
successCallback, function (message) {
displayErrors(message);
});
}
/**
* Following functions should be triggered after AJAX request is made.
*/
function attachDeviceEvents() {
/**
* Following click function would execute
* when a user clicks on "Group" link
* on Device Management page in WSO2 DeviceMgt Console.
*/
if ($("a.group-device-link").length > 0) {
$("a.group-device-link").click(function () {
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
$(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').html(
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
$("a#group-device-update-link").hide();
showPopup();
var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) {
serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups?limit=100";
}
invokerUtil.get(serviceURL, function (data) {
$("a#group-device-add-link").hide();
var groups = JSON.parse(data);
var html = '';
var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<option value="' + groups.deviceGroups[i].id + '">' + groups.deviceGroups[i].name + '</option>';
hasGroups = true;
}
}
if (hasGroups) {
html = '<br/><h4>Please select device group(s)</h4><br/>' +
'<div class="wr-input-control">' +
'<select id="groups" class="form-control select2" multiple="multiple">' +
html + '</select></div>';
markAlreadyAssignedGroups(deviceId, deviceType);
$("a#group-device-update-link").show();
$("a#group-add-link").hide();
} else {
$("a#group-device-update-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);
$("select.select2[multiple=multiple]").select2({
tags: false
});
$("a#group-device-update-link").click(function () {
var deviceIdentifier = {"id": deviceId, "type": deviceType};
var deviceGroupIds = $("#groups").val();
if (!deviceGroupIds) {
deviceGroupIds = [];
}
var deviceToGroupsAssignment = {
deviceIdentifier: deviceIdentifier,
deviceGroupIds: deviceGroupIds
};
serviceURL = "/api/device-mgt/v1.0/groups/device/assign";
invokerUtil.post(serviceURL, deviceToGroupsAssignment, function (data) {
$(modalPopupContent).html($('#group-associate-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
});
}, function (jqXHR) {
if (jqXHR.status == 404) {
$(modalPopupContent).html($('#group-404-content').html());
$("a#cancel-link").click(function () {
hidePopup();
});
} else {
displayDeviceErrors(jqXHR);
}
});
$("a#group-device-cancel-link").click(function () {
hidePopup();
});
});
}
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on Device Management page in WSO2 MDM Console.
*/
$("a.remove-device-link").click(function () {
var deviceIdentifiers = [];
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
if (deviceId && deviceType) {
deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
} else {
deviceIdentifiers = getSelectedDevices();
}
if (deviceIdentifiers.length == 0) {
$(modalPopupContent).html($('#no-device-selected').html());
$("a#no-device-selected-link").click(function () {
hidePopup();
});
showPopup();
return;
}
$(modalPopupContent).html($('#remove-device-modal-content').html());
showPopup();
$("a#remove-device-yes-link").click(function () {
if (groupId) {
var serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {
$(modalPopupContent).html($('#remove-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
} else {
removeDevices(deviceIdentifiers);
}
});
$("a#remove-device-cancel-link").click(function () {
hidePopup();
});
});
/**
* Following click function would execute
* when a user clicks on "Edit" link
* on Device Management page in WSO2 MDM Console.
*/
$("a.edit-device-link").click(function () {
var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype");
var deviceName = $(this).data("devicename");
var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId + "/rename";
$(modalPopupContent).html($('#edit-device-modal-content').html());
$('#edit-device-name').val(deviceName);
showPopup();
$("a#edit-device-yes-link").click(function () {
var newDeviceName = $('#edit-device-name').val();
var request = {};
request['name'] = newDeviceName;
invokerUtil.post(serviceURL, request, function (message) {
$(modalPopupContent).html($('#edit-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
});
$("a#edit-device-cancel-link").click(function () {
hidePopup();
});
});
/**
* Following click function would execute
* when a user clicks on "Add to Group" link
* on Device Management page in WSO2 devicemgt Console.
*/
$("a.add-devices-to-group-link").click(function () {
$("a#group-device-update-link").hide();
var deviceIdentifiers = getSelectedDevices();
if (deviceIdentifiers.length == 0) {
$(modalPopupContent).html($('#no-device-selected').html());
$("a#no-device-selected-link").click(function () {
hidePopup();
});
showPopup();
return;
}
$(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').html(
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
$("a#group-device-add-link").hide();
showPopup();
var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) {
serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups?limit=100";
}
invokerUtil.get(serviceURL, function (data) {
var groups = JSON.parse(data);
var html = '';
var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<option value="' + groups.deviceGroups[i].id + '">' +
groups.deviceGroups[i].name + '</option>';
hasGroups = true;
}
}
if (hasGroups) {
html = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">' +
html + '</select>';
$("a#group-add-link").hide();
$("a#group-device-add-link").show();
} else {
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>';
$("a#group-add-link").show();
$("a#group-device-add-link").hide();
}
$('#user-groups').html(html);
$("a#group-device-add-link").click(function () {
var selectedGroup = $('#assign-group-selector').val();
serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices/add";
invokerUtil.post(serviceURL, deviceIdentifiers, function (data) {
$(modalPopupContent).html($('#group-associate-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
});
}, function (jqXHR) {
if (jqXHR.status == 404) {
$(modalPopupContent).html($('#group-404-content').html());
$("a#cancel-link").click(function () {
hidePopup();
});
} else {
displayDeviceErrors(jqXHR);
}
});
$("a#group-device-cancel-link").click(function () {
hidePopup();
});
});
}
function removeDevices(deviceIdentifiers) {
var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id;
invokerUtil.delete(serviceURL, function (message) {
if (deviceIdentifiers.length > 1) {
deviceIdentifiers.slice(1, deviceIdentifiers.length);
removeDevices(deviceIdentifiers);
} else {
$(modalPopupContent).html($('#remove-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
}
function displayDeviceErrors(jqXHR) {
showPopup();
if (jqXHR.status == 400) {
$(modalPopupContent).html($('#device-400-content').html());
$("a#device-400-link").click(function () {
hidePopup();
});
} else if (jqXHR.status == 403) {
$(modalPopupContent).html($('#device-403-content').html());
$("a#device-403-link").click(function () {
hidePopup();
});
} else if (jqXHR.status == 409) {
$(modalPopupContent).html($('#device-409-content').html());
$("a#device-409-link").click(function () {
hidePopup();
});
} else {
$(modalPopupContent).html($('#device-unexpected-error-content').html());
$("a#device-unexpected-error-link").click(function () {
hidePopup();
});
console.log("Error code: " + jqXHR.status);
}
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
/*
* Function to get selected devices.
*/
function getSelectedDevices() {
var deviceList = [];
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
thisTable.api().rows().every(function () {
if ($(this.node()).hasClass('DTTT_selected')) {
deviceList.push(
{
"id": $(thisTable.api().row(this).node()).data('deviceid'),
"type": $(thisTable.api().row(this).node()).data('devicetype')
}
);
}
});
return deviceList;
}

@ -1,114 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Device Type Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.ui.modal"}}
{{#zone "topCss"}}
{{css "css/custom.css"}}
{{/zone}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/device-types">
Device Types
</a>
</li>
{{/zone}}
{{#zone "navbarActions"}}
{{#unless isCloud}}
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/device-type/add" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Create Device Type
</a>
</li>
{{/unless}}
{{/zone}}
{{#zone "content"}}
{{#if hasDeviceTypes}}
<div id="loading-content" class="col-centered">
<input type="hidden" id="can-edit" value="true"/>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading device types . . .
<br>
</div>
<div id="devicetype-table">
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
id="devicetype-grid">
<thead>
<tr class="sort-row">
<th>By Device Type Name</th>
</tr>
<tr class="bulk-action-row">
<th colspan="3"></th>
</tr>
</thead>
<tbody id="ast-container" data-app-context="{{@app.context}}/"></tbody>
</table>
</div>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<!--suppress HtmlUnknownTag -->
<th>By Device Type name</th>
</div>
</div>
{{else}}
<div id="user-created-msg" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">You Haven't created device types yet.</p>
<br>Please click <b>"Create a Device Type"</b>, if you wish to create a device type.
<hr/>
<a href="{{@app.context}}/device-type/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Create Device Type
</a>
</div>
</div>
{{/if}}
{{/zone}}
{{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="devicetype-listing" data-current-user="{{@user.username}}"
src="{{@page.publicUri}}/templates/devicetype-listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/devicetype-listing.js"}}
{{/zone}}

@ -1,36 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
context["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/device-type")) {
context["editPermitted"] = true;
}
var deviceTypeCount = deviceModule.getDeviceTypeCount();
if (deviceTypeCount > 0) {
context["hasDeviceTypes"] = true;
} else {
context["hasDeviceTypes"] = false;
}
return context;
}

@ -1,207 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var loadDeviceTypeBasedActionURL = function (action, deviceTypeName) {
href = $("#ast-container").data("app-context") + "device-type/" + action + "?type=" + encodeURIComponent(deviceTypeName);
$(location).attr('href', href);
};
$(function () {
var sortableElem = '.wr-sortable';
$(sortableElem).sortable({
beforeStop: function () {
$(this).sortable('toArray');
}
});
$(sortableElem).disableSelection();
});
var apiBasePath = "/api/device-mgt/v1.0";
var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
var isInit = true;
var isCloud = false;
/**
*
* Fires the res_text when ever a data table redraw occurs making
* the font icons change the size to respective screen resolution.
*
*/
$(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2);
});
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).modal('show');
//setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove();
}
/**
* Following function would execute
* when a user clicks on the list item
* initial mode and with out select mode.
*/
function InitiateViewOption() {
// $(location).attr('href', $(this).data("url"));
}
function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html();
}
function loadDeviceTypes() {
var loadingContent = $("#loading-content");
loadingContent.show();
var dataFilter = function (data) {
data = JSON.parse(data);
var objects = [];
$(data).each(function (index) {
objects.push(
{
name: htmlspecialchars(data[index].name),
DT_RowId: "devicetype-" + htmlspecialchars(data[index].name),
metaDefinition: (data[index].deviceTypeMetaDefinition ? true : false)
}
)
});
var json = {
"recordsTotal": data.length,
"recordsFiltered": data.length,
"data": objects
};
return JSON.stringify(json);
};
//noinspection JSUnusedLocalSymbols
var fnCreatedRow = function (nRow, aData, iDataIndex) {
$(nRow).attr('data-type', 'selectable');
};
//noinspection JSUnusedLocalSymbols
var columns = [
{
class: "remove-padding content-fill",
data: null,
defaultContent: "<div class='thumbnail icon'>" +
"<i class='square-element text fw fw-devices' style='font-size: 74px;'></i>" +
"</div>"
},
{
class: "",
data: "name",
render: function (name, type, row, meta) {
return '<h4>' + name.replace("devicemgt", "") + '</h4>';
}
},
{
class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null,
render: function (data, type, row, meta) {
var isCloud = false;
if ($('#is-cloud').length > 0) {
isCloud = true;
}
var innerhtml = '';
if (data.metaDefinition) {
var editLink = '<a onclick="javascript:loadDeviceTypeBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
'data-devicetype="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-devicetype-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-devices fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">Edit</span>' +
'</a>';
var editEventLink = '<a onclick="javascript:loadDeviceTypeBasedActionURL(\'edit-event\', \'' + data.name + '\')" ' +
'data-devicetype="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-event-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-document fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">Edit Event</span>' +
'</a>';
innerhtml = editLink + editEventLink;
}
return innerhtml;
}
}
];
var options = {
"placeholder": "Search By Device Type Name",
"searchKey": "filter",
"searching": false
};
var settings = {
"sorting": false
};
var deviceTypeApiUrl = '/api/device-mgt/v1.0/admin/device-types';
$('#devicetype-grid').datatables_extended_serverside_paging(settings, deviceTypeApiUrl, dataFilter, columns, fnCreatedRow, null, options);
loadingContent.hide();
}
$(document).ready(function () {
loadDeviceTypes();
});

@ -1,44 +0,0 @@
{{#each deviceTypes}}
<tr data-type="selectable" id="devicetype-{{deviceTypeName}}">
<td class="remove-padding icon-only content-fill">
<div class="thumbnail icon">
<i class="square-element text fw fw-user"></i>
</div>
</td>
<td class="remove-padding-top">{{deviceTypeName}}</td>
<td class="text-right content-fill text-left-on-grid-view no-wrap">
{{#if canEdit}}
<a onclick="javascript:loadDeviceTypeBasedActionURL('edit', '{{deviceTypeName}}')" data-devicetype="{{deviceTypeName}}"
data-click-event="edit-form"
class="btn padding-reduce-on-grid-view edit-devicetype-link" title="Edit Device Type">
<span class="fw-stack fw-lg">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-user fw-stack-1x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
<span class="hidden-xs hidden-on-grid-view">Edit</span>
</a>
<a onclick="javascript:loadDeviceTypeBasedActionURL('edit-event', '{{deviceTypeName}}')"
data-devicetype="{{deviceTypeName}}"
data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link"
title="Edit Device Event">
<span class="fw-stack fw-lg">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-security-policy fw-stack-1x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
<span class="hidden-xs hidden-on-grid-view">Edit Event</span>
</a>
{{/if}}
</td>
</tr>
{{/each}}

@ -1,43 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may
obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies">
Policies
</a>
</li>
<li>
<a href="#">
View
</a>
</li>
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.effective-policy.view"}}
{{/zone}}

@ -1,24 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var utility = require("/app/modules/utility.js")["utility"];
var deviceType = context.uriParams.deviceType;
var deviceId = context.uriParams.deviceId;
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
}

@ -1,420 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Group Management"}}
{{unit "cdmf.unit.ui.content.title" pageHeader="Groups"}}
{{unit "cdmf.unit.lib.service-invoker-utility"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.lib.ui-permissions-utility"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/groups">
Groups
</a>
</li>
{{/zone}}
{{#zone "navbarActions"}}
{{#if permissions.ADD_GROUP}}
<li>
<a href="{{@app.context}}/group/add" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Add Group
</a>
</li>
{{/if}}
{{/zone}}
{{#zone "content"}}
<div class="wr-device-list row">
<div class="wr-hidden-operations wr-advance-operations"></div>
<div class="col-md-12 wr-page-content">
<div>
<span id="permission" data-permission="{{permissions.list}}"></span>
<span id="isCloud" data-isCloud="{{isCloud}}"></span>
{{#if groupCount}}
<div class="container-fluid" id="group-listing" data-current-user="{{@user.username}}">
<table class="table table-striped table-hover list-table display responsive nowrap data-table table-selectable grid-view"
id="group-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th class="no-sort"></th>
<th>By Owner</th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th></th>
<th></th>
<th data-for="By Owner" class="text-filter"></th>
<th></th>
</tr>
</thead>
<tbody id="ast-container"></tbody>
</table>
</div>
{{else}}
<div id="ast-container" class="ast-container list-view">
<div class="ctrl-info-panel col-centered text-center wr-login">
<h3 class="text-muted">
<i class="fw fw-group fw-3x"></i>
</h3>
<h3 class="text-muted">You don't have any device group. Let's add a new device group!</h3>
{{#if permissions.ADD_GROUP}}
<h3>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/group/add" class="btn-operations btn-default">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add New Group
</a>
</h3>
{{/if}}
</div>
</div>
{{/if}}
<div id="share-group-w1-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
<span>
<span class="fw-stack add-margin-right-2x">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-share fw-stack-1x"></i>
</span> Group Sharing
</span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div id="user-names">
<h4>
Select user role(s)
</h4>
<div class="wr-input-control" id="rolesListing">
</div>
</div>
</div>
<div class="modal-footer">
<div class="buttons">
{{#if permissions.ADD_ROLE}}
<a href="{{@app.context}}/role/add" class="btn-operations">
New Role
</a>
<a href="#" id="share-group-new-role-from-selection" class="btn-operations">
New Role from Selection
</a>
{{/if}}
<a href="#" id="share-group-next-link" class="btn-operations">
Share
</a>
</div>
</div>
</div>
<div id="share-group-w3-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
<span>
<span class="fw-stack add-margin-right-2x">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-bookmark fw-stack-1x"></i>
</span> Group Sharing Role
</span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div id="user-roles">
<h4>
Enter Group Sharing Role Name
<br><br>
<input type="text" id="group-sharing-role-name"
class="form-control modal-input operationDataKeys" />
<br><br>
</h4>
</div>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="share-group-w3-yes-link" class="btn-operations">
OK
</a>
<a href="#" id="share-group-w3-cancel-link" class="btn-operations btn-default">
Cancel
</a>
</div>
</div>
</div>
<div id="share-group-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group successfully updated.</h3>
<br />
Do you want to manage users?
<div class="buttons">
<a href="{{@app.context}}/users" id="share-group-add-users-yes-link"
class="btn-operations">
Yes
</a>
<a href="#" class="btn-operations btn-default" data-dismiss="modal">
No
</a>
</div>
<br />
</div>
</div>
</div>
</div>
<div id="create-combined-role-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>New Role was successfully created.</h3>
<br />
Do you need to Add / Remove users from the chosen roles?
<div class="buttons">
<a href="{{@app.context}}/users" id="share-group-add-users-yes-link"
class="btn-operations">
Yes
</a>
<a href="#" class="btn-operations btn-default" data-dismiss="modal">
No
</a>
</div>
<br />
</div>
</div>
</div>
</div>
<div id="remove-group-modal-content" class="hide">
<div class="content">
<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">
Yes
</a>
<a href="#" id="remove-group-cancel-link" class="btn-operations btn-default"
data-dismiss="modal">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-group-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully removed.</h3>
</div>
</div>
</div>
</div>
<div id="edit-group-modal-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
<span>
<span class="fw-stack add-margin-right-2x">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x"></i>
</span> Update Group
</span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i></button>
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div>
<h4>
Enter new name and description for the group
<br><br>
<input type="text" id="edit-group-name"
class="form-control modal-input operationDataKeys" placeholder="Group Name"
value="">
</input>
<br>
<input type="text" id="edit-group-description"
class="form-control modal-input operationDataKeys"
placeholder="Group Description" value="">
</h4>
</div>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="edit-group-yes-link" class="btn-operations">
Update
</a>
<a href="#" id="edit-group-cancel-link" class="btn-operations btn-default">
Cancel
</a>
</div>
</div>
</div>
<div id="edit-group-200-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Group was successfully updated.</h3>
</div>
</div>
</div>
</div>
<div id="group-400-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3 id="error-msg">Bad Request. Please contact your administrator.</h3>
<div class="buttons">
<a href="#" id="group-400-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-403-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Operation not permitted.</h3>
<div class="buttons">
<a href="#" id="group-403-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-404-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3 id="group-404-message">Not found.</h3>
<div class="buttons">
<a href="#" id="group-404-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-409-content" class="hide">
<div class="content">
<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="group-409-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-unexpected-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3 id="unexp-error-msg">Unexpected error occurred!</h3>
<div class="buttons">
<a href="#" id="group-unexpected-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
{{#if groupCount}}
{{js "js/listing.js"}}
{{/if}}
{{/zone}}
{{#zone "topCss"}}
<style>
.select2-dropdown {
z-index: 999999999;
}
.wr-input-control {
color: black;
}
.select2-selection__choice {
font-size: medium;
}
</style>
{{/zone}}

@ -1,37 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var constants = require("/app/modules/constants.js");
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var currentUser = session.get(constants.USER_SESSION_KEY);
var page = {};
if (currentUser) {
page.permissions = userModule.getUIPermissions();
page.permissions.list = stringify(page.permissions);
page.currentUser = currentUser;
var groupCount = groupModule.getGroupCount();
if (groupCount > 0) {
page.groupCount = groupCount;
}
}
page.isCloud = deviceMgtProps.isCloud;
return page;
}

@ -1,646 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* 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") {
url = $(this).parent().data("url");
$(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";
/*
* On Select All Groups button click function.
*
* @param button: Select All Groups button
*/
function selectAllDevices(button) {
if (!$(button).data('select')) {
$(groupCheckbox).each(function (index) {
$(this).prop('checked', true);
addGroupSelectedClass(this);
});
$(button).data('select', true);
$(button).html('Deselect All Groups');
} else {
$(groupCheckbox).each(function (index) {
$(this).prop('checked', false);
addGroupSelectedClass(this);
});
$(button).data('select', false);
$(button).html('Select All Groups');
}
}
/*
* On listing layout toggle buttons click function.
*
* @param view: Selected view type
* @param selection: Selection button
*/
function changeDeviceView(view, selection) {
$(".view-toggle").each(function () {
$(this).removeClass("selected");
});
$(selection).addClass("selected");
if (view == "list") {
$(assetContainer).addClass("list-view");
} else {
$(assetContainer).removeClass("list-view");
}
}
/*
* Add selected style class to the parent element function.
*
* @param checkbox: Selected checkbox
*/
function addGroupSelectedClass(checkbox) {
if ($(checkbox).is(":checked")) {
$(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select");
} else {
$(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select");
}
}
function toTitleCase(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html();
}
function loadGroups() {
var groupListing = $("#group-listing");
var currentUser = groupListing.data("currentUser");
var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) {
serviceURL = "/api/device-mgt/v1.0/admin/groups";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups";
} else {
$("#loading-content").remove();
$('#device-table').addClass('hidden');
$('#device-listing-status-msg').text('Permission denied.');
$("#device-listing-status").removeClass(' hidden');
return;
}
var dataFilter = function (data) {
data = JSON.parse(data);
var objects = [];
$(data.deviceGroups).each(function (index) {
objects.push({
groupId: htmlspecialchars(data.deviceGroups[index].id),
name: htmlspecialchars(data.deviceGroups[index].name),
description: htmlspecialchars(data.deviceGroups[index].description),
owner: htmlspecialchars(data.deviceGroups[index].owner)
})
});
var json = {
"recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects
};
return JSON.stringify(json);
};
var columns = [
{
targets: 0,
data: 'id',
class: 'remove-padding icon-only content-fill viewEnabledIcon',
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>';
}
},
{
targets: 1,
data: 'name',
class: 'viewEnabledIcon'
},
{
targets: 2,
data: 'owner',
class: 'remove-padding-top viewEnabledIcon'
},
{
targets: 3,
data: 'description',
class: 'remove-padding-top viewEnabledIcon'
},
{
targets: 4,
data: 'id',
class: 'text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix',
render: function (id, type, row, meta) {
var html = '';
if ($.hasPermission("VIEW_GROUP_DEVICES")) {
/*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-circle-outline fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>'
+
'<span class="hidden-xs hidden-on-grid-view">Analytics</span></a>';*/
}
if (row.owner != "wso2.system.user") {
if ($.hasPermission("SHARE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view share-group-link" data-group-id="'
+ row.groupId + '" ' +
'data-group-owner="' + row.owner
+ '" data-placement="top" data-toggle="tooltip" data-original-title="Share"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-share fw-stack-1x"></i></span>'
+
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
}
if ($.hasPermission("UPDATE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="'
+ row.name + '" ' +
'data-group-owner="' + row.owner + '" data-group-description="' + row.description
+ '" data-group-id="' + row.groupId
+ '" data-placement="top" data-toggle="tooltip" data-original-title="Edit"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
}
if ($.hasPermission("REMOVE_GROUP")) {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-id="'
+ row.groupId + '" ' +
'data-group-owner="' + row.owner
+ '" data-placement="top" data-toggle="tooltip" data-original-title="Delete"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>'
+
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
}
}
return html;
}
}
];
var fnCreatedRow = function (row, data) {
$(row).attr('data-type', 'selectable');
if ($.hasPermission("VIEW_GROUP_DEVICES")) {
$(row).attr('data-url', 'devices?groupId=' + data.groupId + '&groupName=' + data.name);
}
$.each($('td', row), function (colIndex) {
switch (colIndex) {
case 1:
//TODO : The following line encodes html entities.
//Should check for a better solution since it only changes the presentation layer
$(this).text($("<textarea></textarea>").html(this.innerText).text())
$(this).attr('data-grid-label', "Name");
$(this).attr('data-search', data.name);
$(this).attr('data-display', data.name);
break;
case 2:
$(this).attr('data-grid-label', "Owner");
$(this).attr('data-search', data.owner);
$(this).attr('data-display', data.owner);
break;
case 3:
$(this).attr('data-grid-label', "Description");
$(this).attr('data-search', data.description);
$(this).attr('data-display', data.description);
break;
}
});
};
$('#group-grid').datatables_extended_serverside_paging(
null,
serviceURL,
dataFilter,
columns,
fnCreatedRow,
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);
});
}
function openCollapsedNav() {
$('.wr-hidden-nav-toggle-btn').addClass('active');
$('#hiddenNav').slideToggle('slideDown', function () {
if ($(this).css('display') == 'none') {
$('.wr-hidden-nav-toggle-btn').removeClass('active');
}
});
}
/*
* 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
$.setPermission = function (permission) {
permissionSet[permission] = true;
};
$.hasPermission = function (permission) {
return permissionSet[permission];
};
var permissionList = $("#permission").data("permission");
for (var key in permissionList) {
if (permissionList.hasOwnProperty(key)) {
$.setPermission(key);
}
}
loadGroups();
//$('#device-grid').datatables_extended();
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover(
{
html: true,
content: function () {
return $("#content-filter-types").html();
}
}
);
/* for data tables*/
$('[data-toggle="tooltip"]').tooltip();
$("[data-toggle=popover]").popover();
$(".ctrl-filter-type-switcher").popover(
{
html: true,
content: function () {
return $('#content-filter-types').html();
}
}
);
$('#nav').affix(
{
offset: {
top: $('header').height()
}
}
);
});
var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).modal('show');
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html("");
$(modalPopupContent).removeClass("operation-data");
$(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove();
}
/**
* Following functions should be triggered after AJAX request is made.
*/
function attachEvents() {
/**
* Following click function would execute
* when a user clicks on "Share" link
* on Group Management page in WSO2 Device Management Server Console.
*/
$("a.share-group-link").click(function () {
var groupId = $(this).data("group-id");
var groupOwner = $(this).data("group-owner");
$(modalPopupContent).html($('#share-group-w1-modal-content').html());
showPopup();
listAllRoles(groupId);
var shareGroupNextLink = $("a#share-group-next-link");
shareGroupNextLink.click(function () {
var roles = $("#roles").val();
updateGroupShare(groupId, roles);
});
var shareGroupNewRoleFromSelectionLink = $("a#share-group-new-role-from-selection");
shareGroupNewRoleFromSelectionLink.click(function () {
var roles = $("#roles").val();
if (roles && roles.length >= 2) {
addNewRole(roles);
} else {
var errorMsgWrapper = "#notification-error-msg";
var errorMsg = "#notification-error-msg span";
$(errorMsg).text("To create a new role with the combination of roles, at least two roles should be" +
" selected.");
$(errorMsgWrapper).removeClass("hidden");
}
});
});
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on Group Management page in WSO2 IoT Server Console.
*/
$("a.remove-group-link").click(function () {
var groupId = $(this).data("group-id");
var groupOwner = $(this).data("group-owner");
$(modalPopupContent).html($('#remove-group-modal-content').html());
showPopup();
$("a#remove-group-yes-link").click(function () {
var successCallback = function (data, textStatus, xhr) {
if (xhr.status == 200) {
$(modalPopupContent).html($('#remove-group-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
} else {
displayErrors(xhr);
}
};
invokerUtil.delete("/api/device-mgt/v1.0/groups/id/" + groupId,
successCallback, function (message) {
displayErrors(message);
});
});
$("a#remove-group-cancel-link").click(function () {
hidePopup();
});
});
/**
* Following click function would execute
* when a user clicks on "Edit" link
* on Device Management page in WSO2 MDM Console.
*/
$("a.edit-group-link").click(function () {
var groupId = $(this).data("group-id");
var groupName = $(this).data("group-name");
var groupOwner = $(this).data("group-owner");
var groupDescription = $(this).data("group-description");
$(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 newGroupDescription = $('#edit-group-description').val();
var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner};
var successCallback = function (data, textStatus, xhr) {
if (xhr.status == 200) {
$(modalPopupContent).html($('#edit-group-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
} else {
displayErrors(xhr);
}
};
invokerUtil.put("/api/device-mgt/v1.0/groups/id/" + groupId, group,
successCallback, function (message) {
displayErrors(message);
});
});
$("a#edit-group-cancel-link").click(function () {
hidePopup();
});
});
}
function markAlreadySavedUsersRoles(groupId) {
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
if (xhr.status == 200) {
if (data.roles.length > 0) {
var selectedValues = [];
for (var i = 0; i < data.roles.length; i++) {
selectedValues.push(data.roles[i]);
}
$("#roles").val(selectedValues).trigger("change");
} else {
return;
}
} else {
displayErrors(xhr);
}
};
invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles",
successCallback, function (message) {
displayErrors(message);
});
}
function listAllRoles(groupId) {
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
if (xhr.status == 200) {
if (data.roles.length > 0) {
var html = '<select id="roles" class="form-control select2" multiple="multiple">';
for (var i = 0; i < data.roles.length; i++) {
html += '<option value="' + data.roles[i] + '">' + data.roles[i] + '</option>';
}
html += '</select>';
$("#rolesListing").html(html);
markAlreadySavedUsersRoles(groupId);
$("select.select2[multiple=multiple]").select2({tags: false}).on("select2:select", function () {
$("#notification-error-msg").addClass("hidden");
});
} else {
$("#rolesListing").html("No roles available");
}
} else {
displayErrors(xhr);
}
};
invokerUtil.get("/api/device-mgt/v1.0/roles?offset=0&limit=100&user-store=all",
successCallback, function (message) {
displayErrors(message);
});
}
function addNewRole(roles) {
$(modalPopupContent).html($('#share-group-w3-modal-content').html());
$("a#share-group-w3-yes-link").click(function () {
var roleName = $('#group-sharing-role-name').val();
if (roleName) {
createNewCombinedRole(roleName, roles);
} else {
var errorMsgWrapper = "#notification-error-msg";
var errorMsg = "#notification-error-msg span";
$(errorMsg).text("Role name cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
}
});
$("a#share-group-w3-cancel-link").click(function () {
hidePopup();
});
}
function togglePermissionAction(element) {
$(element).data('value', 'checked');
var icon = $(element).find("i")[1];
if ($(icon).hasClass('fw-minus')) {
$(icon).removeClass('fw-minus');
$(icon).addClass('fw-add');
$(element).data('value', 'unchecked');
} else {
$(icon).removeClass('fw-add');
$(icon).addClass('fw-minus');
$(element).data('value', 'checked');
}
}
function updateGroupShare(groupId, roles) {
var successCallback = function (data) {
$(modalPopupContent).html($('#share-group-200-content').html());
};
invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/share",
roles, successCallback, function (message) {
displayErrors(message);
});
}
function createNewCombinedRole(roleName, roleList) {
var successCallback = function (data, status, jqXHR, isLast) {
$(modalPopupContent).html($('#create-combined-role-200-content').html());
showPopup();
};
invokerUtil.post("/api/device-mgt/v1.0/roles/create-combined-role/" + roleName, roleList,
successCallback, function (message) {
displayErrors(message);
});
}
function displayErrors(jqXHR) {
showPopup();
if (jqXHR.status == 400) {
$(modalPopupContent).html($('#group-400-content').html());
if (jqXHR.responseText) {
$('#error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), ""));
}
$("a#group-400-link").click(function () {
hidePopup();
});
} else if (jqXHR.status == 403) {
$(modalPopupContent).html($('#group-403-content').html());
$("a#group-403-link").click(function () {
hidePopup();
});
} else if (jqXHR.status == 404) {
$(modalPopupContent).html($('#group-404-content').html());
$("#group-404-message").html(jqXHR.responseText);
$("a#group-404-link").click(function () {
hidePopup();
});
} else if (jqXHR.status == 409) {
$(modalPopupContent).html($('#group-409-content').html());
$("a#group-409-link").click(function () {
hidePopup();
});
} else {
$(modalPopupContent).html($('#group-unexpected-error-content').html());
if (jqXHR.responseText) {
$('#unexp-error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), ""));
}
$("a#group-unexpected-error-link").click(function () {
hidePopup();
});
console.log("Error code: " + jqXHR.status);
}
}

@ -1,275 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var loadRoleBasedActionURL = function (action, rolename) {
href = $("#ast-container").data("app-context") + "role/" + action + "/?rolename=" + encodeURIComponent(rolename);
$(location).attr('href', href);
};
$(function () {
var sortableElem = '.wr-sortable';
$(sortableElem).sortable({
beforeStop: function () {
$(this).sortable('toArray');
}
});
$(sortableElem).disableSelection();
});
var apiBasePath = "/api/device-mgt/v1.0";
var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modal-content";
var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
var isInit = true;
var isCloud = false;
/**
*
* Fires the res_text when ever a data table redraw occurs making
* the font icons change the size to respective screen resolution.
*
*/
$(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2);
});
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).modal('show');
//setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove();
}
/**
* Following function would execute
* when a user clicks on the list item
* initial mode and with out select mode.
*/
function InitiateViewOption() {
// $(location).attr('href', $(this).data("url"));
}
function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html();
}
function loadRoles() {
isCloud = $("#role-table").data("cloud");
var loadingContent = $("#loading-content");
loadingContent.show();
var dataFilter = function (data) {
data = JSON.parse(data);
var objects = [];
var count = 0;
$(data.roles).each(function (index) {
objects.push(
{
name: htmlspecialchars(data.roles[index]),
DT_RowId: "role-" + htmlspecialchars(data.roles[index])
}
)
});
var json = {
"recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects
};
return JSON.stringify(json);
};
//noinspection JSUnusedLocalSymbols
var fnCreatedRow = function (nRow, aData, iDataIndex) {
$(nRow).attr('data-type', 'selectable');
};
//noinspection JSUnusedLocalSymbols
var columns = [
{
class: "remove-padding icon-only content-fill",
data: null,
defaultContent: "<div class='thumbnail icon'>" +
"<i class='square-element text fw fw-bookmark' style='font-size: 74px;'></i>" +
"</div>"
},
{
class: "",
data: "name",
render: function (name, type, row, meta) {
return '<h4>' + name.replace("devicemgt", ""); + '</h4>';
}
},
{
class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null,
render: function (data, type, row, meta) {
var isCloud = false;
if ($('#is-cloud').length > 0) {
isCloud = true;
}
var innerhtml = '';
var editLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-role-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-bookmark fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">Edit</span>' +
'</a>';
var editPermissionLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-permission-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-security-policy fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">Edit Permission</span>' +
'</a>';
var removeLink = '<a data-role="' + data.name + '" ' +
'data-click-event="remove-form" ' +
'class="btn padding-reduce-on-grid-view remove-role-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-delete fw-stack-1x"></i>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">Remove</span>' +
'</a>';
if (!isCloud) {
innerhtml = editLink + editPermissionLink + removeLink;
}
return innerhtml;
}
}
];
var options = {
"placeholder": "Search By Role Name",
"searchKey": "filter"
};
var settings = {
"sorting": false
};
var roleApiUrl = '/api/device-mgt/v1.0/roles?user-store=all';
if (isCloud) {
roleApiUrl = '/api/device-mgt/v1.0/roles/filter/devicemgt?user-store=all';
}
$('#role-grid').datatables_extended_serverside_paging(settings, roleApiUrl, dataFilter, columns, fnCreatedRow, null, options);
loadingContent.hide();
}
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on Role Listing page in WSO2 Devicemgt Console.
*/
$("#role-grid").on("click", ".remove-role-link", function () {
var role = $(this).data("role");
var userStore;
if (role.indexOf('/') > 0) {
userStore = role.substr(0, role.indexOf('/'));
role = role.substr(role.indexOf('/') + 1);
}
var removeRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(role);
if (userStore) {
removeRoleAPI += "?user-store=" + encodeURIComponent(userStore);
}
modalDialog.header('Do you really want to remove this role ?');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-role-yes-link" class="btn-operations">Remove</a>' +
'<a href="#" id="remove-role-cancel-link" class="btn-operations btn-default">Cancel</a></div>');
modalDialog.show();
$("a#remove-role-yes-link").click(function () {
invokerUtil.delete(
removeRoleAPI,
function () {
if (userStore) {
role = userStore + '/' + role;
}
$('[id="role-' + role + '"]').remove();
modalDialog.header('Done. Role was successfully removed.');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-role-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#remove-role-success-link").click(function () {
modalDialog.hide();
});
},
function () {
// $(modalPopupContent).html($('#remove-role-error-content').html());
modalDialog.header('An unexpected error occurred. Please try again later.');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-role-error-link" ' +
'class="btn-operations">Ok</a></div>');
modalDialog.showAsError();
$("a#remove-role-error-link").click(function () {
modalDialog.hide();
});
}
);
});
$("a#remove-role-cancel-link").click(function () {
modalDialog.hide();
});
});
$(document).ready(function () {
loadRoles();
});

@ -1,56 +0,0 @@
{{#each roles}}
<tr data-type="selectable" id="role-{{roleName}}">
<td class="remove-padding icon-only content-fill">
<div class="thumbnail icon">
<i class="square-element text fw fw-user"></i>
</div>
</td>
<td class="remove-padding-top">{{roleName}}</td>
<td class="text-right content-fill text-left-on-grid-view no-wrap">
{{#unequal adminRole roleName }}
{{#if canEdit}}
<a onclick="javascript:loadRoleBasedActionURL('edit', '{{roleName}}')" data-role="{{roleName}}"
data-click-event="edit-form"
class="btn padding-reduce-on-grid-view edit-role-link" title="Edit Role">
<span class="fw-stack fw-lg">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-user fw-stack-1x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
<span class="hidden-xs hidden-on-grid-view">Edit</span>
</a>
<a onclick="javascript:loadRoleBasedActionURL('edit-permission', '{{roleName}}')"
data-role="{{roleName}}"
data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link"
title="Edit Role Permissions">
<span class="fw-stack fw-lg">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-security-policy fw-stack-1x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span>
<span class="hidden-xs hidden-on-grid-view">Edit Permission</span>
</a>
{{/if}}
{{#if canRemove}}
<a data-role="{{roleName}}" data-click-event="remove-form"
class="btn padding-reduce-on-grid-view remove-role-link" title="Remove Role">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
<span class="hidden-xs hidden-on-grid-view">Remove</span>
</a>
{{/if}}
{{/unequal}}
</td>
</tr>
{{/each}}

@ -1,120 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.ui.modal"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles">
Roles
</a>
</li>
{{/zone}}
{{#zone "navbarActions"}}
{{#unless isCloud}}
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/add" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Add Role
</a>
</li>
{{/unless}}
{{/zone}}
{{#zone "content"}}
{{#if hasRoles}}
<div id="loading-content" class="col-centered">
{{#unless isCloud}}
{{#if removePermitted}}
<input type="hidden" id="can-remove" value="true"/>
{{/if}}
{{#if editPermitted}}
<input type="hidden" id="can-edit" value="true"/>
{{/if}}
{{/unless}}
{{#if isCloud}}
<input type="hidden" id="is-cloud" value="true"/>
{{/if}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading roles . . .
<br>
</div>
<div id="role-table" data-cloud={{isCloud}} data-role={{adminRole}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
id="role-grid">
<thead>
<tr class="sort-row">
<th>By Role Name</th>
</tr>
<tr class="bulk-action-row">
<th colspan="3"></th>
</tr>
</thead>
<tbody id="ast-container" data-app-context="{{@app.context}}/"></tbody>
</table>
</div>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<!--suppress HtmlUnknownTag -->
<th>By Role name</th>
</div>
</div>
{{else}}
<div id="user-created-msg" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">You Haven't created roles yet.</p>
<br>Please click <b>"Add A New Role"</b>, if you wish to add a role.
<hr/>
<a href="{{@app.context}}/role/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Role
</a>
</div>
</div>
{{/if}}
{{/zone}}
{{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="role-listing" data-current-user="{{@user.username}}"
src="{{@page.publicUri}}/templates/role-listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/role-listing.js"}}
{{/zone}}

@ -1,48 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
context["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/delete")) {
context["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/update")) {
context["editPermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) {
context["removePermitted"] = true;
}
context["adminRole"] = deviceMgtProps["adminRole"];
context["isCloud"] = deviceMgtProps["isCloud"];
var roleCount = userModule.getRolesCount()
if (deviceMgtProps["isCloud"]) {
roleCount = userModule.getFilteredRoles("devicemgt").content.count;
}
if (roleCount > 0) {
context["hasRoles"] = true;
} else {
context["hasRoles"] = false;
}
return context;
}

@ -1,48 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "topCss"}}
{{css "css/daterangepicker.css"}}
{{/zone}}
<span id="device-type-details" data-devicetypes="{{deviceTypes}}"></span>
<div id="rangeSliderWrapper" class="pull-right col-lg-9">
<div id="dateRangePickerContainer">
<div class="btn-group" role="group">
<button id="hour-btn" type="button"
class="btn btn-default date-range">Hour
</button>
<button id="h12-btn" type="button"
class="btn btn-default date-range">12 Hours
</button>
<button id="h24-btn" type="button"
class="btn btn-default date-range">24 Hours
</button>
<button id="h48-btn" type="button"
class="btn btn-default date-range">48 Hours
</button>
<button id="date-range" type="button"
class="btn btn-default date-range last-child"
data-toggle="popup"
title="Click to set custom date range"></button>
</div>
</div>
</div>
{{#zone "bottomJs"}}
{{js "js/moment.js"}}
{{js "js/jquery.daterangepicker.js"}}
{{js "js/date-picker.js"}}
{{/zone}}

@ -1,32 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var deviceTypes = context.unit.params.deviceTypes;
var deviceType = context.uriParams.deviceType;
var deviceTypesList = [];
if (deviceTypes) {
for (var i = 0; i < deviceTypes.length; i++) {
deviceTypesList.push(deviceTypes[i].type);
}
} else if (deviceType) {
deviceTypesList.push(deviceType);
}
return {"deviceTypes": stringify(deviceTypesList)};
}

@ -1,361 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
.date-picker {
width: 170px;
height: 25px;
padding: 0;
border: 0;
line-height: 25px;
padding-left: 10px;
font-size: 12px;
font-family: Arial;
font-weight: bold;
cursor: pointer;
color: #303030;
position: relative;
z-index: 2;
}
.date-picker-wrapper {
position: absolute;
z-index: 1;
border: 1px solid #bfbfbf;
background-color: #efefef;
width: 448px;
padding: 5px 12px;
font-size: 12px;
line-height: 20px;
color: #aaa;
font-family: Arial;
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
}
.date-picker-wrapper.single-date {
width: auto;
}
.date-picker-wrapper.no-shortcuts {
padding-bottom: 12px;
}
.date-picker-wrapper .footer {
display: none;
font-size: 11px;
padding-top: 3px;
}
.date-picker-wrapper b {
color: #666;
font-weight: 700;
}
.date-picker-wrapper a {
color: rgb(107, 180, 214);
text-decoration: underline;
}
.date-picker-wrapper .month-wrapper {
border: 1px solid #bfbfbf;
border-radius: 3px;
background-color: #fff;
padding: 5px;
cursor: default;
position: relative;
_overflow: hidden;
}
.date-picker-wrapper .month-wrapper table {
width: 190px;
float: left;
}
.date-picker-wrapper .month-wrapper table.month2 {
width: 190px;
float: right;
}
.date-picker-wrapper .month-wrapper table th,
.date-picker-wrapper .month-wrapper table td {
vertical-align: middle;
text-align: center;
line-height: 14px;
margin: 0px;
padding: 0px;
}
.date-picker-wrapper .month-wrapper table .day {
height: 19px;
line-height: 19px;
font-size: 12px;
margin-bottom: 1px;
color: #999;
cursor: default;
}
.date-picker-wrapper .month-wrapper table div.day.lastMonth,
.date-picker-wrapper .month-wrapper table div.day.nextMonth {
color: #999;
cursor: default;
}
.date-picker-wrapper .month-wrapper table .day.checked {
background-color: rgb(156, 219, 247);
}
.date-picker-wrapper .month-wrapper table .week-name {
height: 20px;
line-height: 20px;
font-weight: 100;
}
.date-picker-wrapper .month-wrapper table .day.has-tooltip {
cursor: help !important;
}
.date-picker-wrapper .month-wrapper table .day.toMonth.valid {
color: #333;
cursor: pointer;
}
.date-picker-wrapper .month-wrapper table .day.real-today {
background-color: rgb(255, 230, 132);
}
.date-picker-wrapper .month-wrapper table .day.real-today.checked {
background-color: rgb(112, 204, 213);
}
.date-picker-wrapper table .caption {
height: 40px;
}
.date-picker-wrapper table .caption .next,
.date-picker-wrapper table .caption .prev {
padding: 0 5px;
cursor: pointer;
}
.date-picker-wrapper table .caption .next:hover,
.date-picker-wrapper table .caption .prev:hover {
background-color: #ccc;
color: white;
}
.date-picker-wrapper .gap {
position: absolute;
display: none;
top: 0px;
left: 204px;
z-index: 1;
width: 15px;
height: 100%;
background-color: red;
font-size: 0;
line-height: 0;
}
.date-picker-wrapper .gap .gap-lines {
height: 100%;
overflow: hidden;
}
.date-picker-wrapper .gap .gap-line {
height: 15px;
width: 15px;
position: relative;
}
.date-picker-wrapper .gap .gap-line .gap-1 {
z-index: 1;
height: 0;
border-left: 8px solid white;
border-top: 8px solid #eee;
border-bottom: 8px solid #eee;
}
.date-picker-wrapper .gap .gap-line .gap-2 {
position: absolute;
right: 0;
top: 0px;
z-index: 2;
height: 0;
border-left: 8px solid transparent;
border-top: 8px solid white;
}
.date-picker-wrapper .gap .gap-line .gap-3 {
position: absolute;
right: 0;
top: 8px;
z-index: 2;
height: 0;
border-left: 8px solid transparent;
border-bottom: 8px solid white;
}
.date-picker-wrapper .gap .gap-top-mask {
width: 6px;
height: 1px;
position: absolute;
top: -1px;
left: 1px;
background-color: #eee;
z-index: 3;
}
.date-picker-wrapper .gap .gap-bottom-mask {
width: 6px;
height: 1px;
position: absolute;
bottom: -1px;
left: 7px;
background-color: #eee;
z-index: 3;
}
.date-picker-wrapper .selected-days {
display: none;
}
.date-picker-wrapper .drp_top-bar {
line-height: 40px;
height: 40px;
position: relative;
}
.date-picker-wrapper .drp_top-bar .error-top {
display: none;
}
.date-picker-wrapper .drp_top-bar .normal-top {
display: none;
}
.date-picker-wrapper .drp_top-bar .default-top {
display: block;
}
.date-picker-wrapper .drp_top-bar.error .default-top {
display: none;
}
.date-picker-wrapper .drp_top-bar.error .error-top {
display: block;
color: red;
}
.date-picker-wrapper .drp_top-bar.normal .default-top {
display: none;
}
.date-picker-wrapper .drp_top-bar.normal .normal-top {
display: block;
}
.date-picker-wrapper .drp_top-bar .apply-btn {
position: absolute;
right: 0px;
top: 6px;
padding: 3px 5px;
margin: 0;
font-size: 12px;
border-radius: 4px;
cursor: pointer;
color: #d9eef7;
border: solid 1px #0076a3;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
color: white;
}
.date-picker-wrapper .drp_top-bar .apply-btn.disabled {
pointer-events: none;
color: #606060;
border: solid 1px #b7b7b7;
background: #fff;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
background: -moz-linear-gradient(top, #fff, #ededed);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
}
/*time styling*/
.time {
position: relative;
}
.time input[type=range] {
vertical-align: middle;
}
.time1, .time2 {
width: 180px;
padding: 0 5px;
text-align: center;
}
.time1 {
float: left;
}
.time2 {
float: right;
}
.hour, .minute {
text-align: left;
}
.hide {
display: none;
}
input.hour-range, input.minute-range {
width: 150px;
}
#dateRangePickerContainer .date-range, #dateRangePickerContainer .input-append {
background: none !important;
}
#date-range {
padding-right: 30px;
width: 300px;
height: 100%;
display: inline-block;
}
#dateRangePickerContainer {
float: right;
}
.date-range {
border: 1px solid #ccc;
}
#dateRangePickerContainer button.active {
background-color: #e6e6e6 !important;
}
#dateRangePickerContainer .btn-default:hover {
background-color: #b2b2b2;
border-color: #000000;
}

@ -1,125 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var fromDate, toDate, currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime());
function initDate() {
currentDay = new Date();
}
var DateRange = convertDate(startDate) + " to " + convertDate(endDate);
$(document).ready(function () {
initDate();
var configObject = {
startOfWeek: 'monday',
separator: ' to ',
format: 'YYYY-MM-DD HH:mm',
autoClose: false,
time: {
enabled: true
},
shortcuts: 'hide',
endDate: currentDay,
maxDays: 2,
getValue: function () {
return this.value;
},
setValue: function (s) {
this.value = s;
}
};
$('#date-range').html(DateRange);
$('#date-range').dateRangePicker(configObject)
.bind('datepicker-apply', function (event, dateRange) {
$(this).addClass('active');
$(this).siblings().removeClass('active');
fromDate = dateRange.date1 != "Invalid Date" ? dateRange.date1.getTime() / 1000 : null;
toDate = dateRange.date2 != "Invalid Date" ? dateRange.date2.getTime() / 1000 : null;
drawGraph(fromDate, toDate);
}
);
setDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
$('#hour-btn').addClass('active');
});
//hour
$('#hour-btn').on('click', function () {
initDate();
setDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
});
//12 hours
$('#h12-btn').on('click', function () {
initDate();
setDateTime(currentDay.getTime() - (3600000 * 12), currentDay.getTime());
});
//24 hours
$('#h24-btn').on('click', function () {
initDate();
setDateTime(currentDay.getTime() - (3600000 * 24), currentDay.getTime());
});
//48 hours
$('#h48-btn').on('click', function () {
initDate();
setDateTime(currentDay.getTime() - (3600000 * 48), currentDay.getTime());
});
$('body').on('click', '.btn-group button', function (e) {
$(this).addClass('active');
$(this).siblings().removeClass('active');
});
function setDateTime(from, to) {
fromDate = from;
toDate = to;
startDate = new Date(from);
endDate = new Date(to);
DateRange = convertDate(startDate) + " to " + convertDate(endDate);
$('#date-range').html(DateRange);
var tzOffset = new Date().getTimezoneOffset() * 60 / 1000;
from += tzOffset;
to += tzOffset;
// Implement drawGraph_<device type name> method in your UI unit for analytics.
var deviceTypes = $("#device-type-details").data("devicetypes");
for (var i = 0; i < deviceTypes.length; i++){
try{
window["drawGraph_" + deviceTypes](parseInt(from / 1000), parseInt(to / 1000));
}catch(e){
}
try{
window["drawTable"](parseInt(from / 1000), parseInt(to / 1000));
}catch(e){
}
}
}
function convertDate(date) {
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
return date.getFullYear() + '-' + (('' + month).length < 2 ? '0' : '') + month + '-' +
(('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '') +
hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute;
}

@ -1,114 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
<span id="operation-details" data-endpoint="{{operationEndpoint}}" data-deviceid="{{device.deviceIdentifier}}">
{{#if control_operations}}
<div class="wr-operations" style="height: 87px; display: block;">
<style>
::-webkit-input-placeholder {
color: #B8B8B8;
}
::-moz-placeholder {
color: #B8B8B8;
}
:-ms-input-placeholder {
color: #B8B8B8;
}
input:-moz-placeholder {
color: #B8B8B8;
}
</style>
{{#each control_operations}}
<a class='operation-tile' href="javascript:operationSelect('{{operation}}')">
<i class="fw fw-service"></i>
<span>{{name}}</span>
</a>
<div class="operation" data-operation-code="{{operation}}">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-service fw-stack-1x"></i>
</span>
{{name}}
<br>
</h3>
<h4>
{{description}}
<br>
</h4>
<form id="form-{{operation}}" style="padding-bottom: 20px;"-->
<select id="operation-type" class="form-control" onChange="operationTypeChage(this)" style="display:none">
<option value="PROFILE">Profile</option>
<option value="COMMAND">Command</option>
</select>
<br />
<input type="hidden" id="operation-code" value="{{operation}}" />
<textarea id="operation-payload" placeholder="payload" class="form-control" rows="10" cols="70"></textarea>
<br />
<button id="btnSend" type="button" onclick="submitForm('form-{{operation}}')" class="btn btn-default">&nbsp;&nbsp;&nbsp;&nbsp;Send
to Device&nbsp;&nbsp;&nbsp;&nbsp;</button>
<label id="lblSending" class="wr-input-label hidden"><i
class="fw fw-lifecycle fw-spin fw-2x"></i> Sending..</label>
<label id="lblSent" class="wr-input-label hidden"><i
class="fw fw-check fw-2x"></i> Sent</label>
</form>
</div>
</div>
</div>
</div>
{{/each}}
</div>
{{else}}
<div align="center">
<h4 style="color: #D8000C"><i class="icon fw fw-error" style="color: #D8000C"></i>
Operations Loading Failed!</h4>
</div>
{{/if}}
<div id="operation-response-template" style="display: none">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack center-block">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i id="status-icon" class="fw fw-error fw-stack-1x"></i>
</span>
<br>
</h3>
<h4>
<span id="title"></span>
<br>
</h4>
<span id="description"></span>
</div>
</div>
</div>
</div>
{{#zone "bottomJs"}}
{{js "js/operation-bar.js"}}
{{/zone}}

@ -1,29 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var log = new Log("operation.js");
var deviceType = context.uriParams.deviceType;
var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var restAPIEndpoint = devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/devices/" + deviceType + "/operations";
var device = context.unit.params.device;
var features = context.unit.params.features;
return {"control_operations": features, "device": device, "operationEndpoint": restAPIEndpoint};
}

@ -1,114 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* On operation click function.
* @param selection: Selected operation
*/
function operationSelect(selection) {
$(modalPopupContent).addClass("operation-data");
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
$(modalPopupContent).data("operation-code", selection);
showPopup();
}
function submitForm(formId) {
var form = $("#" + formId);
var operationDetails = $("#operation-details");
var deviceId = operationDetails.data("deviceid");
var operationEndpoint = operationDetails.data("endpoint");
var contentType = "application/json";
var payload = {};
var devices=[];
devices.push(deviceId);
payload["deviceIdentifiers"] = devices;
var operation = {};
operation["code"] = form.find("#operation-code").val();
operation["type"]= form.find("#operation-type").val();
operation["status"] = "PENDING";
operation["control"] = "REPEAT";
operation["payLoad"] = form.find("#operation-payload").val();
operation["enabled"] = true;
payload["operation"] = operation;
//setting responses callbacks
var defaultStatusClasses = "fw fw-stack-1x";
var content = $("#operation-response-template").find(".content");
var title = content.find("#title");
title.attr("class","center-block text-center");
var statusIcon = content.find("#status-icon");
var description = content.find("#description");
var successCallBack = function (response) {
var res = response;
try {
res = JSON.parse(response).messageFromServer;
} catch (err) {
//do nothing
}
title.html("Operation Triggered!");
statusIcon.attr("class", defaultStatusClasses + " fw-check");
description.html(res);
$(modalPopupContent).html(content.html());
};
var errorCallBack = function (response) {
console.log(response);
title.html("An Error Occurred!");
statusIcon.attr("class", defaultStatusClasses + " fw-error");
var reason = (response.responseText == "null")?response.statusText:response.responseText;
description.html(reason);
$(modalPopupContent).html(content.html());
};
invokerUtil.post(operationEndpoint, payload, successCallBack, errorCallBack, contentType);
}
$(document).on('submit', 'form', function (e) {
e.preventDefault();
var postOperationRequest = $.ajax({
url: $(this).attr("action") + '&' + $(this).serialize(),
method: "post"
});
var btnSubmit = $('#btnSend', this);
btnSubmit.addClass('hidden');
var lblSending = $('#lblSending', this);
lblSending.removeClass('hidden');
var lblSent = $('#lblSent', this);
postOperationRequest.done(function (data) {
lblSending.addClass('hidden');
lblSent.removeClass('hidden');
setTimeout(function () {
hidePopup();
}, 3000);
});
postOperationRequest.fail(function (jqXHR, textStatus) {
lblSending.addClass('hidden');
lblSent.addClass('hidden');
});
});
function operationTypeChage(selectElement) {
if (selectElement.value == "COMMAND") {
$("#operation-payload").hide();
} else {
$("#operation-payload").show();
}
}

@ -1,27 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
<table class="table table-responsive table-striped" id="members">
<tbody>
{{#each device.initialDeviceInfo}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">{{@key}}</td>
<td style="padding:10px 15px;">{{this}}</td>
</tr>
{{/each}}
</tbody>
</table>

@ -1,23 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest (context) {
var log = new Log("overview-section.js");
var device = context.unit.params.device;
return {"device" : device};
}

@ -1,47 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.data-tables-extended"}}
<span id="device-details" data-devices="{{devices}}" data-devicename="{{device.name}}"
data-deviceid="{{device.deviceIdentifier}}"
data-devicetype="{{device.type}}"
data-appcontext="{{@app.context}}" data-attributes="{{attributes}}"></span>
<div id="device-div-chart" data-backend-api-url= {{backendApiUri}}>
{{#if attributes}}
<table class="table table-striped table-hover table-bordered display data-table"
id="stats-table">
<thead>
<tr id="header-rows">
<td>Timestamp</td>
{{#each attributes}}
<td>{{this}}</td>
{{/each}}
</tr>
</thead>
<tbody>
</tbody>
</table>
{{else}}
<div id="warn-config"><h1>Analytics Not Configured</h1> </div>
{{/if}}
</div>
{{#zone "bottomJs"}}
{{js "js/device.js"}}
{{/zone}}

@ -1,71 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var deviceType = context.uriParams.deviceType;
var deviceId = request.getParameter("deviceId");
var keys = [];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/events/" + deviceType;
serviceInvokers.XMLHttp.get(
restAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var data = parse(restAPIResponse["responseText"]);
if (data.eventAttributes.attributes.length > 0) {
for (var i = 0; i < data.eventAttributes.attributes.length; i++) {
var attribute = data.eventAttributes.attributes[i];
if (attribute['name'] == "deviceId") {
continue;
}
keys.push(attribute['name']);
}
}
}
}
);
if (device && device.status != "error") {
if (keys.length === 0 || keys.length === undefined) {
return {
"device": device.content,
"backendApiUri": "/api/device-mgt/v1.0/events/" + deviceType
};
} else {
return {
"device": device.content,
"backendApiUri": "/api/device-mgt/v1.0/events/" + deviceType,
"attributes": keys
};
}
} else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit();
}
}
}

@ -1,74 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var InitiateViewOption = null;
var deviceId = null;
var deviceType = null;
var fromTime = null;
var toTime = null;
var keys = null;
function drawTable(from, to) {
var device = $("#device-details");
deviceId = device.data("deviceid");
deviceType = device.data("devicetype");
keys = device.data("attributes").split(",");
fromTime = from * 1000;
toTime = to * 1000;
if ( $.fn.dataTable.isDataTable( '#stats-table' ) ) {
var table = $('#stats-table').DataTable();
table.clear().draw();
table.ajax.reload();
}
else {
$("#stats-table").datatables_extended({
serverSide: true,
processing: false,
searching: false,
ordering: false,
pageLength: 100,
order: [],
ajax: {
url: "/devicemgt/api/stats/paginate",
data: buildAjaxData
}
});
}
}
function buildAjaxData (){
var settings = $("#stats-table").dataTable().fnSettings();
var obj = {
//default params
"draw" : settings.iDraw,
"start" : settings._iDisplayStart,
"length" : settings._iDisplayLength,
"columns" : "",
"order": "",
"deviceType" : deviceType,
"deviceId" : deviceId,
"from": fromTime,
"to" : toTime,
"attributes" : JSON.stringify(keys)
};
return obj;
}

@ -1,204 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "topCss"}}
<style>
.thumbnail.icon:before {
padding-top: 0;
}
.code-segment{
margin-bottom: 10px;
}
.code-segment span{
display: block;
}
.code-segment code{
padding: 10px;
display: block;
background-color: #f3f3f3;
}
</style>
{{/zone}}
{{#zone "device-thumbnail"}}
<i class='square-element text fw fw-devices' style='font-size: 74px;'></i>
{{/zone}}
{{#zone "device-details"}}
{{unit "cdmf.unit.default.device.overview-section" device=device}}
{{/zone}}
{{#zone "device-opetations"}}
{{#if features}}
<div class="operation-container">
<div class="operation-title">
<h4>Device Operations</h4>
</div>
{{unit "cdmf.unit.default.device.operation-bar" device=device features=features}}
</div>
{{/if}}
{{/zone}}
{{#zone "device-view-tabs"}}
{{#if attributes}}
<li class="active"><a class="list-group-item" href="#device_statistics" role="tab"
data-toggle="tab" aria-controls="device_statistics">Device
Statistics</a>
</li>
{{/if}}
{{#if features}}
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li>
{{/if}}
{{/zone}}
{{#zone "device-view-tab-contents"}}
{{#if attributes}}
<div class="panel panel-default tab-pane active"
id="device_statistics" role="tabpanel" aria-labelledby="device_statistics">
<div class="panel-heading">Device Event</div>
{{unit "cdmf.unit.default.device.type.realtime.analytics-view" device=device attributes=attributes}}
</div>
{{/if}}
{{#if features}}
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-heading">Operations Log <span><a href="#"
id="refresh-operations"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Operations Log . . .
<br>
<br>
</div>
<div id="operations-log-container">
<div class="panel-body">
<table class="table table-striped table-hover table-responsive list-table display responsive nowrap data-table"
id="operation-log">
<thead class="block">
<tr class="sort-row">
<!-- <th class="content-fill no-sort"></th> -->
<th>Name</th>
<th>Position</th>
<th>Office</th>
<!-- <th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th class="no-sort"></th> -->
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<br class="c-both"/>
</div>
</div>
</div>
{{/if}}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">Device Communication</h2>
<hr>
{{#if event}}
<h3 class="uppercase">publish device events :</h3>
{{#if_eq event.transport "MQTT"}}
<div class="code-segment">
<span>MQTT Topic :</span>
<code>{{tenantDomain}}/{{device.type}}/&lt;device_id&gt;/events</code>
</div>
{{#if eventSample}}
<div class="code-segment">
<span>Device Event Payload :</span>
<code>{{eventSample}}</code>
</div>
{{/if}}
{{/if_eq}}
{{#if_eq event.transport "HTTP"}}
<div class="code-segment">
<code> curl -k -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/events/publish/{{device.type}}/{{device.deviceIdentifier}}
-H 'authorization: Bearer %accessToken%'
-H 'content-type: application/json'
-d '{{eventSample}}'
</code>
</div>
{{/if_eq}}
{{/if}}
</br>
<h3 class="uppercase">Retrieve operations</h3>
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
<div class="code-segment">
<span>MQTT Topic :</span>
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/#</code>
<br/>
<div class="code-segment">
<span>Topic Structure :</span>
<ul class="list-unstyled">
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke</code>
</li>
</ul>
</div>
</div>
<div class="code-segment">
<span>Operation Response :</span>
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/update/operation</code>
</div>
<div class="code-segment">
<span>Payload :</span>
<code>{"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}</code>
</div>
<br/>
{{/if_eq}}
{{else}}
<div class="code-segment">
<span>Retrieve pending operation :</span>
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/pending/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</div>
<div class="code-segment">
<span>Retrieve next pending operation :</span>
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</div>
<div class="code-segment">
<span>Update operation :</span>
<code>curl -k -X PUT {{httpsGateway}}/api/device-mgt/v1.0/device/agent/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"id": 1,"status": "COMPLETED", "payload": "this is my response"}'</code>
</div>
{{/if}}
<br>
<br>
</div>
{{/zone}}

@ -1,151 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var process = require("process");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
function onRequest(context) {
var log = new Log("device-view.js");
var deviceType = context.uriParams.deviceType;
var deviceId = request.getParameter("id");
var attributes = [];
var featureList = [];
var user = userModule.getCarbonUser();
var tenantDomain = user.domain;
var autoCompleteParams = [
{"name" : "deviceId", "value" : deviceId}
];
context.handlebars.registerHelper('if_eq', function(a, b, opts) {
if(a == b) // Or === depending on your needs
return opts.fn(this);
else
return opts.inverse(this);
});
var displayData = {};
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/device-types/config/" + deviceType;
displayData.deviceType = deviceType;
displayData.tenantDomain = tenantDomain;
serviceInvokers.XMLHttp.get(
restAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var typeData = parse(restAPIResponse["responseText"]);
displayData.type = typeData;
if (typeData.deviceTypeMetaDefinition) {
var features = typeData.deviceTypeMetaDefinition.features;
if (features) {
var feature;
for (var i = 0; i < features.length; i++) {
feature = {};
feature["operation"] = features[i].code;
feature["name"] = features[i].name;
feature["description"] = features[i].description;
featureList.push(feature);
}
}
}
}
}
);
var eventRestAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/events/" + deviceType;
serviceInvokers.XMLHttp.get(
eventRestAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var typeData = parse(restAPIResponse["responseText"]);
displayData.event = typeData;
var sampleValue = "";
if (typeData.eventAttributes && typeData.eventAttributes.attributes) {
var eventExample = {};
for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) {
var attribute = typeData.eventAttributes.attributes[i];
if (attribute['name'] == "deviceId") {
continue;
}
attributes.push(attribute['name']);
switch (attribute.type) {
case "STRING":
eventExample[attribute.name] = "string";
sampleValue = sampleValue + "\"string\", ";
break;
case "LONG":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "INT":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "FLOAT":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "DOUBLE":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "BOOL":
eventExample[attribute.name] = false;
sampleValue = sampleValue + false + ", ";
break;
}
}
var sample = eventExample;
if (sampleValue && sampleValue.length > 2) {
displayData.sampleValue = sampleValue.substring(0, sampleValue.length - 2);
}
displayData.eventSample = JSON.stringify(sample);
displayData.mqttGateway = "tcp://" + process.getProperty("mqtt.broker.host") + ":" + process.getProperty("mqtt.broker.port");
displayData.httpsGateway = "https://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.https.port");
}
}
}
);
displayData.tenantDomain = tenantDomain;
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") {
displayData.device = device.content;
displayData.autoCompleteParams = autoCompleteParams;
displayData.encodedFeaturePayloads = "";
displayData.features = featureList;
if (attributes.length === 0 || attributes.length === undefined) {
return displayData;
} else {
displayData.attributes = attributes;
return displayData;
}
} else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit();
}
}
}

@ -1,45 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.lib.rickshaw-graph"}}
<div id="div-chart" data-websocketurl="{{websocketEndpoint}}" data-attributes="{{attributes}}">
<span id="time-mode">{{#if timestamp}}Last Known:{{timestamp}}{{/if}}</span>
<table class="table table-responsive table-striped" id="members">
<tbody>
{{#each events}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">{{this.key}}</td>
<td id="{{this.key}}-value" style="padding:10px 15px;">{{this.value}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<a class="padding-left"
href="{{@app.context}}/device/{{device.type}}/analytics?deviceId={{device.deviceIdentifier}}&deviceName={{device.name}}">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-statistics fw-stack-1x"></i>
</span> View Device Analytics
</a>
<!-- /statistics -->
{{#zone "bottomJs"}}
{{js "js/moment.min.js"}}
{{js "js/socket.io.min.js"}}
{{js "js/device-stats.js"}}
{{/zone}}

@ -1,96 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
function onRequest(context) {
var log = new Log("stats.js");
var carbonServer = require("carbon").server;
var device = context.unit.params.device;
var attributes = context.unit.params.attributes;
var events = [];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]);
var token = "";
var user = userModule.getCarbonUser();
var tenantDomain = user.domain;
if (encodedClientKeys) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
if (tenantDomain == "carbon.super") {
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {});
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint = websocketEndpoint + "/secured-websocket/iot.per.device.stream." + tenantDomain + "." + device.type + "/1.0.0?"
+ "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type + "&websocketToken=" + token;
} else {
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + tenantDomain,"default", {});
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint = websocketEndpoint + "/secured-websocket" + "/t/" + tenantDomain + "/iot.per.device.stream." + tenantDomain
+ "." + device.type + "/1.0.0?" + "deviceId=" + device.deviceIdentifier + "&deviceType="
+ device.type + "&websocketToken=" + token;
}
}
var events = [];
var viewModel = {};
viewModel.device = device;
viewModel.websocketEndpoint = websocketEndpoint;
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/events/last-known/" + device.type + "/" + device.deviceIdentifier;
serviceInvokers.XMLHttp.get(
restAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var responsePayload = parse(restAPIResponse["responseText"]);
var records = responsePayload["records"];
if (records && records[0] && records[0].values) {
var record = records[0].values;
viewModel.timestamp = new Date(records[0].timestamp);
for (var eventAttribute in attributes){
var event = {};
event.key = attributes[eventAttribute];
event.value = record["" + attributes[eventAttribute]];
events.push(event);
}
} else {
for (var eventAttribute in attributes){
var event = {};
event.key = attributes[eventAttribute];
event.value = "-";
events.push(event);
}
}
}
}
);
viewModel.attributes = attributes;
viewModel.events = events;
return viewModel;
}

@ -1,59 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var ws;
var attributes = null;
$(window).load(function () {
var div = $("#div-chart");
var websocketUrl = div.data("websocketurl");
attributes = div.data("attributes").split(",");
connect(websocketUrl)
});
$(window).unload(function () {
disconnect();
});
//websocket connection
function connect(target) {
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
console.log('WebSocket is not supported by this browser.');
}
if (ws) {
ws.onmessage = function (webSocketData) {
var data = JSON.parse(webSocketData.data);
console.log(data);
var payloadData = data["event"]["payloadData"];
for (var i = 0; i < attributes.length; i++){
$("#" + attributes[i] +"-value").text(payloadData[attributes[i]]);
}
$("#time-mode").text("Real Time Mode");
};
}
}
function disconnect() {
if (ws != null) {
ws.close();
ws = null;
}
}

@ -1,49 +0,0 @@
{
"deviceType": {
"label": "Windows",
"category": "mobile",
"scopes" : [
"perm:windows:enroll",
"perm:windows:lock-devices",
"perm:windows:ring",
"perm:windows:wipe",
"perm:windows:lock-reset",
"perm:windows:reboot",
"perm:windows:location",
"perm:windows:disenroll"
],
"analyticsEnabled": "false",
"groupingEnabled": "false",
"features": {
"DEVICE_RING": {
"icon": "fw-dial-up",
"permission": "/device-mgt/devices/owning-device/operations/android/ring"
},
"DEVICE_LOCK": {
"icon": "fw-lock",
"permission": "/device-mgt/devices/owning-device/operations/windows/lock"
},
"DEVICE_LOCATION": {
"icon": "fw-map-location",
"permission": "/device-mgt/devices/owning-device/operations/windows/location"
},
"DEVICE_REBOOT": {
"icon": "fw-refresh",
"permission": "/device-mgt/devices/owning-device/operations/windows/reboot"
},
"LOCK_RESET": {
"icon": "fw-security",
"permission": "/device-mgt/devices/owning-device/operations/windows/lock-reset"
},
"DISENROLL": {
"icon": "fw-block",
"permission": "/device-mgt/devices/owning-device/operations/windows/disenroll"
},
"WIPE_DATA": {
"icon": "fw-delete",
"permission": "/device-mgt/devices/owning-device/operations/windows/wipe"
}
}
}
}

@ -1,61 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.circle {
background: none repeat scroll 0 0 #191919;
border-radius: 50px;
height: 50px;
padding: 10px;
width: 50px;
color: #fff;
}
.padding-top-double {
padding-top: 20px;
}
.padding-double {
padding: 20px;
}
.grey {
color: #333;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #7f7f7f;
margin: 1em 0;
padding: 0;
opacity: 0.2;
}
.light-grey {
color: #7c7c7c;
}
.uppercase {
text-transform: uppercase;
}
.grey-bg {
background-color: #f6f4f4;
}
.doc-link {
background: #11375B;
padding: 20px;
color: white;
margin-top: 0;
}
.doc-link a {
color: white;
}

@ -1,474 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var modalPopup = ".modal",
modalPopupContainer = modalPopup + " .modal-content",
modalPopupContent = modalPopup + " .modal-content";
var emmAdminBasePath = "/api/device-mgt/v1.0";
//function openCollapsedNav() {
// $(".wr-hidden-nav-toggle-btn").addClass("active");
// $("#hiddenNav").slideToggle("slideDown", function () {
// if ($(this).css("display") == "none") {
// $(".wr-hidden-nav-toggle-btn").removeClass("active");
// }
// });
//}
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
var maxHeight = "max-height";
var marginTop = "margin-top";
var body = "body";
$(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).modal('show');
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html("");
$(modalPopupContent).removeClass("operation-data");
$(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px');
$('.modal-backdrop').remove();
}
/*
* QR-code generation function.
*/
function generateQRCode(qrCodeClass) {
var enrollmentURL = $("#qr-code-modal").data("enrollment-url");
$(qrCodeClass).qrcode({
text: enrollmentURL,
width: 200,
height: 200
});
}
function toggleEnrollment() {
$(".modal-content").html($("#qr-code-modal").html());
generateQRCode(".modal-content .qr-code");
modalDialog.show();
}
var updateNotificationCountOnSuccess = function (data, textStatus, jqXHR) {
var notificationBubble = "#notification-bubble";
if (jqXHR.status == 200 && data) {
var responsePayload = JSON.parse(data);
var newNotificationsCount = responsePayload["count"];
if (newNotificationsCount > 0) {
$(notificationBubble).html(newNotificationsCount);
$(notificationBubble).show();
} else {
$(notificationBubble).hide();
}
}
};
function updateNotificationCountOnError() {
var notificationBubble = "#notification-bubble";
$(notificationBubble).html("Error");
$(notificationBubble).show();
}
function loadNewNotificationsOnSideViewPanel() {
if ($("#right-sidebar").attr("is-authorized") == "false") {
$("#notification-bubble-wrapper").remove();
} else {
var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
invokerUtil.get(serviceURL, updateNotificationCountOnSuccess, updateNotificationCountOnError);
loadNewNotifications();
}
}
function loadNewNotifications() {
var messageSideBar = ".sidebar-messages";
if ($("#right-sidebar").attr("is-authorized") == "false") {
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications.</h4>");
} else {
var notifications = $("#notifications");
var currentUser = notifications.data("currentUser");
$.template("notification-listing", notifications.attr("src"), function (template) {
var serviceURL = emmAdminBasePath + "/notifications?offset=0&limit=5&status=NEW";
invokerUtil.get(
serviceURL,
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
var viewModel = {};
var responsePayload = JSON.parse(data);
if (responsePayload["notifications"]) {
if (responsePayload.count > 0) {
viewModel["notifications"] = responsePayload["notifications"];
viewModel["appContext"] = context;
$(messageSideBar).html(template(viewModel));
} else {
$(messageSideBar).html("<h4 class='text-center'>No New Notifications</h4>" +
"<h5 class='text-center text-muted'>" +
"Check this section for error notifications<br>related to device operations" +
"</h5>");
}
} else {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error " +
"occurred while loading new notifications.</h4>");
}
}
},
// on error
function (jqXHR) {
if (jqXHR.status = 500) {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " +
"to retrieve any new notifications.</h4>");
}
}
);
});
}
}
/**
* Toggle function for
* notification listing sidebar.
* @return {Null}
*/
$.sidebar_toggle = function (action, target, container) {
var elem = '[data-toggle=sidebar]',
button,
containerOffsetLeft,
containerOffsetRight,
targetOffsetLeft,
targetOffsetRight,
targetWidth,
targetSide,
relationship,
pushType,
buttonParent;
var sidebar_window = {
update: function (target, container, button) {
containerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0;
containerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0;
targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0;
targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0;
targetWidth = $(target).data('width');
targetSide = $(target).data("side");
pushType = $(container).parent().is('body') == true ? 'padding' : 'margin';
if (button !== undefined) {
relationship = button.attr('rel') ? button.attr('rel') : '';
buttonParent = $(button).parent();
}
},
show: function () {
if ($(target).data('sidebar-fixed') == true) {
$(target).height($(window).height() - $(target).data('fixed-offset'));
}
$(target).trigger('show.sidebar');
if (targetWidth !== undefined) {
$(target).css('width', targetWidth);
}
$(target).addClass('toggled');
if (button !== undefined) {
if (relationship !== '') {
// Removing active class from all relative buttons
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
}
// Adding active class to button
if (button.attr('data-handle') !== 'close') {
button.addClass("active");
button.attr('aria-expanded', 'true');
}
if (buttonParent.is('li')) {
if (relationship !== '') {
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
}
buttonParent.addClass("active");
buttonParent.attr('aria-expanded', 'true');
}
}
// Sidebar open function
if (targetSide == 'left') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetLeft);
}
$(target).css(targetSide, targetOffsetLeft);
} else if (targetSide == 'right') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetRight);
}
$(target).css(targetSide, targetOffsetRight);
}
$(target).trigger('shown.sidebar');
},
hide: function () {
$(target).trigger('hide.sidebar');
$(target).removeClass('toggled');
if (button !== undefined) {
if (relationship !== '') {
// Removing active class from all relative buttons
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
}
// Removing active class from button
if (button.attr('data-handle') !== 'close') {
button.removeClass("active");
button.attr('aria-expanded', 'false');
}
if ($(button).parent().is('li')) {
if (relationship !== '') {
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
}
}
}
// Sidebar close function
if (targetSide == 'left') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetOffsetLeft);
}
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
} else if (targetSide == 'right') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetOffsetRight);
}
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
$(target).trigger('hidden.sidebar');
}
};
if (action === 'show') {
sidebar_window.update(target, container);
sidebar_window.show();
}
if (action === 'hide') {
sidebar_window.update(target, container);
sidebar_window.hide();
}
// binding click function
var body = 'body';
$(body).off('click', elem);
$(body).on('click', elem, function (e) {
e.preventDefault();
button = $(this);
container = button.data('container');
target = button.data('target');
sidebar_window.update(target, container, button);
/**
* Sidebar function on data container divide
* @return {Null}
*/
if (button.attr('aria-expanded') == 'false') {
sidebar_window.show();
} else if (button.attr('aria-expanded') == 'true') {
sidebar_window.hide();
}
});
};
$.fn.collapse_nav_sub = function () {
var navSelector = 'ul.nav';
if (!$(navSelector).hasClass('collapse-nav-sub')) {
$(navSelector + ' > li', this).each(function () {
var position = $(this).offset().left - $(this).parent().scrollLeft();
$(this).attr('data-absolute-position', (position + 5));
});
$(navSelector + ' li', this).each(function () {
if ($('ul', this).length !== 0) {
$(this).addClass('has-sub');
}
});
$(navSelector + ' > li', this).each(function () {
$(this).css({
'left': $(this).data('absolute-position'),
'position': 'absolute'
});
});
$(navSelector + ' li.has-sub', this).on('click', function () {
var elem = $(this);
if (elem.attr('aria-expanded') !== 'true') {
elem.siblings().fadeOut(100, function () {
elem.animate({'left': '15'}, 200, function () {
$(elem).first().children('ul').fadeIn(200);
});
});
elem.siblings().attr('aria-expanded', 'false');
elem.attr('aria-expanded', 'true');
} else {
$(elem).first().children('ul').fadeOut(100, function () {
elem.animate({'left': $(elem).data('absolute-position')}, 200, function () {
elem.siblings().fadeIn(100);
});
});
elem.siblings().attr('aria-expanded', 'false');
elem.attr('aria-expanded', 'false');
}
});
$(navSelector + ' > li.has-sub ul', this).on('click', function (e) {
e.stopPropagation();
});
$(navSelector).addClass('collapse-nav-sub');
}
};
$(".download-link").click(function(){
toggleEnrollment();
});
var apiBasePath = "/api/device-mgt/v1.0";
$(document).ready(function () {
$.sidebar_toggle();
if (typeof $.fn.collapse == 'function') {
$('.navbar-collapse.tiles').on('shown.bs.collapse', function () {
$(this).collapse_nav_sub();
});
}
loadNewNotificationsOnSideViewPanel();
$("#right-sidebar").on("click", ".new-notification", function () {
var notificationId = $(this).data("id");
var redirectUrl = $(this).data("url");
var markAsReadNotificationsEpr = emmAdminBasePath + "/notifications/" + notificationId + "/mark-checked";
var messageSideBar = ".sidebar-messages";
invokerUtil.put(
markAsReadNotificationsEpr,
null,
// on success
function (data) {
data = JSON.parse(data);
if (data.statusCode == responseCodes["ACCEPTED"]) {
location.href = redirectUrl;
}
},
// on error
function () {
var content = "<li class='message message-danger'><h4><i class='icon fw fw-error'></i>Warning</h4>" +
"<p>Unexpected error occurred while loading notification. Please refresh the page and" +
" try again</p></li>";
$(messageSideBar).html(content);
}
);
});
/**
* Following click function would execute
* when a user clicks on "Add Device type" button.
*/
$("button#add-device-btn").click(function () {
var errorMsgWrapper = "#device-create-error-msg";
var errorMsg = "#device-create-error-msg span";
var successMsgWrapper = "#device-create-success-msg";
var successMsg = "#device-create-success-msg span";
var deviceName = $("#deviceName").val();
var deviceType = $("#deviceTypeName").val();
var deviceId = $("#deviceId").val();
var deviceDescription = $("#deviceDescription").val();
if (!deviceType || deviceType.trim() == "" || !deviceName || deviceName.trim() == "" || !deviceId || deviceId.trim() == "") {
$(errorMsg).text("Device ID/Name Cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
return;
}
var device = {};
device.name = deviceName;
device.deviceIdentifier = deviceId;
device.description = deviceDescription;
device.type = deviceType;
device.enrolmentInfo = {};
device.enrolmentInfo.status = "ACTIVE";
device.enrolmentInfo.ownership = "BYOD";
device.properties = [];
$('input[name^="properties"]').each(function() {
var propName = $(this).attr('id');
var propValue = $(this).val();
if (propName && propName.trim() != "" && propValue && propValue.trim() != "") {
var property = {};
property.name = propName.trim();
property.value = propValue.trim();
device.properties.push(property);
}
});
var addDeviceAPI = apiBasePath + "/device/agent/enroll";
invokerUtil.post(
addDeviceAPI,
device,
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) {
$.ajax({
type: "GET",
url: "/devicemgt/api/devices/agent/" + deviceType + "/" + deviceId + "/config",
success: function(data, status, xhr) {
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(data, null, 4));
var dlAnchorElem = document.getElementById('downloadAnchorElem');
dlAnchorElem.setAttribute("href", dataStr );
dlAnchorElem.setAttribute("download", deviceId + ".json");
dlAnchorElem.click();
$("#modalDevice").modal('show');
},
error: function(xhr, status, error) {
$(errorMsg).text("Device Created, But failed to download the agent configuration.");
$(errorMsgWrapper).removeClass("hidden");
}
});
}
},
function (jqXHR) {
if (jqXHR.status == 500) {
$(errorMsg).text("Unexpected error.");
$(errorMsgWrapper).removeClass("hidden");
}
if (jqXHR.status == 409) {
$(errorMsg).text("Device already exists");
$(errorMsgWrapper).removeClass("hidden");
}
}
);
});
});
function redirectPage(url) {
var deviceType = $("#deviceTypeName").val();
var deviceId = $("#deviceId").val();
location.href= url + '/' + deviceType + "?id=" + deviceId;
}

@ -1,222 +0,0 @@
<div class="col-lg-12 margin-top-double">
<h1 class="grey ">{{deviceType}}</h1>
<hr>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-3 padding-top add-margin-bottom-5x">
<img src="{{@unit.publicUri}}/images/deviceType.png" class="img-responsive">
</div>
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
</div>
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
<h3 class="uppercase">Description</h3>
<hr>
<p class="grey margin-top">{{type.deviceTypeMetaDefinition.description}}</p>
<br>
<hr>
<br>
<a href="#create"
class="btn-operations"><i class="fw fw-add add-margin-1x"></i> Create Device</i>
</a>
<a href="/api-store/apis/info?name=DeviceAgent Service&version=1.0.0&provider=admin"
class="btn-operations"
target="_blank"><i class="fw fw-api add-margin-1x"></i> View API</i>
</a>
<div id="device-agent-downloading-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Device Agent will downloading shortly.</h3>
</div>
</div>
</div>
</div>
<div id="device-400-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Exception at backend. Try Later.</h3>
<div class="buttons">
<a href="#" id="device-400-link" class="btn-operations">
OK
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-401-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>You have to log in first.</h3><br/>
<div class="buttons">
<a href="#" id="device-401-link" class="blue-button">
Goto Login Page
</a>&nbsp;&nbsp;
<a href="#" onclick="hidePopup();" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-403-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Action not permitted.</h3><br/>
<div class="buttons">
<a href="#" id="device-403-link" class="btn-operations">
OK
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-409-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Device Sketch does not exist.</h3><br/>
<div class="buttons">
<a href="#" id="device-409-link" class="btn-operations">
OK
</a>
</div>
</div>
</div>
</div>
</div>
<div id="device-unexpected-error-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Unexpected error.</h3><br/>
<div class="buttons">
<a href="#" id="device-unexpected-error-link" class="btn-operations">
OK
</a>
</div>
</div>
</div>
</div>
</div>
<br/><br/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">How To Enroll a Device</h2>
<hr>
<ul class="list-unstyled">
<li class="padding-top-double"><span><h4 class="uppercase">Generate Application</h4></span>
<code>curl -k -X POST {{httpsGateway}}/api-application-registration/register -H
'authorization: Basic Base64(username:password)' -H 'content-type: application/json'
-d '{ "applicationName":"testme", "isAllowedToAllDomains":false, "tags":["device_agent"]}'</code>
</li>
<li class="padding-top-double"><span><h4 class="uppercase">Generate Token</h4></span>
<code>curl -k -d "grant_type=password&username=%username%&password=%password%&scope=perm:device:enroll perm:device:disenroll perm:device:modify perm:device:operations perm:device:publish-event"
-H "Authorization: Basic Base64(client_id:client_secret)"
-H "Content-Type: application/x-www-form-urlencoded" {{httpsGateway}}/token</code>
</li>
<li class="padding-top-double"><span><h4 class="uppercase">Create Device</h4></span>
<code>curl -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/enroll -H 'accept: application/json'
-H 'authorization: Bearer %accessToken%'
-H 'content-type: application/json' -d '{ "name": "devicename", "type": "{{deviceType}}",
"description": "descritption", "deviceIdentifier": "1234", "enrolmentInfo":
{"ownership": "BYOD", "status": "ACTIVE"}
,"properties": [{"name": "propertyName","value": "propertyValue"}]}'</code>
</li>
</ul>
<br>
<br>
</div>
<hr/>
<div id="create" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">Create A Device</h2>
<hr>
<div id="device-create-form" class=" wr-content">
<div class="wr-form">
<div class="row">
<div class="col-lg-8">
<div id="device-create-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<input aria-describedby="basic-addon1" type="text" id="deviceTypeName" style="display: none;"
data-error-msg="invalid device type name" class="form-control" value="{{deviceType}}"/>
<br>
<label class="wr-input-label">Name</label>
<input aria-describedby="basic-addon1" type="text" id="deviceName"
data-error-msg="invalid device name" class="form-control hidden-input"/>
<br/>
<label class="wr-input-label">Device Identifier</label>
<input aria-describedby="basic-addon1" type="text" id="deviceId"
data-error-msg="invalid device id" class="form-control hidden-input"/>
<br/>
<label class="wr-input-label">Description</label>
<input aria-describedby="basic-addon1" type="text" id="deviceDescription"
data-error-msg="invalid device description" class="form-control hidden-input"/>
<br/>
{{#if type.deviceTypeMetaDefinition}}
{{#each type.deviceTypeMetaDefinition.properties}}
<label class="wr-input-label">{{this}}</label>
<input aria-describedby="basic-addon1" type="text" id="{{this}}" name="properties"
data-error-msg="invalid device description" class="form-control hidden-input"/>
<br/>
{{/each}}
{{/if}}
<br>
<button id="add-device-btn" class="wr-btn">Create Device</button>
<a id="downloadAnchorElem" style="display:none"></a>
<div id="device-create-success-msg" class="alert hidden" role="alert">
<i class="icon fw fw-success"></i><span></span>
</div>
</div>
</div>
<div id="devicetype-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<p class="page-sub-title">Device Type Event was added successfully.</p>
<b>"View Device Type List"</b> to complete the process and go back to the devie type list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/device-types'">
View Device Type List
</button>
</div>
</div>
<div class="modal fade" id="modalDevice" tabindex="-1" role="dialog" aria-labelledby="modalDevice">
<div class="modal-dialog" role="document">
<div class="modal-content clearfix">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
<h3 class="modal-title" id="deviceModalLabel">Device Created Succesfully</h3>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="redirectPage('{{@app.context}}/device');">Go To Device Page</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div>
</div>
<br>
<br>
</div>
{{#zone "topCss"}}
{{css "css/styles.css"}}
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/type-view.js"}}
{{/zone}}

@ -1,105 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var deviceType = context.uriParams.deviceType;
var displayData = {};
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var user = userModule.getCarbonUser();
var tenantDomain = user.domain;
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var process = require("process");
context.handlebars.registerHelper('if_eq', function(a, b, opts) {
if(a == b) // Or === depending on your needs
return opts.fn(this);
else
return opts.inverse(this);
});
var restAPIEndpoint = deviceMgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/device-types/config/" + deviceType;
displayData.deviceType = deviceType;
displayData.tenantDomain = tenantDomain;
serviceInvokers.XMLHttp.get(
restAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var typeData = parse(restAPIResponse["responseText"]);
displayData.type = typeData;
}
}
);
var eventRestAPIEndpoint = deviceMgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/events/" + deviceType;
serviceInvokers.XMLHttp.get(
eventRestAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var typeData = parse(restAPIResponse["responseText"]);
displayData.event = typeData;
var sampleValue = "";
if (typeData.eventAttributes && typeData.eventAttributes.attributes) {
var eventExample = {};
for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) {
var attribute = typeData.eventAttributes.attributes[i];
switch (attribute.type) {
case "STRING":
eventExample[attribute.name] = "string";
sampleValue = sampleValue + "\"string\", ";
break;
case "LONG":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "INT":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "FLOAT":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "DOUBLE":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "BOOL":
eventExample[attribute.name] = false;
sampleValue = sampleValue + false + ", ";
break;
}
}
var sample = eventExample;
if (sampleValue && sampleValue.length > 2) {
displayData.sampleValue = sampleValue.substring(0, sampleValue.length - 2);
}
displayData.eventSample = JSON.stringify(sample);
displayData.mqttGateway = "tcp://" + process.getProperty("mqtt.broker.host") + ":" + process.getProperty("mqtt.broker.port");
displayData.httpsGateway = "https://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.https.port");
}
}
}
);
return displayData;
}

@ -1,152 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var policy = {};
var displayPolicy = function (policyPayloadObj) {
policy["name"] = policyPayloadObj["policyName"];
policy["platform"] = policyPayloadObj["profile"]["deviceType"];
// updating next-page wizard title with selected platform
$("#policy-heading").text(policy["platform"].toUpperCase() + " POLICY - " + policy["name"].toUpperCase());
$("#policy-platform").text(policy["platform"].toUpperCase());
$("#policy-assignment").text(policyPayloadObj.deviceGroups);
$("#policy-action").text(policyPayloadObj.compliance.toUpperCase());
$("#policy-description").text(policyPayloadObj["description"]);
var policyStatus = "Active";
if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == true) {
policyStatus = '<i class="fw fw-warning icon-success"></i> Active/Updated</span>';
} else if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == false) {
policyStatus = '<i class="fw fw-success icon-success"></i> Active</span>';
} else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == true) {
policyStatus = '<i class="fw fw-warning icon-warning"></i> Inactive/Updated</span>';
} else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == false) {
policyStatus = '<i class="fw fw-error icon-danger"></i> Inactive</span>';
}
$("#policy-status").html(policyStatus);
if (policyPayloadObj.users == null) {
$("#policy-users").text("NONE");
}
else if (policyPayloadObj.users.length > 0) {
$("#policy-users").text(policyPayloadObj.users.toString().split(",").join(", "));
} else {
$("#users-row").addClass("hidden");
}
if (policyPayloadObj.deviceGroups == null) {
$("#policy-groups").text("NONE");
} else if (policyPayloadObj.deviceGroups.length > 0) {
debugger;
var deviceGroups = policyPayloadObj.deviceGroups;
var assignedGroups = [];
for (var index in deviceGroups) {
if (deviceGroups.hasOwnProperty(index)) {
assignedGroups.push(deviceGroups[index].name);
}
}
$("#policy-groups").text(assignedGroups.toString().split(",").join(", "));
} else {
$("#policy-groups").text("NONE");
}
if (policyPayloadObj.roles == null) {
$("#policy-roles").text("NONE");
}
else if (policyPayloadObj.roles.length > 0) {
$("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", "));
} else {
$("#roles-row").addClass("hidden");
}
var deviceType = policy["platform"];
var policyOperationsTemplateSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
'.policy-view/templates/' + deviceType + '-policy-view.hbs';
var policyOperationsScriptSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
'.policy-view/js/' + deviceType + '-policy-view.js';
var policyOperationsStylesSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
'.policy-view/css/' + deviceType + '-policy-view.css';
var policyOperationsTemplateCacheKey = deviceType + '-policy-operations';
$.isResourceExists(policyOperationsTemplateSrc, function (status) {
if (status) {
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
var content = template();
$("#device-type-policy-operations").html(content).removeClass("hidden");
$(".policy-platform").addClass("hidden");
$.isResourceExists(policyOperationsScriptSrc, function (status) {
if (status) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script);
/*
This method should be implemented in the relevant plugin side and should include the logic to
populate the policy profile in the plugin specific UI.
*/
polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]);
}
});
});
$.isResourceExists(policyOperationsStylesSrc, function (status) {
if (status) {
var style = document.createElement('link');
style.type = 'text/css';
style.rel = 'stylesheet';
style.href = policyOperationsStylesSrc;
$(".wr-advance-operations").prepend(style);
}
});
} else {
$("#generic-policy-operations").removeClass("hidden");
}
$(".wr-advance-operations-init").addClass("hidden");
});
};
/**
* This method will return query parameter value given its name.
* @param name Query parameter name
* @returns {string} Query parameter value
*/
var getParameterByName = function (name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
};
$(document).ready(function () {
var policyPayloadObj;
// Adding initial state of wizard-steps.
invokerUtil.get(
"/api/device-mgt/v1.0" + "/policies/effective-policy/" + getParameterByName("type") + "/" + getParameterByName("id"),
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
policyPayloadObj = JSON.parse(data);
displayPolicy(policyPayloadObj);
}
},
// on error
function (jqXHR) {
console.log(jqXHR);
// should be redirected to an error page
}
);
});

@ -1,83 +0,0 @@
{{#zone "content"}}
{{!--#if isAuthorized--}}
{{#defineZone "policy-profile-top"}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
<label id="policy-heading" class="device-id device-select">
</label>
</div>
</div>
{{/defineZone}}
<!-- #page-content-wrapper -->
<div class="page-content-wrapper">
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Policy Overview
</div>
{{#defineZone "policy-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 14%;">Platform</td>
<td id="policy-platform" style="padding:10px 15px;"></td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">Groups</td>
<td id="policy-groups" style="padding:10px 15px;"></td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Action upon non-compliance</td>
<td id="policy-action" style="padding:10px 15px;"></td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Status</td>
<td id="policy-status" style="padding:10px 15px;"></td>
</tr>
<tr role="row" id="users-row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Assigned Users</td>
<td id="policy-users" style="padding:10px 15px;"></td>
</tr>
<tr role="row" id="roles-row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Assigned Roles</td>
<td id="policy-roles" style="padding:10px 15px;"></td>
</tr>
</tbody>
</table>
{{/defineZone}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Description
</div>
<div class="add-margin-top-4x">
<div id="policy-description" class="panel-title-description"></div>
</div>
<br>
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Profile Information
</div>
<div class="add-margin-top-4x">
<div id="policy-profile-main-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div class="wr-advance-operations">
<div class='wr-advance-operations-init'>
<br/>
<i class='fw fw-settings fw-spin fw-2x'></i>
Loading Platform Features . . .
<br/>
<br/>
</div>
<div id="device-type-policy-operations" class="hidden">
</div>
<div id="generic-policy-operations" class="hidden">
{{unit "cdmf.unit.device.type.generic.policy-wizard"}}
</div>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/view.js"}}
{{/zone}}

@ -1,27 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var utility = require("/app/modules/utility.js")["utility"];
var deviceType = context.uriParams.deviceType;
var deviceId = context.uriParams.deviceId;
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
}

@ -1,783 +0,0 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "topCss"}}
{{css "css/app.css" combine=false}}
{{css "css/map.css" combine=false}}
{{css "css/leaflet.css" combine=false}}
{{css "css/L.Control.Locate.css" combine=false}}
{{css "css/MarkerCluster.Default.css" combine=false}}
{{css "css/leaflet_fullscreen/leaflet.fullscreen.css" combine=false}}
{{css "css/leaflet/leaflet.draw.css" combine=false}}
{{css "css/d3/c3.css" combine=false}}
{{css "css/bootstrap-datepicker.min.css" combine=false}}
<style>
.datepicker-inline {
margin:0 auto;
}
</style>
{{/zone}}
{{#zone "content"}}
<div id="alerts-common"></div>
{{/zone}}
<span id="geo-charts" data-ws-endpoint="{{wsEndpoint}}" data-ws-token="{{wsToken}}" data-geo-public-uri="{{@unit.publicUri}}"
data-device-location="{{lastLocation}}"></span>
<div class="map-wrapper">
{{#unless @unit.params.hideSearch}}
<div class="navbar-collapse collapse" style="display:inline-block;">
<ul class="nav navbar-nav-right">
<li>
<form id="mapSearch" class="navbar-form" role="search"
onsubmit="focusOnSpatialObject($(this).find('#searchbox').val());return false;">
<div class="form-group has-feedback">
<input autofocus="true" id="searchbox" type="text" placeholder="Search"
class="form-control typeahead">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
<input style="visibility: hidden; position: fixed;" type="submit"/>
</form>
</li>
</ul>
</div>
{{/unless}}
<div id="" style="height: 63vh;">
<!-- Sidebar -->
<div id="map"></div>
{{#if geoServicesEnabled}}
<div id="ws-alerts">
<i id="ws-alert-stream" class="fw fw-circle text-muted"></i> Alerts Stream&nbsp;
<i id="ws-spatial-stream" class="fw fw-circle text-muted"></i> Spatial Stream
</div>
{{/if}}
</div>
<div id="predictionResults" style="background: darkgray;display: none;border-radius: 13px;height: 94%;padding: 0"
class="col-md-2 pull-right">
<div class="panel-heading text-center">
<h4> Prediction Results For: <span id="predictionResultsID" class="text-info"></span>
<i id="objectInfoCloseButton" class="fa fa-times pull-right"
onclick="$('#predictionResults').animate({width: ['toggle','swing']},200);toggeled = false;spatialObject = currentSpatialObjects[selectedSpatialObject];spatialObject.removePath();spatialObject.marker.closePopup();selectedSpatialObject = null;">
</i>
</h4>
</div>
<br>
<div class="panel panel-default" style="overflow: auto;box-shadow: 0 0 8px 0 #635749">
<div class="panel-heading text-center"><h4>Prediction</h4>
</div>
<br>
<div class="panel-body">
<div style="max-height: 100%;margin: 0;border: none;margin-left: -25px" id="prediction_chart_div"></div>
</div>
</div>
</div>
<div id="loading">
<div class="loading-indicator">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%"></div>
</div>
</div>
</div>
<div class="modal" id="aboutModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Welcome to the BootLeaf template!</h4>
</div>
<div class="modal-body">
<ul class="nav nav-tabs" id="aboutTabs">
<li class="active"><a href="#about" data-toggle="tab"><i class="fa fa-question-circle"></i>&nbsp;About
the project</a></li>
<li><a href="#contact" data-toggle="tab"><i class="fa fa-envelope"></i>&nbsp;Contact us</a></li>
<li><a href="#disclaimer" data-toggle="tab"><i class="fa fa-exclamation-circle"></i>&nbsp;Disclaimer</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-globe"></i>&nbsp;Metadata
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#boroughs-tab" data-toggle="tab">Boroughs</a></li>
<li><a href="#subway-lines-tab" data-toggle="tab">Subway Lines</a></li>
<li><a href="#theaters-tab" data-toggle="tab">Theaters</a></li>
<li><a href="#museums-tab" data-toggle="tab">Museums</a></li>
</ul>
</li>
</ul>
<div class="tab-content" id="aboutTabsContent" style="padding-top: 10px;">
<div class="tab-pane fade active in" id="about">
<p>A simple, responsive template for building web mapping applications with <a
href="http://getbootstrap.com/">Bootstrap 3</a>, <a href="http://leafletjs.com/"
target="_blank">Leaflet</a>, and <a
href="http://twitter.github.io/typeahead.js/" target="_blank">typeahead.js</a>. Open
source, MIT licensed, and available on <a href="https://github.com/bmcbride/bootleaf"
target="_blank">GitHub</a>.</p>
<div class="panel panel-primary">
<div class="panel-heading">Features</div>
<ul class="list-group">
<li class="list-group-item">Fullscreen mobile-friendly map template with responsive
navbar and modal placeholders
</li>
<li class="list-group-item">jQuery loading of external GeoJSON files</li>
<li class="list-group-item">Logical multiple layer marker clustering via the <a
href="https://github.com/Leaflet/Leaflet.markercluster" target="_blank">leaflet
marker cluster plugin</a></li>
<li class="list-group-item">Elegant client-side multi-layer feature search with
autocomplete using <a href="http://twitter.github.io/typeahead.js/" target="_blank">typeahead.js</a>
</li>
<li class="list-group-item">Responsive sidebar feature list with sorting and filtering
via <a href="http://listjs.com/" target="_blank">list.js</a></li>
<li class="list-group-item">Marker icons included in grouped layer control via the <a
href="https://github.com/ismyrnow/Leaflet.groupedlayercontrol" target="_blank">grouped
layer control plugin</a></li>
</ul>
</div>
</div>
<div id="disclaimer" class="tab-pane fade text-danger">
<p>The data provided on this site is for informational and planning purposes only.</p>
<p>Absolutely no accuracy or completeness guarantee is implied or intended. All information on
this map is subject to such variations and corrections as might result from a complete title
search and/or accurate field survey.</p>
</div>
<div class="tab-pane fade" id="contact">
<form id="contact-form">
<div class="well well-sm">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="first-name">First Name:</label>
<input type="text" class="form-control" id="first-name">
</div>
<div class="form-group">
<label for="last-email">Last Name:</label>
<input type="text" class="form-control" id="last-email">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="text" class="form-control" id="email">
</div>
</div>
<div class="col-md-8">
<label for="message">Message:</label>
<textarea class="form-control" rows="8" id="message"></textarea>
</div>
<div class="col-md-12">
<p>
<button type="submit" class="btn btn-primary pull-right"
data-dismiss="modal">Submit
</button>
</p>
</div>
</div>
</div>
</form>
</div>
<div class="tab-pane fade" id="boroughs-tab">
<p>Borough data courtesy of <a
href="http://www.nyc.gov/html/dcp/html/bytes/meta_dis_nyboroughwi.shtml"
target="_blank">New York City Department of City Planning</a></p>
</div>
<div class="tab-pane fade" id="subway-lines-tab">
<p><a href="http://spatialityblog.com/2010/07/08/mta-gis-data-update/#datalinks"
target="_blank">MTA Subway data</a> courtesy of the <a
href="http://www.urbanresearch.org/about/cur-components/cuny-mapping-service"
target="_blank">CUNY Mapping Service at the Center for Urban Research</a></p>
</div>
<div class="tab-pane fade" id="theaters-tab">
<p>Theater data courtesy of <a
href="https://data.cityofnewyork.us/Recreation/Theaters/kdu2-865w" target="_blank">NYC
Department of Information & Telecommunications (DoITT)</a></p>
</div>
<div class="tab-pane fade" id="museums-tab">
<p>Museum data courtesy of <a
href="https://data.cityofnewyork.us/Recreation/Museums-and-Galleries/sat5-adpb"
target="_blank">NYC Department of Information & Telecommunications (DoITT)</a></p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal" id="attributionModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 id = "title" class="modal-title">
WSO2 Geo Dashboard
</h4>
</div>
<div class="modal-body">
<div id="attribution"></div>
</div>
</div>
</div>
</div>
<div class="modal" id="addTileServer" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content" style="width:50%; margin:0 auto;">
<div class="modal-header"
style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
&lt;!&ndash; TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip &ndash;&gt;
Add tiler server URL <sup id="aboutTileUrl" style="cursor: pointer;" data-toggle="tooltip"
title="What is a tile URL?"><i class="fa fa-question" style="color: #39F;"
data-toggle="collapse"
data-target="#collapseOne"></i></sup>
</h4>
</div>
<div class="modal-body">
<div id="urlInput">
<div style="height: 0px;" id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<p>A string of the following form:</p>
<pre><code class="javascript"><span class="string">'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'</span></code></pre>
<p><code class="javascript">{s}</code> means one of the available subdomains (used
sequentially to help with browser parallel requests per domain limitation; subdomain
values are specified in options; <code class="javascript">a</code>, <code
class="javascript">b</code> or <code class="javascript">c</code> by default, can
be omitted), <code class="javascript">{z}</code> — zoom level, <code class="javascript">{x}</code>
and <code class="javascript">{y}</code> — tile coordinates.</p>
<p>You can use custom keys in the template, which will be <a
href="#util-template">evaluated</a> from TileLayer options, like this:</p>
<pre><code class="javascript">L.tileLayer(<span class="string">'http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png'</span>,
{foo: <span class="string">'bar'</span>});</code></pre>
</div>
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-italic"></i></span>
<input autofocus="enable" id="tileName" type="text" class="form-control"
placeholder="Tile URL name">
</div>
<br>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-globe"></i></span>
<input id="tileUrl" class="form-control" type="text"
placeholder="http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png">
<span class="input-group-btn">
<button class="btn btn-info" type="button" onclick="addTileUrl()"><i class="fa fa-plus"></i>
</button>
</span>
</div>
<br/>
<div class="panel panel-default" style="width: 80%;">
<div>
<h4 class="panel-title" style="font-size: 12px;line-height: 1.5;">
<button style="text-align: left;" class="btn btn-default btn-xs btn-block collapsed"
onclick="$('.fa-chevron-right').toggleClass('fa-rotate-90')"
data-toggle="collapse" data-parent="#accordion" href="#tileUrlOptions">
<i class="fa fa-chevron-right"></i> Options
</button>
</h4>
</div>
<div style="height: 0px;" id="tileUrlOptions" class="panel-collapse collapse">
<div class="panel-body">
<div class="input-group input-group-sm col-sm-9">
<small class="text-primary">
<label class="col-sm-2 control-label" for="sub_domains">Sub-domains</label>
</small>
<input id="sub_domains" type="text" class="form-control"
placeholder="Enter sub-domains in CSV format">
</div>
<br/>
<div class="input-group input-group-sm col-sm-9">
<small class="text-primary">
<label class="col-sm-9 control-label" for="maxzoom">Max zoom level</label>
</small>
<input id="maxzoom" type="text" class="form-control"
placeholder="Number between(around) 1~19">
</div>
<br/>
<div class="input-group input-group-sm col-sm-9">
<small class="text-primary">
<label class="col-sm-2 control-label" for="data_attribution">Attribution</label>
</small>
<input id="data_attribution" type="text" class="form-control"
placeholder="Enter attribution">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="addWmsUrl" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content" style="width:50%; margin:0 auto;">
<div class="modal-header"
style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
<sup id="aboutWms" style="cursor: pointer;" data-toggle="tooltip"
title="What WMS end-point"><i class="fa fa-question"
style="color: #39F;"
data-toggle="collapse"
data-target="#wmsOverview"></i></sup>
</h4>
</div>
<div class="modal-body">
<div>
<div style="height: 0px;" id="wmsOverview" class="panel-collapse collapse">
<div class="panel-body">
The OpenGIS® Web Map Service Interface Standard (WMS) provides a simple HTTP interface for
requesting geo-registered map images from one or more distributed geospatial databases.
A WMS request defines the geographic layer(s) and area of interest to be processed.
The response to the request is one or more geo-registered map images (returned as JPEG, PNG,
etc) that can be displayed in a browser application.
The interface also supports the ability to specify whether the returned images should be
transparent so that layers from multiple servers can be combined or not.
</div>
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-italic"></i></span>
<input autofocus="enable" id="serviceName" type="text" class="form-control"
placeholder="Service provider name">
</div>
<br>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-align-justify"></i></span>
<input autofocus="enable" id="layers" type="text" class="form-control"
placeholder="Service layers as comma seperated values">
</div>
<br>
<div class="input-group input-group-sm">
<span class="input-group-addon">V.</span>
<input autofocus="enable" id="wmsVersion" type="text" class="form-control"
placeholder="WMS version (i.e: 1.1.1 or 1.3.0)">
</div>
<br>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-globe"></i></span>
<input id="serviceEndPoint" class="form-control" type="text"
placeholder="http(s)://sedac.ciesin.columbia.edu/geoserver/wms">
<span class="input-group-btn">
<button class="btn btn-info" type="button" onclick="addWmsEndPoint()"><i
class="fa fa-plus"></i>
</button>
</span>
</div>
<br/>
<div class="panel panel-default" style="width: 80%;">
<div>
<h4 class="panel-title" style="font-size: 12px;line-height: 1.5;">
<button style="text-align: left;" class="btn btn-default btn-xs btn-block collapsed"
onclick="$('.fa-chevron-right').toggleClass('fa-rotate-90')"
data-toggle="collapse" data-parent="#accordion" href="#wmsOptions">
<i class="fa fa-chevron-right"></i> Options
</button>
</h4>
</div>
<div style="height: 0px;" id="wmsOptions" class="panel-collapse collapse">
<div class="panel-body">
<div class="input-group input-group-sm col-sm-11">
<small class="text-primary">
<label class="col-sm-6 control-label" for="outputFormat">Output format</label>
</small>
<input id="outputFormat" type="text" class="form-control"
placeholder="Output format (i.e: image/png, image/jpeg, image/svg)">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="commonModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
<div class="modal" id="editWithinGeoJSON" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
</h4>
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Adding GeoJson
<br>
</h4>
</div>
</div>
<div class="modal-body">
<div class="col-lg-8 col-md-8 col-centered">
<div>
<label for="importGeoJsonFile">Import GeoJson</label>
<input id="importGeoJsonFile" type="file">
<hr />
<label for="enterGeoJson">Enter GeoJson</label>
<textarea id="enterGeoJson" class="form-control" rows="10"></textarea>
</div>
<div class="pull-right">
<button id="updateGeoJson" class="btn btn-primary" onclick="importGeoJson()">Import</button>
<button type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>
<br />
<br />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="editExitGeoJSON" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
</h4>
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Adding GeoJson
<br>
</h4>
</div>
</div>
<div class="modal-body">
<div class="col-lg-8 col-md-8 col-centered">
<div>
<label for="importGeoJsonFile">Import GeoJson</label>
<input id="importGeoJsonFile" type="file">
<hr />
<label for="enterGeoJson">Enter GeoJson</label>
<textarea id="enterGeoJson" class="form-control" rows="10"></textarea>
</div>
<div class="pull-right">
<button id="updateGeoJson" class="btn btn-primary" onclick="importGeoJson()">Import</button>
<button type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>
<br />
<br />
</div>
</div>
</div>
</div>
</div>
</div>
<div style="display: none">
<div id="markerPopup" class="popover top">
<div class="arrow"></div>
<h3 class="popover-title">ID <span id="objectId"></span></h3>
<div class="popover-content">
<h6>Information</h6>
<p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
{{#if geoServicesEnabled}}
<h6>Speed<span class="label label-primary pull-right"><span id="speed"></span> km/h</span></h6>
<h6>Heading<span id="heading" class="label label-primary pull-right"></span></h6>
<button type="button" class="btn btn-info btn-xs" onClick="toggleSpeedGraph();return false;">Speed Graph</button>
<button type="button" class="btn btn-info btn-xs" onClick="focusOnRecentHistorySpatialObject();return false;">Recent History</button>
<button type="button" class="btn btn-info btn-xs" onClick="popupDateRange();">Full History</button>
{{/if}}
</div>
</div>
<div id="dateRangePopup">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-3">From:</label>
<div class="col-sm-9">
<input id="timeFromCal" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3">To:</label>
<div class="col-sm-9">
<input id="timeToCal" type="text">
</div>
</div>
</div>
<button type="button" class="btn btn-info btn-xs" onClick="focusOnHistorySpatialObject(document.getElementById('objectId').innerHTML, document.getElementById('timeFromCal').value, document.getElementById('timeToCal').value);return false;">Full History</button>
</div>
<div id="markerPopupStop" class="popover top">
<div class="arrow"></div>
<h3 class="popover-title">ID <span id="objectId"></span></h3>
<div class="popover-content">
<h6>Information</h6>
<p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
</div>
</div>
<div id="areaPopup" class="popover top">
<div class="arrow"></div>
<h3 class="popover-title">ID <span id="objectId"></span></h3>
<div class="popover-content">
<h6>Severity</h6>
<p id="severity" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
</div>
<div class="popover-content">
<h6>Information</h6>
<p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
</div>
</div>
<div id="setWithinAlert">
<form role="form" style="width: auto;">
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Fence name" type="text">
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<button id="addWithinAlert" onclick="setWithinAlert($(this).attr('leaflet_id'))" type="button"
class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left"
title="Save selected area for alerts">Save
</button>
</div>
<div class="btn-group">
<button id="editGeoJson"
onclick="$('#editWithinGeoJSON #updateGeoJson').attr('leaflet_id',$(this).attr('leaflet_id'));$('#editWithinGeoJSON textarea').text(JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'));$('#editWithinGeoJSON').modal('toggle')"
type="button" class="btn btn-default btn-xs">Edit
</button>
</div>
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#"
onclick="exportToGeoJSON(this, JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))"
class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left"
title="Export selected area as a geoJson file">Export</a>
</div>
</div>
</div>
</form>
</div>
<div id="setExitAlert">
<form role="form" style="width: auto;">
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Fence name" type="text">
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<button id="addExitAlert" onclick="setExitAlert($(this).attr('leaflet_id'))" type="button"
class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left"
title="Save selected area for alerts">Save
</button>
</div>
<div class="btn-group">
<button id="editGeoJson"
onclick="$('#editExitGeoJSON #updateGeoJson').attr('leaflet_id',$(this).attr('leaflet_id'));$('#editExitGeoJSON textarea').text(JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'));$('#editExitGeoJSON').modal('toggle')"
type="button" class="btn btn-default btn-xs">Edit
</button>
</div>
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#"
onclick="exportToGeoJSON(this, JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))"
class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left"
title="Export selected area as a geoJson file">Export</a>
</div>
</div>
</div>
</form>
</div>
<div id="templateLoader"></div>
<div id="setStationeryAlert">
<form role="form" style="width: auto;">
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Stationery name" type="text">
<span class="help-block">Name of the selected area(e.g. colombo)</span>
<label class="text-primary" for="fRadius">Fluctuation radius</label>
<input class="form-control" id="fRadius" onblur="reformatRadius(this.form.fRadius.value);" placeholder="m" type="text">
<label class="text-primary" for="time">Time</label>
<input class="form-control" id="time" placeholder="Seconds" type="text">
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<button id="addStationeryAlert" onclick="setStationeryAlert($(this).attr('leaflet_id'))" type="button"
class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left"
title="Save selected area for alerts">Save
</button>
</div>
<div class="btn-group">
<button id="editGeoJson"
onclick="$('#editWithinGeoJSON #updateGeoJson').attr('leaflet_id',$(this).attr('leaflet_id'));$('#editWithinGeoJSON textarea').text(JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'));$('#editWithinGeoJSON').modal('toggle')"
type="button" class="btn btn-default btn-xs">Edit
</button>
</div>
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#"
onclick="exportToGeoJSON(this, JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))"
class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left"
title="Export selected area as a geoJson file">Export</a>
</div>
</div>
</div>
</form>
</div>
<div id="setTrafficAlert">
<form role="form" style="width: auto;">
<div class="form-group">
<label class="text-primary" for="areaName">Fence name</label>
<input class="form-control" id="areaName" placeholder="Area Name" type="text">
<span class="help-block">Name of the selected area(e.g. colombo)</span>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<button id="addTrafficAlert" onclick="setTrafficAlert($(this).attr('leaflet_id'))" type="button"
class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left"
title="Save selected area for alerts">Save
</button>
</div>
<div class="btn-group">
<button id="editGeoJson"
onclick="$('#editTrafficGeoJSON #updateGeoJson').attr('leaflet_id',$(this).attr('leaflet_id'));$('#editTrafficGeoJSON textarea').text(JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'));$('#editTrafficGeoJSON').modal('toggle')"
type="button" class="btn btn-default btn-xs">Edit
</button>
</div>
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#"
onclick="exportToGeoJSON(this, JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))"
class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left"
title="Export selected area as a geoJson file">Export</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
{{#zone "bottomJs" }}
{{js "js/leaflet/leaflet.js" }}
{{js "js/leaflet/leaflet.markercluster.js" }}
{{js "js/leaflet/L.Control.Locate.js" }}
{{js "js/leaflet/L.Control.Focus.js" }}
{{js "js/leaflet/L.Control.GeoAlerts.js" }}
{{js "js/leaflet/leaflet.groupedlayercontrol.js" }}
{{js "js/leaflet/Leaflet.fullscreen.min.js" }}
{{js "js/leaflet/Marker.Rotate.js" }}
{{js "js/leaflet/leaflet.draw.js" }}
{{!js "js/jquery/jquery-ui.min.js" }}
<!-- Leaflet plugins libries -->
{{js "js/firstTemp.js" }}
{{js "js/typeahead.bundle.min.js" }}
<!-- C3 charting library using D3 core -->
{{js "js/d3/d3.min.js" }}
{{js "js/d3/c3.min.js" }}
{{js "js/application_options.js" }}
{{js "js/secondTemp.js" }}
{{js "js/geo_remote.js" }}
{{js "js/show_alert_in_map.js" }}
{{js "js/app.js" }}
{{js "js/websocket.js" }}
{{js "js/geo_fencing.js" }}
<script type="text/javascript">
$(document).ready(function () {
var geoLocationLink = $(".initGeoLocationLink");
if (geoLocationLink) {
geoLocationLink.on('click', function () {
initializeGeoLocation({{geoServicesEnabled}});
});
geoPublicUri = $("#geo-charts").data("geo-public-uri");
{{#if geoServicesEnabled}}
var geoToolsMenu = $('#location-action-bar');
var refreshMap = createGeoToolListItem('javascript:void(0);', 'Refresh', 'fw fw-refresh', geoToolsMenu, true);
refreshMap.addClass("geo-alert");
refreshMap.on("click", function(){enableRealTime();});
var realtTime = createGeoToolListItem('javascript:void(0);', 'Return to Real Time View', 'fw fw-undo', geoToolsMenu, true);
realtTime.on("click", function(){enableRealTime();});
realtTime.css("display", "none");
realtTime.attr("id", "realTimeShow");
var speedAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/speed_alert.html',
'Set Speed Alert', 'glyphicon glyphicon-dashboard', geoToolsMenu);
speedAlert.addClass("geo-alert");
var stationaryAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/stationery_alert.html',
'Add Stationary Alert', 'glyphicon glyphicon-link', geoToolsMenu);
stationaryAlert.addClass("geo-alert");
var withinAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/within_alert.html',
'Add Geofence Alert', 'glyphicon glyphicon-log-in', geoToolsMenu);
withinAlert.addClass("geo-alert");
var exitAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/exit_alert.html',
'Add Geofence Exit Alert', 'glyphicon glyphicon-log-out', geoToolsMenu);
exitAlert.addClass("geo-alert");
{{/if}}
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('#dateRangePopup.ui-dialog-content').dialog('close');
});
});
</script>
{{/zone}}

@ -1,57 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var log = new Log("geo-dashboard.js");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var viewModel = {};
var carbonServer = require("carbon").server;
var device = context.unit.params.device;
var constants = require("/app/modules/constants.js");
var wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/";
var spatialWSEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var alertsWSEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]);
var token = "";
if (encodedClientKeys) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username, "default", {});
if (tokenPair) {
token = tokenPair.accessToken;
}
}
viewModel.device = device;
viewModel.wsToken = token;
viewModel.wsEndpoint = wsEndpoint;
if (device.latestDeviceInfo) {
viewModel.lastLocation = stringify(device.latestDeviceInfo.location);
} else if (device.location) {
viewModel.lastLocation = stringify(device.location);
} else {
viewModel.lastLocation = stringify({});
}
viewModel.geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled;
return viewModel;
}

@ -1,47 +0,0 @@
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Set 'Exit Fence' alerts
<br>
</h4>
</div>
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-8 col-md-8 col-centered">
<div class="">
<table class="table table-hover" id="exit-alert">
<thead>
<tr>
<th>Fence Name</th>
<th>Query Name</th>
<th>Created On</th>
<th></th>
</tr>
</thead>
<tbody>
<div class="alert alert-info fence-not-exist" role="alert">
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
</div>
</tbody>
</table>
</div>
<div class="pull-right">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="openTools('Exit')">Draw area
</button>
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="$('#editExitGeoJSON').modal('toggle')">Enter area
</button>
<br/>
<br/>
</div>
</div>
</div>
</div>
</div>
<script src="/devicemgt/public/cdmf.unit.geo-dashboard/js/geo_exit_fence.js"></script>

@ -1,95 +0,0 @@
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.-->
<!DOCTYPE html>
<html>
<head lang="en">
<link href="/portal/store/carbon.super/fs/gadget/geo-dashboard/css/leaflet/L.Grid.css" rel="stylesheet" type="text/css"/>
<link href="/portal/store/carbon.super/fs/gadget/geo-dashboard/css/main.css" rel="stylesheet" type="text/css"/>
<script src="/portal/store/carbon.super/fs/gadget/geo-dashboard/js/leaflet/L.Grid.js"></script>
<script src="/portal/store/carbon.super/fs/gadget/geo-dashboard/js/leaflet/L.MeasuringTool.js"></script>
<style>
.leaflet-grid-label .lng {
margin-left: 8px;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.measuring-line-for-look {
stroke-dasharray: 3, 20;
}
.measuring-label-tooltip .leaflet-popup-content-wrapper {
border-radius: 4px 4px 4px 4px;
opacity: 0.7;
padding: 1px;
text-align: center;
}
.measuring-label-tooltip .leaflet-popup-content {
margin: 0 5px;
/*width: 0;*/
}
.measuring-label-tooltip .leaflet-popup-tip-container {
display: none;
}
</style>
</head>
<body>
<div class="modal-header"
style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
Define proximity
</h4>
</div>
<div class="modal-body">
<div id="proximityMap" style="height: 50%; margin: 0 auto;"></div>
<div class="row">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<form class="form-inline" role="form">
<div class="input-group input-group-sm">
<input type="text" id="proximityDistance" class="form-control" placeholder="Distance" >
<span class="input-group-addon">m</span>
</div>
<div class="input-group input-group-sm">
<input autofocus="enable" id="proximityTime" type="number" class="form-control"
placeholder="Close time in S" >
<span class="input-group-addon">Seconds</span>
</div>
</form>
</div>
</div>
<div style="margin-bottom: -15px" class="btn-group btn-group-justified">
<div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="setProximityAlert()">Set Proximity
</button>
</div>
<div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="closeAll()">Cancel
</button>
</div>
</div>
</div>
</div>
<script src="/portal/store/carbon.super/fs/gadget/geo-dashboard/js/geo_proximity.js"></script>
</body>
</html>

@ -1,49 +0,0 @@
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Setup global speed limit
<br>
</h4>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<div class="input-group input-group-sm">
<input autofocus="enable" id="speedAlertValue" type="number" class="form-control" placeholder="Speed alert value " autocomplete="off">
<span class="input-group-addon">km/h</span>
</div>
<br>
<button type="button" class="btn btn-default pull-right btn-sm" onclick="closeAll()">Cancel</button>
<button type="button" class="btn btn-info pull-right btn-sm" onclick="setSpeedAlert()" style="margin-right: 10px;">Set speed alert</button>
<br><br>
</div>
</div>
</div>
<script src="/devicemgt/public/cdmf.unit.geo-dashboard/js/geo_speed.js"></script>
</body>
</html>

@ -1,80 +0,0 @@
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
.fa-trash-o:hover {
color: red;
}
</style>
<script>
</script>
</head>
<body>
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Set 'Stationary' alerts
<br>
</h4>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-8 col-md-8 col-centered">
<div class="">
<table class="table table-hover" id="stationary-alert-table">
<thead>
<tr>
<th>Stationary Name</th>
<th>Stationary Time</th>
<th>Fluctuation Radius</th>
<th>Query Name</th>
<th>Created On</th>
<th></th>
</tr>
</thead>
<tbody>
<div class="alert alert-info fence-not-exist" role="alert">
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
</div>
</tbody>
</table>
</div>
<br/>
<br/>
<div class="pull-right">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="openTools('Stationery')">Draw area
</button>
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="$('#editWithinGeoJSON').modal('toggle')">Enter area
</button>
</div>
<br/>
<br/>
</div>
</div>
<script src="/devicemgt/public/cdmf.unit.geo-dashboard/js/geo_stationary.js"></script>
</body>
</html>

@ -1,104 +0,0 @@
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
.fa-trash-o:hover{color:red;}
</style>
<script>
$(".removeGeoFence").tooltip();
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
viewFence(this.parentElement,'Traffic');
});
</script>
</head>
<body>
<div class="modal-header" style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
Set <i>traffic</i> alerts
</h4>
</div>
<div class="modal-body">
<div class="row">
<p class="text-info text-center">View current fences</p>
<div class="">
<table class="table table-hover">
<thead>
<tr >
<th>Query Name</th>
<th>Traffic Congestion Area Name</th>
<th></th>
</tr>
</thead>
<tbody>
<%
var alerts = get('traffic');
if(alerts){
for each(var alert in alerts){
%>
<tr class="viewGeoFenceRow" style="cursor: pointer" data-areaName='<%= alert.areaName %>' data-queryName='<%= alert.queryName %>' data-geoJson='<%= alert.geoJson %>'>
<td><%= alert.queryName %></td>
<td><%= alert.areaName %></td>
<td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence" data-toggle="tooltip" title="Remove fence" ><i class="fa fa-trash-o"></i></td>
</tr>
<%
}
}
else{
%>
<div class="alert alert-danger" role="alert">
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
</div>
<%
}
%>
</tbody>
</table>
</div>
<p class="text-info text-center">Select Interested Area</p>
<div style="margin-bottom: -15px" class="btn-group btn-group-justified">
<div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="openTools('Traffic')">Draw area</button>
</div>
<div class="btn-group">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="$('#editWithinGeoJSON').modal('toggle')" >Enter area</button>
</div>
<!--<div class="btn-group">-->
<!--<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>-->
<!--</div>-->
</div>
</div>
</div>
</body>
</html>

@ -1,47 +0,0 @@
<div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
<div class="col-lg-5 col-md-6 col-centered">
<h4>
Set 'Within' alerts
<br>
</h4>
</div>
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-8 col-md-8 col-centered">
<div class="">
<table class="table table-hover" id="within-alert">
<thead>
<tr>
<th>Fence Name</th>
<th>Query Name</th>
<th>Created On</th>
<th></th>
</tr>
</thead>
<tbody>
<div class="alert alert-info fence-not-exist" role="alert">
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
</div>
</tbody>
</table>
</div>
<div class="pull-right">
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="openTools('WithIn')">Draw area
</button>
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
onclick="$('#editWithinGeoJSON').modal('toggle')">Enter area
</button>
<br/>
<br/>
</div>
</div>
</div>
</div>
</div>
<script src="/devicemgt/public/cdmf.unit.geo-dashboard/js/geo_within.js"></script>

@ -1,52 +0,0 @@
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="viewExitAlert" >
<h3 class="popover-title" id="viewAreaName"></h3>
<div class="popover-content">
<form role="form" style="width: auto" id="exitAlertForm">
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
</form>
</div>
</div>
<div id="viewWithinAlert" >
<h3 class="popover-title" id="viewAreaName"></h3>
<div class="popover-content">
<form role="form" style="width: auto" class="" id="withinAlertForm">
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
</form>
</div>
</div>
<div id="viewStationeryAlert" >
<h3 class="popover-title" id="viewAreaName"></h3>
<div class="popover-content">
<form role="form" style="width: auto" id="stationaryAlertForm">
<h6>Stationery time(Seconds)<span id="viewAreaTime" class="label label-primary pull-right">N/A</span></h6>
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
</form>
</div>
</div>
</body>
</html>

@ -1,20 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==false and id == "$deviceId"]#geodashboard:subscribe()
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=false and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -1,140 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Geo-ExecutionPlan-Proximity_alert')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string );
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
@IndexBy('id')
define table ProximityTable(id string, timeStamp long);
@IndexBy('id')
define table AlertsTable(id string , proximityWith string, eventId string);
from dataIn#geodashboard:subscribe()
select id, latitude, longitude, timeStamp, type, speed, heading, eventId
insert into initialStream;
from initialStream[type == 'STOP']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from initialStream[type != 'STOP']
select *
insert into objectInitialStream;
from objectInitialStream#geo:proximity(id,longitude,latitude, $proximityDistance)
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith
insert into proxymityStream;
from proxymityStream[AlertsTable.id == proxymityStream.id in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
insert into innerStreamOne;
from proxymityStream[not(AlertsTable.id == proxymityStream.id in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
insert into innerStreamOne;
from proxymityStream[AlertsTable.id == proxymityStream.proximityWith in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
insert into innerStreamSeven;
from proxymityStream[not(AlertsTable.id == proxymityStream.proximityWith in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
insert into innerStreamSeven;
from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
select id,str:concat(",",proximityWith) as proximityWith , eventId
insert into AlertsTable;
from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
select proximityWith as id,str:concat(",",id) as proximityWith , eventId
insert into AlertsTable;
from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
from updateStream
select *
update AlertsTable
on id== AlertsTable.id;
from updateStream[proximityWith == ""]
delete AlertsTable
on id== AlertsTable.id;
from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, true as inAlertTable
insert into publishStream;
from objectInitialStream[not(AlertsTable.id == objectInitialStream.id in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, false as inAlertTable
insert into publishStream;
from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
on publishStream.id== AlertsTable.id
select publishStream.id as id, publishStream.latitude as latitude, publishStream.longitude as longitude, publishStream.timeStamp as timeStamp, publishStream.type as type, publishStream.speed as speed, publishStream.heading as heading, publishStream.eventId as eventId, AlertsTable.proximityWith as proximityInfo
insert into innerStreamTwo;
from publishStream[inAlertTable == false]
delete ProximityTable on ProximityTable.id==id;
from publishStream[inAlertTable == false]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
insert into innerStreamThree;
from innerStreamThree#window.length(0) join ProximityTable
on innerStreamThree.id == ProximityTable.id
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId, ProximityTable.timeStamp as storedTime, innerStreamThree.proximityInfo as proximityInfo
insert into innerStreamFour;
from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,proximityInfo,"true" as isProximity
insert into dataOutStream;
from innerStreamFour[(timeStamp - storedTime) < $proximityTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , proximityInfo ,"false" as isProximity
insert into dataOutStream;
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
select innerStreamTwo.id, innerStreamTwo.timeStamp
insert into ProximityTable;
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from dataOutStream[isProximity == 'true']
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,"WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information
insert into dataOut;
from dataOutStream[isProximity == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
insert into dataOut;

@ -1,20 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Geo-ExecutionPlan-Speed---$deviceId_alert')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string);
from dataIn[speed >= $speedAlertValue and id == "$deviceId"]#geodashboard:subscribe()
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "ALERTED" as state, "This device movement is not normal!!" as information
insert into dataOut;
from dataIn[speed < $speedAlertValue and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information
insert into dataOut;

@ -1,89 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
@IndexBy('id')
define table StationeryTable(id string, timeStamp long);
@IndexBy('id')
define table AlertsTable(id string, stationary bool);
from dataIn#geodashboard:subscribe()
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,geo:within(longitude,latitude,"$geoFenceGeoJSON") as isWithin
insert into innerStreamOne;
from innerStreamOne[isWithin == false]
delete StationeryTable on StationeryTable.id==id;
from innerStreamOne[isWithin == false]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true]#geo:stationary(id,longitude,latitude, $fluctuationRadius)
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,stationary
insert into innerStreamTwo;
from innerStreamTwo[innerStreamTwo.stationary == true]
select innerStreamTwo.id, innerStreamTwo.stationary
insert into AlertsTable;
from innerStreamTwo[innerStreamTwo.stationary == false]
delete AlertsTable on AlertsTable.id==id;
from innerStreamTwo[innerStreamTwo.stationary == false]
delete StationeryTable on StationeryTable.id==id;
from innerStreamOne[isWithin == true AND not(AlertsTable.id == innerStreamOne.id in AlertsTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true AND AlertsTable.id == innerStreamOne.id in AlertsTable]
insert into innerStreamThree;
from innerStreamThree#window.length(0) join AlertsTable
on innerStreamThree.id == AlertsTable.id
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId
insert into innerStreamFour;
from innerStreamFour[not(StationeryTable.id == innerStreamFour.id in StationeryTable)]
select innerStreamFour.id, innerStreamFour.timeStamp
insert into StationeryTable;
from innerStreamOne[isWithin == true AND not(StationeryTable.id == innerStreamOne.id in StationeryTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true AND StationeryTable.id == innerStreamOne.id in StationeryTable]
insert into innerStreamFive;
from innerStreamFive#window.length(0) join StationeryTable
on innerStreamFive.id == StationeryTable.id
select innerStreamFive.id , innerStreamFive.latitude, innerStreamFive.longitude,innerStreamFive.timeStamp, innerStreamFive.type, innerStreamFive.speed, innerStreamFive.heading ,innerStreamFive.eventId, StationeryTable.timeStamp as storedTime
insert into innerStreamSix;
from innerStreamSix[(timeStamp - storedTime) >= $stationeryTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"true" as isStationary
insert into dataOutStream;
from innerStreamSix[(timeStamp - storedTime) < $stationeryTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"false" as isStationary
insert into dataOutStream;
from dataOutStream[isStationary == 'true']
select id ,latitude, longitude,timeStamp, type, speed, heading ,eventId ,"ALERTED" as state, "This device is in $stationeryName area!!!" as information
insert into dataOut;
from dataOutStream[isStationary == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
insert into dataOut;

@ -1,17 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('rawGeoStream:1.0.0')
define stream dataIn (id string, timeStamp long, geometry string, state string, information string);
@Export('AlertsNotifications:1.0.0')
define stream dataOut (id string, state string, information string, timeStamp long, latitude double, longitude double);
from dataIn[geo:intersects(geometry, "$geoFenceGeoJSON")==true and geodashboard:needToNotify(id, str:concat(information, state), "sendFirst") == true and id == $deviceId]
select id, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
insert into dataOut

@ -1,20 +0,0 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe()
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -1,31 +0,0 @@
/* Compatible with Leaflet 0.7 */
@import url('font/locate-fa.woff');
@import url('css/locate-fa.css');
@import url('css/animation.css');
.leaflet-touch .leaflet-bar-part-single {
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
border-bottom: none;
}
.leaflet-control-locate a {
font-size: 1.4em;
margin-left: 1px;
color: #444;
}
.leaflet-control-locate.active a {
color: #2074B6;
}
.leaflet-control-locate.active.following a {
color: #FC8428;
}
.leaflet-touch .leaflet-control-locate {
box-shadow: none;
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}

@ -1,14 +0,0 @@
/* Conditional stylesheet for IE. */
@import url('css/locate-fa-ie7.css');
.leaflet-control-locate {
border: 3px solid #999;
}
.leaflet-control-locate a {
background-color: #eee;
}
.leaflet-control-locate a:hover {
background-color: #fff;
}

@ -1,60 +0,0 @@
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
}
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}
/* IE 6-8 fallback colors */
.leaflet-oldie .marker-cluster-small {
background-color: rgb(181, 226, 140);
}
.leaflet-oldie .marker-cluster-small div {
background-color: rgb(110, 204, 57);
}
.leaflet-oldie .marker-cluster-medium {
background-color: rgb(241, 211, 87);
}
.leaflet-oldie .marker-cluster-medium div {
background-color: rgb(240, 194, 12);
}
.leaflet-oldie .marker-cluster-large {
background-color: rgb(253, 156, 115);
}
.leaflet-oldie .marker-cluster-large div {
background-color: rgb(241, 128, 23);
}
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}

@ -1,6 +0,0 @@
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
-webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
-moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
-o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

@ -1,151 +0,0 @@
input[type="radio"], input[type="checkbox"] {
margin: 0;
}
.map-wrapper{
background: #37474f;
}
#left_side_pannel> .nav > li > a{
color: #fff;
}
.typeahead {
background-color: #FFFFFF;
}
#map {
width: auto;
height: 100%;
}
#loading {
position: absolute;
width: 220px;
height: 19px;
top: 50%;
left: 50%;
margin: -10px 0 0 -110px;
z-index: 20001;
}
/*.sidebar-wrapper {
width: 100%;
height: 100%;
position: relative;
}
.sidebar-table {
position: absolute;
width: 100%;
top: 124px;
bottom: 0px;
overflow: auto;
}*/
.leaflet-control-layers label {
font-weight: normal;
margin-bottom: 0px;
}
.leaflet-control-layers-group-name {
font-weight: bold;
margin-bottom: .2em;
display: block;
}
.leaflet-control-layers-group {
margin-bottom: .5em;
}
.leaflet-control-layers-group label {
padding-left: .5em;
}
.table {
margin-bottom: 0px;
}
.tt-dropdown-menu {
background-color: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 4px 4px 4px 4px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
margin-top: 4px;
padding: 4px 0;
width: 100%;
max-height: 300px;
overflow: auto;
}
.tt-suggestion {
font-size: 14px;
line-height: 20px;
padding: 3px 10px;
}
.tt-suggestion.tt-cursor {
background-color: #0097CF;
color: #FFFFFF;
cursor: pointer;
}
.tt-suggestion p {
margin: 0;
}
.tt-suggestion + .tt-suggestion {
border-top: 1px solid #ccc;
}
.typeahead-header {
margin: 0 5px 5px 5px;
padding: 3px 0;
border-bottom: 2px solid #333;
}
.has-feedback .form-control-feedback {
position: absolute;
top: 0;
right: 0;
display: block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
}
@media (max-width: 992px) {
/*.navbar .navbar-brand {
font-size: 18px;
}*/
}
@media (max-width: 767px){
.url-break {
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
hyphens: auto;
}
#sidebar {
display: none;
}
}
.leaflet-geo-alerts{
border-radius: 4px;
border: none;
background-color: white;
padding: 5px;
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
width: 200px;
font-size: 11px;
}
.leaflet-geo-alerts a{
padding: 5px 10px;
}
/*
!* Print Handling *!
@media print {
.navbar {
display: none !important;
}
.leaflet-control-container {
display: none !important;
}
}
.nav > li > a {
padding: 25px 15px !important;
}
.nav > li > a:hover, .nav > li > a:focus {
background-color: transparent !important;
}
*/

@ -1,19 +0,0 @@
Copyright (C) 2013 Panopta, Andrew Moffat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -1,182 +0,0 @@
/* WIZARD GENERAL */
.wizard {
display:none;
}
.wizard-dialog {}
.wizard-content {}
.wizard-body {
padding: 0;
margin: 0;
}
/* WIZARD HEADER */
.wizard-header {
padding: 9px 15px;
border-bottom: 0;
}
.wizard-header h3 {
margin: 0;
line-height: 35px;
display: inline;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-family: inherit;
font-weight: bold;
text-rendering: optimizelegibility;
color: rgb(51, 51, 51);
}
.wizard-subtitle {
font-weight:bold;
color:#AFAFAF;
padding-left:20px;
}
/* WIZARD NAVIGATION */
.wizard-steps {
width: 28%;
background-color: #f5f5f5;
border-bottom-left-radius: 6px;
position: relative;
}
.wizard-nav-container {
padding-bottom: 30px;
}
.wizard-nav-list {
margin-bottom: 0;
}
.wizard-nav-link .glyphicon-chevron-right {
float:right;
margin-top:12px;
margin-right:-6px;
opacity:.25;
}
li.wizard-nav-item.active .glyphicon-chevron-right {
opacity:1;
}
li.wizard-nav-item {
line-height:40px;
}
.wizard-nav-list > li > a {
background-color:#f5f5f5;
padding:3px 15px 3px 20px;
cursor:default;
color:#B4B4B4;
}
.wizard-nav-list > li > a:hover {
background-color: transparent;
}
.wizard-nav-list > li.already-visited > a.wizard-nav-link {
color:#08C;
cursor:pointer;
}
.wizard-nav-list > li.active > a.wizard-nav-link {
color:white;
}
.wizard-nav-item .already-visited .active {
background-color:#08C;
}
.wizard-nav-list li.active > a {
background-color:#08C;
}
/* WIZARD CONTENT */
.wizard-body form {
padding: 0;
margin: 0;
}
/* WIZARD PROGRESS BAR */
.wizard-progress-container {
margin-top: 20px;
padding: 15px;
width: 100%;
position: absolute;
bottom: 0;
}
.wizard-card-container {
margin-left: 28%;
}
/* WIZARD CARDS */
.wizard-error,
.wizard-failure,
.wizard-success,
.wizard-loading,
.wizard-card {
border-top: 1px solid #EEE;
display:none;
padding:35px;
padding-top:20px;
overflow-y:auto;
/*
position:relative;
height:300px;
margin-right: 5px;
*/
}
.wizard-card-overlay {
overflow-y: initial;
}
.wizard-card > h3 {
margin-top:0;
margin-bottom:20px;
font-size:21px;
line-height:40px;
font-weight:normal;
}
/* WIZARD FOOTER */
.wizard-footer {
padding:0;
}
.wizard-buttons-container {
padding:20px;
}
.wizard-cancel {
margin-left: 12px;
}
/* Inner Card */
.wizard-input-section {
margin-bottom:20px;
}
.wizard-dialog .popover.error-popover {
background-color:#F2DEDE;
color:#B94A48;
border-color:#953B39;
}
.wizard-dialog .popover.error-popover .arrow::after {
border-right-color:#F2DEDE;
}
.wizard-dialog .popover.error-popover .popover-title {
display:none;
}
.wizard-dialog .popover.error-popover .arrow {
border-right-color:#953B39;
}

@ -1,85 +0,0 @@
/*
Animation example, for spinners
*/
.animate-spin:before {
-moz-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
display: inline-block;
}
@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
-o-transform: rotate(359deg);
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@-webkit-keyframes spin {
0% {
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
-o-transform: rotate(359deg);
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@-o-keyframes spin {
0% {
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
-o-transform: rotate(359deg);
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@-ms-keyframes spin {
0% {
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
-o-transform: rotate(359deg);
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes spin {
0% {
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
-o-transform: rotate(359deg);
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}

@ -1,4 +0,0 @@
.icon-location:before { content: '\e802'; } /* '' */
.icon-direction:before { content: '\e800'; } /* '' */
.icon-spinner:before { content: '\e801'; } /* '' */

@ -1,4 +0,0 @@
.icon-location { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe802;&nbsp;'); }
.icon-direction { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe800;&nbsp;'); }
.icon-spinner { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe801;&nbsp;'); }

@ -1,15 +0,0 @@
[class^="icon-"], [class*=" icon-"] {
font-family: 'locate-fa';
font-style: normal;
font-weight: normal;
/* fix buttons height */
line-height: 1em;
/* you can be more comfortable with increased icons size */
/* font-size: 120%; */
}
.icon-location { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe802;&nbsp;'); }
.icon-direction { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe800;&nbsp;'); }
.icon-spinner { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '&#xe801;&nbsp;'); }

@ -1,72 +0,0 @@
@font-face {
font-family: 'locate-fa';
src: url('../font/locate-fa.eot?9201824');
src: url('../font/locate-fa.eot?9201824#iefix') format('embedded-opentype'),
url('../font/locate-fa.woff?9201824') format('woff'),
url('../font/locate-fa.ttf?9201824') format('truetype'),
url('../font/locate-fa.svg?9201824#locate-fa') format('svg');
font-weight: normal;
font-style: normal;
}
/* use SVG only on mobile devices to avoid display issue on android
issue: https://github.com/domoritz/leaflet-locatecontrol/issues/78
solution: http://stackoverflow.com/a/21050160/1106908
*/
@media only screen and (max-width: 320px),
screen and (max-device-width: 720px) and (orientation: portrait),
screen and (max-device-width: 1280px) and (orientation: landscape)
{
@font-face {
font-family: 'locate-fa';
src: url('../font/locate-fa.eot?9201824');
src: url('../font/locate-fa.svg?9201824#locate-fa') format('svg');
font-weight: normal;
font-style: normal;
}
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'locate-fa';
src: url('../font/locate-fa.svg?9201824#locate-fa') format('svg');
}
}
*/
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: "locate-fa";
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-decoration: inherit;
width: 1em;
margin-right: .2em;
text-align: center;
/* opacity: .8; */
/* For safety - reset parent styles, that can break glyph codes*/
font-variant: normal;
text-transform: none;
/* fix buttons height, for twitter bootstrap */
line-height: 1em;
/* Animation center compensation - margins should be symmetric */
/* remove if not needed */
margin-left: .2em;
/* you can be more comfortable with increased icons size */
/* font-size: 120%; */
/* Uncomment for 3D effect */
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}
.icon-location:before { content: '\e802'; } /* '' */
.icon-direction:before { content: '\e800'; } /* '' */
.icon-spinner:before { content: '\e801'; } /* '' */

@ -1,203 +0,0 @@
/*-- Chart --*/
.c3 svg {
font: 10px sans-serif;
}
.c3 path, .c3 line {
fill: none;
stroke: #000;
}
.c3 text {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.c3-legend-item-tile,
.c3-xgrid-focus,
.c3-ygrid,
.c3-event-rect,
.c3-bars path {
shape-rendering: crispEdges;
}
.c3-chart-arc path {
stroke: #fff;
}
.c3-chart-arc text {
fill: #fff;
font-size: 13px;
}
/*-- Axis --*/
.c3-axis-x .tick {
}
.c3-axis-x-label {
}
.c3-axis-y .tick {
}
.c3-axis-y-label {
}
.c3-axis-y2 .tick {
}
.c3-axis-y2-label {
}
/*-- Grid --*/
.c3-grid line {
stroke: #aaa;
}
.c3-grid text {
fill: #aaa;
}
.c3-xgrid, .c3-ygrid {
stroke-dasharray: 3 3;
}
.c3-xgrid-focus {
}
/*-- Text on Chart --*/
.c3-text {
}
.c3-text.c3-empty {
fill: #808080;
font-size: 2em;
}
/*-- Line --*/
.c3-line {
stroke-width: 1px;
}
/*-- Point --*/
.c3-circle._expanded_ {
stroke-width: 1px;
stroke: white;
}
.c3-selected-circle {
fill: white;
stroke-width: 2px;
}
/*-- Bar --*/
.c3-bar {
stroke-width: 0;
}
.c3-bar._expanded_ {
fill-opacity: 0.75;
}
/*-- Arc --*/
.c3-chart-arcs-title {
font-size: 1.3em;
}
/*-- Focus --*/
.c3-target.c3-focused path.c3-line, .c3-target.c3-focused path.c3-step {
stroke-width: 2px;
}
/*-- Region --*/
.c3-region {
fill: steelblue;
fill-opacity: .1;
}
/*-- Brush --*/
.c3-brush .extent {
fill-opacity: .1;
}
/*-- Select - Drag --*/
.c3-dragarea {
}
/*-- Legend --*/
.c3-legend-item {
font-size: 12px;
}
.c3-legend-background {
opacity: 0.75;
fill: white;
stroke: lightgray;
stroke-width: 1
}
/*-- Tooltip --*/
.c3-tooltip {
border-collapse:collapse;
border-spacing:0;
background-color:#fff;
empty-cells:show;
-webkit-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
-moz-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
box-shadow: 7px 7px 12px -9px rgb(119,119,119);
opacity: 0.9;
}
.c3-tooltip tr {
border:1px solid #CCC;
}
.c3-tooltip th {
background-color: #aaa;
font-size:14px;
padding:2px 5px;
text-align:left;
color:#FFF;
}
.c3-tooltip td {
font-size:13px;
padding: 3px 6px;
background-color:#fff;
border-left:1px dotted #999;
}
.c3-tooltip td > span {
display: inline-block;
width: 10px;
height: 10px;
margin-right: 6px;
}
.c3-tooltip td.value{
text-align: right;
}
.c3-area {
stroke-width: 0;
opacity: 0.2;
}
.c3-chart-arcs .c3-chart-arcs-background {
fill: #e0e0e0;
stroke: none;
}
.c3-chart-arcs .c3-chart-arcs-gauge-unit {
fill: #000;
font-size: 16px;
}
.c3-chart-arcs .c3-chart-arcs-gauge-max {
fill: #777;
}
.c3-chart-arcs .c3-chart-arcs-gauge-min {
fill: #777;
}
.c3-chart-arc .c3-gauge-value {
fill: #000;
font-size: 28px;
}

@ -1,10 +0,0 @@
Font license info
## Font Awesome
Copyright (C) 2012 by Dave Gandy
Author: Dave Gandy
License: SIL ()
Homepage: http://fortawesome.github.com/Font-Awesome/

@ -1,75 +0,0 @@
This webfont is generated by http://fontello.com open source project.
================================================================================
Please, note, that you should obey original font licences, used to make this
webfont pack. Details available in LICENSE.txt file.
- Usually, it's enough to publish content of LICENSE.txt file somewhere on your
site in "About" section.
- If your project is open-source, usually, it will be ok to make LICENSE.txt
file publically available in your repository.
- Fonts, used in Fontello, don't require to make clickable links on your site.
But any kind of additional authors crediting is welcome.
================================================================================
Comments on archive content
---------------------------
- /font/* - fonts in different formats
- /css/* - different kinds of css, for all situations. Should be ok with
twitter bootstrap. Also, you can skip <i> style and assign icon classes
directly to text elements, if you don't mind about IE7.
- demo.html - demo file, to show your webfont content
- LICENSE.txt - license info about source fonts, used to build your one.
- config.json - keeps your settings. You can import it back to fontello anytime,
to continue your work
Why so many CSS files ?
-----------------------
Because we like to fit all your needs :)
- basic file, <your_font_name>.css - is usually enougth, in contains @font-face
and character codes definition
- *-ie7.css - if you need IE7 support, but still don't wish to put char codes
directly into html
- *-codes.css and *-ie7-codes.css - if you like to use your own @font-face
rules, but still wish to benefit of css generation. That can be very
convenient for automated assets build systems. When you need to update font -
no needs to manually edit files, just override old version with archive
content. See fontello source codes for example.
- *-embedded.css - basic css file, but with embedded WOFF font, to avoid
CORS issues in Firefox and IE9+, when fonts are hosted on the separate domain.
We strongly recommend to resolve this issue by `Access-Control-Allow-Origin`
server headers. But if you ok with dirty hack - this file is for you. Note,
that data url moved to separate @font-face to avoid problems with <IE9, when
string is too long.
- animate.css - use it to get ideas about spinner rotation animation.
Attention for server setup
--------------------------
You MUST setup server to reply with proper `mime-types` for font files. In other
case, some browsers will fail to show fonts.
Usually, `apache` already has necessary settings, but `nginx` and other
webservers should be tuned. Here is list of mime types for our file extentions:
- `application/vnd.ms-fontobject` - eot
- `application/x-font-woff` - woff
- `application/x-font-ttf` - ttf
- `image/svg+xml` - svg

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save