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.

467 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: c_id
  145. },
  146. failure: failureAJAXFunction
  147. });
  148. };
  149. function updateUserContent(){
  150. cid = content_lvl3 + content_lvl2 * 10 + content_lvl1*100 + content_lvl0*1000;
  151. 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. ssSetupTimer();
  254. $(window).focus(function() {
  255. ssResetTimer();
  256. });
  257. $(window).blur(function() {
  258. ssStopTimer();
  259. });
  260. var viewport = new Ext.Viewport({
  261. id: 'main_viewport',
  262. layout:'border',
  263. frame: false,
  264. border: false,
  265. items: [{
  266. xtype: 'panel',
  267. region: 'north',
  268. baseCls: 'x-plain',
  269. height: 60,
  270. layout: 'hbox',
  271. frame: false,
  272. border: false,
  273. items:[{
  274. xtype: 'panel',
  275. width: 600,
  276. layout: 'hbox',
  277. baseCls: 'x-plain',
  278. frame: false,
  279. border: false,
  280. margins: {top:10, right:10, bottom:10, left:10},
  281. items:[{
  282. xtype: 'panel',
  283. baseCls: 'x-plain',
  284. frame: false,
  285. border: false,
  286. margins: {top:5, right:20, bottom:0, left:10},
  287. html: '<img src="/style/assets/argus_logo_text.png" height="42px">'
  288. },{
  289. xtype: 'button',
  290. text: '<?=$Labels->GetLabel('_MONITORING_');?>',
  291. id: 'tbtn_0',
  292. iconCls: 'mon',
  293. scale: 'large',
  294. enableToggle: true,
  295. //pressed: (Math.floor(initView/100)==0),
  296. allowDepress: false,
  297. toggleGroup: 'gopa_gopa',
  298. toggleHandler: function( bt, state ){
  299. if( state ) showContent( 0 );
  300. }
  301. },{
  302. xtype: 'spacer',
  303. width: 10
  304. },{
  305. xtype: 'button',
  306. text: '<?=$Labels->GetLabel('_REPO_HISTORY_');?>',
  307. id: 'tbtn_1',
  308. iconCls: 'rep',
  309. scale: 'large',
  310. enableToggle: true,
  311. //pressed: (Math.floor(initView/100)==1),
  312. allowDepress: false,
  313. toggleGroup: 'gopa_gopa',
  314. toggleHandler: function( bt, state ){
  315. if( state ) showContent( 1000 );
  316. }
  317. },{
  318. xtype: 'spacer',
  319. width: 10
  320. },{
  321. xtype: 'button',
  322. text: '<?=$Labels->GetLabel('_SETTINGS_');?>',
  323. id: 'tbtn_2',
  324. iconCls: 'cog',
  325. scale: 'large',
  326. enableToggle: true,
  327. //pressed: (Math.floor(initView/100)==2),
  328. allowDepress: false,
  329. toggleGroup: 'gopa_gopa',
  330. toggleHandler: function( bt, state ){
  331. if( state ) showContent( 2000 );
  332. }
  333. }]
  334. },{
  335. xtype: 'panel',
  336. baseCls: 'x-plain',
  337. frame: false,
  338. border: false,
  339. margins: {top:5, right:0, bottom:0, left:0},
  340. html: '<p style="font-family: \'Ubuntu\';font-size: 24px;">'+ap_title+'</p>',
  341. flex: 1
  342. },{
  343. xtype: 'panel',
  344. layout: 'fit',
  345. baseCls: 'x-plain',
  346. frame: false,
  347. border: false,
  348. margins: {top:10, right:10, bottom:10, left:10},
  349. items:[<?php
  350. if( $AP_DATA['type'] == 1 ){
  351. ?>{
  352. xtype: 'button',
  353. id: 'logout_btn',
  354. text: 'Logout',
  355. iconCls: 'lout',
  356. scale: 'large',
  357. handler: doLogout
  358. }<?php
  359. } else {
  360. ?>{
  361. xtype: 'button',
  362. id: 'snd_mode_btn',
  363. text: 'Sound',
  364. iconCls: 'snd'+SoundMode,
  365. scale: 'large',
  366. handler: function(){
  367. if( SoundMode == 0 ){
  368. SoundMode = 3;
  369. } else {
  370. SoundMode --;
  371. };
  372. Ext.getCmp('snd_mode_btn').setIconClass( 'snd'+SoundMode );
  373. }
  374. }<?php
  375. };
  376. ?>]
  377. }]
  378. },{
  379. xtype: 'panel',
  380. id:'left_side_menu',
  381. region:'west',
  382. bsaseCls:'x-plain',
  383. //title: '<?=$Labels->GetLabel('_SEC_SYSTEM_');?>',
  384. collapsible: true,
  385. split:true,
  386. width:180,
  387. minWidth: 180,
  388. maxWidth: 180,
  389. hidden: (Math.floor(initView/100)==0),
  390. layout:'accordion',
  391. margins: '5 0 5 5',
  392. cmargins:'5 5 5 5',
  393. layoutConfig:{
  394. animate: true//,
  395. //activeOnTop: true
  396. },
  397. items: []
  398. },{
  399. xtype: 'panel',
  400. region:'center',
  401. margins: '5 5 5 0',
  402. id: 'main_content',
  403. //title: '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>',
  404. items:[{
  405. xtype: 'portal',
  406. id: 'main_portal',
  407. frame: false,
  408. border: false,
  409. items:{
  410. html: ''
  411. }//,
  412. //listeners:{
  413. // drop: function( a ){
  414. // updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
  415. // }
  416. //}
  417. }]
  418. },{
  419. xtype: 'panel',
  420. region:'east',
  421. id:'right_side_menu',
  422. //title: '',
  423. margins: '5 5 5 0',
  424. //id: 'help_content',
  425. frame: false,
  426. border: false,
  427. collapsible: false,
  428. split:true,
  429. width:200,
  430. minWidth: 150,
  431. maxWidth: 200,
  432. items:[]
  433. }]
  434. });
  435. showContent( initView );
  436. });