Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

566 lines
18 KiB

//<?php require_once('../../js_asm.php');
$QS="SELECT * FROM sites WHERE id={$SiteID}";
$RV = $DATABASE->Query( $QS );
?>
var SiteLat=<?=$RV[0]['anchor_lat'];?>;
var SiteLon=<?=$RV[0]['anchor_lon'];?>;
var SiteAlt=<?=$RV[0]['anchor_alt'];?>;
var map = null;
var timelineObj = null;
var tlGroups = new vis.DataSet();
var tlItems = new vis.DataSet();
var tlOptions = {
groupOrder: 'content', // groupOrder can be a property name or a sorting function
stack: true,
showCurrentTime: true,
//verticalScroll: true,
//zoomKey: 'ctrlKey',
minHeight: 308,
maxHeight: 308
};
var tlLoadLocker = false;
var tlLastTS = 0;
var tlInterval = null;
var tlMonitoring = false;
var eventsListStore = new Ext.data.JsonStore({
root: 'log',
totalProperty: 'totalCount',
idProperty: 'id',
remoteSort: true,
fields: [{
name: 'id',
type: 'int'
},{
name: 'date',
type: 'string'
},{
name: 'time',
type: 'string'
},{
name: 'device',
type: 'string'
},{
name: 'event',
type: 'string'
},{
name: 'data',
type: 'string',
},{
name: 'has_target',
type: 'boolean'
},{
name: 'has_geo',
type: 'boolean'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/controller/getEventRecords.php',
headers: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
NID: 1
}
})
});
var SelectedEvent = 0;
function ModeRenderer(val){
var p1, p2, p3;
if( ( val & 1 ) == 1 ){
p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
} else {
p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
};
if( ( val & 2 ) == 2 ){
p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
} else {
p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
};
if( ( val & 4 ) == 4 ){
p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
} else {
p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
};
return p1+p2+p3;
};
function LocRenderer( val ){
if( val ){
return '<img src="/style/icons/icons/accept.png" alt="Location">';
};
return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location">';
};
var eventsListColModel_ops = {
columns: [
{header: "ID", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "Date",width: 80, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
{header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
{header: "Device", width: 150, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
{header: "Event", width: 80, sortable: false, dataIndex: 'event' },
{header: "Info", width: 200, sortable: false, dataindex: 'data' },
{header: "", width: 20, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer }
],
defaults: {
sortable: true,
menuDisabled: true,
width: 100
},
listeners: {
hiddenchange: function(cm, colIndex, hidden) {
//saveConfig(colIndex, hidden);
}
}
};
var eventsListSelModel_ops = {
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
loadEventProperties( rec.data.id );
//SelectedEvent = rec.data.id;
//alert( SelectedEvent );
//var CB = Ext.getCmp('con_to_src');
//CB.enable();
}
}
};
function loadTimeLineGroups( NID ){
Ext.Ajax.request({
url: '/lib/controller/getTimeLineGroups.php',
params: {
NID: NID,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
//for(var i = 0; i < data.length; i++) {
//tlGroups.add(data[i]);
//};
tlGroups.update( data );
loadTimeLineItems( selectedSite );
tlInterval = window.setInterval( loadTimeLineItems, 333, selectedSite );
},
failure: function( response, opts ) {
//Ext.fly('some_div').update('Fail!');
}/*,
callback: function(options,success,response){
// use this if you need to perform your own success/failure checking
}*/
});
};
function loadMapZones( SID ){
Ext.Ajax.request({
url: '/lib/controller/getGeoZones.php',
params: {
SITE: SID,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
for(var i = 0; i < data.totalCount; i++ ) {
switch( data.zones[i].type ){
case 'circle':{
L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
break;
};
case 'poly':{
L.polygon( data.zones[i].points, {color: data.zones[i].color, dashArray: "4 1 2 3", weight: 1, opacity: 0.8, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
break;
};
case 'image':{
L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 }).addTo( map );
break;
};
case 'image_rot':{
L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
opacity: 0.8 //,
//interactive: true,
//attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geográfico Nacional de España</a>"
}).addTo( map );
break;
};
};
if( data.zones[i].zang != undefined ){
//L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
};
if( data.zones[i].center != undefined ){
//L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
};
};
//tlGroups.update( data );
//loadTimeLineItems( selectedSite );
LoadMapEvents( selectedSite );
tlInterval = window.setInterval( LoadMapEvents, 333, selectedSite );
},
failure: function( response, opts ) {
//Ext.fly('some_div').update('Fail!');
}
});
};
function loadTimeLineItems( NID ){
if( tlLoadLocker ) return;
tlLoadLocker = true;
Ext.Ajax.request({
url: '/lib/controller/getTimeLineEvents.php',
params: {
NID: NID,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
LTS: tlLastTS
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
var i = 0;
for(; i < data.length; i++ ){
tlLastTS = data[i].start;
data[i].start = moment.utc( ''+data[i].start, 'X' );
tlItems.add( data[i] );
};
if( timelineObj == null ){
var container = document.getElementById('timeline');
timelineObj = new vis.Timeline( container );
timelineObj.setOptions( tlOptions );
timelineObj.setGroups( tlGroups );
timelineObj.setItems( tlItems );
timelineObj.on('select', function (properties) {
//alert( properties.items[0] );
loadEventProperties( properties.items[0] );
//logEvent('select', properties.items[0]);
});
} else {
timelineObj.redraw();
};
if( tlMonitoring ) timelineObj.moveTo( moment.utc() );
eventsListStore.reload();
tlLoadLocker = false;
},
failure: function( response, opts ) {
//Ext.fly('some_div').update('Fail!');
tlLoadLocker = false;
}
});
};
var cevt = Array();
var coz = Array();
function LoadMapEvents( SID ){
if( tlLoadLocker ) return;
tlLoadLocker = true;
Ext.Ajax.request({
url: '/lib/controller/getGeoAlerts.php',
params: {
SITE: SID,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
if( cevt.length ){
for( i=0; i< cevt.length; i++ ){
if( cevt[i]!= null ){
cevt[i].remove();
delete( cevt[i] );
cevt[i] = null;
};
};
};
if( coz.length ){
for( i=0; i< coz.length; i++ ){
if( coz[i]!= null ){
coz[i].remove();
delete( coz[i] );
coz[i]=null;
};
};
};
var data = Ext.decode( response.responseText );
var zz = ( 1.0 / ( data.evt.length + 0 ) );
for( i=0; i < data.evt.length; i++ ){
cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
loadEventProperties( this.options.id );
} );
cevt[i].addTo(map);
};
for( i=0; i < data.other.length; i++ ){
switch( data.other[i].type ){
case 'circle':{
coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } );
coz[i].addTo(map);
break;
};
};
};
eventsListStore.reload();
tlLoadLocker = false;
},
failure: function( response, opts ) {
//Ext.fly('some_div').update('Fail!');
tlLoadLocker = false;
}
});
};
function loadEventProperties( EventID ){
//alert( 'Node: ' + NodeID );
Ext.Ajax.request({
url: '/lib/controller/getEventProps.php',
params: {
NID: <?=$SiteID;?>,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
EVENT: EventID
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
var tPanel = Ext.getCmp('prop_content');
tPanel.remove(0);
tPanel.add( data );
tPanel.doLayout();
},
failure: function( response, opts ) {
//Ext.fly('some_div').update('Fail!');
}
});
};
function loadTimeLine(){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
var tPanel = Ext.getCmp('main_portal');
tPanel.removeAll( true );
Ext.getCmp('main_content').setTitle( 'Full Events Log' );
tPanel.add({
columnWidth: 0.83,
frame: false,
border: false,
items: [{
title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
frame: false,
border: false,
layout: 'vbox',
layoutConfig: {
align : 'stretch',
pack : 'start',
},
height: PanelH-300,
items:[{
height: PanelH-325,
flex: 1,
frame: false,
border: false,
layout: 'fit',
items:{
//style: 'background: ivory;',
id: 'event_map',
html: '&nbsp;'
},
tbar:[{
id: 'fev',
text: 'Fit Events',
disabled: tlMonitoring,
handler: function(){
timelineObj.fit();
}
},{
id: 'gtn',
text: 'Go to Now',
disabled: tlMonitoring,
handler: function(){
timelineObj.moveTo( moment.utc() );
}
},{
text: 'Live Monitoring',
enableToggle: true,
pressed: tlMonitoring,
toggleHandler: function(){
tlMonitoring = !tlMonitoring;
if( tlMonitoring ){
Ext.getCmp('gtn').disable();
Ext.getCmp('fev').disable();
} else {
Ext.getCmp('gtn').enable();
Ext.getCmp('fev').enable();
};
}
}]
}]
},{
title: 'Event Log',
frame: false,
height: 303,
xtype: 'grid',
ds: eventsListStore,
cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
//viewConfig: {
//forceFit: true
//},
bbar: [{
text: 'Clear',
handler: function(){
Ext.Ajax.request({
url: '/lib/controller/clearEventCloud.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
},
failure: function( response, opts ) {
}
});
}
}/*,'->',{
id: 'con_to_src',
text: 'Connect To Selected',
disabled: ( SelectedCam == 0 ),
handler: connectToSeleced
}*/]
}]
});
tPanel.add({
columnWidth: 0.17,
frame: false,
id: 'prop_content',
border: false,
items: [{
title: 'Event Information',
border: true,
frame: true,
html: '<p align="center">Select an Event from TimeLine to See Information</p>'
}]
});
tPanel.doLayout();
map = L.map('event_map',{
attributionControl: true,
//preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,
zoom: 17,
minZoom: 17,
maxZoom: 17,*/
keyboard: false
}).setView([SiteLat, SiteLon], 17);
//L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
var mapLayers = [];
/*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
detectRetina: true
});*/
mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxNativeZoom: 18,
maxZoom: 24,
})
// https://leaflet-extras.github.io/leaflet-providers/preview/
mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
maxZoom: 19
});
mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
maxZoom: 19
});
mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
maxZoom: 24
});
mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
maxZoom: 19
});
mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
maxZoom: 19
});
/*
mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
maxZoom: 22
});
mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
maxZoom: 22
});
mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
maxZoom: 22
});
*/
var baseMaps = {
"MyMap": mapLayers["MyMap"],
"OpenStreetMap": mapLayers["OpenStreetMap"],
"OpenTopoMap": mapLayers["OpenTopoMap"],
"EsriSat": mapLayers["EsriSat"],
"EsriStreet": mapLayers["EsriStreet"],
"EsriTopo": mapLayers["EsriTopo"],
//"Bing": mapLayers["Bing"],
//"OSM-Cycle": mapLayers["Cycle"],
//"Landscape": mapLayers["Landscape"],
//"Outdoor": mapLayers["Outdoor"],
};
L.control.layers( baseMaps ).addTo(map);
mapLayers["MyMap"].addTo(map);
/*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxNativeZoom: 18,
maxZoom: 24,
}).addTo(map); */
//loadTimeLineGroups( selectedSite );
loadMapZones( selectedSite );
eventsListStore.load({params:{start:0, limit:50}});
};
function loadOnlineMonitoring(devID){
var tPanel = Ext.getCmp('main_content');
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
tPanel.remove(0);
tPanel.add({
html: 'Device Monitoring '+devID
});
tPanel.doLayout();
};