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.

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