Web Interface For Lite Argus Control modules
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.

514 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. function ssShowSS() {
  3. ssStopTimer();
  4. document.removeEventListener( "mousemove", ssResetTimer );
  5. document.removeEventListener( "mousedown", ssResetTimer );
  6. document.removeEventListener( "keypress", ssResetTimer );
  7. document.removeEventListener( "touchmove", ssResetTimer );
  8. document.addEventListener( "mousemove", ssHideSS, false );
  9. document.addEventListener( "mousedown", ssHideSS, false );
  10. document.addEventListener( "keypress", ssHideSS, false );
  11. document.addEventListener( "touchmove", ssHideSS, false );
  12. document.getElementById('ss_bg').className='ss_bg_overlay';
  13. document.getElementById('ss_content').className='ss_overlay';
  14. ssShowTime();
  15. if( ssInterval == null ){
  16. ssInterval = window.setInterval( ssShowTime, 333 );
  17. };
  18. ssIsActive = true;
  19. };
  20. function ssShowTime(){
  21. document.getElementById('ss_content').style.fontSize = '240px';
  22. var currentdate = new Date();
  23. var cTime = (( currentdate.getHours()<10 )? '0'+currentdate.getHours(): currentdate.getHours() ) + ":" + (( currentdate.getMinutes()<10 )? '0'+currentdate.getMinutes(): currentdate.getMinutes() ) + ":" + (( currentdate.getSeconds()<10 )? '0'+currentdate.getSeconds(): currentdate.getSeconds() );
  24. document.getElementById('ss_content').innerHTML= cTime;
  25. };
  26. function ssResetTimer() {
  27. ssStopTimer();
  28. ssStartTimer();
  29. };
  30. function ssStartTimer() {
  31. if( ssTimer == null ){
  32. ssTimer = window.setTimeout( ssShowSS, ssTimeOut );
  33. };
  34. };
  35. function ssStopTimer() {
  36. if( ssTimer ){
  37. window.clearTimeout( ssTimer );
  38. ssTimer = null;
  39. };
  40. };
  41. function ssSetupTimer() {
  42. document.addEventListener( "mousemove", ssResetTimer, false);
  43. document.addEventListener( "mousedown", ssResetTimer, false);
  44. document.addEventListener( "keypress", ssResetTimer, false);
  45. document.addEventListener( "touchmove", ssResetTimer, false);
  46. ssStartTimer();
  47. };
  48. function ssHideSS(){
  49. document.getElementById('ss_bg').className='ss_hidden';
  50. document.getElementById('ss_content').className='ss_hidden';
  51. document.removeEventListener( "mousemove", ssHideSS );
  52. document.removeEventListener( "mousedown", ssHideSS );
  53. document.removeEventListener( "keypress", ssHideSS );
  54. document.removeEventListener( "touchmove", ssHideSS );
  55. if( ssInterval != null ){
  56. window.clearInterval( ssInterval );
  57. ssInterval = null;
  58. };
  59. ssSetupTimer();
  60. ssIsActive = false;
  61. };
  62. var sndBeep = null;
  63. var sndExcl = null;
  64. function playSound( t ){
  65. if( SoundEnable ){
  66. switch( t ){
  67. case 1:{
  68. if( sndBeep == null ) sndBeep = new Howl({
  69. src: [
  70. '/style/assets/audio/beep-07a.mp3',
  71. '/style/assets/audio/beep-07a.wav'
  72. ],
  73. loop: false,
  74. volume: 0.99,
  75. onend: function() {
  76. //console.log('Finished!');
  77. }
  78. });
  79. sndBeep.volume( SoundMode / 3 );
  80. if( !sndBeep.playing() ) sndBeep.play();
  81. break;
  82. };
  83. default:{
  84. if( sndExcl == null ) sndExcl = new Howl({
  85. src: [
  86. '/style/assets/audio/button-42.mp3',
  87. '/style/assets/audio/button-42.wav'
  88. ],
  89. loop: false,
  90. volume: 0.99
  91. });
  92. sndExcl.volume( SoundMode / 3 );
  93. if( !sndExcl.playing() ) sndExcl.play();
  94. };
  95. };
  96. };
  97. };
  98. function doRefresh(){
  99. window.location="/?t="+123;
  100. };
  101. function doLogout(){
  102. window.location = '/login.php?UID=1';
  103. };
  104. function stopStatusUpdater(){
  105. if( tlInterval!= null ){
  106. window.clearInterval( tlInterval );
  107. tlInterval = null;
  108. };
  109. };
  110. function failureAJAXFunction( responce, opts ){
  111. if( tlInterval!= null ){
  112. window.clearInterval( tlInterval );
  113. tlInterval = null;
  114. };
  115. //playSound();
  116. //Ext.Msg.show({
  117. // title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
  118. // msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
  119. // buttons: Ext.Msg.OK,
  120. // icon: Ext.MessageBox.INFO
  121. //});
  122. doLogout();
  123. };
  124. function updateUserScreenResolution( x, y ){
  125. Ext.Ajax.request({
  126. url: '/lib/controller/updateUserSettings.php',
  127. params: {
  128. UID: <?=$UserID;?>,
  129. SID: '<?=$Session;?>',
  130. SSS: 15,
  131. WID: x,
  132. HEI: y
  133. },
  134. success: function( response, opts ){
  135. doRefresh();
  136. },
  137. failure: failureAJAXFunction
  138. });
  139. };
  140. function setUserContent( c_id ){
  141. initView = c_id;
  142. Ext.Ajax.request({
  143. url: '/lib/controller/updateUserSettings.php',
  144. params: {
  145. UID: <?=$UserID;?>,
  146. SID: '<?=$Session;?>',
  147. SSS: 26,
  148. CID: initView
  149. },
  150. success: function(){
  151. content_lvl0 = Math.floor( initView / 1000 );
  152. content_lvl1 = Math.floor( ( initView % 1000 )/ 100 );
  153. content_lvl2 = Math.floor( ( initView % 100 )/ 10 );
  154. content_lvl3 = initView % 10;
  155. },
  156. failure: failureAJAXFunction
  157. });
  158. };
  159. function updateUserContent(){
  160. cid = content_lvl3 + content_lvl2 * 10 + content_lvl1*100 + content_lvl0*1000;
  161. if( initView != cid ) {
  162. setUserContent( cid );
  163. return true;
  164. };
  165. return false;
  166. };
  167. var gSessionValidatorInterval = null;
  168. function sessionValidator(){
  169. Ext.Ajax.request({
  170. url: '/lib/controller/validateUserSession.php',
  171. params: {
  172. UID: <?=$UserID;?>,
  173. SID: '<?=$Session;?>'
  174. },
  175. success: function( response, opts ){
  176. var data = Ext.decode(response.responseText);
  177. if( !data.sessionIsValid ){
  178. playSound();
  179. Ext.Msg.show({
  180. title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
  181. msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
  182. buttons: Ext.Msg.OK,
  183. icon: Ext.MessageBox.INFO
  184. });
  185. doLogout();
  186. };
  187. },
  188. failure: failureAJAXFunction
  189. });
  190. };
  191. function doCheckWindowSize(){
  192. if (parseInt(navigator.appVersion)>3) {
  193. if (navigator.appName=="Netscape") {
  194. winW2 = window.innerWidth;
  195. winH2 = window.innerHeight;
  196. if ( winH2<700 ) winH2=700;
  197. };
  198. if (navigator.appName.indexOf("Microsoft")!=-1) {
  199. winW2 = document.body.offsetWidth;
  200. winH2 = document.body.offsetHeight;
  201. if ( winH2<700 ) winH2=700;
  202. };
  203. };
  204. if ( winW2 != winW || winH2!=winH ){
  205. updateUserScreenResolution( winW2, winH2 );
  206. };
  207. };
  208. var NotificationStack = null;
  209. function tryKeepScreenAlive(minutes) {
  210. navigator.wakeLock.request("screen").then(lock => {
  211. setTimeout(() => lock.release(), minutes * 60 * 1000);
  212. });
  213. }
  214. function showContent( cid ){
  215. var lvl0 = Math.floor( cid / 1000 );
  216. var lvl1 = Math.floor( ( cid % 1000 )/ 100 );
  217. var lvl2 = Math.floor( ( cid % 100 )/ 10 );
  218. var lvl3 = cid % 10;
  219. var refresh = ( lvl0 != content_lvl0 );
  220. if( lvl3 != content_lvl3 ){ content_lvl3 = lvl3; };
  221. if( lvl2 != content_lvl2 ){ content_lvl2 = lvl2; };
  222. if( lvl1 != content_lvl1 ){ content_lvl1 = lvl1; };
  223. if( lvl0 != content_lvl0 ){ content_lvl0 = lvl0; };
  224. updateUserContent();
  225. if( refresh ){
  226. switch( content_lvl0 ){
  227. case 0:{
  228. var tt = Ext.getCmp('tbtn_0');
  229. tt.toggle( true, true );
  230. tt = Ext.getCmp('tbtn_1');
  231. tt.toggle( false, true );
  232. tt = Ext.getCmp('tbtn_2');
  233. tt.toggle( false, true );
  234. var tP = Ext.getCmp('left_side_menu');
  235. tP.setVisible( false );
  236. var tZ = Ext.getCmp('right_side_menu');
  237. tZ.setVisible( false );
  238. initMonitoring();
  239. Ext.getCmp('main_viewport').doLayout();
  240. break;
  241. };
  242. case 1:{
  243. var tt = Ext.getCmp('tbtn_0');
  244. tt.toggle( false, true );
  245. tt = Ext.getCmp('tbtn_1');
  246. tt.toggle( true, true );
  247. tt = Ext.getCmp('tbtn_2');
  248. tt.toggle( false, true );
  249. var tP = Ext.getCmp('left_side_menu');
  250. tP.setVisible( true );
  251. var tZ = Ext.getCmp('right_side_menu');
  252. tZ.setVisible( false );
  253. initReportsView();
  254. Ext.getCmp('main_viewport').doLayout();
  255. break;
  256. };
  257. case 2:{
  258. var tt = Ext.getCmp('tbtn_0');
  259. tt.toggle( false, true );
  260. tt = Ext.getCmp('tbtn_1');
  261. tt.toggle( false, true );
  262. tt = Ext.getCmp('tbtn_2');
  263. tt.toggle( true, true );
  264. var tP = Ext.getCmp('left_side_menu');
  265. tP.setVisible( true );
  266. var tZ = Ext.getCmp('right_side_menu');
  267. tZ.setVisible( false );
  268. initSettingsView();
  269. Ext.getCmp('main_viewport').doLayout();
  270. break;
  271. };
  272. };
  273. };
  274. };
  275. Ext.onReady(function(){
  276. if ('wakeLock' in navigator) {
  277. // Screen Wake Lock API supported
  278. tryKeepScreenAlive(10);
  279. };
  280. doCheckWindowSize();
  281. loadSystemDevices();
  282. gSessionValidatorInterval = window.setInterval( sessionValidator, 1000 );
  283. NotificationStack = new PNotify.Stack({dir1: 'down', firstpos1: 25});
  284. //window.onresize = doCheckWindowSize;
  285. Ext.QuickTips.init();
  286. if( ssEnabled ){
  287. ssSetupTimer();
  288. $(window).focus(function() {
  289. ssResetTimer();
  290. });
  291. $(window).blur(function() {
  292. ssStopTimer();
  293. });
  294. };
  295. var viewport = new Ext.Viewport({
  296. id: 'main_viewport',
  297. layout:'border',
  298. frame: false,
  299. border: false,
  300. items: [{
  301. xtype: 'panel',
  302. region: 'north',
  303. baseCls: 'x-plain',
  304. height: 60,
  305. //layout: 'fit',
  306. layout: 'hbox',
  307. frame: false,
  308. border: false,
  309. items:[{
  310. xtype: 'panel',
  311. width: '100%',
  312. layout: 'table',
  313. baseCls: 'x-plain',
  314. layoutConfig: {
  315. columns: 13
  316. },
  317. frame: false,
  318. border: true,
  319. margins: {top:10, right:10, bottom:10, left:10},
  320. items:[{
  321. xtype: 'panel',
  322. baseCls: 'x-plain',
  323. frame: false,
  324. border: false,
  325. margins: {top:5, right:20, bottom:0, left:20},
  326. html: '<img src="/style/assets/argus_logo_text.png" height="42px">'
  327. },{
  328. xtype: 'spacer',
  329. width: 10
  330. },{
  331. xtype: 'button',
  332. text: '<?=$Labels->GetLabel('_MONITORING_');?>',
  333. id: 'tbtn_0',
  334. iconCls: 'mon',
  335. scale: 'large',
  336. enableToggle: true,
  337. //pressed: (Math.floor(initView/100)==0),
  338. allowDepress: false,
  339. toggleGroup: 'gopa_gopa',
  340. toggleHandler: function( bt, state ){
  341. if( state ) showContent( 0 );
  342. }
  343. },{
  344. xtype: 'spacer',
  345. width: 10
  346. },{
  347. xtype: 'button',
  348. text: '<?=$Labels->GetLabel('_REPO_HISTORY_');?>',
  349. id: 'tbtn_1',
  350. iconCls: 'rep',
  351. scale: 'large',
  352. enableToggle: true,
  353. //pressed: (Math.floor(initView/100)==1),
  354. allowDepress: false,
  355. toggleGroup: 'gopa_gopa',
  356. toggleHandler: function( bt, state ){
  357. if( state ) showContent( 1000 );
  358. }
  359. },{
  360. xtype: 'spacer',
  361. width: 10
  362. },{
  363. xtype: 'button',
  364. text: '<?=$Labels->GetLabel('_SETTINGS_');?>',
  365. id: 'tbtn_2',
  366. iconCls: 'cog',
  367. scale: 'large',
  368. enableToggle: true,
  369. allowDepress: false,
  370. toggleGroup: 'gopa_gopa',
  371. toggleHandler: function( bt, state ){
  372. if( state ) showContent( 2000 );
  373. }
  374. },{
  375. xtype: 'spacer',
  376. width: 10
  377. },{
  378. xtype: 'panel',
  379. baseCls: 'x-plain',
  380. frame: false,
  381. border: false,
  382. margins: {top:5, right:0, bottom:0, left:0},
  383. width: PanelW - <?=($AP_DATA['type'] == 1)?'700':'800';?>,
  384. html: '<p style="font-family: \'Ubuntu\', \'Arial\';font-size: 24px;">'+ap_title+'</p>'
  385. },{
  386. xtype: 'spacer',
  387. width: 10
  388. },<?php
  389. if( $AP_DATA['type'] == 1 ){
  390. ?>{
  391. xtype: 'button',
  392. id: 'logout_btn',
  393. text: 'Logout',
  394. iconCls: 'lout',
  395. scale: 'large',
  396. style:'text-align: right;',
  397. handler: doLogout
  398. }<?php
  399. } else {
  400. ?>{
  401. xtype: 'button',
  402. id: 'snd_mode_btn',
  403. text: '<?=$Labels->GetLabel('_SOUND_');?>',
  404. iconCls: 'snd'+SoundMode,
  405. scale: 'large',
  406. style:'text-align: right;',
  407. handler: function(){
  408. if( SoundMode == 0 ){
  409. SoundMode = 3;
  410. } else {
  411. SoundMode --;
  412. };
  413. Ext.getCmp('snd_mode_btn').setIconClass( 'snd'+SoundMode );
  414. playSound();
  415. }
  416. },{
  417. xtype: 'spacer',
  418. width: 10
  419. },{
  420. xtype: 'button',
  421. id: 'logout_btn',
  422. text: '<?=$Labels->GetLabel('_LOGOUT_');?>',
  423. iconCls: 'lout',
  424. scale: 'large',
  425. style:'text-align: right;',
  426. handler: doLogout
  427. }<?php
  428. };
  429. ?>
  430. ]
  431. }]
  432. },{
  433. xtype: 'panel',
  434. id:'left_side_menu',
  435. region:'west',
  436. bsaseCls:'x-plain',
  437. layout: 'fit',
  438. collapsible: true,
  439. split: true,
  440. width: 180,
  441. minWidth: 180,
  442. maxWidth: 180,
  443. hidden: (Math.floor(initView/100)==0),
  444. margins: '5 0 5 5',
  445. cmargins:'5 5 5 5',
  446. items: []
  447. },{
  448. xtype: 'panel',
  449. region:'center',
  450. margins: '5 5 5 0',
  451. id: 'main_content',
  452. //title: '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>',
  453. items:[{
  454. xtype: 'portal',
  455. id: 'main_portal',
  456. frame: false,
  457. border: false,
  458. items:{
  459. html: ''
  460. }//,
  461. //listeners:{
  462. // drop: function( a ){
  463. // updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
  464. // }
  465. //}
  466. }]
  467. },{
  468. xtype: 'panel',
  469. region:'east',
  470. id:'right_side_menu',
  471. //title: '',
  472. margins: '5 5 5 0',
  473. //id: 'help_content',
  474. frame: false,
  475. border: false,
  476. collapsible: false,
  477. split:true,
  478. width:200,
  479. minWidth: 150,
  480. maxWidth: 200,
  481. items:[]
  482. }]
  483. });
  484. showContent( initView );
  485. });