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.

525 lines
13 KiB

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