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.
 
 
 
 

649 lines
16 KiB

//<?php require_once('../../js_asm.php'); ?>
function uuidv4() {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
function ssShowSS() {
if( monitoringActiveSession ){
ssResetTimer();
return;
};
ssStopTimer();
document.removeEventListener( "mousemove", ssResetTimer );
document.removeEventListener( "mousedown", ssResetTimer );
document.removeEventListener( "keypress", ssResetTimer );
document.removeEventListener( "touchmove", ssResetTimer );
document.addEventListener( "mousemove", ssHideSS, false );
document.addEventListener( "mousedown", ssHideSS, false );
document.addEventListener( "keypress", ssHideSS, false );
document.addEventListener( "touchmove", ssHideSS, false );
document.getElementById('ss_bg').className='ss_bg_overlay';
document.getElementById('ss_content').className='ss_overlay';
ssShowTime();
updateSSMode( 1 );
changeContent(0,0,'');
updateUserContent();
showContent();
if( ssInterval == null ){
ssInterval = window.setInterval( ssShowTime, 333 );
};
ssIsActive = true;
autoRiseEvent = true;
};
function ssShowTime(){
document.getElementById('ss_content').style.fontSize = '240px';
var currentdate = new Date();
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() );
document.getElementById('ss_content').innerHTML= cTime;
};
function ssResetTimer() {
ssStopTimer();
ssStartTimer();
};
function ssStartTimer() {
if( ssTimer == null ){
ssTimer = window.setTimeout( ssShowSS, ssTimeOut );
};
};
function ssStopTimer() {
if( ssTimer ){
window.clearTimeout( ssTimer );
ssTimer = null;
};
};
function ssSetupTimer() {
document.addEventListener( "mousemove", ssResetTimer, false);
document.addEventListener( "mousedown", ssResetTimer, false);
document.addEventListener( "keypress", ssResetTimer, false);
document.addEventListener( "touchmove", ssResetTimer, false);
ssStartTimer();
};
function ssHideSS(){
document.getElementById('ss_bg').className='ss_hidden';
document.getElementById('ss_content').className='ss_hidden';
document.removeEventListener( "mousemove", ssHideSS );
document.removeEventListener( "mousedown", ssHideSS );
document.removeEventListener( "keypress", ssHideSS );
document.removeEventListener( "touchmove", ssHideSS );
if( ssInterval != null ){
window.clearInterval( ssInterval );
ssInterval = null;
};
updateSSMode( 0 );
ssIsActive = true;
autoRiseEvent = true;
var tt = Ext.getCmp('aer_button');
if( tt != undefined ){
tt.toggle( true, true );
} else doRefresh();
ssSetupTimer();
ssIsActive = false;
};
var sndBeep = null;
var sndExcl = null;
function playSound( t ){
if( SoundEnable ){
switch( t ){
case 1:{
if( sndBeep == null ) sndBeep = new Howl({
src: [
'/style/assets/audio/beep-07a.mp3',
'/style/assets/audio/beep-07a.wav'
],
loop: false,
volume: 0.99,
onend: function() {
//console.log('Finished!');
}
});
sndBeep.volume( SoundMode / 3 );
if( !sndBeep.playing() ) sndBeep.play();
break;
};
default:{
if( sndExcl == null ) sndExcl = new Howl({
src: [
'/style/assets/audio/button-42.mp3',
'/style/assets/audio/button-42.wav'
],
loop: false,
volume: 0.99
});
sndExcl.volume( SoundMode / 3 );
if( !sndExcl.playing() ) sndExcl.play();
};
};
};
};
function doRefresh(){
window.location="/?t=" + uuidv4();//crypto.randomUUID();
};
function doLogout(){
window.location = '/login.php?login=guest';//'/login.php?UID=1';
};
function stopStatusUpdater(){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
};
};
function failureAJAXFunction( responce, opts ){
//if( tlInterval!= null ){
// window.clearInterval( tlInterval );
// tlInterval = null;
// };
//playSound();
//Ext.Msg.show({
// title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
// msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
// buttons: Ext.Msg.OK,
// icon: Ext.MessageBox.INFO
// });
//doLogout();
};
function doCheckHeap(){
if( performance != undefined ){
if( performance.memory != undefined ){
cMV = performance.memory;
//console.log( cMV.totalJSHeapSize );
if( cMV.totalJSHeapSize > MemCheckMaxHS ) doRefresh();
if( tlMemCheckInterval == null ){
tlMemCheckInterval = window.setInterval( doCheckHeap, 3000 );
};
};
};
if (performance.measureUserAgentSpecificMemory) {
try {
const memorySample = performance.measureUserAgentSpecificMemory();
console.log(`Total page memory usage: ${memorySample.bytes} bytes`);
} catch (error) {
console.error("Measurement failed:", error);
};
};
};
function doUserOperation( OPId, Param, reload ){
Ext.Ajax.request({
url: '/lib/controller/updateUserSettings.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
SSS: OPId,
CID: Param
},
success: function( response, opts ){
if( reload ) doRefresh();
},
failure: failureAJAXFunction
});
};
function updateUserScreenResolution( x, y ){
Ext.Ajax.request({
url: '/lib/controller/updateUserSettings.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
SSS: 15,
WID: x,
HEI: y
},
success: function( response, opts ){
doRefresh();
},
failure: failureAJAXFunction
});
};
//var contentChangesCount = 0;
function updateUserContent(){
var ser_c = Ext.encode( contentView );
if( contentViewConfig != ser_c ) {
Ext.Ajax.request({
url: '/lib/controller/updateUserSettings.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
SSS: 26,
CID: ser_c
},
success: function(){
contentViewConfig = ser_c;
//Handle Memory by Checking Heap Sizes in Timer Function
//contentChangesCount++;
//if( contentChangesCount%5== 0 ) doRefresh();
},
failure: failureAJAXFunction
});
return true;
};
return false;
};
if( contentView.l == undefined ){
contentView.l =[];
contentView.l[0] = { v: 0, p: '' };
contentView.l[1] = { v: 0, p: '' };
contentView.l[2] = { v: 0, p: '' };
contentView.l[3] = { v: 0, p: '' };
updateUserContent();
};
function updateSSMode( mode ){
Ext.Ajax.request({
url: '/lib/controller/updateUserSettings.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
SSS: 27,
CID: mode
}
});
};
var gSessionValidatorInterval = null;
function sessionValidator(){
var cTS = (new Date())/1000;
Ext.Ajax.request({
url: '/lib/controller/validateUserSession.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
CTS: cTS
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( !data.sessionIsValid ){
playSound();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
doLogout();
};
},
failure: failureAJAXFunction
});
};
function doCheckWindowSize(){
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
winW2 = window.innerWidth;
winH2 = window.innerHeight;
if ( winH2<700 ) winH2=700;
};
if (navigator.appName.indexOf("Microsoft")!=-1) {
winW2 = document.body.offsetWidth;
winH2 = document.body.offsetHeight;
if ( winH2<700 ) winH2=700;
};
};
if ( winW2 != winW || winH2!=winH ){
updateUserScreenResolution( winW2, winH2 );
};
};
var NotificationStack = null;
function tryKeepScreenAlive(minutes) {
navigator.wakeLock.request("screen").then(lock => {
setTimeout(() => lock.release(), minutes * 60 * 1000);
});
}
function changeContent( lvl, ctx, param ){
if( lvl <= contentView.l.length ){
for( i = 0; i< contentView.l.length; i++){
if( i == lvl ){
contentView.l[i].p = param;
contentView.l[i].v = ctx;
} else if( i > lvl ) {
contentView.l[i].p = '';
contentView.l[i].v = 0;
};
};
} else {
contentView.l[lvl]={
v: ctx,
p: ''
};
};
};
function showContent( force ){
if( force || updateUserContent() ){
switch( contentView.l[0].v ){
case 0:{
if( mSesPlay!= null ) {
mSesPlay.dispose();
mSesPlay = null;
};
var tt = Ext.getCmp('tbtn_0');
tt.toggle( true, true );
tt = Ext.getCmp('tbtn_1');
tt.toggle( false, true );
tt = Ext.getCmp('tbtn_2');
tt.toggle( false, true );
var tP = Ext.getCmp('left_side_menu');
tP.setVisible( true );
var tZ = Ext.getCmp('right_side_menu');
tZ.setVisible( false );
initMonitoring();
Ext.getCmp('main_viewport').doLayout();
break;
};
case 1:{
if( mSesPlay!= null ) {
mSesPlay.dispose();
mSesPlay = null;
};
var tt = Ext.getCmp('tbtn_0');
tt.toggle( false, true );
tt = Ext.getCmp('tbtn_1');
tt.toggle( true, true );
tt = Ext.getCmp('tbtn_2');
tt.toggle( false, true );
var tP = Ext.getCmp('left_side_menu');
tP.setVisible( true );
var tZ = Ext.getCmp('right_side_menu');
tZ.setVisible( false );
initReportsView();
Ext.getCmp('main_viewport').doLayout();
break;
};
case 2:{
if( mSesPlay!= null ) {
mSesPlay.dispose();
mSesPlay = null;
};
var tt = Ext.getCmp('tbtn_0');
tt.toggle( false, true );
tt = Ext.getCmp('tbtn_1');
tt.toggle( false, true );
tt = Ext.getCmp('tbtn_2');
tt.toggle( true, true );
var tP = Ext.getCmp('left_side_menu');
tP.setVisible( true );
var tZ = Ext.getCmp('right_side_menu');
tZ.setVisible( false );
initSettingsView();
Ext.getCmp('main_viewport').doLayout();
break;
};
};
};
};
function loadHelpTopic( cid, htopic ){
Ext.Ajax.request({
url: '/lib/controller/getHelpTopic.php',
params: {
HID: htopic,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( data.status == 'ok' ){
var tPanel = Ext.getCmp( cid );
var res = Ext.decode( data.content );
tPanel.removeAll( true );
tPanel.add( res );
tPanel.doLayout();
};
},
failure: failureAJAXFunction
});
};
Ext.onReady(function(){
if( 'wakeLock' in navigator ) tryKeepScreenAlive(10);
doCheckHeap();
doCheckWindowSize();
if( <?=intval($CUser->Data['ss_mode']);?> == 1 ) ssShowSS();
gSessionValidatorInterval = window.setInterval( sessionValidator, 5000 );
NotificationStack = new PNotify.Stack({dir1: 'down', firstpos1: 25});
//window.onresize = doCheckWindowSize;
Ext.QuickTips.init();
if( ssEnabled ){
ssSetupTimer();
$(window).focus(function() {
ssResetTimer();
});
$(window).blur(function() {
ssStopTimer();
});
};
var viewport = new Ext.Viewport({
id: 'main_viewport',
layout:'border',
frame: false,
border: false,
items: [{
xtype: 'panel',
region: 'north',
baseCls: 'x-plain',
height: 60,
//layout: 'fit',
layout: 'hbox',
frame: false,
border: false,
items:[{
xtype: 'panel',
width: '100%',
layout: 'table',
baseCls: 'x-plain',
layoutConfig: {
columns: 13
},
frame: false,
border: true,
margins: {top:10, right:10, bottom:10, left:10},
items:[{
xtype: 'panel',
baseCls: 'x-plain',
frame: false,
border: false,
margins: {top:5, right:20, bottom:0, left:20},
html: '<img src="/style/assets/argus_logo_text.png" height="42px">'
},{
xtype: 'spacer',
width: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel('_MONITORING_');?>',
id: 'tbtn_0',
iconCls: 'mon',
scale: 'large',
enableToggle: true,
//pressed: (Math.floor(initView/100)==0),
allowDepress: false,
toggleGroup: 'gopa_gopa',
toggleHandler: function( bt, state ){
if( state ) {
autoRiseEvent = true;
changeContent(0,0,'');
updateUserContent();
showContent();
};
}
},{
xtype: 'spacer',
width: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel('_REPO_HISTORY_');?>',
id: 'tbtn_1',
iconCls: 'rep',
scale: 'large',
enableToggle: true,
//pressed: (Math.floor(initView/100)==1),
allowDepress: false,
toggleGroup: 'gopa_gopa',
toggleHandler: function( bt, state ){
if( state ){
changeContent(0,1,'');
updateUserContent();
showContent();
};
}
},{
xtype: 'spacer',
width: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel('_SETTINGS_');?>',
id: 'tbtn_2',
iconCls: 'cog',
scale: 'large',
enableToggle: true,
allowDepress: false,
toggleGroup: 'gopa_gopa',
toggleHandler: function( bt, state ){
if( state ) {
changeContent(0,2,'');
updateUserContent();
showContent();
};
}
},{
xtype: 'spacer',
width: 10
},{
xtype: 'panel',
baseCls: 'x-plain',
frame: false,
border: false,
margins: {top:5, right:0, bottom:0, left:0},
width: PanelW - <?=($AP_DATA['type'] == 1)?'700':'800';?>,
html: '<p style="font-family: \'Ubuntu\', \'Arial\';font-size: 24px;">'+ap_title+'</p>'
},{
xtype: 'spacer',
width: 10
},<?php
if( $AP_DATA['type'] == 1 ){
?>{
xtype: 'button',
id: 'logout_btn',
text: 'Logout',
iconCls: 'lout',
scale: 'large',
style:'text-align: right;',
handler: doLogout
}<?php
} else {
?>{
xtype: 'button',
id: 'snd_mode_btn',
text: '<?=$Labels->GetLabel('_SOUND_');?>',
iconCls: 'snd'+SoundMode,
scale: 'large',
style:'text-align: right;',
handler: function(){
if( SoundMode == 0 ){
SoundMode = 3;
SoundEnable = true;
} else {
SoundMode --;
if( SoundMode == 0 ) SoundEnable = false;
};
Ext.getCmp('snd_mode_btn').setIconClass( 'snd'+SoundMode );
playSound();
doApplicationOperation( 6, SoundMode );
}
},{
xtype: 'spacer',
width: 10
},{
xtype: 'button',
id: 'logout_btn',
text: '<?=$Labels->GetLabel('_LOGOUT_');?>',
iconCls: 'lout',
scale: 'large',
style:'text-align: right;',
handler: doLogout
}<?php
};
?>
]
}]
},{
xtype: 'panel',
id:'left_side_menu',
region:'west',
bsaseCls:'x-plain',
layout: 'fit',
collapsible: true,
split: true,
width: 180,
minWidth: 180,
maxWidth: 180,
hidden: ( contentView.l[1].v == 0 ),
margins: '5 0 5 5',
cmargins:'5 5 5 5',
items: []
},{
xtype: 'panel',
region:'center',
margins: '5 5 5 0',
id: 'main_content',
//title: '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>',
items:[{
xtype: 'portal',
id: 'main_portal',
frame: false,
border: false,
items:{
html: ''
}//,
//listeners:{
// drop: function( a ){
// updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position );
// }
//}
}]
},{
xtype: 'panel',
region:'east',
id:'right_side_menu',
//title: '',
margins: '5 5 5 0',
//id: 'help_content',
frame: false,
border: false,
collapsible: false,
split:true,
width:200,
minWidth: 150,
maxWidth: 200,
items:[]
}]
});
showContent( true );
});