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.

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