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.

985 lines
28 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var monitoringViewLevel = 0;
  3. var mon_selectedEventId = 0;
  4. var mon_selectedPlatform = 0;
  5. var mon_selectedStation = 0;
  6. var mon_selectedTrack = 0;
  7. var mon_selectedModule = 0;
  8. var autoRiseEvent = true;
  9. var activeEvents = [];
  10. var expiredEvents = [];
  11. function imgLoadEvent(){
  12. alert('l c');
  13. };
  14. function createEventTagContent( a ){
  15. var gif='green_2.gif';
  16. var add=','+a.status;
  17. if( a.status == 0 ){
  18. gif='red_2.gif';
  19. };
  20. if( mon_selectedEventId == a.id ){
  21. return '<div id="event_tag_'+a.id+'"class="evt_side_tag_selected" onclick="selectEvent('+a.id+add+');"><table width="100%" border=0><tr><td colspan=2><div class="evt_side_stname">'+a.station_name+'</div></td><td width="18px"><img src="/style/assets/'+gif+'"></td></tr><tr><td><div class="evt_side_plname">'+a.id+' '+a.platform_name+'</div></td><td colspan=2><div class="level_label_title">'+a.track_tag+'</div></td></tr></div>';
  22. };
  23. return '<div id="event_tag_'+a.id+'"class="evt_side_tag" onclick="selectEvent('+a.id+add+');"><table width="100%" border=0><tr><td colspan=2><div class="evt_side_stname">'+a.station_name+'</div></td><td width="18px"><img src="/style/assets/'+gif+'"></td></tr><tr><td><div class="evt_side_plname">'+a.id+' '+a.platform_name+'</div></td><td colspan=2><div class="level_label_title">'+a.track_tag+'</div></td></tr></div>';
  24. };
  25. var GREEN_Icon = L.icon({
  26. iconUrl: '/style/assets/igr.png',
  27. iconSize: [44, 44],
  28. iconAnchor: [22, 22],
  29. popupAnchor: [0, -22]
  30. //shadowUrl: 'leaf-shadow.png',
  31. //shadowSize: [50, 64], // size of the shadow
  32. //shadowAnchor: [4, 62], // the same for the shadow
  33. });
  34. var RED_Icon = L.icon({
  35. iconUrl: '/style/assets/ira.png',
  36. iconSize: [44, 44],
  37. iconAnchor: [22, 22],
  38. popupAnchor: [0, -22]
  39. });
  40. var REDB_Icon = L.icon({
  41. iconUrl: '/style/assets/irabl.gif',
  42. iconSize: [44, 44],
  43. iconAnchor: [22, 22],
  44. popupAnchor: [0, -22]
  45. });
  46. var GREY_Icon = L.icon({
  47. iconUrl: '/style/assets/ign.png',
  48. iconSize: [44, 44],
  49. iconAnchor: [22, 22],
  50. popupAnchor: [0, -22]
  51. });
  52. var GREYN_Icon = L.icon({
  53. iconUrl: '/style/assets/ign.png',
  54. iconSize: [44, 44],
  55. iconAnchor: [22, 22],
  56. popupAnchor: [0, -22]
  57. });
  58. function makePtzMove( me ){
  59. var name = me.target.id;
  60. const myArray = name.split("_");
  61. Ext.Ajax.request({
  62. url: '/lib/controller/doModuleOperations.php',
  63. params: {
  64. UID: <?=$UserID;?>,
  65. SID: '<?=$Session;?>',
  66. OPID: 8,
  67. MID: myArray[3],
  68. MOV: myArray[2]
  69. },
  70. failure: failureAJAXFunction
  71. });
  72. };
  73. function makePtzStop( me ){
  74. var name = me.target.id;
  75. const myArray = name.split("_");
  76. Ext.Ajax.request({
  77. url: '/lib/controller/doModuleOperations.php',
  78. params: {
  79. SITE: <?=$SiteID;?>,
  80. UID: <?=$UserID;?>,
  81. SID: '<?=$Session;?>',
  82. OPID: 8,
  83. MID: myArray[3],
  84. MOV: 0
  85. },
  86. failure: failureAJAXFunction
  87. });
  88. };
  89. function makePtzHome( me ){
  90. var name = me.target.id;
  91. const myArray = name.split("_");
  92. Ext.Ajax.request({
  93. url: '/lib/controller/doModuleOperation.php',
  94. params: {
  95. SITE: <?=$SiteID;?>,
  96. UID: <?=$UserID;?>,
  97. SID: '<?=$Session;?>',
  98. OPID: 9,
  99. MID: myArray[3],
  100. MOV: 0
  101. },
  102. failure: failureAJAXFunction
  103. });
  104. };
  105. var fsDrawID = 0;
  106. function exitFullScreen( evt ){
  107. if( document.fullscreenElement ){
  108. } else {
  109. if( fsDrawID ){
  110. console.log("Leaving fullscreen mode.");
  111. };
  112. };
  113. };
  114. function fullScreen( id = '' ){
  115. if(
  116. id == '' ||
  117. document.fullscreenElement ||
  118. document.webkitFullscreenElement ||
  119. document.mozFullScreenElement ||
  120. document.msFullscreenElement
  121. ){
  122. if( document.exitFullscreen ){
  123. document.exitFullscreen();
  124. }else if( document.mozCancelFullScreen ){
  125. document.mozCancelFullScreen();
  126. }else if( document.webkitExitFullscreen ){
  127. document.webkitExitFullscreen();
  128. }else if( document.msExitFullscreen ){
  129. document.msExitFullscreen();
  130. };
  131. if( fsDrawID ){
  132. console.log('resized');
  133. };
  134. }else{
  135. var element = document.getElementById( id );
  136. if( element.requestFullscreen ){
  137. element.requestFullscreen();
  138. }else if( element.mozRequestFullScreen ){
  139. element.mozRequestFullScreen();
  140. }else if( element.webkitRequestFullscreen ){
  141. element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  142. }else if( element.msRequestFullscreen ){
  143. element.msRequestFullscreen();
  144. };
  145. };
  146. };
  147. function loadStationViewEvt( e ){
  148. loadStationView( e.target.options.mycustomid );
  149. };
  150. function loadStationView( STT, buba ){
  151. if( buba == undefined ){
  152. autoRiseEvent = false;
  153. } else {
  154. autoRiseEvent = buba;
  155. };
  156. if( mon_selectedEventId ) unselectEvent();
  157. changeContent( 1, 1, STT );
  158. updateUserContent();
  159. Ext.Ajax.request({
  160. url: '/lib/controller/getMonitoringStationView.php',
  161. params: {
  162. STT: STT,
  163. UID: <?=$UserID;?>,
  164. SID: '<?=$Session;?>'
  165. },
  166. success: function( response, opts ){
  167. var data = Ext.decode(response.responseText);
  168. if( data.status == 'ok' ){
  169. monitoringViewLevel = 1;
  170. Ext.getCmp('main_content').removeAll(true);
  171. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  172. Ext.getCmp('main_content').doLayout();
  173. if( data.pids != undefined ){
  174. if( data.pids.length > 0 ){
  175. //for( i=0; i<data.pids.length; i++ )correctPlatformView( data.pids[i] );
  176. };
  177. };
  178. fetchStatus();
  179. } else {
  180. if( data.status == 'steight' ){
  181. loadPlatformView( data.next_id );
  182. };
  183. };
  184. },
  185. failure: failureAJAXFunction
  186. });
  187. return;
  188. };
  189. function correctPlatformView( id ){
  190. var pp = Ext.getCmp('plat_panel_'+id);
  191. var pawi = pp.getWidth() / 70;
  192. var tt = document.getElementById('plat_table_'+id );
  193. if( tt != null ){
  194. tt.width = 36.5 * pawi +'px';
  195. };
  196. tt = Ext.getCmp('plat_schematics_'+id );
  197. if( tt != null ){
  198. tt.setHeight( 18 * pawi + 2 * 56 );
  199. };
  200. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(0).custom);
  201. if( tt != null ){
  202. tt.style.width = 16 * pawi +'px';
  203. tt.style.height = 9 * pawi +'px';
  204. };
  205. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(2).custom);
  206. if( tt != null ){
  207. tt.style.width = 16 * pawi +'px';
  208. tt.style.height = 9 * pawi +'px';
  209. };
  210. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(3).custom);
  211. if( tt != null ){
  212. tt.style.width = 16 * pawi +'px';
  213. tt.style.height = 9 * pawi +'px';
  214. };
  215. tt = document.getElementById('plat_video_'+id+'_'+pp.getComponent(4).custom);
  216. if( tt != null ){
  217. tt.style.width = 16 * pawi +'px';
  218. tt.style.height = 9 * pawi +'px';
  219. };
  220. };
  221. function correctModuleView( id ){
  222. var juja = Ext.getCmp('module_panel_'+id );
  223. var pawi = juja.getWidth() / 70;
  224. var tt = Ext.getCmp('module_schematics_'+id);
  225. tt.setWidth( 20+35 * pawi );
  226. tt.setHeight( 38+19 * pawi );
  227. tt = document.getElementById('plat_video_div_'+id );
  228. tt.style.width = 32 * pawi +'px';
  229. tt.style.height = 18 * pawi +'px';
  230. pawi = Ext.getCmp('plat_video_panel_'+id);
  231. pawi.setWidth( 32+32 * pawi);
  232. pawi.setHeight( 32+ 18 * pawi);
  233. };
  234. function addSetSessionUI( session_id ){
  235. Ext.Ajax.request({
  236. url: '/lib/controller/doSessionOperations.php',
  237. params: {
  238. SESSION: session_id,
  239. OPID: 2,
  240. OPAR: 0,
  241. UID: <?=$UserID;?>,
  242. SID: '<?=$Session;?>'
  243. },
  244. success: function( response, opts ){
  245. var data = Ext.decode(response.responseText);
  246. if( data.status == 'ok' ){
  247. var tv = Ext.getCmp('trx_view');
  248. if( tv != undefined ){
  249. var tt = Ext.getCmp('sets_ui');
  250. if( tt != undefined ){
  251. tv.remove( tt );
  252. };
  253. tv.add( Ext.decode( data.content ) );
  254. tv.doLayout();
  255. };
  256. };
  257. },
  258. failure: failureAJAXFunction
  259. });
  260. };
  261. function doSessionOperation( session_id, op, param, reload ){
  262. Ext.Ajax.request({
  263. url: '/lib/controller/doSessionOperations.php',
  264. params: {
  265. SESSION: session_id,
  266. OPID: op,
  267. OPAR: param,
  268. UID: <?=$UserID;?>,
  269. SID: '<?=$Session;?>'
  270. },
  271. success: function( response, opts ){
  272. var data = Ext.decode(response.responseText);
  273. if( data.status == 'ok' ){
  274. if( reload ){
  275. };
  276. };
  277. },
  278. failure: failureAJAXFunction
  279. });
  280. };
  281. function loadPlatformView( pid, buba ){
  282. if( buba == undefined ){
  283. autoRiseEvent = false;
  284. } else {
  285. autoRiseEvent = buba;
  286. };
  287. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  288. mon_selectedPlatform = pid;
  289. changeContent( 1, 2, pid );
  290. updateUserContent();
  291. Ext.Ajax.request({
  292. url: '/lib/controller/getMonitoringPlatformView.php',
  293. params: {
  294. PID: mon_selectedPlatform,
  295. UID: <?=$UserID;?>,
  296. SID: '<?=$Session;?>'
  297. },
  298. success: function( response, opts ){
  299. var data = Ext.decode(response.responseText);
  300. if( data.status == 'ok' ){
  301. monitoringViewLevel = 2;
  302. Ext.getCmp('main_content').removeAll(true);
  303. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  304. Ext.getCmp('main_content').doLayout();
  305. correctPlatformView( data.pid );
  306. fetchStatus();
  307. };
  308. },
  309. failure: failureAJAXFunction
  310. });
  311. return;
  312. };
  313. function loadTrackViewBySession( session_id ){
  314. autoRiseEvent = false;
  315. mSvgElements = [];
  316. Ext.Ajax.request({
  317. url: '/lib/controller/getMonitoringTrackView.php',
  318. params: {
  319. SESSION: session_id,
  320. UID: <?=$UserID;?>,
  321. SID: '<?=$Session;?>'
  322. },
  323. success: function( response, opts ){
  324. var data = Ext.decode(response.responseText);
  325. if( data.status == 'ok' ){
  326. monitoringViewLevel = 3;
  327. mon_selectedTrack = data.track_id;
  328. changeContent( 1, 3, mon_selectedTrack );
  329. updateUserContent();
  330. Ext.getCmp('main_content').removeAll(true);
  331. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  332. Ext.getCmp('main_content').doLayout();
  333. fetchStatus();
  334. };
  335. },
  336. failure: failureAJAXFunction
  337. });
  338. return;
  339. };
  340. function loadTrackView( tid ){
  341. autoRiseEvent = false;
  342. mon_selectedTrack = tid;
  343. changeContent( 1, 3, mon_selectedTrack );
  344. updateUserContent();
  345. mSvgElements = [];
  346. Ext.Ajax.request({
  347. url: '/lib/controller/getMonitoringTrackView.php',
  348. params: {
  349. TID: mon_selectedTrack,
  350. UID: <?=$UserID;?>,
  351. SID: '<?=$Session;?>'
  352. },
  353. success: function( response, opts ){
  354. var data = Ext.decode(response.responseText);
  355. if( data.status == 'ok' ){
  356. monitoringViewLevel = 3;
  357. mon_selectedPlatform = data.platform_id;
  358. mon_selectedStation = data.station_id;
  359. Ext.getCmp('main_content').removeAll(true);
  360. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  361. Ext.getCmp('main_content').doLayout();
  362. fetchStatus();
  363. };
  364. },
  365. failure: failureAJAXFunction
  366. });
  367. return;
  368. };
  369. function loadModuleView( pid, mid ){
  370. autoRiseEvent = false;
  371. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  372. changeContent( 1, 4, pid+'-'+mid );
  373. updateUserContent();
  374. Ext.Ajax.request({
  375. url: '/lib/controller/getMonitoringModuleView.php',
  376. params: {
  377. PID: pid,
  378. MID: mid,
  379. UID: <?=$UserID;?>,
  380. SID: '<?=$Session;?>'
  381. },
  382. success: function( response, opts ){
  383. var data = Ext.decode(response.responseText);
  384. if( data.status == 'ok' ){
  385. monitoringViewLevel = 4;
  386. Ext.getCmp('main_content').removeAll(true);
  387. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  388. Ext.getCmp('main_content').doLayout();
  389. correctModuleView( mid );
  390. fetchStatus();
  391. };
  392. },
  393. failure: failureAJAXFunction
  394. });
  395. return;
  396. };
  397. function loadMapView(){
  398. autoRiseEvent = false;
  399. if( mon_selectedEventId ) unselectEvent( mon_selectedEventId );
  400. Ext.Ajax.request({
  401. url: '/lib/controller/getMonitoringMapView.php',
  402. params: {
  403. UID: <?=$UserID;?>,
  404. SID: '<?=$Session;?>'
  405. },
  406. success: function( response, opts ){
  407. var data = Ext.decode(response.responseText);
  408. if( data.status == 'ok' ){
  409. monitoringViewLevel = 0;
  410. Ext.getCmp('main_content').removeAll(true);
  411. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  412. Ext.getCmp('main_content').doLayout();
  413. };
  414. },
  415. failure: failureAJAXFunction
  416. });
  417. return;
  418. };
  419. var monitoring_map = null;
  420. var c_icon = null;
  421. var stationMarkers = [];
  422. function initMonitoringMap( map_id, x, y ){
  423. var mapLayers = [];
  424. if( monitoring_map != null ){
  425. monitoring_map.off();
  426. monitoring_map.remove();
  427. monitoring_map = null;
  428. };
  429. monitoring_map = L.map( map_id,{
  430. crs: L.CRS.Simple,
  431. attributionControl: false,
  432. preferCanvas: true,
  433. zoomControl: true,
  434. center: [x,y],
  435. zoom: 0,
  436. minZoom: -3,
  437. maxZoom: 0,
  438. keyboard: false
  439. });
  440. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  441. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( monitoring_map );
  442. Ext.Ajax.request({
  443. url: '/lib/controller/listStations.php',
  444. params: {
  445. UID: <?=$UserID;?>,
  446. SID: '<?=$Session;?>'
  447. },
  448. success: function( response, opts ){
  449. var data = Ext.decode(response.responseText);
  450. if( data.status == 'ok' ){
  451. for( i=0; i < data.stations.length; i++ ){
  452. stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREY_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( monitoring_map ).on('click', loadStationViewEvt );;
  453. };
  454. };
  455. // Ready -> Start Getting data
  456. fetchStatus();
  457. },
  458. failure: failureAJAXFunction
  459. });
  460. };
  461. function getBackToMap(){
  462. autoRiseEvent = true;
  463. changeContent( 1, 0 );
  464. updateUserContent();
  465. loadMapView();
  466. };
  467. function initMonitoring( x, y ){
  468. if( tlInterval!= null ){
  469. window.clearInterval( tlInterval );
  470. tlInterval = null;
  471. timelineObj = null;
  472. };
  473. var tP = Ext.getCmp('left_side_menu');
  474. tP.removeAll( true );
  475. tP.add({
  476. layout:'vbox',
  477. frame: false,
  478. border: false,
  479. items:[{
  480. width: "100%",
  481. html: '<div class="mon_side_tag">Active Alerts</div>'
  482. },{
  483. id: 'sme_inner',
  484. layout:'vbox',
  485. width: "100%",
  486. height: PanelH/2,
  487. frame: false,
  488. border: false,
  489. items:[]
  490. },{
  491. width: "100%",
  492. html: '<div class="mon_side_tag">Expired Alerts</div>'
  493. },{
  494. id: 'sme_outer',
  495. layout:'vbox',
  496. width: "100%",
  497. height: PanelH/2,
  498. frame: false,
  499. border: true,
  500. items:[]
  501. }]
  502. });
  503. tP.doLayout();
  504. monitoringViewLevel = contentView.l[1].v;
  505. switch( monitoringViewLevel ){
  506. case 0:{
  507. loadMapView();
  508. break;
  509. };
  510. case 1:{
  511. loadStationView( parseInt( contentView.l[1].p ), autoRiseEvent );
  512. break;
  513. };
  514. case 2:{
  515. loadPlatformView( parseInt( contentView.l[1].p ), autoRiseEvent );
  516. break;
  517. };
  518. case 3:{
  519. loadTrackView( parseInt( contentView.l[1].p ), autoRiseEvent );
  520. break;
  521. };
  522. case 4:{
  523. var tA = contentView.l[1].p.split('-');
  524. a = parseInt( tA[0] );
  525. b = parseInt( tA[1] );
  526. loadModuleView( a, b );
  527. break;
  528. };
  529. case 5:{
  530. selectEvent( parseInt( contentView.l[1].p ), true );
  531. break;
  532. };
  533. };
  534. Ext.getCmp('main_content').doLayout();
  535. };
  536. var statusLTS = 0;
  537. var statusLID = 0;
  538. function manageSideTags( tag_area, buba ){
  539. var tP = Ext.getCmp( tag_area );
  540. if( tP != undefined ){
  541. if( buba != undefined ){
  542. if( buba.length ){
  543. var idx_a = 0;
  544. //alert( tag_area + ' has '+tP.items.getCount() );
  545. while( a = tP.getComponent( idx_a ) ){
  546. var f=false;
  547. for( var zz=0; zz < buba.length; zz++ ){
  548. if( a.getId() == 'tag_panel_'+buba[zz].id ){
  549. f = true;
  550. break;
  551. };
  552. };
  553. if( !f ) {
  554. tt--;
  555. tP.remove( a, true );
  556. } else idx_a++;
  557. };
  558. tP.doLayout();
  559. var aa = tP.items.getRange();
  560. var tt = aa.length;
  561. for( var zz=0; zz < buba.length; zz++ ){
  562. var f=false;
  563. for( var i=0; i < aa.length; i++ ){
  564. if( aa[i].getId() == 'tag_panel_'+buba[zz].id ){
  565. f = true;
  566. break;
  567. };
  568. };
  569. if( !f ){
  570. tP.insert( 0,{
  571. id: 'tag_panel_'+buba[zz].id,
  572. width: "100%",
  573. html: createEventTagContent( buba[zz] )
  574. });
  575. tt++;
  576. };
  577. if( tt > 32 ){
  578. tP.remove( aa[31], true );
  579. tt--;
  580. };
  581. };
  582. if( tag_area == 'sme_inner' ){
  583. // Active
  584. activeEvents = [];
  585. for( var zz=0; zz < buba.length; zz++ ) activeEvents[zz]={id: buba[zz].id};
  586. } else {
  587. // Expired
  588. expiredEvents = [];
  589. for( var zz=0; zz < buba.length; zz++ ) expiredEvents[zz]={id: buba[zz].id};
  590. };
  591. } else {
  592. tP.removeAll( true );
  593. if( tag_area == 'sme_inner' ){
  594. // Active
  595. activeEvents = [];
  596. } else {
  597. // Expired
  598. expiredEvents = [];
  599. };
  600. };
  601. } else {
  602. tP.removeAll( true );
  603. if( tag_area == 'sme_inner' ){
  604. // Active
  605. activeEvents = [];
  606. } else {
  607. // Expired
  608. expiredEvents = [];
  609. };
  610. };
  611. tP.doLayout();
  612. };
  613. };
  614. var mSvgElements = [];
  615. function fetchStatus(){
  616. if( tlInterval!= null ){
  617. window.clearTimeout( tlInterval );
  618. tlInterval = null;
  619. };
  620. switch(monitoringViewLevel){
  621. case 0:{
  622. var ll = monitoring_map.getCenter();
  623. CX = ll.lat;
  624. CY = ll.lng;
  625. ajax_params = {
  626. VLVL: monitoringViewLevel,
  627. UID: <?=$UserID;?>,
  628. SID: '<?=$Session;?>',
  629. LTS: statusLTS,
  630. LID: statusLID,
  631. MX: CX,
  632. MY: CY
  633. };
  634. break;
  635. };
  636. case 1:{
  637. ajax_params = {
  638. VLVL: monitoringViewLevel,
  639. UID: <?=$UserID;?>,
  640. SID: '<?=$Session;?>',
  641. LTS: statusLTS,
  642. LID: statusLID,
  643. SSID: mon_selectedStation
  644. };
  645. break;
  646. };
  647. case 2:{
  648. ajax_params = {
  649. VLVL: monitoringViewLevel,
  650. UID: <?=$UserID;?>,
  651. SID: '<?=$Session;?>',
  652. PID: mon_selectedPlatform,
  653. LTS: statusLTS,
  654. LID: statusLID
  655. };
  656. break;
  657. };
  658. case 3:{
  659. ajax_params = {
  660. VLVL: monitoringViewLevel,
  661. UID: <?=$UserID;?>,
  662. SID: '<?=$Session;?>',
  663. TID: mon_selectedTrack,
  664. LTS: statusLTS,
  665. LID: statusLID
  666. };
  667. break;
  668. };
  669. case 4:{
  670. ajax_params = {
  671. VLVL: monitoringViewLevel,
  672. UID: <?=$UserID;?>,
  673. SID: '<?=$Session;?>',
  674. MID: mon_selectedModule,
  675. LTS: statusLTS,
  676. LID: statusLID
  677. };
  678. break;
  679. };
  680. case 5:{
  681. ajax_params = {
  682. VLVL: monitoringViewLevel,
  683. UID: <?=$UserID;?>,
  684. SID: '<?=$Session;?>',
  685. SESSION: mon_selectedEventId,
  686. LTS: statusLTS,
  687. LID: statusLID
  688. };
  689. break;
  690. };
  691. };
  692. Ext.Ajax.request({
  693. url: '/lib/controller/getStatus.php',
  694. params: ajax_params,
  695. success: function( response, opts ){
  696. var data = Ext.decode(response.responseText);
  697. if( data.status == 'ok' ){
  698. if( monitoringViewLevel == data.VLVL ){
  699. statusLTS = data.LTS;
  700. //debugger;
  701. switch( monitoringViewLevel ){
  702. case 0:{
  703. for( i=0; i < data.station_ids.length; i++ ){
  704. switch( data.station_status[i] ){
  705. case 0: {
  706. if( stationMarkers[data.station_ids[i]].options.icon != GREY_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREY_Icon );
  707. break;
  708. };
  709. case 1: {
  710. if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon );
  711. break;
  712. };
  713. case 2: {
  714. if( stationMarkers[data.station_ids[i]].options.icon != GREY_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREY_Icon );
  715. break;
  716. };
  717. case 3: {
  718. if( ( Math.floor(Date.now() / 1000) % 2 ) == 0 ) {
  719. if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon );
  720. } else {
  721. if( stationMarkers[data.station_ids[i]].options.icon != RED_Icon ) stationMarkers[data.station_ids[i]].setIcon( RED_Icon );
  722. };
  723. break;
  724. };
  725. case 4: {
  726. if( stationMarkers[data.station_ids[i]].options.icon != REDB_Icon ) stationMarkers[data.station_ids[i]].setIcon( REDB_Icon );
  727. break;
  728. };
  729. };
  730. };
  731. break;
  732. };
  733. case 2:{
  734. if( data.modules != undefined ){
  735. for( var i=0; i< data.modules.length; i++){
  736. if( data.modules[i].status > 0 ){
  737. var tt = document.getElementById('plat_video_'+mon_selectedPlatform+'_'+data.modules[i].id );
  738. if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img;
  739. tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id );
  740. switch( data.modules[i].status ){
  741. case 1: tt.innerHTML='<img src="/style/assets/bul_gray.png">'; break;
  742. case 2: tt.innerHTML='<img src="/style/assets/bul_green.png">'; break;
  743. case 3: tt.innerHTML='<img src="/style/assets/bul_green_rst.png">'; break;
  744. };
  745. };
  746. };
  747. };
  748. if( data.events != undefined ){
  749. };
  750. if( data.scada != undefined ){
  751. };
  752. break;
  753. };
  754. case 3:{
  755. if( data.active_session_id != undefined ){
  756. if( mon_selectedEventId != data.active_session_id ){
  757. mon_selectedEventId = data.active_session_id;
  758. for( var zz=0; zz< activeEvents.length; zz++ ){
  759. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  760. if( tP != undefined ){
  761. tP.className ='';
  762. if( activeEvents[zz].id == mon_selectedEventId ){
  763. tP.classList.add("evt_side_tag_selected");
  764. } else {
  765. tP.classList.add("evt_side_tag");
  766. };
  767. };
  768. };
  769. addSetSessionUI( mon_selectedEventId );
  770. };
  771. };
  772. if( data.modules != undefined ){
  773. for( var i=0; i< data.modules.length; i++){
  774. if( data.modules[i].status > 0 ){
  775. var tt = document.getElementById('plat_video_img_'+data.modules[i].id );
  776. if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img;
  777. tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id );
  778. var tt = document.getElementById('cam_ctrl_'+data.modules[i].id );
  779. if( data.modules[i].status > 1 ) {
  780. if( tt.style.display != 'block' )tt.style.display = 'block';
  781. } else {
  782. if( tt.style.display != 'none' )tt.style.display = 'none';
  783. };
  784. };
  785. };
  786. };
  787. if( data.events != undefined ){
  788. var sid = data.events.length - 1;
  789. if( sid > -1 ){
  790. for( var i=0; i< max_grad_levels; i++ ){
  791. var cid = sid-i;
  792. var csize = getSize( i );
  793. //debugger;
  794. if( typeof mSvgElements[i] === 'undefined') {
  795. if( cid > -1 ){
  796. var svgns = "http://www.w3.org/2000/svg";
  797. mSvgElements[i] = document.createElementNS(svgns, 'rect');
  798. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  799. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  800. mSvgElements[i].setAttribute('height', ''+csize);
  801. mSvgElements[i].setAttribute('width', ''+csize);
  802. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  803. var tt = document.getElementById('svgTrackMap');
  804. var zz = document.getElementById('scheme_anch');
  805. tt.insertBefore( mSvgElements[i], zz );
  806. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  807. };
  808. } else {
  809. if( cid > -1 ){
  810. mSvgElements[i].setAttribute('x', data.events[cid].x+'%');
  811. mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  812. mSvgElements[i].setAttribute('height', ''+csize);
  813. mSvgElements[i].setAttribute('width', ''+csize);
  814. mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  815. } else {
  816. mSvgElements[i].setAttribute('fill', '#FF000000');
  817. };
  818. };
  819. };
  820. } else
  821. for( var i=0; i< max_grad_levels; i++ )
  822. if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000');
  823. };
  824. if( data.scada != undefined ){
  825. };
  826. break;
  827. };
  828. };
  829. manageSideTags('sme_inner', data.actual );
  830. manageSideTags('sme_outer', data.expired );
  831. };
  832. };
  833. tlInterval = window.setTimeout( fetchStatus, 333, selectedSite );
  834. },
  835. failure: failureAJAXFunction
  836. });
  837. };
  838. function selectEvent( ii, bb ){
  839. mon_selectedEventId = ii;
  840. if( tlInterval!= null ){
  841. window.clearTimeout( tlInterval );
  842. tlInterval = null;
  843. };
  844. for( var zz=0; zz< expiredEvents.length; zz++ ){
  845. var tP = document.getElementById('event_tag_'+expiredEvents[zz].id );
  846. if( tP != undefined ){
  847. tP.className ='';
  848. if( expiredEvents[zz].id == mon_selectedEventId ){
  849. tP.classList.add("evt_side_tag_selected");
  850. } else {
  851. tP.classList.add("evt_side_tag");
  852. };
  853. };
  854. };
  855. for( var zz=0; zz< activeEvents.length; zz++ ){
  856. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  857. if( tP != undefined ){
  858. tP.className ='';
  859. if( activeEvents[zz].id == mon_selectedEventId ){
  860. tP.classList.add("evt_side_tag_selected");
  861. } else {
  862. tP.classList.add("evt_side_tag");
  863. };
  864. };
  865. };
  866. if( bb ){
  867. loadMonitoringSessionView( ii );
  868. } else {
  869. loadTrackViewBySession( ii );
  870. };
  871. };
  872. function setSessionStatus( a , b ){
  873. Ext.Ajax.request({
  874. url: '/lib/controller/doSessionOperations.php',
  875. params: {
  876. SESSION: a,
  877. OPID: 2,
  878. OPAR: b,
  879. UID: <?=$UserID;?>,
  880. SID: '<?=$Session;?>'
  881. },
  882. success: function( response, opts ){
  883. var data = Ext.decode(response.responseText);
  884. if( data.status == 'ok' ){
  885. var tv = Ext.getCmp('trx_view');
  886. if( tv != undefined ){
  887. var tt = Ext.getCmp('sets_ui');
  888. if( tt != undefined ){
  889. tv.remove( tt );
  890. };
  891. tv.add( Ext.decode( data.content ) );
  892. tv.doLayout();
  893. };
  894. };
  895. },
  896. failure: failureAJAXFunction
  897. });
  898. };
  899. function unselectEvent( ii ){
  900. mon_selectedEventId = 0;
  901. for( var zz=0; zz< activeEvents.length; zz++ ){
  902. var tP = document.getElementById('event_tag_'+activeEvents[zz].id );
  903. if( tP != undefined ){
  904. tP.className ='';
  905. tP.classList.add("evt_side_tag");
  906. };
  907. };
  908. for( var zz=0; zz< expiredEvents.length; zz++ ){
  909. var tP = document.getElementById('event_tag_'+expiredEvents[zz].id );
  910. if( tP != undefined ){
  911. tP.className ='';
  912. tP.classList.add("evt_side_tag");
  913. };
  914. };
  915. };
  916. function loadMonitoringSessionView( session_id ){
  917. autoRiseEvent = false;
  918. mon_selectedEventId = session_id;
  919. changeContent( 1, 5, mon_selectedEventId );
  920. updateUserContent();
  921. Ext.Ajax.request({
  922. url: '/lib/controller/getMonitoringSessionView.php',
  923. params: {
  924. SESSION: mon_selectedEventId,
  925. UID: <?=$UserID;?>,
  926. SID: '<?=$Session;?>'
  927. },
  928. success: function( response, opts ){
  929. var data = Ext.decode(response.responseText);
  930. if( data.status == 'ok' ){
  931. monitoringViewLevel = 5;
  932. if( mSesPlay!= null ) {
  933. mSesPlay.dispose();
  934. mSesPlay = null;
  935. };
  936. Ext.getCmp('main_content').removeAll(true);
  937. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  938. Ext.getCmp('main_content').doLayout();
  939. mSesPlay = new argusSessionPlayer( mon_selectedEventId );
  940. fetchStatus();
  941. };
  942. },
  943. failure: failureAJAXFunction
  944. });
  945. };