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.
371 lines
9.6 KiB
371 lines
9.6 KiB
//<?php require_once('../../js_asm.php'); ?>
|
|
|
|
|
|
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;
|
|
|
|
var eventsListSelModel = new Ext.grid.RowSelectionModel({
|
|
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 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 = new Ext.grid.ColumnModel({
|
|
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: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
|
|
{header: "event", width: 80, sortable: false, dataIndex: 'event' },
|
|
{header: "targ", 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);
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
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 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;
|
|
}/*,
|
|
callback: function(options,success,response){
|
|
// use this if you need to perform your own success/failure checking
|
|
}*/
|
|
});
|
|
};
|
|
|
|
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!');
|
|
}/*,
|
|
callback: function(options,success,response){
|
|
// use this if you need to perform your own success/failure checking
|
|
}*/
|
|
});
|
|
};
|
|
|
|
|
|
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: 'Events Monitoring',
|
|
frame: false,
|
|
border: false,
|
|
layout: 'vbox',
|
|
layoutConfig: {
|
|
align : 'stretch',
|
|
pack : 'start',
|
|
},
|
|
height: 375,
|
|
//flex: 1,
|
|
//border: true,
|
|
items:[{
|
|
//title: 'TimeLine',
|
|
height: 350,
|
|
flex: 1,
|
|
frame: true,
|
|
border: false,
|
|
layout: 'fit',
|
|
items:{
|
|
style: 'background: ivory;',
|
|
html: '<div id="timeline"></div>'
|
|
},
|
|
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: 400,
|
|
xtype: 'grid',
|
|
ds: eventsListStore,
|
|
cm: eventsListColModel,
|
|
sm: eventsListSelModel,
|
|
//listeners:{
|
|
// beforedestroy: function( t ){
|
|
// addDialog = null;
|
|
// return true;
|
|
// }
|
|
//},
|
|
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();
|
|
loadTimeLineGroups( 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();
|
|
};
|