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.

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