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.

1237 lines
39 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var map = null;
  3. var selectedMarker = null;
  4. var timelineObj = null;
  5. var tlGroups = new vis.DataSet();
  6. var tlItems = new vis.DataSet();
  7. var selecredActiveSourceFilter = 0;
  8. var ActiveZones = null;
  9. var selectedMarkerIcon = L.icon({
  10. iconUrl: '/style/assets/cursor.png',
  11. iconSize: [32, 32],
  12. iconAnchor: [16, 16]//,
  13. //popupAnchor: [-3, -76],
  14. //shadowUrl: 'my-icon-shadow.png',
  15. //shadowSize: [68, 95],
  16. //shadowAnchor: [22, 94]
  17. });
  18. selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
  19. var tlOptions = {
  20. groupOrder: 'content', // groupOrder can be a property name or a sorting function
  21. stack: true,
  22. showCurrentTime: true,
  23. //verticalScroll: true,
  24. //zoomKey: 'ctrlKey',
  25. minHeight: 308,
  26. maxHeight: 308
  27. };
  28. var tlLoadLocker = false;
  29. var tlLastTS = 0;
  30. var tlInterval = null;
  31. var tlMonitoring = false;
  32. // Calendar
  33. var CurrentDate=(new Date())/1000;
  34. var today=new Date();
  35. var SY=1900+today.getYear();
  36. var SMO=today.getMonth()+1;
  37. var SD=today.getDate();
  38. var SelectedDay = SD;
  39. var Dates = new Array();
  40. function CheckDate(D){
  41. for(j_index=0;j_index<Dates.length;j_index++){
  42. if (Dates[j_index]==D)return true;
  43. };
  44. return false;
  45. };
  46. function ShiftBAK(){
  47. CurrentDate=CurrentDate-24*3600*GetMonthLength(CurrentDate);
  48. BuildCalendar();
  49. SMO = GetMonthNum(CurrentDate);
  50. SY = GetYear(CurrentDate);
  51. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  52. loadCalendarDates();
  53. };
  54. function ShiftFWD(){
  55. CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate);
  56. BuildCalendar();
  57. SMO = GetMonthNum(CurrentDate);
  58. SY = GetYear(CurrentDate);
  59. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  60. loadCalendarDates();
  61. };
  62. function GetMonthName(UTS){ // Unix Time Stamp
  63. var MoNames= new Array();
  64. MoNames[0]='January';
  65. MoNames[1]='February';
  66. MoNames[2]='March';
  67. MoNames[3]='April';
  68. MoNames[4]='May';
  69. MoNames[5]='June';
  70. MoNames[6]='July';
  71. MoNames[7]='August';
  72. MoNames[8]='September';
  73. MoNames[9]='October';
  74. MoNames[10]='November';
  75. MoNames[11]='December';
  76. CDate=new Date();
  77. CDate.setTime(UTS*1000);
  78. CMo=CDate.getMonth();
  79. return MoNames[CMo];
  80. };
  81. function GetMonthShift(UTS){ // Unix Time Stamp
  82. CDate=new Date();
  83. CDate.setTime(UTS*1000);
  84. CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000);
  85. return CDate.getDay();
  86. };
  87. function GetMonthLength(UTS){ // Unix Time Stamp
  88. CDate=new Date();
  89. CDate.setTime(UTS*1000);
  90. CD=CDate.getDate();
  91. RetVal=31;
  92. CDate.setTime((UTS+(31-CD)*86400)*1000);
  93. if ( CDate.getDate()==31) return RetVal;
  94. RetVal=30;
  95. CDate.setTime((UTS+(30-CD)*86400)*1000);
  96. if ( CDate.getDate()==30) return RetVal;
  97. RetVal=29;
  98. CDate.setTime((UTS+(29-CD)*86400)*1000);
  99. if ( CDate.getDate()==29) return RetVal;
  100. RetVal=28;
  101. CDate.setTime((UTS+(28-CD)*86400)*1000);
  102. if ( CDate.getDate()==28) return RetVal;
  103. return -1;
  104. };
  105. function GetMonthNum(UTS){ // Unix Time Stamp
  106. CDate=new Date();
  107. CDate.setTime(UTS*1000);
  108. return CDate.getMonth()+1;
  109. };
  110. function GetYear(UTS){ // Unix Time Stamp
  111. CDate=new Date();
  112. CDate.setTime(UTS*1000);
  113. y=CDate.getYear();
  114. if (y<100)y+=2000;
  115. if (y<200)y+=1900;
  116. return y;
  117. };
  118. function GetDay(UTS){ // Unix Time Stamp
  119. CDate=new Date();
  120. CDate.setTime(UTS*1000);
  121. y=CDate.getDate();
  122. return y;
  123. };
  124. function selectDate( m, d ){
  125. SY = GetYear(CurrentDate);
  126. SMO = m;
  127. SD = d;
  128. SelectedDay = SD;
  129. getData( 'arch' );
  130. };
  131. function BuildCalendar( ){
  132. Msh=GetMonthShift(CurrentDate);
  133. Mnm=GetMonthName(CurrentDate);
  134. Mln=GetMonthLength(CurrentDate);
  135. Mid=GetMonthNum(CurrentDate);
  136. Mye=GetYear(CurrentDate);
  137. 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>';
  138. 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>';
  139. InDTA+='<tr>';
  140. for(index=0;index<Msh;index++){
  141. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  142. };
  143. for(;index<(Mln+Msh);index++){
  144. if( CheckDate(index-Msh+1) ){
  145. //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>';
  146. if( SD == index ){
  147. 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>';
  148. } else {
  149. 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>';
  150. };
  151. } else {
  152. if( SD == index ){
  153. InDTA+='<td style="padding: 1px"><div id="selected_day" class="calendar_t" title="Selected">'+(index-Msh+1).toString()+'</a></td>';
  154. } else {
  155. InDTA+='<td style="padding: 1px"><div id="no_data_day" class="calendar_t" title="No Events">'+(index-Msh+1).toString()+'</a></td>';
  156. };
  157. };
  158. if ((index+1)%7==0){
  159. InDTA+='</tr><tr>';
  160. };
  161. };
  162. for(;(index)%7!=0;index++){
  163. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  164. };
  165. InDTA+='</tr></table>';
  166. tab=document.getElementById('calendar_TD');
  167. tab.innerHTML=InDTA;
  168. };
  169. function loadCalendarDates(){
  170. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  171. width: '100%',
  172. hidden: true,
  173. progress: true,
  174. closable: false
  175. });
  176. Ext.Ajax.request({
  177. url: '/lib/controller/getEventDates.php',
  178. params: {
  179. NID: selecredActiveSourceFilter,
  180. UID: <?=$UserID;?>,
  181. SID: '<?=$Session;?>',
  182. SYE: SY,
  183. SMO: SMO
  184. },
  185. success: function( response, opts ){
  186. Ext.MessageBox.hide();
  187. var data = Ext.decode( response.responseText );
  188. if( data.status == 'ok' ){
  189. Dates = data.days;
  190. BuildCalendar();
  191. //for( var i = 0; i < data.days.length; i++ ){
  192. //
  193. //};
  194. };
  195. },
  196. failure: function( response, opts ) {
  197. Ext.MessageBox.hide();
  198. }
  199. });
  200. };
  201. var eventsListStore = new Ext.data.JsonStore({
  202. root: 'log',
  203. totalProperty: 'totalCount',
  204. idProperty: 'id',
  205. remoteSort: true,
  206. fields: [{
  207. name: 'id',
  208. type: 'int'
  209. },{
  210. name: 'date',
  211. type: 'string'
  212. },{
  213. name: 'time',
  214. type: 'string'
  215. },{
  216. name: 'device',
  217. type: 'string'
  218. },{
  219. name: 'event',
  220. type: 'int'
  221. },{
  222. name: 'data',
  223. type: 'string',
  224. },{
  225. name: 'has_target',
  226. type: 'boolean'
  227. },{
  228. name: 'has_geo',
  229. type: 'boolean'
  230. },{
  231. name: 'has_images',
  232. type: 'boolean'
  233. },{
  234. name: 'images',
  235. type: 'Array'
  236. },{
  237. name: 'dev_type',
  238. type: 'int'
  239. },{
  240. name: 'geo',
  241. type: 'object'
  242. }] /*,
  243. proxy : new Ext.data.HttpProxy({
  244. method: 'POST',
  245. prettyUrls: false,
  246. url: '/lib/controller/getEventRecords.php',
  247. headers: {
  248. UID: <?=$UserID;?>,
  249. SID: '<?=$Session;?>',
  250. NID: 1
  251. }
  252. })*/
  253. });
  254. var SelectedEvent = 0;
  255. var EventPanelWindow = null;
  256. function showEventPanel(){
  257. if( EventPanelWindow == null ){
  258. EventPanelWindow = new Ext.Window({
  259. modal: true,
  260. title: '<?=$Labels->GetLabel("_EVENT_VIEWER_");?>',
  261. width: winW*0.66,
  262. height: winH*0.66,
  263. layout: 'fit',
  264. closeAction: 'hide',
  265. items:[{
  266. title: 'Cameras',
  267. html:'koko',
  268. autoScroll: true,
  269. height: 320
  270. },{
  271. html: 'koko22',
  272. height: 320
  273. }]
  274. });
  275. };
  276. EventPanelWindow .show();
  277. };
  278. function ModeRenderer(val){
  279. var p1, p2, p3;
  280. if( ( val & 1 ) == 1 ){
  281. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  282. } else {
  283. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  284. };
  285. if( ( val & 2 ) == 2 ){
  286. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  287. } else {
  288. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  289. };
  290. if( ( val & 4 ) == 4 ){
  291. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  292. } else {
  293. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  294. };
  295. return p1+p2+p3;
  296. };
  297. function LocRenderer( val ){
  298. if( val ){
  299. return '<img src="/style/icons/icons/accept.png" alt="Location" />';
  300. };
  301. return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location" />';
  302. };
  303. function PicRenderer( val ){
  304. if( val ){
  305. return '<img src="/style/icons/icons/camera_link.png"/>';
  306. };
  307. return '<img src="/style/icons/icons/bullet_white.png"/>';
  308. };
  309. function EvtTypeRenderer( val ){
  310. switch( val ){
  311. case 6: return 'Device Enters Into Study Mode';
  312. case 7: return 'Device Is BUSY';
  313. case 8: return 'Flip Complete';
  314. case 9: return 'Scan Complete';
  315. case 10:
  316. case 11:
  317. case 12:
  318. case 13:
  319. case 14: return 'Target';
  320. case 36: return 'Region Of Interest';
  321. default: return 'Event ['+val+']';
  322. };
  323. };
  324. var eventsListColModel_ops = {
  325. columns: [
  326. {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  327. {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
  328. {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
  329. {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
  330. {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer },
  331. {header: "Info", width: 200, sortable: false, dataindex: 'data' },
  332. {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer },
  333. {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer }
  334. ],
  335. defaults: {
  336. sortable: true,
  337. menuDisabled: true,
  338. width: 100
  339. },
  340. listeners: {
  341. hiddenchange: function(cm, colIndex, hidden) {
  342. //saveConfig(colIndex, hidden);
  343. }
  344. }
  345. };
  346. var SelectedRow = -1;
  347. var eventsListSelModel_ops = {
  348. singleSelect: true,
  349. listeners: {
  350. rowselect: function(sm, row, rec ) {
  351. loadEventProperties( rec.data );
  352. SelectedEvent = rec.data.id;
  353. SelectedRow = row;
  354. //alert( SelectedEvent );
  355. //var CB = Ext.getCmp('con_to_src');
  356. //CB.enable();
  357. }
  358. }
  359. };
  360. function loadTimeLineGroups( NID ){
  361. Ext.Ajax.request({
  362. url: '/lib/controller/getTimeLineGroups.php',
  363. params: {
  364. NID: NID,
  365. UID: <?=$UserID;?>,
  366. SID: '<?=$Session;?>'
  367. },
  368. success: function( response, opts ){
  369. // If the response is JSON, you have to decode it
  370. var data = Ext.decode(response.responseText);
  371. //for(var i = 0; i < data.length; i++) {
  372. //tlGroups.add(data[i]);
  373. //};
  374. tlGroups.update( data );
  375. loadTimeLineItems( SelectedSite );
  376. tlInterval = window.setInterval( loadTimeLineItems, 333, SelectedSite );
  377. },
  378. failure: function( response, opts ) {
  379. //Ext.fly('some_div').update('Fail!');
  380. }/*,
  381. callback: function(options,success,response){
  382. // use this if you need to perform your own success/failure checking
  383. }*/
  384. });
  385. };
  386. function clickDeviceSelector( id ){
  387. var rr = document.getElementById(id+'_div');
  388. if( selecredActiveSourceFilter != id ){
  389. if( selecredActiveSourceFilter > 0 ){
  390. var oo = document.getElementById( selecredActiveSourceFilter + '_div');
  391. oo.classList.remove( "cardDeviceSourceSelected" );
  392. oo.classList.add( "cardDeviceSource" );
  393. };
  394. rr.classList.remove( "cardDeviceSource" );
  395. rr.classList.add( "cardDeviceSourceSelected" );
  396. selecredActiveSourceFilter = id;
  397. turnOffAllGzButThis( selecredActiveSourceFilter );
  398. } else {
  399. selecredActiveSourceFilter = 0;
  400. rr.classList.remove( "cardDeviceSourceSelected" );
  401. rr.classList.add( "cardDeviceSource" );
  402. turnAllGzOn();
  403. var tPanel = Ext.getCmp('prop_content');
  404. tPanel.remove(0);
  405. tPanel.add( {
  406. title: 'Event Information',
  407. border: false,
  408. frame: false,
  409. collapsible: false,
  410. draggable: false,
  411. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  412. } );
  413. tPanel.doLayout();
  414. };
  415. };
  416. function getZoneByNode( nid ){
  417. var rVal = -1;
  418. for( var i=0; i < ActiveZones.totalCount; i++ ){
  419. if( ActiveZones.zones[i].dev_id == nid ){
  420. rVal = i;
  421. break;
  422. };
  423. };
  424. return rVal;
  425. };
  426. function turnOffAllGzButThis( nid ){
  427. var chocho = -1;
  428. for( var i=0; i < ActiveZones.totalCount; i++ ){
  429. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  430. map.removeLayer( ActiveZones.fig[i] );
  431. map.removeLayer( ActiveZones.zang[i] );
  432. map.removeLayer( ActiveZones.center[i] );
  433. };
  434. if( chocho > -1 ){
  435. map.addLayer( ActiveZones.fig[chocho] );
  436. map.addLayer( ActiveZones.zang[chocho] );
  437. map.addLayer( ActiveZones.center[chocho] );
  438. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  439. map.flyToBounds( cVisible.getBounds() );
  440. };
  441. };
  442. function turnAllGzOn(){
  443. var tall = Array();
  444. for( var i=0; i < ActiveZones.totalCount; i++ ){
  445. tall[i*3] = ActiveZones.fig[i];
  446. tall[i*3+1] = ActiveZones.zang[i];
  447. tall[i*3+2] = ActiveZones.center[i];
  448. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  449. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  450. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  451. };
  452. var cVisible = L.featureGroup( tall );
  453. map.flyToBounds( cVisible.getBounds() );
  454. };
  455. function loadMapZones( SID ){
  456. Ext.Ajax.request({
  457. url: '/lib/controller/getGeoZones.php',
  458. params: {
  459. SITE: SID,
  460. UID: <?=$UserID;?>,
  461. SID: '<?=$Session;?>'
  462. },
  463. success: function( response, opts ){
  464. // If the response is JSON, you have to decode it
  465. var data = Ext.decode(response.responseText);
  466. var pp = Ext.getCmp('sources_panel');
  467. if( typeof pp !== 'undefined' ) pp.removeAll();
  468. ActiveZones = data;
  469. ActiveZones.fig = new Array();
  470. ActiveZones.zang = new Array();
  471. ActiveZones.center = new Array();
  472. for(var i = 0; i < data.totalCount; i++ ) {
  473. switch( data.zones[i].type ){
  474. case 'circle':{
  475. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  476. ActiveZones.fig[i] = new L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } );
  477. //map.addLayer( ActiveZones.fig[i] );
  478. break;
  479. };
  480. case 'poly':{
  481. ActiveZones.fig[i] = new 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);
  482. //map.addLayer( ActiveZones.fig[i] );
  483. break;
  484. };
  485. case 'image':{
  486. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  487. //map.addLayer( ActiveZones.fig[i] );
  488. break;
  489. };
  490. case 'image_rot':{
  491. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  492. opacity: 0.8 //,
  493. //interactive: true,
  494. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geográfico Nacional de España</a>"
  495. });//.addTo( map );
  496. //map.addLayer( ActiveZones.fig[i] );
  497. break;
  498. };
  499. };
  500. if( data.zones[i].dev_is_source ){
  501. if( typeof pp !== 'undefined' ) {
  502. var sty = '';
  503. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  504. sty = 'cardDeviceSourceSelected';
  505. } else {
  506. sty = 'cardDeviceSource';
  507. };
  508. pp.add( {
  509. id: data.zones[i].dev_id+'_container',
  510. frame: false,
  511. border: false,
  512. width: 130,
  513. height: 130,
  514. html: '<div id="'+data.zones[i].dev_id+'_div" class="'+sty+'" onclick="clickDeviceSelector('+data.zones[i].dev_id+');"><img id="'+data.zones[i].dev_id+'_ind" width="16px" src="/style/assets/led_green_blink_300ms.gif"><center><img src="/style/assets/'+data.zones[i].dev_type+'_node.png"><br/><p class="dev_name">'+data.zones[i].dev_name+'</p></center></div>'
  515. });
  516. };
  517. };
  518. if( data.zones[i].zang != undefined ){
  519. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  520. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  521. };
  522. if( data.zones[i].center != undefined ){
  523. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  524. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  525. };
  526. };
  527. if( selecredActiveSourceFilter == 0 ){
  528. turnAllGzOn();
  529. } else {
  530. turnOffAllGzButThis( selecredActiveSourceFilter );
  531. };
  532. if( typeof pp !== 'undefined' ) pp.doLayout();
  533. //LoadMapEvents( SelectedSite );
  534. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  535. },
  536. failure: function( response, opts ) {
  537. //Ext.fly('some_div').update('Fail!');
  538. }
  539. });
  540. };
  541. var cevt = Array();
  542. var coz = Array();
  543. function showEventsOnMap( data, removeCursor = true ){
  544. if( removeCursor ) map.removeLayer( selectedMarker );
  545. if( cevt.length ){
  546. for( i=0; i< cevt.length; i++ ){
  547. if( cevt[i]!= null ){
  548. cevt[i].remove();
  549. delete( cevt[i] );
  550. cevt[i] = null;
  551. };
  552. };
  553. };
  554. if( coz.length ){
  555. for( i=0; i< coz.length; i++ ){
  556. if( coz[i]!= null ){
  557. coz[i].remove();
  558. delete( coz[i] );
  559. coz[i]=null;
  560. };
  561. };
  562. };
  563. var zz = ( 1.0 / ( data.log.length + 0 ) );
  564. var idx = 0;
  565. for( i=0; i < data.log.length; i++ ){
  566. if( data.log[i].has_geo ){
  567. var cp_color='#FF0000';
  568. switch( data.log[i].event ){
  569. case 36: cp_color='#0000FF'; break;
  570. };
  571. cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  572. loadEventPropertiesByID( this.options.id );
  573. } );
  574. cevt[idx].addTo(map);
  575. idx++;
  576. };
  577. };
  578. };
  579. function LoadMapEventsZ( Mode ){
  580. if( tlLoadLocker ) return;
  581. tlLoadLocker = true;
  582. Ext.Ajax.request({
  583. url: '/lib/controller/getGeoAlerts.php',
  584. params: {
  585. SITE: <?=$SiteID;?>,
  586. UID: <?=$UserID;?>,
  587. SID: '<?=$Session;?>',
  588. MODE: Mode
  589. },
  590. success: function( response, opts ){
  591. if( cevt.length ){
  592. for( i=0; i< cevt.length; i++ ){
  593. if( cevt[i]!= null ){
  594. cevt[i].remove();
  595. delete( cevt[i] );
  596. cevt[i] = null;
  597. };
  598. };
  599. };
  600. if( coz.length ){
  601. for( i=0; i< coz.length; i++ ){
  602. if( coz[i]!= null ){
  603. coz[i].remove();
  604. delete( coz[i] );
  605. coz[i]=null;
  606. };
  607. };
  608. };
  609. var data = Ext.decode( response.responseText );
  610. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  611. for( i=0; i < data.evt.length; i++ ){
  612. 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 ){
  613. loadEventProperties( this.options.id );
  614. } );
  615. cevt[i].addTo(map);
  616. };
  617. for( i=0; i < data.other.length; i++ ){
  618. switch( data.other[i].type ){
  619. case 'circle':{
  620. 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 } );
  621. coz[i].addTo(map);
  622. break;
  623. };
  624. };
  625. };
  626. //eventsListStore.reload();
  627. tlLoadLocker = false;
  628. },
  629. failure: function( response, opts ) {
  630. //Ext.fly('some_div').update('Fail!');
  631. tlLoadLocker = false;
  632. }
  633. });
  634. };
  635. function loadEventPropertiesByID( id ){
  636. var d = eventsListStore.findExact( 'id', id );
  637. if( d > -1 ) {
  638. var EventRec = eventsListStore.getAt( d );
  639. loadEventProperties( EventRec.data );
  640. };
  641. };
  642. function loadEventProperties( EventRec ){
  643. var tPanel = Ext.getCmp('prop_content');
  644. tPanel.removeAll();// remove( 0 );
  645. var tt = '';
  646. if( selectedMarker!= null ){
  647. selectedMarker.remove();
  648. //map.removeLayer( selectedMarker );
  649. if( EventRec.has_geo ){
  650. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  651. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  652. selectedMarker.addTo( map );
  653. };
  654. };
  655. tPanel.add( {
  656. title: 'Event Details',
  657. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  658. } );
  659. if( EventRec.has_images ){
  660. for( var i=0; i < EventRec.images.length; i++ ){
  661. tPanel.add( {
  662. frame: false,
  663. 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+'"/>'
  664. });
  665. };
  666. };
  667. tPanel.doLayout();
  668. };
  669. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  670. if( tlLoadLocker ) return;
  671. tlLoadLocker = true;
  672. if( Mode == 'arch' ){
  673. Ext.MessageBox.wait("Loading Data","Please Wait",{
  674. width: '100%',
  675. hidden: true,
  676. animate: true,
  677. progress: true,
  678. closable: false
  679. });
  680. };
  681. Ext.Ajax.request({
  682. url: '/lib/controller/getEventRecords.php',
  683. params: {
  684. SITE: <?=$SiteID;?>,
  685. UID: <?=$UserID;?>,
  686. SID: '<?=$Session;?>',
  687. MODE: Mode,
  688. FIL: selecredActiveSourceFilter,
  689. SDA: SD,
  690. SMO: SMO,
  691. SYE: SY,
  692. STM: ST,
  693. ETM: ET,
  694. STR: SR,
  695. DIR: DR
  696. },
  697. success: function( response, opts ){
  698. tlLoadLocker = false;
  699. var data = Ext.decode(response.responseText);
  700. if( data.updateFROMTO ){
  701. Ext.getCmp('STimeFROM').setValue( data.STT );
  702. Ext.getCmp('STimeTO').setValue( data.ENT );
  703. if( data.SLD > 0 ){
  704. SMO = GetMonthNum(data.SLD);
  705. SY = GetYear(data.SLD);
  706. SD = GetDay(data.SLD);
  707. BuildCalendar();
  708. };
  709. };
  710. eventsListStore.loadData( data, false );
  711. if( Mode == 'arch' ){
  712. showEventsOnMap( data, true );
  713. Ext.MessageBox.hide();
  714. if( DR > 0 ){
  715. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  716. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  717. };
  718. if( DR < 0 ){
  719. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  720. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  721. };
  722. } else {
  723. showEventsOnMap( data, false );
  724. //LoadMapEventsZ( Mode );
  725. };
  726. },
  727. failure: failureAJAXFunction
  728. });
  729. };
  730. function loadArchive(){
  731. if( tlInterval!= null ){
  732. window.clearInterval( tlInterval );
  733. tlInterval = null;
  734. timelineObj = null;
  735. };
  736. setUserContent( 2 );
  737. var tPanel = Ext.getCmp('main_portal');
  738. tPanel.removeAll( true );
  739. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  740. tPanel.add({
  741. columnWidth: 0.83,
  742. frame: false,
  743. border: false,
  744. items: [{
  745. title: 'Site Map',
  746. frame: false,
  747. border: false,
  748. layout: 'vbox',
  749. layoutConfig: {
  750. align : 'stretch',
  751. pack : 'start',
  752. },
  753. height: PanelH-300,
  754. items:[{
  755. height: PanelH-325,
  756. flex: 1,
  757. frame: false,
  758. border: false,
  759. layout: 'fit',
  760. items:{
  761. id: 'event_map',
  762. html: '&nbsp;'
  763. }
  764. }]
  765. },{
  766. frame: false,
  767. border: false,
  768. collapsible: false,
  769. draggable: false,
  770. layout: 'hbox',
  771. items:[{
  772. layout: 'form',
  773. title: 'Date/Time',
  774. width: 200,
  775. frame: true,
  776. border: false,
  777. labelAlign: 'right',
  778. labelWidth: 50,
  779. defaults: { width: 80},
  780. items: [{
  781. xtype: 'combo',
  782. id: 'STimeFROM',
  783. fieldLabel: 'From',
  784. editable: false,
  785. typeAhead: true,
  786. triggerAction: 'all',
  787. width: 120,
  788. lazyRender:true,
  789. mode: 'local',
  790. store: new Ext.data.ArrayStore({
  791. id: 0,
  792. fields: ['ss', 'displayText' ],
  793. data: [<?php
  794. $zuzu = array();
  795. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  796. echo implode( ',', $zuzu ); ?>]
  797. }),
  798. valueField: 'ss',
  799. displayField: 'displayText'
  800. },{
  801. xtype: 'combo',
  802. id: 'STimeTO',
  803. fieldLabel: 'Till',
  804. editable: false,
  805. typeAhead: true,
  806. triggerAction: 'all',
  807. width: 120,
  808. lazyRender:true,
  809. mode: 'local',
  810. store: new Ext.data.ArrayStore({
  811. id: 0,
  812. fields: ['ss', 'displayText' ],
  813. data: [<?php
  814. $zuzu = array();
  815. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  816. echo implode( ',', $zuzu ); ?>]
  817. }),
  818. valueField: 'ss',
  819. displayField: 'displayText'
  820. }],
  821. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  822. buttons: [{
  823. xtype: 'button',
  824. text: 'Display History',
  825. handler: function(){
  826. var STU = Ext.getCmp('STimeFROM').getValue();
  827. var ETU = Ext.getCmp('STimeTO').getValue();
  828. getData( 'arch', STU, ETU );
  829. }
  830. }]
  831. },{
  832. title: 'Event Log',
  833. frame: false,
  834. height: 303,
  835. id: 'evtArchLog',
  836. xtype: 'grid',
  837. ds: eventsListStore,
  838. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  839. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  840. listeners:{
  841. keydown: function( e ) {
  842. if( e.getKey() == e.UP ){
  843. if( SelectedRow == 0 ){
  844. var id = eventsListStore.getAt( 0 ).id;
  845. getData( 'arch', 0, 0, id, 1 );
  846. };
  847. };
  848. if( e.getKey() == e.DOWN ){
  849. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  850. var id = eventsListStore.getAt( SelectedRow ).id;
  851. getData( 'arch', 0, 0, id, -1 );
  852. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  853. Ext.getCmp('evtArchLog').focus( false, true );
  854. };
  855. };
  856. }
  857. }
  858. }]
  859. }]
  860. });
  861. tPanel.add({
  862. columnWidth: 0.17,
  863. frame: true,
  864. title: 'Event Information',
  865. id: 'prop_content',
  866. border: false,
  867. items: [{
  868. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  869. }]
  870. });
  871. tPanel.doLayout();
  872. /*
  873. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  874. Ext.getCmp('evtLog').getEl().addKeyMap({
  875. eventName: "keyup",
  876. binding: [{
  877. key: Ext.EventObject.SPACE,
  878. fn: function(){ alert("Space key pressed"); }
  879. },{
  880. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  881. shift: true,
  882. fn: function(){ alert("Left or right pressed while pressing shift"); }
  883. }]
  884. });
  885. */
  886. //BuildCalendar();
  887. loadCalendarDates();
  888. map = L.map('event_map',{
  889. attributionControl: true,
  890. //preferCanvas: true,
  891. zoomControl: true,
  892. center: [SiteLat, SiteLon],
  893. /*zoomControl: false,
  894. zoom: 17,
  895. minZoom: 17,
  896. maxZoom: 17,*/
  897. keyboard: false
  898. }).setView([SiteLat, SiteLon], 17);
  899. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  900. var mapLayers = [];
  901. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  902. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  903. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  904. detectRetina: true
  905. });*/
  906. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  907. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  908. maxNativeZoom: 18,
  909. maxZoom: 24,
  910. })
  911. // https://leaflet-extras.github.io/leaflet-providers/preview/
  912. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  913. 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',
  914. maxZoom: 19
  915. });
  916. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  917. 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',
  918. maxZoom: 19
  919. });
  920. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  921. 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',
  922. maxZoom: 24
  923. });
  924. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  925. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  926. maxZoom: 19
  927. });
  928. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  929. 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>) ',
  930. maxZoom: 19
  931. });
  932. /*
  933. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  934. 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>',
  935. maxZoom: 22
  936. });
  937. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  938. 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>',
  939. maxZoom: 22
  940. });
  941. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  942. 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>',
  943. maxZoom: 22
  944. });
  945. */
  946. var baseMaps = {
  947. "MyMap": mapLayers["MyMap"],
  948. "OpenStreetMap": mapLayers["OpenStreetMap"],
  949. "OpenTopoMap": mapLayers["OpenTopoMap"],
  950. "EsriSat": mapLayers["EsriSat"],
  951. "EsriStreet": mapLayers["EsriStreet"],
  952. "EsriTopo": mapLayers["EsriTopo"],
  953. //"Bing": mapLayers["Bing"],
  954. //"OSM-Cycle": mapLayers["Cycle"],
  955. //"Landscape": mapLayers["Landscape"],
  956. //"Outdoor": mapLayers["Outdoor"],
  957. };
  958. L.control.layers( baseMaps ).addTo(map);
  959. mapLayers["MyMap"].addTo(map);
  960. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  961. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  962. maxNativeZoom: 18,
  963. maxZoom: 24,
  964. }).addTo(map); */
  965. //loadTimeLineGroups( selectedSite );
  966. loadMapZones( SelectedSite );
  967. getData( 'arch' );
  968. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  969. };
  970. function loadMonitoring(){
  971. if( tlInterval!= null ){
  972. window.clearInterval( tlInterval );
  973. tlInterval = null;
  974. timelineObj = null;
  975. };
  976. setUserContent( 1 );
  977. var tPanel = Ext.getCmp('main_portal');
  978. tPanel.removeAll( true );
  979. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  980. tPanel.add({
  981. columnWidth: 0.83,
  982. frame: false,
  983. border: false,
  984. items: [{
  985. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  986. frame: false,
  987. border: false,
  988. collapsible: false,
  989. draggable: false,
  990. layout: 'vbox',
  991. layoutConfig: {
  992. align : 'stretch',
  993. pack : 'start',
  994. },
  995. height: PanelH-300,
  996. items:[{
  997. height: PanelH-325,
  998. flex: 1,
  999. frame: false,
  1000. border: false,
  1001. layout: 'fit',
  1002. items:{
  1003. id: 'event_map',
  1004. html: '&nbsp;'
  1005. }
  1006. }]
  1007. },{
  1008. frame: false,
  1009. border: true,
  1010. collapsible: false,
  1011. draggable: false,
  1012. layout: 'hbox',
  1013. items:[{
  1014. title: 'Alarm Sources',
  1015. xtype: 'panel',
  1016. border: false,
  1017. frame: false,
  1018. collapsible: false,
  1019. draggable: false,
  1020. id: 'sources_panel',
  1021. width: 160,
  1022. autoScroll: 'auto',
  1023. height: 303
  1024. },{
  1025. title: 'Event Log',
  1026. height: 303,
  1027. xtype: 'grid',
  1028. border: false,
  1029. frame: false,
  1030. collapsible: false,
  1031. draggable: false,
  1032. ds: eventsListStore,
  1033. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1034. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1035. bbar: [{
  1036. text: 'Clear',
  1037. handler: function(){
  1038. Ext.Ajax.request({
  1039. url: '/lib/controller/clearEventCloud.php',
  1040. params: {
  1041. UID: <?=$UserID;?>,
  1042. SID: '<?=$Session;?>'
  1043. },
  1044. success: function( response, opts ){
  1045. },
  1046. failure: function( response, opts ) {
  1047. }
  1048. });
  1049. }
  1050. }]
  1051. }]
  1052. }]
  1053. });
  1054. tPanel.add({
  1055. columnWidth: 0.17,
  1056. title: 'Event Information',
  1057. frame: true,
  1058. id: 'prop_content',
  1059. border: false,
  1060. items: [{
  1061. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1062. }]
  1063. });
  1064. tPanel.doLayout();
  1065. map = L.map('event_map',{
  1066. attributionControl: true,
  1067. //preferCanvas: true,
  1068. zoomControl: true,
  1069. center: [SiteLat, SiteLon],
  1070. /*zoomControl: false,
  1071. zoom: 17,
  1072. minZoom: 17,
  1073. maxZoom: 17,*/
  1074. keyboard: false
  1075. }).setView([SiteLat, SiteLon], 17);
  1076. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1077. var mapLayers = [];
  1078. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1079. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1080. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1081. detectRetina: true
  1082. });*/
  1083. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1084. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1085. maxNativeZoom: 18,
  1086. maxZoom: 24,
  1087. })
  1088. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1089. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1090. 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',
  1091. maxZoom: 19
  1092. });
  1093. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1094. 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',
  1095. maxZoom: 19
  1096. });
  1097. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1098. 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',
  1099. maxZoom: 24
  1100. });
  1101. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1102. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1103. maxZoom: 19
  1104. });
  1105. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1106. 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>) ',
  1107. maxZoom: 19
  1108. });
  1109. /*
  1110. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1111. 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>',
  1112. maxZoom: 22
  1113. });
  1114. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1115. 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>',
  1116. maxZoom: 22
  1117. });
  1118. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1119. 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>',
  1120. maxZoom: 22
  1121. });
  1122. */
  1123. var baseMaps = {
  1124. "MyMap": mapLayers["MyMap"],
  1125. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1126. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1127. "EsriSat": mapLayers["EsriSat"],
  1128. "EsriStreet": mapLayers["EsriStreet"],
  1129. "EsriTopo": mapLayers["EsriTopo"],
  1130. //"Bing": mapLayers["Bing"],
  1131. //"OSM-Cycle": mapLayers["Cycle"],
  1132. //"Landscape": mapLayers["Landscape"],
  1133. //"Outdoor": mapLayers["Outdoor"],
  1134. };
  1135. L.control.layers( baseMaps ).addTo(map);
  1136. mapLayers["MyMap"].addTo(map);
  1137. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1138. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1139. maxNativeZoom: 18,
  1140. maxZoom: 24,
  1141. }).addTo(map); */
  1142. loadMapZones( SelectedSite );
  1143. tlInterval = window.setInterval( getData, 333, 'live' );
  1144. };
  1145. function loadOnlineMonitoring(devID){
  1146. var tPanel = Ext.getCmp('main_content');
  1147. if( tlInterval!= null ){
  1148. window.clearInterval( tlInterval );
  1149. tlInterval = null;
  1150. timelineObj = null;
  1151. };
  1152. tPanel.remove(0);
  1153. tPanel.add({
  1154. html: 'Device Monitoring '+devID
  1155. });
  1156. tPanel.doLayout();
  1157. };