// 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: , SID: '', 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 = 'Video Source'; } else { p1 = 'NO Video Source'; }; if( ( val & 2 ) == 2 ){ p2 = 'Audio Source'; } else { p2 = 'NO Audio Source'; }; if( ( val & 4 ) == 4 ){ p3 = 'PTZ Control'; } else { p3 = 'NO PTZ Control'; }; return p1+p2+p3; }; function LocRenderer( val ){ if( val ){ return 'Location'; }; return '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: , SID: '' }, 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: , SID: '', 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: , UID: , SID: '', 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: '
' }, 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: , SID: '' }, 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: '

Select an Event from TimeLine to See Information

' }] }); 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(); };