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.

519 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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=" + crypto.randomUUID();
  100. };
  101. function doLogout(){
  102. window.location = '/login.php?login=guest';//'/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. var cTS = (new Date())/1000;
  170. Ext.Ajax.request({
  171. url: '/lib/controller/validateUserSession.php',
  172. params: {
  173. UID: <?=$UserID;?>,
  174. SID: '<?=$Session;?>',
  175. CTS: cTS
  176. },
  177. success: function( response, opts ){
  178. var data = Ext.decode(response.responseText);
  179. if( !data.sessionIsValid ){
  180. playSound();
  181. Ext.Msg.show({
  182. title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
  183. msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
  184. buttons: Ext.Msg.OK,
  185. icon: Ext.MessageBox.INFO
  186. });
  187. doLogout();
  188. };
  189. },
  190. failure: failureAJAXFunction
  191. });
  192. };
  193. function doCheckWindowSize(){
  194. if (parseInt(navigator.appVersion)>3) {
  195. if (navigator.appName=="Netscape") {
  196. winW2 = window.innerWidth;
  197. winH2 = window.innerHeight;
  198. if ( winH2<700 ) winH2=700;
  199. };
  200. if (navigator.appName.indexOf("Microsoft")!=-1) {
  201. winW2 = document.body.offsetWidth;
  202. winH2 = document.body.offsetHeight;
  203. if ( winH2<700 ) winH2=700;
  204. };
  205. };
  206. if ( winW2 != winW || winH2!=winH ){
  207. updateUserScreenResolution( winW2, winH2 );
  208. };
  209. };
  210. var NotificationStack = null;
  211. function tryKeepScreenAlive(minutes) {
  212. navigator.wakeLock.request("screen").then(lock => {
  213. setTimeout(() => lock.release(), minutes * 60 * 1000);
  214. });
  215. }
  216. function showContent( cid ){
  217. var lvl0 = Math.floor( cid / 1000 );
  218. var lvl1 = Math.floor( ( cid % 1000 )/ 100 );
  219. var lvl2 = Math.floor( ( cid % 100 )/ 10 );
  220. var lvl3 = cid % 10;
  221. var refresh = ( lvl0 != content_lvl0 );
  222. if( lvl3 != content_lvl3 ){ content_lvl3 = lvl3; };
  223. if( lvl2 != content_lvl2 ){ content_lvl2 = lvl2; };
  224. if( lvl1 != content_lvl1 ){ content_lvl1 = lvl1; };
  225. if( lvl0 != content_lvl0 ){ content_lvl0 = lvl0; };
  226. updateUserContent();
  227. if( refresh ){
  228. switch( content_lvl0 ){
  229. case 0:{
  230. var tt = Ext.getCmp('tbtn_0');
  231. tt.toggle( true, true );
  232. tt = Ext.getCmp('tbtn_1');
  233. tt.toggle( false, true );
  234. tt = Ext.getCmp('tbtn_2');
  235. tt.toggle( false, true );
  236. var tP = Ext.getCmp('left_side_menu');
  237. tP.setVisible( false );
  238. var tZ = Ext.getCmp('right_side_menu');
  239. tZ.setVisible( false );
  240. //initMonitoring();
  241. Ext.getCmp('main_viewport').doLayout();
  242. break;
  243. };
  244. case 1:{
  245. var tt = Ext.getCmp('tbtn_0');
  246. tt.toggle( false, true );
  247. tt = Ext.getCmp('tbtn_1');
  248. tt.toggle( true, true );
  249. tt = Ext.getCmp('tbtn_2');
  250. tt.toggle( false, true );
  251. var tP = Ext.getCmp('left_side_menu');
  252. tP.setVisible( true );
  253. var tZ = Ext.getCmp('right_side_menu');
  254. tZ.setVisible( false );
  255. //initReportsView();
  256. Ext.getCmp('main_viewport').doLayout();
  257. break;
  258. };
  259. case 2:{
  260. var tt = Ext.getCmp('tbtn_0');
  261. tt.toggle( false, true );
  262. tt = Ext.getCmp('tbtn_1');
  263. tt.toggle( false, true );
  264. tt = Ext.getCmp('tbtn_2');
  265. tt.toggle( true, true );
  266. var tP = Ext.getCmp('left_side_menu');
  267. tP.setVisible( true );
  268. var tZ = Ext.getCmp('right_side_menu');
  269. tZ.setVisible( false );
  270. //initSettingsView();
  271. Ext.getCmp('main_viewport').doLayout();
  272. break;
  273. };
  274. };
  275. };
  276. };
  277. Ext.onReady(function(){
  278. if ('wakeLock' in navigator) {
  279. // Screen Wake Lock API supported
  280. tryKeepScreenAlive(10);
  281. };
  282. doCheckWindowSize();
  283. //loadSystemDevices();
  284. gSessionValidatorInterval = window.setInterval( sessionValidator, 1000 );
  285. NotificationStack = new PNotify.Stack({dir1: 'down', firstpos1: 25});
  286. //window.onresize = doCheckWindowSize;
  287. Ext.QuickTips.init();
  288. if( ssEnabled ){
  289. ssSetupTimer();
  290. $(window).focus(function() {
  291. ssResetTimer();
  292. });
  293. $(window).blur(function() {
  294. ssStopTimer();
  295. });
  296. };
  297. var viewport = new Ext.Viewport({
  298. id: 'main_viewport',
  299. layout:'border',
  300. frame: false,
  301. border: false,
  302. items: [{
  303. xtype: 'panel',
  304. region: 'north',
  305. baseCls: 'x-plain',
  306. height: 60,
  307. //layout: 'fit',
  308. layout: 'hbox',
  309. frame: false,
  310. border: false,
  311. items:[{
  312. xtype: 'panel',
  313. width: '100%',
  314. layout: 'table',
  315. baseCls: 'x-plain',
  316. layoutConfig: {
  317. columns: 13
  318. },
  319. frame: false,
  320. border: true,
  321. margins: {top:10, right:10, bottom:10, left:10},
  322. items:[{
  323. xtype: 'panel',
  324. baseCls: 'x-plain',
  325. frame: false,
  326. border: false,
  327. margins: {top:5, right:20, bottom:0, left:20},
  328. html: '<img src="/style/assets/argus_logo_text.png" height="42px">'
  329. },{
  330. xtype: 'spacer',
  331. width: 10
  332. },{
  333. xtype: 'button',
  334. text: '<?=$Labels->GetLabel('_MONITORING_');?>',
  335. id: 'tbtn_0',
  336. iconCls: 'mon',
  337. scale: 'large',
  338. enableToggle: true,
  339. //pressed: (Math.floor(initView/100)==0),
  340. allowDepress: false,
  341. toggleGroup: 'gopa_gopa',
  342. toggleHandler: function( bt, state ){
  343. if( state ) showContent( 0 );
  344. }
  345. },{
  346. xtype: 'spacer',
  347. width: 10
  348. },{
  349. xtype: 'button',
  350. text: '<?=$Labels->GetLabel('_REPO_HISTORY_');?>',
  351. id: 'tbtn_1',
  352. iconCls: 'rep',
  353. scale: 'large',
  354. enableToggle: true,
  355. //pressed: (Math.floor(initView/100)==1),
  356. allowDepress: false,
  357. toggleGroup: 'gopa_gopa',
  358. toggleHandler: function( bt, state ){
  359. if( state ) showContent( 1000 );
  360. }
  361. },{
  362. xtype: 'spacer',
  363. width: 10
  364. },{
  365. xtype: 'button',
  366. text: '<?=$Labels->GetLabel('_SETTINGS_');?>',
  367. id: 'tbtn_2',
  368. iconCls: 'cog',
  369. scale: 'large',
  370. enableToggle: true,
  371. allowDepress: false,
  372. toggleGroup: 'gopa_gopa',
  373. toggleHandler: function( bt, state ){
  374. if( state ) showContent( 2000 );
  375. }
  376. },{
  377. xtype: 'spacer',
  378. width: 10
  379. },{
  380. xtype: 'panel',
  381. baseCls: 'x-plain',
  382. frame: false,
  383. border: false,
  384. margins: {top:5, right:0, bottom:0, left:0},
  385. width: PanelW - <?=($AP_DATA['type'] == 1)?'700':'800';?>,
  386. html: '<p style="font-family: \'Ubuntu\', \'Arial\';font-size: 24px;">'+ap_title+'</p>'
  387. },{
  388. xtype: 'spacer',
  389. width: 10
  390. },<?php
  391. if( $AP_DATA['type'] == 1 ){
  392. ?>{
  393. xtype: 'button',
  394. id: 'logout_btn',
  395. text: 'Logout',
  396. iconCls: 'lout',
  397. scale: 'large',
  398. style:'text-align: right;',
  399. handler: doLogout
  400. }<?php
  401. } else {
  402. ?>{
  403. xtype: 'button',
  404. id: 'snd_mode_btn',
  405. text: '<?=$Labels->GetLabel('_SOUND_');?>',
  406. iconCls: 'snd'+SoundMode,
  407. scale: 'large',
  408. style:'text-align: right;',
  409. handler: function(){
  410. if( SoundMode == 0 ){
  411. SoundMode = 3;
  412. SoundEnable = true;
  413. } else {
  414. SoundMode --;
  415. if( SoundMode == 0 ) SoundEnable = false;
  416. };
  417. Ext.getCmp('snd_mode_btn').setIconClass( 'snd'+SoundMode );
  418. playSound();
  419. doApplicationOperation( 6, SoundMode );
  420. }
  421. },{
  422. xtype: 'spacer',
  423. width: 10
  424. },{
  425. xtype: 'button',
  426. id: 'logout_btn',
  427. text: '<?=$Labels->GetLabel('_LOGOUT_');?>',
  428. iconCls: 'lout',
  429. scale: 'large',
  430. style:'text-align: right;',
  431. handler: doLogout
  432. }<?php
  433. };
  434. ?>
  435. ]
  436. }]
  437. },{
  438. xtype: 'panel',
  439. id:'left_side_menu',
  440. region:'west',
  441. bsaseCls:'x-plain',
  442. layout: 'fit',
  443. collapsible: true,
  444. split: true,
  445. width: 180,
  446. minWidth: 180,
  447. maxWidth: 180,
  448. hidden: (Math.floor(initView/100)==0),
  449. margins: '5 0 5 5',
  450. cmargins:'5 5 5 5',
  451. items: []
  452. },{
  453. xtype: 'panel',
  454. region:'center',
  455. margins: '5 5 5 0',
  456. id: 'main_content',
  457. //title: '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>',
  458. items:[{
  459. xtype: 'portal',
  460. id: 'main_portal',
  461. frame: false,
  462. border: false,
  463. items:{
  464. html: ''
  465. }//,
  466. //listeners:{
  467. // drop: function( a ){
  468. // updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
  469. // }
  470. //}
  471. }]
  472. },{
  473. xtype: 'panel',
  474. region:'east',
  475. id:'right_side_menu',
  476. //title: '',
  477. margins: '5 5 5 0',
  478. //id: 'help_content',
  479. frame: false,
  480. border: false,
  481. collapsible: false,
  482. split:true,
  483. width:200,
  484. minWidth: 150,
  485. maxWidth: 200,
  486. items:[]
  487. }]
  488. });
  489. showContent( initView );
  490. });