Web UI for ARGUS server
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.

335 lines
14 KiB

5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../jscript_asm.php'); ?>
  2. var ChatModule;
  3. var ChatModuleEnabled = false;
  4. var ChatMode = 1;
  5. var SoundEnabled = true;
  6. var MessegesIntervalHandler;
  7. var WiFiNetworksWindow;
  8. var ChatPopUpWindow;
  9. var ChatForwardingWindow;
  10. var ChatQueryBusy = false;
  11. var ChatForwardingLoader;
  12. function PopUpChatForwarding(){
  13. if( !ChatForwardingLoader ){
  14. ChatForwardingLoader = new Ext.tree.TreeLoader({
  15. dataUrl: 'lib/connector/json/chat_device_list.php?UID='+UserID+'&SID='+SessionID+'&DID='+CDevID,
  16. baseAttrs:{
  17. expanded: true
  18. },
  19. listeners:{
  20. load: function( tre, tnode, response ){
  21. //alert('lib/connector/json/tracking_device_list.php?UID='+UserID+'&SID='+SessionID);
  22. //GMapToolbox.doLayout();
  23. //GMapToolbox.expand();
  24. if ( tnode.getPath() == InitTreeNodePath ){
  25. tnode.select();
  26. };
  27. }
  28. }
  29. });
  30. };
  31. if( !ChatForwardingWindow ){
  32. ChatForwardingWindow = new Ext.Window({
  33. title : "Forward Device Messeges",
  34. layout : 'fit',
  35. width : 300,
  36. height : 440,
  37. closeAction :'hide',
  38. items: new Ext.tree.TreePanel({
  39. id:'chat-dev-tree',
  40. title: "Chat Enabled Devices",
  41. frame: true,
  42. loader: ChatForwardingLoader,
  43. rootVisible: true,
  44. lines: true,
  45. autoScroll:true,
  46. root: new Ext.tree.AsyncTreeNode({
  47. text: '****',
  48. expanded: true
  49. })
  50. }),
  51. buttons: [{
  52. text: 'Apply Changes',
  53. handler: function(){
  54. A=ChatForwardingWindow.getComponent(0).getChecked('device_db_id');
  55. B='';
  56. for(i=0;i<A.length;i++){
  57. B = B+'|'+A[i];
  58. };
  59. Ext.Ajax.request({
  60. url: 'lib/connector/json/chat_forwarding.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID,
  61. success: function( response, opts ){
  62. ChatForwardingWindow.hide();
  63. },
  64. failure: function( response, opts ){
  65. },
  66. headers: {
  67. 'hnodes': B
  68. },
  69. params: {
  70. nodes: B
  71. }
  72. });
  73. }
  74. },{
  75. text: 'Cancel',
  76. handler: function(){
  77. ChatForwardingWindow.hide();
  78. }
  79. }]
  80. });
  81. };
  82. ChatForwardingWindow.show();
  83. ChatForwardingWindow.getComponent(0).getRootNode().setText(DevNMS[CDevID]);
  84. ChatForwardingWindow.getComponent(0).getLoader().dataUrl = 'lib/connector/json/chat_device_list.php?UID='+UserID+'&SID='+SessionID+'&DID='+CDevID;
  85. ChatForwardingWindow.getComponent(0).getRootNode().reload();
  86. };
  87. function PopUpChat(){
  88. if( !ChatPopUpWindow ){
  89. ChatPopUpWindow = new Ext.Window({
  90. title : "Chat History Window",
  91. layout : 'fit',
  92. width : 500,
  93. height : 400,
  94. closeAction :'hide',
  95. listeners: {
  96. hide: function(){
  97. //ChatMode = 1;
  98. //GetMesseges();
  99. }
  100. },
  101. plain : false,
  102. resizable : false,
  103. items : [ new Ext.Panel({
  104. id: 'chat_ext_module',
  105. tbar: [ {xtype: 'tbspacer'}, { xtype: 'tbtext', id: 'pc_dev', text: '', style: 'color: white; font-weight: bold;' }, '->'/*, {
  106. id: 'dis_ext_sound',
  107. text: '',
  108. iconCls: (( SoundEnabled )?'chat_mute_on_icon':'chat_mute_off_icon'),
  109. tooltip: 'Mute Sound Notification',
  110. handler: function(){
  111. if ( SoundEnabled ){
  112. Ext.Msg.show({
  113. title:'Disable Sound Notification',
  114. width: 500,
  115. msg: '<center>Are You Certain You Want To Do This ?<br/>The Emergency Event and Ne',
  116. buttons: Ext.Msg.YESNOCANCEL,
  117. fn: function(btn, text){
  118. if (btn == 'yes'){
  119. SoundEnabled = false;
  120. Ext.getCmp('dis_sound').setIconClass('chat_mute_off_icon');
  121. Ext.getCmp('dis_ext_sound').setIconClass('chat_mute_off_icon');
  122. } else {
  123. SoundEnabled = true;
  124. };
  125. },
  126. //animEl: 'elId',
  127. icon: Ext.MessageBox.QUESTION
  128. });
  129. if ( SoundEnabled ){
  130. niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/que.mp3');
  131. };
  132. } else {
  133. SoundEnabled = true;
  134. Ext.getCmp('dis_sound').setIconClass('chat_mute_on_icon');
  135. Ext.getCmp('dis_ext_sound').setIconClass('chat_mute_on_icon');
  136. };
  137. }
  138. } */],
  139. items: [{
  140. html: '<table width="100%" border=0 height="300px"><tr><td id="chat_calendar_TD" valign="top" width="140px"></td><td><div id="chat_ext_div" class="chat_ext_chat_class" style="height: 300px;"><div style="text-align: center; height: ' + ( PanelH - 390 ) + 'px; width: 100%; font-size: 12px; font-weight: bold; vertical-align: middle;"><br /><br />Loading Data ... <img src="/style/img/wait.gif"></div></div></td></tr></table>'
  141. }]
  142. })],
  143. buttonAlign: 'right',
  144. buttons: [ {
  145. id: 'chat_ffwd_wnd',
  146. text: 'Configure Forwaring',
  147. handler: function(){
  148. PopUpChatForwarding();
  149. }
  150. }]
  151. });
  152. };
  153. //ChatMode = 2;
  154. ChatPopUpWindow.show();
  155. Ext.getCmp('pc_dev').setText( DevNMS[CDevID] );
  156. StartCCalendarSession();
  157. //GetMesseges();
  158. };
  159. var PreviewTimer = null;
  160. var PreviewLP;
  161. var PreviewLZ;
  162. var PreviewICO = null;
  163. var PreviewMarker = null;
  164. function BeginPreviewWP(a,b){
  165. if( PreviewTimer ){
  166. window.clearTimeout( PreviewTimer );
  167. };
  168. if( !PreviewICO ){
  169. PreviewICO = new GIcon();
  170. PreviewICO.image = "resources/markers/pos.gif";
  171. PreviewICO.iconSize = new GSize(32,32);
  172. PreviewICO.iconAnchor = new GPoint(16,26);
  173. PreviewICO.infoWindowAnchor = new GPoint (0,16);
  174. };
  175. if( PreviewMarker ){
  176. map.removeOverlay( PreviewMarker );
  177. PreviewMarker = null;
  178. };
  179. PreviewMarker = new GMarker( new GLatLng( b/1000000, a/1000000 ) , {
  180. icon: PreviewICO,
  181. zIndexProcess: function(){
  182. return 281250;
  183. }
  184. });
  185. map.addOverlay( PreviewMarker );
  186. PreviewLP = map.getCenter();
  187. PreviewLZ = map.getZoom();
  188. map.setCenter( new GLatLng( b/1000000, a/1000000 ) , PreviewLZ );
  189. map.checkResize();
  190. //alert( ' coords:'+a+'x'+b );
  191. PreviewTimer = window.setTimeout('EndPreviewWP();', 5000 ); // 5Sec;
  192. };
  193. function EndPreviewWP(){
  194. window.clearTimeout( PreviewTimer );
  195. map.removeOverlay( PreviewMarker );
  196. PreviewMarker = null;
  197. map.setCenter( PreviewLP, PreviewLZ );
  198. PreviewTimer = null;
  199. };
  200. function GetMesseges(){
  201. if( !ChatQueryBusy ){
  202. ChatQueryBusy = true;
  203. window.clearTimeout( MessegesIntervalHandler );
  204. Ext.Ajax.abort();
  205. Ext.MessageBox.hide();
  206. Ext.Ajax.request({
  207. url: 'lib/connector/json/get_messages.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID +'&mode='+ChatMode,
  208. success: function( response, opts ){
  209. var obj = Ext.decode( response.responseText );
  210. if ( ChatMode == 1 ){
  211. var cdiv = document.getElementById('chat_div');
  212. } else {
  213. var cdiv = document.getElementById('chat_ext_div');
  214. };
  215. if ( cdiv ){
  216. var i = 0;
  217. var begin_in = '<div class="chat_msg_in"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
  218. var begin_out = '<div class="chat_msg_out"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
  219. var end = '</td><td class="chat_msg_23"></td></tr><tr><td class="chat_msg_31"></td><td class="chat_msg_32"></td><td class="chat_msg_33"></td></tr></table></div><div style="height: 3px;"><div>';
  220. cdiv.innerHTML = '';
  221. for( i=0; i< obj.rows.length; i++ ){
  222. if( obj.rows[i].src == 0 ){
  223. if ( obj.rows[i].status == 'R' ){
  224. status_t = '<img src="/style/img/wait.gif" title="Message Dispatched for Delivery">';
  225. } else {
  226. status_t = '<img src="/style/img/chat/new_g.gif" title="Message Was Sent to Device">';
  227. };
  228. cdiv.innerHTML += begin_out + '<div class="chat_msg_body"><img src="/style/img/chat/out.gif" title="Message to Device">' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
  229. } else {
  230. if ( obj.rows[i].status == 'R' ){
  231. if ( obj.rows[i].body == 'Emergency !!!') {
  232. if ( SoundEnabled ) niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/beep.mp3');
  233. Ext.Msg.show({
  234. title:'Emergency !!',
  235. msg: '<center>The device <b>' + DevNMS[ CDevID ] + '</b><br>Entered into Emergency Mode</center>',
  236. buttons: Ext.Msg.OK,
  237. width: 500,
  238. fn: function(){
  239. if ( SoundEnabled ){
  240. niftyplayer('niftyPlayer1').stop();
  241. };
  242. },
  243. //animEl: 'elId',
  244. icon: Ext.MessageBox.WARNING
  245. });
  246. } else {
  247. if ( SoundEnabled ) niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/ndr.mp3');
  248. };
  249. status_t = '<img src="/style/img/chat/new.gif">';
  250. } else {
  251. status_t = '<img src="/style/img/chat/new_g.gif">';
  252. };
  253. if( ( obj.rows[i].lat != 0 ) && ( obj.rows[i].lon != 0 ) ){
  254. status_t += '&nbsp;<a href="#" onclick="BeginPreviewWP('+obj.rows[i].lon+','+obj.rows[i].lat+');" title="Show Position On Map"><img border=0 src="/style/img/chat/onmap.gif"></a>';
  255. } else {
  256. status_t += '&nbsp;<a href="#" title="No Position Information"><img src="/style/img/chat/onmap_g.gif"></a>';
  257. };
  258. cdiv.innerHTML += begin_in + '<div class="chat_msg_body"><img src="/style/img/chat/in.gif" title="Message from Device">' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
  259. };
  260. };
  261. };
  262. ChatQueryBusy = false;
  263. if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();',20000);
  264. },
  265. failure: function( response, opts ){
  266. ChatQueryBusy = false;
  267. //Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00225');
  268. if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();', 1000);
  269. }/*,
  270. headers: {
  271. 'my-header': 'foo'
  272. },
  273. params: { foo: 'bar' }*/
  274. });
  275. };
  276. };
  277. function GetHistoryMesseges(){
  278. //if( !ChatQueryBusy ){
  279. //ChatQueryBusy = true;
  280. //window.clearTimeout( MessegesIntervalHandler );
  281. Ext.Ajax.abort();
  282. Ext.MessageBox.hide();
  283. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Histo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  284. width: '100%',
  285. hidden: true,
  286. progress: true,
  287. closable: false
  288. });
  289. Ext.Ajax.request({
  290. url: 'lib/connector/json/get_messages_history.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID +'&mode='+ChatMode + '&M=' + SM + '&D=' + SD + '&Y=' + SY,
  291. success: function( response, opts ){
  292. var obj = Ext.decode( response.responseText );
  293. var cdiv = document.getElementById('chat_ext_div');
  294. if ( cdiv ){
  295. var i = 0;
  296. var begin_in = '<div class="chat_msg_in"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
  297. var begin_out = '<div class="chat_msg_out"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
  298. var end = '</td><td class="chat_msg_23"></td></tr><tr><td class="chat_msg_31"></td><td class="chat_msg_32"></td><td class="chat_msg_33"></td></tr></table></div><div style="height: 3px;"><div>';
  299. cdiv.innerHTML = '';
  300. for( i=0; i< obj.rows.length; i++ ){
  301. if( obj.rows[i].src == 0 ){
  302. if ( obj.rows[i].status == 'R' ){
  303. status_t = '<img src="/style/img/wait.gif" title="Message Dispatched for Delivery">';
  304. } else {
  305. status_t = '<img src="/style/img/chat/new_g.gif" title="Message Was Sent to Device">';
  306. };
  307. cdiv.innerHTML += begin_out + '<div class="chat_msg_body"><img src="/style/img/chat/out.gif" title="Message to Device">' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
  308. } else {
  309. if ( obj.rows[i].status == 'R' ){
  310. status_t = '<img src="/style/img/chat/new.gif">';
  311. } else {
  312. status_t = '<img src="/style/img/chat/new_g.gif">';
  313. };
  314. cdiv.innerHTML += begin_in + '<div class="chat_msg_body"><img src="/style/img/chat/in.gif" title="Message from Device">' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
  315. };
  316. };
  317. };
  318. //ChatQueryBusy = false;
  319. //if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();',20000);
  320. Ext.MessageBox.hide();
  321. },
  322. failure: function( response, opts ){
  323. //ChatQueryBusy = false;
  324. //Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>Code: CENDL00225');
  325. //if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();', 1000);
  326. Ext.MessageBox.hide();
  327. }
  328. });
  329. //};
  330. };