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.

648 lines
16 KiB

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