Merge pull request #168 from charithag/IoTS-1.0.0-M2

Add policy specific functionality
Ruwan 9 years ago
commit 5c0d4b9aba

@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.iot.service; package org.wso2.carbon.device.mgt.iot.service;
import org.wso2.carbon.device.mgt.iot.config.server.DeviceManagementConfigurationManager;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.ControlQueue; import org.wso2.carbon.device.mgt.iot.config.server.datasource.ControlQueue;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceManagementConfiguration; import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceMgtServerInfo; import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceMgtServerInfo;
@ -26,16 +27,16 @@ public class ConfigurationServiceImpl implements ConfigurationService {
@Override @Override
public DeviceManagementConfiguration getDeviceCloudMgtConfig() { public DeviceManagementConfiguration getDeviceCloudMgtConfig() {
return null; return DeviceManagementConfigurationManager.getInstance().getDeviceCloudMgtConfig();
} }
@Override @Override
public ControlQueue getControlQueue(String name) { public ControlQueue getControlQueue(String name) {
return null; return DeviceManagementConfigurationManager.getInstance().getControlQueue(name);
} }
@Override @Override
public DeviceMgtServerInfo getDeviceManagementServerInfo() { public DeviceMgtServerInfo getDeviceManagementServerInfo() {
return null; return DeviceManagementConfigurationManager.getInstance().getDeviceManagementServerInfo();
} }
} }

