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.
 
 
 
 

1593 lines
49 KiB

//<?php require_once('../../js_asm.php'); ?>
var map = null;
var selectedMarker = null;
var timelineObj = null;
var tlGroups = new vis.DataSet();
var tlItems = new vis.DataSet();
var selecredActiveSourceFilter = 0;
var rep_store_id = 0;
var rep_array = new Array();
var rep_store = new Ext.data.JsonStore({
autoDestroy: false,
storeId: 'log_store',
//idIndex: 0,
idProperty: 'id',
fields: [
{name: 'id', type: 'int' },
{name: 'node_id', type: 'int' },
{name: 'geo', type: 'bool' },
{name: 'node_name', type: 'string' },
{name: 'dts', type: 'string'},
{name: 'ts', type: 'int'},
{name: 'ms', type: 'string'},
{name: 'type', type: 'int'},
{name: 'range', type: 'string'},
{name: 'az', type: 'string'},
{name: 'el', type: 'string'},
{name: 'r', type: 'int'},
{name: 'width', type: 'int'},
//{name: 'video_id',type: 'int'},
{name: 'video',type: 'bool'},
{name: 'lat', type: 'float'},
{name: 'lon', type: 'float'}
//{name: 'alt', type: 'float'},
//{name: 'area', type: 'float'},
//{name: 'video', type: 'string'},
//{name: 'v_cpoint', type: 'int'}
]
});
function rep_sn_Renderer( value, meta, record ){
//Must be set according to events
var kaka = record.data.node_id % 3;
return '<div class="log_line_' + kaka + '">'+value+'</div>';
};
function rep_et_Renderer( value, meta, record ){
var kaka = record.data.node_id % 3;
switch( value ){
case 6: ov = "<?=$Labels->GetLabel('_EVT_MSG_STUMO_');?>"; break;
case 7: ov = "<?=$Labels->GetLabel('_EVT_MSG_BUMO_');?>"; break;
case 8: ov = "<?=$Labels->GetLabel('_EVT_MSG_FLIPO_');?>"; break;
case 9: ov = "<?=$Labels->GetLabel('_EVT_MSG_SCANC_');?>"; break;
case 12: ov = "<?=$Labels->GetLabel('_EVT_MSG_B2DTRG_');?>"; break;
case 13: ov = "<?=$Labels->GetLabel('_EVT_MSG_W2DTRG_');?>"; break;
case 36: ov = "<?=$Labels->GetLabel('_EVT_MSG_ROI_');?>"; break;
case 39: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_CT_');?>"; break;
case 40: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_USD_');?>"; break;
case 41: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_BSD_');?>"; break;
case 42: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_TD_');?>"; break;
case 43: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_TUPD_');?>"; break;
case 44: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_SUSPA_');?>"; break;
case 45: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_SUSPN_');?>"; break;
case 46: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_RD_');?>"; break;
case 47: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_DD_');?>"; break;
case 48: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_SUSPD_');?>"; break;
case 49: ov = "<?=$Labels->GetLabel('_EVT_MSG_TF_DIFD_');?>"; break;
case 52: ov = "<?=$Labels->GetLabel('_EVT_MSG_EVT_START_');?>"; break;
case 53: ov = "<?=$Labels->GetLabel('_EVT_MSG_EVT_END_');?>"; break;
case 54: ov = "<?=$Labels->GetLabel('_EVT_MSG_EVT_CLOMA_');?>"; break;
case 55: ov = "<?=$Labels->GetLabel('_EVT_MSG_CONNECTED_');?>"; break;
case 56: ov = "<?=$Labels->GetLabel('_EVT_MSG_DISCONNECTED_');?>"; break;
case 57: ov = "<?=$Labels->GetLabel('_EVT_MSG_COM_JAMED_');?>"; break;
case 58: ov = "<?=$Labels->GetLabel('_EVT_MSG_VIFDEC_');?>"; break;
case 59: ov = "<?=$Labels->GetLabel('_EVT_MSG_VIFINC_');?>"; break;
case 68: ov = "<?=$Labels->GetLabel('_EVT_MSG_ACKON_');?>"; break;
case 69: ov = "<?=$Labels->GetLabel('_EVT_MSG_ACKOFF_');?>"; break;
case 70: ov = "<?=$Labels->GetLabel('_EVT_MSG_MASKON_');?>"; break;
case 71: ov = "<?=$Labels->GetLabel('_EVT_MSG_MASKOFF_');?>"; break;
default: ov = "<?=$Labels->GetLabel('_EVENT_');?> ["+value+"]";
};
return '<div class="log_line_' + kaka + '">'+ov+'</div>';
};
var rep_ColModel_ops = {
columns: [
{header: "<?=$Labels->GetLabel('_TIME_');?>", width: 100, fixed: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'dts' },
{header: "<?=$Labels->GetLabel('_SOURCE_');?>", width: 100, renderer: rep_sn_Renderer, align: 'left', css: 'vertical-align: middle;', dataIndex: 'node_name' },
{header: "<?=$Labels->GetLabel('_TYPE_');?>", width: 180, renderer: rep_et_Renderer, fixed: false, align: 'center', css: 'vertical-align: middle;', dataIndex: 'type' },
{header: "<?=$Labels->GetLabel('_RANGE_');?>", width: 100, dataIndex: 'range' },
{header: "<?=$Labels->GetLabel('_AZIMUTH_');?>", width: 100, dataIndex: 'az' },
{header: "<?=$Labels->GetLabel('_WIDTH_');?>", width: 100, dataIndex: 'width' }
],
defaults: {
sortable: false,
fixed: true,
menuDisabled: true,
width: 100
}
};
var cRowSelected = -1;
var rep_SelModel_ops = {
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec ) {
cRowSelected = row;
if( map!= undefined ) if( map != null ){
if( selectedMarker!= null ){
selectedMarker.remove();
if( rec.data.geo ){
//alert( 'Geo!' );
//map.removeLayer( selectedMarker );
//tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
selectedMarker.setLatLng([rec.data.lat, rec.data.lon]);
selectedMarker.addTo( map );
};
};
};
loadEventData( rec.data );
//alert( rec.data.id );
//loadEventProperties( rec.data );
//SelectedEvent = rec.data.id;
//alert( SelectedEvent );
//var CB = Ext.getCmp('con_to_src');
//CB.enable();
//selectedArchiveRecord = rec;
//if( rec.data.bk_type!=3 ){
//
//} else {
//
//};
}
}
};
var cevt = Array();
var coz = Array();
function showHistoryOnMap( data, removeCursor ){
if( removeCursor ) map.removeLayer( selectedMarker );
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;
};
};
};
if( data.log.length ){
var zz = 1.0 / ( data.log.length + 1 );
var idx = 0;
for( i=0; i < data.log.length; i++ ){
if( data.log[i].geo ){
var cp_color='#FF0000';
var opa = ( 1.0 - i * zz );
switch( data.log[i].type ){
case 36: cp_color='#0000FF'; opa = 1.0; break;
};
cevt[idx] = L.circleMarker( [data.log[i].lat, data.log[i].lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: opa } );//.on('click', function( e, a ){ loadEventPropertiesByID( this.options.id ); } );
cevt[idx].addTo(map);
idx++;
};
};
};
};
var selectedMarkerIcon = L.icon({
iconUrl: '/style/assets/cursor.png',
iconSize: [32, 32],
iconAnchor: [16, 16]//,
//popupAnchor: [-3, -76],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
});
selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
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;
// Calendar
var CurrentDate=(new Date())/1000;
var today=new Date();
var SY=1900+today.getYear();
var SMO=today.getMonth()+1;
var SD=today.getDate();
var SelectedDay = SD;
var Dates = new Array();
function CheckDate(D){
for(j_index=0;j_index<Dates.length;j_index++){
if (Dates[j_index]==D)return true;
};
return false;
};
function ShiftBAK(){
CurrentDate=CurrentDate-24*3600*GetMonthLength(CurrentDate);
BuildCalendar();
SMO = GetMonthNum(CurrentDate);
SY = GetYear(CurrentDate);
if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
loadCalendarDates();
};
function ShiftFWD(){
CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate);
BuildCalendar();
SMO = GetMonthNum(CurrentDate);
SY = GetYear(CurrentDate);
if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
loadCalendarDates();
};
function GetMonthName(UTS){ // Unix Time Stamp
var MoNames= new Array();
MoNames[0]='January';
MoNames[1]='February';
MoNames[2]='March';
MoNames[3]='April';
MoNames[4]='May';
MoNames[5]='June';
MoNames[6]='July';
MoNames[7]='August';
MoNames[8]='September';
MoNames[9]='October';
MoNames[10]='November';
MoNames[11]='December';
CDate=new Date();
CDate.setTime(UTS*1000);
CMo=CDate.getMonth();
return MoNames[CMo];
};
function GetMonthShift(UTS){ // Unix Time Stamp
CDate=new Date();
CDate.setTime(UTS*1000);
CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000);
return CDate.getDay();
};
function GetMonthLength(UTS){ // Unix Time Stamp
CDate=new Date();
CDate.setTime(UTS*1000);
CD=CDate.getDate();
RetVal=31;
CDate.setTime((UTS+(31-CD)*86400)*1000);
if ( CDate.getDate()==31) return RetVal;
RetVal=30;
CDate.setTime((UTS+(30-CD)*86400)*1000);
if ( CDate.getDate()==30) return RetVal;
RetVal=29;
CDate.setTime((UTS+(29-CD)*86400)*1000);
if ( CDate.getDate()==29) return RetVal;
RetVal=28;
CDate.setTime((UTS+(28-CD)*86400)*1000);
if ( CDate.getDate()==28) return RetVal;
return -1;
};
function GetMonthNum(UTS){ // Unix Time Stamp
CDate=new Date();
CDate.setTime(UTS*1000);
return CDate.getMonth()+1;
};
function GetYear(UTS){ // Unix Time Stamp
CDate=new Date();
CDate.setTime(UTS*1000);
y=CDate.getYear();
if (y<100)y+=2000;
if (y<200)y+=1900;
return y;
};
function GetDay(UTS){ // Unix Time Stamp
CDate=new Date();
CDate.setTime(UTS*1000);
y=CDate.getDate();
return y;
};
function selectDate( m, d ){
SY = GetYear(CurrentDate);
SMO = m;
SD = d;
SelectedDay = SD;
getData( 'arch' );
};
function BuildCalendar( ){
Msh=GetMonthShift(CurrentDate);
Mnm=GetMonthName(CurrentDate);
Mln=GetMonthLength(CurrentDate);
Mid=GetMonthNum(CurrentDate);
Mye=GetYear(CurrentDate);
InDTA='<table cellpadding="2" cellspacing="0"><tr height="19px"><td valign="middle"><a href="#" onclick="ShiftBAK();"><img src="/style/img/calendar/l_cal_b.gif"></a></td><td colspan="5" class="CalendarMN" align="center">'+Mnm+' '+Mye+'</td><td><a href="#" onclick="ShiftFWD();"><img border=0 src="/style/img/calendar/r_cal_b.gif"></a></td></tr>';
InDTA+='<tr><td class="CalendarWT" align="center">Su</td><td class="CalendarWT" align="center">Mo</td><td class="CalendarWT" align="center">Tu</td><td class="CalendarWT" align="center">We</td><td class="CalendarWT" align="center">Th</td><td class="CalendarWT" align="center">Fr</td><td class="CalendarWT" align="center">Sa</td></tr>';
InDTA+='<tr>';
for(index=0;index<Msh;index++){
InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
};
for(;index<(Mln+Msh);index++){
if( CheckDate(index-Msh+1) ){
//InDTA+='<td style="padding: 1px"><div id="ds'+Mid.toString()+(index-Msh+1).toString()+'" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" href="#" title="'+(index-Msh+1).toString()+'" class="CalendarDE">'+(index-Msh+1).toString()+'</a></td>';
if( SD == index ){
InDTA+='<td style="padding: 1px"><div id="selected_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Selected" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
} else {
InDTA+='<td style="padding: 1px"><div id="have_data_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Have Events" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
};
} else {
if( SD == index ){
InDTA+='<td style="padding: 1px"><div id="selected_day" class="calendar_t" title="Selected">'+(index-Msh+1).toString()+'</a></td>';
} else {
InDTA+='<td style="padding: 1px"><div id="no_data_day" class="calendar_t" title="No Events">'+(index-Msh+1).toString()+'</a></td>';
};
};
if ((index+1)%7==0){
InDTA+='</tr><tr>';
};
};
for(;(index)%7!=0;index++){
InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
};
InDTA+='</tr></table>';
tab=document.getElementById('calendar_TD');
tab.innerHTML=InDTA;
};
function loadCalendarDates(){
ReportSelectionMode = 0;
Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
width: '100%',
hidden: true,
progress: true,
closable: false
});
ReportLayoutLoadded = false;
Ext.Ajax.request({
url: '/lib/controller/getEventDates.php',
params: {
NID: selecredActiveSourceFilter,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
SYE: SY,
SMO: SMO
},
success: function( response, opts ){
Ext.MessageBox.hide();
var data = Ext.decode( response.responseText );
if( data.status == 'ok' ){
Dates = data.days;
BuildCalendar();
//for( var i = 0; i < data.days.length; i++ ){
//
//};
};
},
failure: function( response, opts ) {
Ext.MessageBox.hide();
}
});
};
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: 'int'
},{
name: 'data',
type: 'string',
},{
name: 'has_target',
type: 'boolean'
},{
name: 'has_geo',
type: 'boolean'
},{
name: 'has_images',
type: 'boolean'
},{
name: 'images',
type: 'Array'
},{
name: 'dev_type',
type: 'int'
},{
name: 'geo',
type: 'object'
}] /*,
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 EventPanelWindow = null;
function showEventPanel(){
if( EventPanelWindow == null ){
EventPanelWindow = new Ext.Window({
modal: true,
title: '<?=$Labels->GetLabel("_EVENT_VIEWER_");?>',
width: winW*0.66,
height: winH*0.66,
layout: 'fit',
closeAction: 'hide',
items:[{
title: 'Cameras',
html:'koko',
autoScroll: true,
height: 320
},{
html: 'koko22',
height: 320
}]
});
};
EventPanelWindow .show();
};
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" />';
};
function PicRenderer( val ){
if( val ){
return '<img src="/style/icons/icons/camera_link.png"/>';
};
return '<img src="/style/icons/icons/bullet_white.png"/>';
};
function EvtTypeRenderer( val ){
switch( val ){
case 6: return 'Device Enters Into Study Mode';
case 7: return 'Device Is BUSY';
case 8: return 'Flip Complete';
case 9: return 'Scan Complete';
case 10:
case 11:
case 12:
case 13:
case 14: return 'Target';
case 36: return 'Region Of Interest';
default: return 'Event ['+val+']';
};
};
var eventsListColModel_ops = {
columns: [
{header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "Date",width: 100, 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: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer },
{header: "Info", width: 200, sortable: false, dataindex: 'data' },
{header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer },
{header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer }
],
defaults: {
sortable: true,
menuDisabled: true,
width: 100
},
listeners: {
hiddenchange: function(cm, colIndex, hidden) {
//saveConfig(colIndex, hidden);
}
}
};
var SelectedRow = -1;
var eventsListSelModel_ops = {
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec ) {
loadEventProperties( rec.data );
SelectedEvent = rec.data.id;
SelectedRow = row;
//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 clickDeviceSelector( id ){
var rr = document.getElementById(id+'_div');
if( selecredActiveSourceFilter != id ){
if( selecredActiveSourceFilter > 0 ){
var oo = document.getElementById( selecredActiveSourceFilter + '_div');
oo.classList.remove( "cardDeviceSourceSelected" );
oo.classList.add( "cardDeviceSource" );
};
rr.classList.remove( "cardDeviceSource" );
rr.classList.add( "cardDeviceSourceSelected" );
selecredActiveSourceFilter = id;
turnOffAllGzButThis( selecredActiveSourceFilter );
} else {
selecredActiveSourceFilter = 0;
rr.classList.remove( "cardDeviceSourceSelected" );
rr.classList.add( "cardDeviceSource" );
turnAllGzOn();
var tPanel = Ext.getCmp('prop_content');
tPanel.remove(0);
tPanel.add( {
title: 'Event Information',
border: false,
frame: false,
collapsible: false,
draggable: false,
html: '<p align="center">Select an Event from TimeLine to See Information</p>'
} );
tPanel.doLayout();
};
};
function loadEventPropertiesByID( id ){
var d = eventsListStore.findExact( 'id', id );
if( d > -1 ) {
var EventRec = eventsListStore.getAt( d );
loadEventProperties( EventRec.data );
};
};
function loadEventProperties( EventRec ){
var tPanel = Ext.getCmp('prop_content');
tPanel.removeAll();// remove( 0 );
var tt = '';
if( map!=undefined) if(map!=null){
if( selectedMarker!= null ){
selectedMarker.remove();
//map.removeLayer( selectedMarker );
if( EventRec.has_geo ){
tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
selectedMarker.addTo( map );
};
};
};
tPanel.add( {
title: 'Event Details',
html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
} );
if( EventRec.has_images ){
for( var i=0; i < EventRec.images.length; i++ ){
tPanel.add( {
frame: false,
html: '<img width="100%" src="/lib/controller/getPicture.php?PID='+EventRec.images[i]+'" data-enlargeable000 ondblclick="fullScreen(\'img-'+EventRec.id+'\');" style="cursor: zoom-in" id="img-'+EventRec.id+'"/>'
});
};
};
tPanel.doLayout();
};
var cEventTSS = 0;
var cEventETS = 0;
var VSRCC ='';
function setVideoSource( mid, frame ){
var video_t = document.getElementById( 'video-img-' + mid );
if( video_t != undefined ){
video_t.src = "/video_view/stream?id="+videoNfo[mid][1]+"&TS="+videoNfo[mid][0]+"&sf=" + frame;
};
};
function loadEventData( record ){
ReportSelectionMode = 3; // Just One Event
cEventTSS = record.ts+record.ms/1000;
clearAllRadars();
if( record.type == 13 || record.type == 14 || record.type == 36 ){
markEventOnRadar( record.node_id, record.az, record.r );
};
if( record.video ){
showVideos();
Ext.Ajax.request({
url: '/lib/controller/getVideoInfo.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
TS: record.ts,
ID: record.id
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( data.videos != undefined ){
if( data.videos.length ){
for( i=0; i < data.videos.length; i++ ){
//var video_t = document.getElementById( 'video-'+data.videos[i].media_stream_id );
videoNfo[data.videos[i].media_stream_id] = [];
videoNfo[data.videos[i].media_stream_id][0] = data.ts;
videoNfo[data.videos[i].media_stream_id][1] = data.videos[i].md5;
videoNfo[data.videos[i].media_stream_id][2] = data.videos[i].fps;
data.videos[i].frame -= 20;
if( data.videos[i].frame < 0 ) data.videos[i].frame = 0;
setVideoSource( data.videos[i].media_stream_id, data.videos[i].frame );
var slider_t = Ext.getCmp( 'video-slider-'+data.videos[i].media_stream_id );
if( slider_t != undefined ){
slider_t.setMaxValue( 60 * data.videos[i].fps );
slider_t.suspendEvents();
slider_t.setValue( data.videos[i].frame );
slider_t.resumeEvents();
};
};
};
};
}
});
} else {
hideVideos();
};
};
function clearAllRadars(){
for( i=1; i< 1000; i++ ){
var csvg = document.getElementById( 'draw_svgr_' + i );
if( csvg!= undefined ){
var roi = csvg.getElementById( "roi" );
if( roi != null ) csvg.removeChild( roi );
};
};
};
function markEventOnRadar( rid, az, range ){
var csvg = document.getElementById( 'draw_svgr_' + rid );
if( csvg!= undefined ){
var roi = csvg.getElementById( "roi" );
if( roi != null ) csvg.removeChild( roi );
var bBox = csvg.getBBox();
var max = 2048;
switch( drawZoomLevels[rid] ){
case 50: max = 1024; break;
case 25: max = 512; break;
case 12: max = 256; break;
};
if( range < max ){
var ak = 2.0*Math.PI/360;
var ok = 1.0/35;
var rk = bBox.width / ( max * 2 );
var cpx = bBox.width / 2.0;
var cpy = bBox.height / 2.0;
x = cpx + rk * range * Math.cos( az*ak );
y = cpy - rk * range * Math.sin( az*ak );
var cc = document.createElementNS('http://www.w3.org/2000/svg', "circle");
var rz = bBox.width / csvg.clientWidth;
cc.setAttributeNS(null, "cx", x );
cc.setAttributeNS(null, "cy", y );
cc.setAttributeNS(null, "r", ""+(6*rz)+"" );
cc.setAttributeNS(null, "stroke", "#800000" );
cc.setAttributeNS(null, "stroke-width", ""+(2*rz)+"" );
cc.setAttributeNS(null, "stroke-opacity", ""+(1.0));
cc.setAttributeNS(null, "fill", "#ff0000" );
cc.setAttributeNS(null, "fill-opacity", ""+(1.0));
cc.setAttributeNS(null, "id", "roi" );
csvg.appendChild( cc );
};
};
};
function getData( Mode, ST/* = 0*/, ET /*= 0*/, SR /*= 0*/, DR /*= 0*/){
if( tlLoadLocker ) return;
tlLoadLocker = true;
if( Mode == 'arch' ){
Ext.MessageBox.wait("Loading Data","Please Wait",{
width: '100%',
hidden: true,
animate: true,
progress: true,
closable: false
});
};
Ext.Ajax.request({
url: '/lib/controller/getEventRecords.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
MODE: Mode,
FIL: selecredActiveSourceFilter,
SDA: SD,
SMO: SMO,
SYE: SY,
STM: ST,
ETM: ET,
STR: SR,
DIR: DR
},
success: function( response, opts ){
tlLoadLocker = false;
var data = Ext.decode(response.responseText);
if( data.updateFROMTO ){
Ext.getCmp('STimeFROM').setValue( data.STT );
Ext.getCmp('STimeTO').setValue( data.ENT );
if( data.SLD > 0 ){
SMO = GetMonthNum(data.SLD);
SY = GetYear(data.SLD);
SD = GetDay(data.SLD);
BuildCalendar();
};
};
eventsListStore.loadData( data, false );
if( Mode == 'arch' ){
showHistoryOnMap( data, true );
Ext.MessageBox.hide();
if( DR > 0 ){
Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
};
if( DR < 0 ){
Ext.getCmp('evtArchLog').getView().focusRow( 0 );
Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
};
} else {
showHistoryOnMap( data, false );
//LoadMapEventsZ( Mode );
};
},
failure: failureAJAXFunction
});
};
function loadArchive(){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
setUserContent( 2 );
var tPanel = Ext.getCmp('main_portal');
tPanel.removeAll( true );
Ext.getCmp('main_content').setTitle( 'Events Archive' );
tPanel.add({
columnWidth: 0.83,
frame: false,
border: false,
items: [{
title: 'Site Map',
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:{
id: 'event_map',
html: '&nbsp;'
}
}]
},{
frame: false,
border: false,
collapsible: false,
draggable: false,
layout: 'hbox',
items:[{
layout: 'form',
title: 'Date/Time',
width: 200,
frame: true,
border: false,
labelAlign: 'right',
labelWidth: 50,
defaults: { width: 80},
items: [{
xtype: 'combo',
id: 'STimeFROM',
fieldLabel: 'From',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 120,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: ['ss', 'displayText' ],
data: [<?php
$zuzu = array();
for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
echo implode( ',', $zuzu ); ?>]
}),
valueField: 'ss',
displayField: 'displayText'
},{
xtype: 'combo',
id: 'STimeTO',
fieldLabel: 'Till',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 120,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: ['ss', 'displayText' ],
data: [<?php
$zuzu = array();
for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
echo implode( ',', $zuzu ); ?>]
}),
valueField: 'ss',
displayField: 'displayText'
}],
html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
buttons: [{
xtype: 'button',
text: 'Display History',
handler: function(){
var STU = Ext.getCmp('STimeFROM').getValue();
var ETU = Ext.getCmp('STimeTO').getValue();
getData( 'arch', STU, ETU );
}
}]
},{
title: 'Event Log',
frame: false,
height: 303,
id: 'evtArchLog',
xtype: 'grid',
ds: eventsListStore,
cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
listeners:{
keydown: function( e ) {
if( e.getKey() == e.UP ){
if( SelectedRow == 0 ){
var id = eventsListStore.getAt( 0 ).id;
getData( 'arch', 0, 0, id, 1 );
};
};
if( e.getKey() == e.DOWN ){
if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
var id = eventsListStore.getAt( SelectedRow ).id;
getData( 'arch', 0, 0, id, -1 );
Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
Ext.getCmp('evtArchLog').focus( false, true );
};
};
}
}
}]
}]
});
tPanel.add({
columnWidth: 0.17,
frame: true,
title: 'Event Information',
id: 'prop_content',
border: false,
items: [{
html:"<div class='setEd_infoPanel' id='NUNU'><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>"
}]
});
tPanel.doLayout();
/*
Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
Ext.getCmp('evtLog').getEl().addKeyMap({
eventName: "keyup",
binding: [{
key: Ext.EventObject.SPACE,
fn: function(){ alert("Space key pressed"); }
},{
key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
shift: true,
fn: function(){ alert("Left or right pressed while pressing shift"); }
}]
});
*/
//BuildCalendar();
loadCalendarDates();
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 );
getData( 'arch' );
//eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
};
function loadMonitoring(){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
setUserContent( 1 );
var tPanel = Ext.getCmp('main_portal');
tPanel.removeAll( true );
Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
tPanel.add({
columnWidth: 0.83,
frame: false,
border: false,
items: [{
title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
frame: false,
border: false,
collapsible: false,
draggable: false,
layout: 'vbox',
layoutConfig: {
align : 'stretch',
pack : 'start',
},
height: PanelH-300,
items:[{
height: PanelH-325,
flex: 1,
frame: false,
border: false,
layout: 'fit',
items:{
id: 'event_map',
html: '&nbsp;'
}
}]
},{
frame: false,
border: true,
collapsible: false,
draggable: false,
layout: 'hbox',
items:[{
title: 'Alarm Sources',
xtype: 'panel',
border: false,
frame: false,
collapsible: false,
draggable: false,
id: 'sources_panel',
width: 160,
autoScroll: 'auto',
height: 303
},{
title: 'Event Log',
height: 303,
xtype: 'grid',
border: false,
frame: false,
collapsible: false,
draggable: false,
ds: eventsListStore,
cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
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 ) {
}
});
}
}]
}]
}]
});
tPanel.add({
columnWidth: 0.17,
title: 'Event Information',
frame: true,
id: 'prop_content',
border: false,
items: [{
html:"<div class='setEd_infoPanel' id='NUNU'><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>"
}]
});
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); */
loadMapZones( SelectedSite );
tlInterval = window.setInterval( getData, 333, 'live' );
};
function loadOnlineMonitoring(devID){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
var tPanel = Ext.getCmp('main_content');
tPanel.removeAll( true );
tPanel.add({
html: 'Device Monitoring '+devID
});
tPanel.doLayout();
};
function shutImg( img, a /* = '' */){
if( a == '' ){
img.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAI=;';
} else {
img.src = a;
};
};
var ReportMask = null;
var ReportLayoutLoadded = false;
var ReportSelectionMode = 0; //All
function loadReportSegment( ts, bid, eid ){
if( !ReportLayoutLoadded ){
ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"Please wait..."});
ReportMask.show();
Ext.Ajax.request({
url: '/lib/controller/getReportLayout.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'//,
//BID: nid,
//EID: evt_ts
},
success: function(response, opts ){
var data = Ext.decode( response.responseText );
var tPanel = Ext.getCmp('main_content');
tPanel.removeAll(true);
Ext.getCmp('main_content').add({
xtype: 'portal',
id: 'segment_portal',
frame: false,
border: false,
items:{
html: ''
},
listeners:{
drop: function( a ){
updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
}
}
});
Ext.getCmp('main_content').doLayout();
tPanel = Ext.getCmp('segment_portal');
//nodeDashboardStatuses = new Array();
for( i=0; i < data.length; i++) tPanel.add( data[i] );
tPanel.doLayout();
ReportMask.hide();
ReportLayoutLoadded = true;
loadReportData( ts, bid, eid );
},
error: function(){
ReportMask.hide();
}
});
} else {
loadReportData( ts, bid, eid );
};
};
function loadReportData( ts, bid, eid ){
ReportSelectionMode = 2; // Session Selected
hideVideos();
Ext.Ajax.request({
url: '/lib/controller/getHistoryEvents.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
TS: ts,
BID: bid,
EID: eid,
},
success: function(response, opts ){
var data = Ext.decode( response.responseText );
if( data.log != undefined ){
if( map != undefined ) if( map != null ) showHistoryOnMap( data, true );
if( data.log.length ){
rep_store_id = data.log[0].id;
rep_array = data.log;//.concat( rep_array );
//if( log_array.length > 32 ){
// log_array = log_array.slice( 0, 31 );
//};
rep_store.removeAll();
rep_store.loadData( rep_array );
};
} else {
// alert('No Log');
// clear the log
rep_store.removeAll();
};
}
});
};
function loadReportDayTree( ts ){
ReportSelectionMode = 1;//Day Selected
ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
ReportMask.show();
Ext.Ajax.request({
url: '/lib/controller/getHistoryDay.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
DTS: ts
},
success: function(response, opts ){
var data = Ext.decode( response.responseText );
var sPanel = Ext.getCmp('left_side_menu');
sPanel.removeAll( true );
sPanel.add({
xtype: 'panel',
layout: 'vbox',
frame: true,
border: false,
items:[{
xtype: 'spacer',
height: 3
},{
html: '<p class="cur_date">'+( new Date( ts * 1000)).toLocaleDateString()+'</p><p class="cur_sessions">'+data.sessions+'</p><p class="cur_events">'+data.events+'</p><p class="cur_videos">'+data.videos+'</p>',
frame: false,
width: '100%',
border: false
},{
xtype: 'spacer',
height: 5
},{
xtype: 'treepanel',
autoScroll: true,
width: '100%',
height: PanelH-206,
border: true,
frame: true,
loader: new Ext.tree.TreeLoader(),
rootVisible: false,
root: new Ext.tree.AsyncTreeNode( data ),
listeners: {
click: function(n) {
if( n.attributes.leaf ){
Ext.getCmp('chu_adate').show();
sPanel.doLayout();
loadReportSegment( ts, n.attributes.bid, n.attributes.eid );
//Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.ts + '"');
};
}
}
},{
xtype: 'spacer',
height: 10
},{
xtype: 'button',
id: 'chu_adate',
text: 'Show Dates',
hidden: true,
width: '100%',
iconCls: 'reports_dates_btn',
scale: 'large',
handler: function(){
Ext.getCmp('chu_adate').hide();
initReportsView();
}
}]
});
sPanel.doLayout();
ReportMask.hide();
}
});
};
var videoElements = [];
var videoNfo=[];
function hideVideos(){
if( videoElements.length ) for( i = 0; i < videoElements.length; i++ ) hideVideo( videoElements[i] );
};
function hideVideo( a ){
var tt = Ext.getCmp( 'video-ctl-panel-' + a );
if( tt != undefined ) tt.hide();
var video_t = document.getElementById( 'video-img-' + a );
if( video_t != undefined ){
video_t.src = "/style/assets/no-signal.png";
};
};
function showVideo( a ){
var tt = Ext.getCmp( 'video-ctl-panel-' + a );
if( tt != undefined ) tt.show();
};
function showVideos(){
if( videoElements.length ) for( i = 0; i < videoElements.length; i++ ) showVideo( videoElements[i] );
};
function downloadCurrentVideo( stid ){
var d = new Date( videoNfo[stid][0] * 1000 );
var videoFileDownloadTarget = d.getFullYear()+'_'+(d.getMonth()+1)+'_'+d.getDate()+'_'+d.getHours()+'-'+d.getMinutes()+'-'+d.getSeconds()+'.mp4';
// TS, MD5, FPS
downloadVideoFile( videoNfo[stid][0], videoNfo[stid][1], videoNfo[stid][2], videoFileDownloadTarget );
};
function initReportsView(){
ReportSelectionMode = 0; // All History
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
ReportLayoutLoadded = false;
var tPanel = Ext.getCmp('main_content');
var sPanel = Ext.getCmp('left_side_menu');
tPanel.removeAll( true );
sPanel.removeAll( true );
tPanel.add({
xtype: 'panel',
height: PanelH+15,
html: '<div id="activity_ph"></div>',
listeners:{
afterrender: function(){
ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"<?=$Labels->GetLabel('_Please_Wait_');?>..."});
ReportMask.show();
var jj = (PanelW - 230)/55;
changeStyleSheet('amap-empty-day','{width: '+jj+'px; height: '+jj+'px;}');
changeStyleSheet('amap-week-day','{width: '+jj+'px; height: '+jj+'px;}');
changeStyleSheet('amap-week-name','{width: '+jj+'px; height: '+jj+'px;}');
Ext.Ajax.request({
url: '/lib/controller/getHistoryDates.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function(response, opts ){
var data = Ext.decode( response.responseText );
var activityMap = new ActivityMap( data, {
id: "dji-volume-map",
parent: '#activity_ph',
showTitle: false,
showYears: true,
width: 100,
hue: 1,
fit: true,
compact: true,
timeColumn: "t",
valueColumn: "v"
});
activityMap.render();
ReportMask.hide();
},
error: function(){
ReportMask.hide();
}
});
}
}
});
tPanel.doLayout();
sPanel.add({
xtype: 'panel',
frame: true,
border: false,
items: [{
html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
height: PanelH - 30
}]
});
sPanel.doLayout();
};
function downloadVideoFile( a, b, c, d ){
ReportMask = new Ext.LoadMask( Ext.getBody(), {msg:"<?=$Labels->GetLabel('_Please_Wait_');?>..."} );
ReportMask.show();
Ext.Ajax.request({
url: '/lib/controller/downloadVideo.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
FTS: a,
FMD: b,
FPS: c
},
success: function(response, opts ){
const a = document.createElement('a');
a.style.display = 'none';
a.href = response.responseText;
a.download = d;
document.body.appendChild(a);
a.click();
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_SUCCESS_');?>',
msg: '<?=$Labels->GetLabel('_VIDEO_FILE_HAS_DOWNLOADED_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
},
error: function(){
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
});
};