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.

509 lines
12 KiB

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