mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge pull request #744 from rasika/windows-geo-fencing
Adding geo-fencing to the Windows
This commit is contained in:
commit
d3e6d35fde
@ -1,4 +1,3 @@
|
|||||||
{{unit "cdmf.unit.device.type.windows.leaflet"}}
|
|
||||||
{{unit "cdmf.unit.lib.editable"}}
|
{{unit "cdmf.unit.lib.editable"}}
|
||||||
{{unit "cdmf.unit.lib.qrcode"}}
|
{{unit "cdmf.unit.lib.qrcode"}}
|
||||||
{{unit "cdmf.unit.device.type.qr-modal"}}
|
{{unit "cdmf.unit.device.type.qr-modal"}}
|
||||||
@ -72,14 +71,33 @@
|
|||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|
||||||
{{#zone "device-details-tab-injected"}}
|
{{#zone "device-details-tab-injected"}}
|
||||||
<li><a data-toggle="tab" href="#location">Location</a></li>
|
<li><a data-toggle="tab" href="#location"
|
||||||
|
data-lat="{{device.location.latitude}}"
|
||||||
|
data-long="{{device.location.longitude}}"
|
||||||
|
class="initGeoLocationLink">Location</a></li>
|
||||||
<li><a data-toggle="tab" href="#policy">Policy Compliance</a></li>
|
<li><a data-toggle="tab" href="#policy">Policy Compliance</a></li>
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|
||||||
{{#zone "device-view-tab-injected-conents"}}
|
{{#zone "device-view-tab-injected-conents"}}
|
||||||
<div id="location" class="tab-pane fade ">
|
<div id="location" class="tab-pane fade ">
|
||||||
<iframe width="100%" height="100%" frameborder="0" style="border:0"
|
{{#if device.location}}
|
||||||
src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJk_gsqyVZ4joR4UxR7brwMnA&key=AIzaSyChgf100i4rBz6neCNRyK1D05g9VLY8jvo" allowfullscreen></iframe>
|
<div class="tab-actions">
|
||||||
|
<div class="action-btn-container" id="location-action-bar">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{{unit "cdmf.unit.geo-dashboard" device=device noGeoFencing=false hideSearch=true}}
|
||||||
|
{{else}}
|
||||||
|
<div id="map-error" class="message message-warning">
|
||||||
|
<h4 class="remove-margin">
|
||||||
|
<i class="icon fw fw-warning"></i>
|
||||||
|
Device location information is not available.
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<p class="add-padding-5x"></p>
|
||||||
|
<p class="add-padding-5x"></p>
|
||||||
|
<p class="add-padding-5x"></p>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div id="policy" class="tab-pane fade">
|
<div id="policy" class="tab-pane fade">
|
||||||
<div id="policy-list-container">
|
<div id="policy-list-container">
|
||||||
@ -112,7 +130,5 @@
|
|||||||
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
|
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
|
||||||
type="text/x-handlebars-template"></script>
|
type="text/x-handlebars-template"></script>
|
||||||
{{js "js/device-detail.js"}}
|
{{js "js/device-detail.js"}}
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
|
|
||||||
{{js "js/load-map.js"}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|||||||
@ -74,6 +74,7 @@ function onRequest(context) {
|
|||||||
viewModel["location"] = {};
|
viewModel["location"] = {};
|
||||||
viewModel["location"]["latitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["latitude"];
|
viewModel["location"]["latitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["latitude"];
|
||||||
viewModel["location"]["longitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["longitude"];
|
viewModel["location"]["longitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["longitude"];
|
||||||
|
viewModel["location"]["updatedTime"] = filteredDeviceData["latestDeviceInfo"]["location"]["updatedTime"];
|
||||||
}
|
}
|
||||||
if (filteredDeviceData["latestDeviceInfo"]["vendor"] && filteredDeviceData["latestDeviceInfo"]["deviceModel"]) {
|
if (filteredDeviceData["latestDeviceInfo"]["vendor"] && filteredDeviceData["latestDeviceInfo"]["deviceModel"]) {
|
||||||
viewModel["vendor"] = filteredDeviceData["latestDeviceInfo"]["vendor"];
|
viewModel["vendor"] = filteredDeviceData["latestDeviceInfo"]["vendor"];
|
||||||
@ -96,7 +97,7 @@ function onRequest(context) {
|
|||||||
if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
|
if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
|
||||||
viewModel["deviceInfoAvailable"] = false;
|
viewModel["deviceInfoAvailable"] = false;
|
||||||
}
|
}
|
||||||
|
viewModel.locationHistory = stringify(filteredDeviceData["locationHistory"]);
|
||||||
deviceViewData["device"] = viewModel;
|
deviceViewData["device"] = viewModel;
|
||||||
} else if (response["status"] == "unauthorized") {
|
} else if (response["status"] == "unauthorized") {
|
||||||
deviceViewData["deviceFound"] = true;
|
deviceViewData["deviceFound"] = true;
|
||||||
|
|||||||
@ -1,54 +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 map;
|
|
||||||
|
|
||||||
function loadLeafletMap() {
|
|
||||||
var deviceLocationID = "#device-location",
|
|
||||||
lat = $(deviceLocationID).data("lat"),
|
|
||||||
long = $(deviceLocationID).data("long"),
|
|
||||||
container = "device-location",
|
|
||||||
zoomLevel = 13,
|
|
||||||
tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
||||||
attribution = "© <a href='https://openstreetmap.org/copyright'>OpenStreetMap</a> contributors";
|
|
||||||
|
|
||||||
if (lat && long) {
|
|
||||||
map = L.map(container).setView([lat, long], zoomLevel);
|
|
||||||
L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
|
|
||||||
L.marker([lat, long]).addTo(map).bindPopup("Device is here...").openPopup();
|
|
||||||
|
|
||||||
$("#map-error").hide();
|
|
||||||
$("#device-location").show();
|
|
||||||
} else {
|
|
||||||
$("#device-location").hide();
|
|
||||||
$("#map-error").show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
$("a[data-toggle='tab']").on("shown.bs.tab", function() {
|
|
||||||
var url = $(this).prop("href");
|
|
||||||
var hash = url.substring(url.indexOf("#") + 1);
|
|
||||||
|
|
||||||
if (hash == "device_location_tab") {
|
|
||||||
if (!map) {
|
|
||||||
loadLeafletMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user