@ -20,8 +20,8 @@
data-toggle="tab" aria-controls="device_statistics">Device data-toggle="tab" aria-controls="device_statistics">Device
Statistics</a> Statistics</a>
</li> </li>
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#device_location" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#device_location" role="tab" data-toggle="tab"
aria-controls="device_location">Device Location</a></li> aria-controls="device_location">Device Location</a></li>
@ -38,28 +38,32 @@
{{unit "iot.unit.device.stats" device=device}} {{unit "iot.unit.device.stats" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="device_location" role="tabpanel" <div class="panel panel-default tab-pane" id="device_location" role="tabpanel"
aria-labelledby="device_location"> aria-labelledby="device_location">

@ -27,8 +27,8 @@
data-toggle="tab" aria-controls="device_statistics">Device data-toggle="tab" aria-controls="device_statistics">Device
Statistics</a> Statistics</a>
</li> </li>
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li> aria-controls="event_log">Operations Log</a></li>
@ -43,28 +43,32 @@
{{unit "iot.unit.device.stats" device=device}} {{unit "iot.unit.device.stats" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" <div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log"> aria-labelledby="event_log">

@ -23,8 +23,8 @@
<div class="media"> <div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2"> <div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist"> <ul class="list-group" role="tablist">
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li> aria-controls="event_log">Operations Log</a></li>
@ -33,28 +33,32 @@
<div class="media-body add-padding-left-5x remove-padding-xs tab-content"> <div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content"> <div class="panel-group tab-content">
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" <div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log"> aria-labelledby="event_log">

@ -16,8 +16,8 @@
<div class="media"> <div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2"> <div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist"> <ul class="list-group" role="tablist">
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li> aria-controls="event_log">Operations Log</a></li>
@ -26,28 +26,32 @@
<div class="media-body add-padding-left-5x remove-padding-xs tab-content"> <div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content"> <div class="panel-group tab-content">
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" <div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log"> aria-labelledby="event_log">

@ -1,197 +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 () {
var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type");
var payload = [deviceIdentifier];
var operationTable;
if (deviceType == "ios") {
var serviceUrl = "/ios/operation/deviceinfo";
} else if (deviceType == "android") {
var serviceUrl = "/mdm-android-agent/operation/device-info";
}
if(serviceUrl){
invokerUtil.post(serviceUrl, payload,
function(message){
console.log(message);
}, function (message) {
console.log(message);
});
}
$(document).ready(function(){
$(".panel-body").removeClass("hidden");
$("#loading-content").remove();
loadOperationBar(deviceType);
loadOperationsLog();
loadApplicationsList();
loadPolicyCompliance();
$("#refresh-policy").click(function () {
$('#policy-spinner').removeClass('hidden');
loadPolicyCompliance();
});
$("#refresh-apps").click(function () {
$('#apps-spinner').removeClass('hidden');
loadApplicationsList();
});
$("#refresh-operations").click(function () {
$('#operations-spinner').removeClass('hidden');
loadOperationsLog(true);
});
});
function loadOperationsLog(update) {
var operationsLog = $("#operations-log");
var deviceListingSrc = operationsLog.attr("src");
var deviceId = operationsLog.data("device-id");
var deviceType = operationsLog.data("device-type");
$.template("operations-log", deviceListingSrc, function (template) {
var serviceURL = "/devicemgt_admin/operations/"+deviceType+"/"+deviceId;
var successCallback = function (data) {
data = JSON.parse(data);
$('#operations-spinner').addClass('hidden');
var viewModel = {};
viewModel.operations = data;
if(data.length > 0){
var content = template(viewModel);
if(!update) {
$("#operations-log-container").html(content);
operationTable = $('#operations-log-table').datatables_extended();
}else{
$('#operations-log-table').dataTable().fnClearTable();
for(var i=0; i < data.length; i++) {
var status;
if(data[i].status == "COMPLETED") {
status = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
} else if(data[i].status == "PENDING") {
status = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
} else if(data[i].status == "ERROR") {
status = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
} else if(data[i].status == "IN_PROGRESS") {
status = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
}
$('#operations-log-table').dataTable().fnAddData([
data[i].code,
status,
data[i].createdTimeStamp
]);
}
}
}
};
invokerUtil.get(serviceURL,
successCallback, function(message){
console.log(message);
});
});
}
function loadApplicationsList() {
var applicationsList = $("#applications-list");
var deviceListingSrc = applicationsList.attr("src");
var deviceId = applicationsList.data("device-id");
var deviceType = applicationsList.data("device-type");
$.template("application-list", deviceListingSrc, function (template) {
var serviceURL = "/devicemgt_admin/operations/"+deviceType+"/"+deviceId+"/apps";
var successCallback = function (data) {
data = JSON.parse(data);
$('#apps-spinner').addClass('hidden');
var viewModel = {};
if(data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) {
data[i].name = data[i].name.replace(/[^\w\s]/gi, ' ');
data[i].name = data[i].name.replace(/[0-9]/g, ' ');
}
}
viewModel.applications = data;
viewModel.deviceType = deviceType;
if(data.length > 0){
var content = template(viewModel);
$("#applications-list-container").html(content);
}
};
invokerUtil.get(serviceURL,
successCallback, function(message){
console.log(message);
});
});
}
function loadPolicyCompliance() {
var policyCompliance = $("#policy-view");
var policySrc = policyCompliance.attr("src");
var deviceId = policyCompliance.data("device-id");
var deviceType = policyCompliance.data("device-type");
var activePolicy = null;
$.template("policy-view", policySrc, function (template) {
var serviceURLPolicy ="/devicemgt_admin/policies/"+deviceType+"/"+deviceId+"/active-policy"
var serviceURLCompliance = "/devicemgt_admin/policies/"+deviceType+"/"+deviceId;
var successCallbackCompliance = function (data) {
var viewModel = {};
viewModel.policy = activePolicy;
viewModel.deviceType = deviceType;
if(data != null && data.complianceFeatures!= null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) {
viewModel.compliance = "NON-COMPLIANT";
viewModel.complianceFeatures = data.complianceFeatures;
var content = template(viewModel);
$("#policy-list-container").html(content);
} else {
viewModel.compliance = "COMPLIANT";
var content = template(viewModel);
$("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden");
}
};
var successCallbackPolicy = function (data) {
data = JSON.parse(data);
$('#policy-spinner').addClass('hidden');
if(data != null && data.active == true){
activePolicy = data;
invokerUtil.get(serviceURLCompliance,
successCallbackCompliance, function(message){
console.log(message);
});
}
};
invokerUtil.get(serviceURLPolicy,
successCallbackPolicy, function(message){
console.log(message);
});
});
}
}());

@ -1,55 +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.
*/
$(document).ready(function(){
if (document.getElementById('device-location')){
loadMap();
}
});
function loadMap() {
var map;
function initialize() {
var mapOptions = {
zoom: 18
};
var lat = $("#device-location").data("lat");
var long = $("#device-location").data("long");
if(lat != null && lat != undefined && lat != "" && long != null && long != undefined && long != "") {
$("#map-error").hide();
$("#device-location").show();
map = new google.maps.Map(document.getElementById('device-location'),
mapOptions);
var pos = new google.maps.LatLng(lat,
long);
var marker = new google.maps.Marker({
position: pos,
map: map
});
map.setCenter(pos);
}else{
$("#device-location").hide();
$("#map-error").show();
}
}
google.maps.event.addDomListener(window, 'load', initialize);
}

@ -1,12 +0,0 @@
<div class="wr-app-listing">
<div class="wr-applist">
{{#each applications}}
<a style="text-align: center;width: 100px;height: 100px;">
{{#equal platform "android"}}<i class="fw fw-android"></i>{{/equal}}
{{#equal platform "ios"}}<i class="fw fw-apple"></i>{{/equal}}
{{#equal platform "windows"}}<i class="fw fw-windows"></i>{{/equal}}
<span>{{name}}</span>
</a>
{{/each}}
</div>
</div>

@ -1,24 +0,0 @@
<table class="table table-striped table-hover table-bordered display data-table" id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
{{#each operations}}
<tr data-type="selectable" data-id="{{id}}">
<td data-display="{{code}}" data-grid-label="Code">{{code}}</td>
<td data-display="{{status}}" data-grid-label="Status">
{{#equal status "COMPLETED"}}<span><i class="fw fw-ok icon-success"></i> Completed</span>{{/equal}}
{{#equal status "PENDING"}}<span><i class="fw fw-warning icon-warning"></i> Pending</span>{{/equal}}
{{#equal status "ERROR"}}<span><i class="fw fw-error icon-danger"></i> Error</span>{{/equal}}
{{#equal status "IN_PROGRESS"}}<span><i class="fw fw-ok icon-warning"></i> In Progress</span>{{/equal}}
</td>
<td data-display="{{createdTimeStamp}}" data-grid-label="Created Timestamp">{{createdTimeStamp}}</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -1,79 +0,0 @@
<div class="wr-list-group wr-sortable policy-list">
<span class="list-group-item" id="{{id}}">
<div class="row">
<div class="col-lg-3 clearfix">
<span class="wr-list-icon">
{{#equal deviceType "android"}}
<i class=" fw fw-android"></i>
{{/equal}}
{{#equal deviceType "ios"}}
<i class=" fw fw-apple"></i>
{{/equal}}
{{#equal deviceType "windows"}}
<i class=" fw fw-windows"></i>
{{/equal}}
</span>
<span class="wr-list-desc">
<h3 class="wr-list-name">{{policy.policyName}}</h3>
<span class="wr-list-username">{{deviceType}}</span>
</span>
</div>
<div class="col-lg-6">
<div class="row no-gutter">
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Ownership Type : </b> {{policy.ownershipType}}
</div>
</div>
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Compliance Type :</b> {{policy.compliance}}
</div>
</div>
<div class="wr-desc-list-configs col-lg-4">
<div>
<b>Compliance :</b>
{{#equal compliance "COMPLIANT"}}
<span><i class="fw fw-ok icon-success"></i> Compliant</span>
{{/equal}}
{{#equal compliance "NON-COMPLIANT"}}
<span><i class="fw fw-warning icon-danger"></i> Not Compliant</span>
{{/equal}}
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<span class="list-group-item-actions">
<a href="/mdm/policies/view?id={{policy.id}}" class="cu-btn-inner policy-view-link" data-id="{{id}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
</span>
</div>
</div>
</span>
</div>
<table class="table table-striped table-hover table-bordered display data-table" id="policy-compliance-table">
<thead>
<tr class="sort-row">
<th>Feature</th>
<th>Compliance</th>
</tr>
</thead>
<tbody>
{{#each complianceFeatures}}
<tr data-type="selectable">
<td data-display="{{featureCode}}" data-grid-label="Feature Code">{{featureCode}}</td>
<td data-display="{{compliance}}" data-grid-label="Status">
{{#equal compliance true}}<span><i class="fw fw-ok icon-success"></i> Compliant</span>{{/equal}}
{{#equal compliance false}}<span><i class="fw fw-warning icon-danger"></i> Not Compliant</span>{{/equal}}
</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -41,7 +41,7 @@
data-direct="{{@app.context}}/policies/"> data-direct="{{@app.context}}/policies/">
View policy list View policy list
</button> </button>
<a href="{{@app.context}}/policies/add-policy" class="cu-btn-inner"> <a href="{{@app.context}}/policy/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>

@ -267,6 +267,7 @@ function publishToDevice() {
"description": policy["description"], "description": policy["description"],
"compliance": policy["selectedNonCompliantAction"], "compliance": policy["selectedNonCompliantAction"],
"ownershipType": "ANY", "ownershipType": "ANY",
"deviceId": getParameterByName('deviceId'),
"profile": { "profile": {
"profileName": policy["policyName"], "profileName": policy["policyName"],
"deviceType": { "deviceType": {
@ -659,4 +660,11 @@ $(document).ready(function () {
$("." + nextStep).removeClass("hidden"); $("." + nextStep).removeClass("hidden");
} }
}); });
}); });
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, " "));
}

@ -48,7 +48,7 @@
data-direct="{{@app.context}}/policies"> data-direct="{{@app.context}}/policies">
View policy list View policy list
</button> </button>
<a href="{{@app.context}}/policies/add-policy" class="cu-btn-inner"> <a href="{{@app.context}}/policy/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
@ -229,7 +229,7 @@
</div> </div>
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div class="wr-input-control wr-btn-grp">
<a href="{{@app.context}}/policies/add-policy" <a href="javascript:window.history.back()"
class="wr-btn wizard-stepper" data-is-back-btn="true" class="wr-btn wizard-stepper" data-is-back-btn="true"
data-current="policy-profile" data-next="policy-platform"> data-current="policy-profile" data-next="policy-platform">
Back Back

@ -27,8 +27,8 @@
data-toggle="tab" aria-controls="device_statistics">Device data-toggle="tab" aria-controls="device_statistics">Device
Statistics</a> Statistics</a>
</li> </li>
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li> aria-controls="event_log">Operations Log</a></li>
@ -43,28 +43,32 @@
{{unit "iot.unit.device.stats" device=device}} {{unit "iot.unit.device.stats" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" <div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log"> aria-labelledby="event_log">

@ -27,8 +27,8 @@
data-toggle="tab" aria-controls="device_statistics">Device data-toggle="tab" aria-controls="device_statistics">Device
Statistics</a> Statistics</a>
</li> </li>
<li><a class="list-group-item" href="#policy_compliance" role="tab" <li><a class="list-group-item" href="#policies" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a> data-toggle="tab" aria-controls="policies">Policies</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" <li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
aria-controls="event_log">Operations Log</a></li> aria-controls="event_log">Operations Log</a></li>
@ -43,28 +43,32 @@
{{unit "iot.unit.device.stats" device=device}} {{unit "iot.unit.device.stats" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policy_compliance"> aria-labelledby="policies">
<div class="panel-heading">Policy Compliance <span><a href="#" <div class="panel-heading">Policies</div>
id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body"> <div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner" class="wr-advance-operations-init hidden">
<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . . Loading Policies . . .
<br> <br>
<br> <br>
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="panel-body"> <div class="panel-body">
Not available yet No policies found
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
</div> </div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" <div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
aria-labelledby="event_log"> aria-labelledby="event_log">

@ -8,6 +8,10 @@
aria-controls="device_details">Device aria-controls="device_details">Device
Details</a> Details</a>
</li> </li>
<li><a class="list-group-item" href="#policies"
role="tab"
data-toggle="tab" aria-controls="policies">Policies</a>
</li>
<li><a class="list-group-item" href="#policy_compliance" <li><a class="list-group-item" href="#policy_compliance"
role="tab" role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy data-toggle="tab" aria-controls="policy_compliance">Policy
@ -36,7 +40,33 @@
aria-labelledby="device_details"> aria-labelledby="device_details">
{{unit "cdmf.unit.device.details" device=device}} {{unit "cdmf.unit.device.details" device=device}}
</div> </div>
<div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policies">
<div class="panel-heading">Policies</div>
<div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden">
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp;
Loading Policies . . .
<br>
<br>
</div>
<div id="policy-list-container">
<div class="panel-body">
No policies found
</div>
<br class="c-both"/>
</div>
</div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div>
<div class="panel panel-default tab-pane" id="policy_compliance" <div class="panel panel-default tab-pane" id="policy_compliance"
role="tabpanel" aria-labelledby="policy_compliance"> role="tabpanel" aria-labelledby="policy_compliance">
<div class="panel-heading">Policy Compliance <span><a <div class="panel-heading">Policy Compliance <span><a

@ -1,17 +1,17 @@
/* /*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. * in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
@ -22,95 +22,25 @@
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
var payload = [deviceIdentifier]; var payload = [deviceIdentifier];
var operationTable; var operationTable;
if (deviceType == "ios") { var serviceUrl = "/mdm-android-agent/operation/device-info";
var serviceUrl = "/ios/operation/deviceinfo"; invokerUtil.post(serviceUrl, payload,
} else if (deviceType == "android") { function (message) {
var serviceUrl = "/mdm-android-agent/operation/device-info"; console.log(message);
} }, function (message) {
if(serviceUrl){
invokerUtil.post(serviceUrl, payload,
function(message){
console.log(message);
}, function (message) {
console.log(message); console.log(message);
}); });
} $(document).ready(function () {
$(document).ready(function(){
$(".panel-body").removeClass("hidden"); $(".panel-body").removeClass("hidden");
$("#loading-content").remove(); $("#loading-content").remove();
loadOperationBar(deviceType);
loadOperationsLog();
loadApplicationsList(); loadApplicationsList();
loadPolicyCompliance();
$("#refresh-policy").click(function () {
$('#policy-spinner').removeClass('hidden');
loadPolicyCompliance();
});
$("#refresh-apps").click(function () { $("#refresh-apps").click(function () {
$('#apps-spinner').removeClass('hidden'); $('#apps-spinner').removeClass('hidden');
loadApplicationsList(); loadApplicationsList();
}); });
$("#refresh-operations").click(function () {
$('#operations-spinner').removeClass('hidden');
loadOperationsLog(true);
});
}); });
function loadOperationsLog(update) {
var operationsLog = $("#operations-log");
var deviceListingSrc = operationsLog.attr("src");
var deviceId = operationsLog.data("device-id");
var deviceType = operationsLog.data("device-type");
$.template("operations-log", deviceListingSrc, function (template) {
var serviceURL = "/devicemgt_admin/operations/"+deviceType+"/"+deviceId;
var successCallback = function (data) {
data = JSON.parse(data);
$('#operations-spinner').addClass('hidden');
var viewModel = {};
viewModel.operations = data;
if(data.length > 0){
var content = template(viewModel);
if(!update) {
$("#operations-log-container").html(content);
operationTable = $('#operations-log-table').datatables_extended();
}else{
$('#operations-log-table').dataTable().fnClearTable();
for(var i=0; i < data.length; i++) {
var status;
if(data[i].status == "COMPLETED") {
status = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
} else if(data[i].status == "PENDING") {
status = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
} else if(data[i].status == "ERROR") {
status = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
} else if(data[i].status == "IN_PROGRESS") {
status = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
}
$('#operations-log-table').dataTable().fnAddData([
data[i].code,
status,
data[i].createdTimeStamp
]);
}
}
}
};
invokerUtil.get(serviceURL,
successCallback, function(message){
console.log(message);
});
});
}
function loadApplicationsList() { function loadApplicationsList() {
var applicationsList = $("#applications-list"); var applicationsList = $("#applications-list");
var deviceListingSrc = applicationsList.attr("src"); var deviceListingSrc = applicationsList.attr("src");
@ -118,13 +48,13 @@
var deviceType = applicationsList.data("device-type"); var deviceType = applicationsList.data("device-type");
$.template("application-list", deviceListingSrc, function (template) { $.template("application-list", deviceListingSrc, function (template) {
var serviceURL = "/devicemgt_admin/operations/"+deviceType+"/"+deviceId+"/apps"; var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps";
var successCallback = function (data) { var successCallback = function (data) {
data = JSON.parse(data); data = JSON.parse(data);
$('#apps-spinner').addClass('hidden'); $('#apps-spinner').addClass('hidden');
var viewModel = {}; var viewModel = {};
if(data != null && data.length > 0) { if (data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); data[i].name = data[i].name.replace(/[^\w\s]/gi, ' ');
data[i].name = data[i].name.replace(/[0-9]/g, ' '); data[i].name = data[i].name.replace(/[0-9]/g, ' ');
@ -132,66 +62,17 @@
} }
viewModel.applications = data; viewModel.applications = data;
viewModel.deviceType = deviceType; viewModel.deviceType = deviceType;
if(data.length > 0){ if (data.length > 0) {
var content = template(viewModel); var content = template(viewModel);
$("#applications-list-container").html(content); $("#applications-list-container").html(content);
} }
}; };
invokerUtil.get(serviceURL, invokerUtil.get(serviceURL,
successCallback, function(message){ successCallback, function (message) {
console.log(message); console.log(message);
});
});
}
function loadPolicyCompliance() {
var policyCompliance = $("#policy-view");
var policySrc = policyCompliance.attr("src");
var deviceId = policyCompliance.data("device-id");
var deviceType = policyCompliance.data("device-type");
var activePolicy = null;
$.template("policy-view", policySrc, function (template) {
var serviceURLPolicy ="/devicemgt_admin/policies/"+deviceType+"/"+deviceId+"/active-policy"
var serviceURLCompliance = "/devicemgt_admin/policies/"+deviceType+"/"+deviceId;
var successCallbackCompliance = function (data) {
var viewModel = {};
viewModel.policy = activePolicy;
viewModel.deviceType = deviceType;
if(data != null && data.complianceFeatures!= null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) {
viewModel.compliance = "NON-COMPLIANT";
viewModel.complianceFeatures = data.complianceFeatures;
var content = template(viewModel);
$("#policy-list-container").html(content);
} else {
viewModel.compliance = "COMPLIANT";
var content = template(viewModel);
$("#policy-list-container").html(content);
$("#policy-compliance-table").addClass("hidden");
}
};
var successCallbackPolicy = function (data) {
data = JSON.parse(data);
$('#policy-spinner').addClass('hidden');
if(data != null && data.active == true){
activePolicy = data;
invokerUtil.get(serviceURLCompliance,
successCallbackCompliance, function(message){
console.log(message);
}); });
}
};
invokerUtil.get(serviceURLPolicy,
successCallbackPolicy, function(message){
console.log(message);
});
}); });
} }
}()); }());

@ -26,7 +26,7 @@
data-direct="{{@app.context}}/policies/"> data-direct="{{@app.context}}/policies/">
&nbsp;&nbsp;&nbsp;&nbsp;View policy list&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;View policy list&nbsp;&nbsp;&nbsp;&nbsp;
</button> </button>
<a href="{{@app.context}}/policies/add-policy" class="cu-btn-inner"> <a href="{{@app.context}}/policy/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>

@ -45,7 +45,7 @@
data-direct="{{@app.context}}/policies"> data-direct="{{@app.context}}/policies">
&nbsp;&nbsp;&nbsp;&nbsp;View policy list&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;View policy list&nbsp;&nbsp;&nbsp;&nbsp;
</button> </button>
<a href="{{@app.context}}/policies/add-policy" class="cu-btn-inner"> <a href="{{@app.context}}/policy/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
@ -243,7 +243,7 @@
</div> </div>
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div class="wr-input-control wr-btn-grp">
<a href="{{@app.context}}/policies/add-policy" <a href="javascript:window.history.back()"
class="wr-btn wizard-stepper" data-is-back-btn="true" class="wr-btn wizard-stepper" data-is-back-btn="true"
data-current="policy-profile" data-next="policy-platform"> data-current="policy-profile" data-next="policy-platform">
&nbsp;&nbsp;&nbsp;&nbsp;Back&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Back&nbsp;&nbsp;&nbsp;&nbsp;

Loading…
Cancel
Save