forked from community/device-mgt-plugins
Merge pull request #168 from charithag/IoTS-1.0.0-M2
Add policy specific functionality
commit
5c0d4b9aba
@ -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>
|
Loading…
Reference in new issue