Better multi-server implementation

This commit is contained in:
Benjamin Drieu 2021-12-01 16:18:38 +01:00
parent 46dd36c653
commit 489a59b31f
4 changed files with 30 additions and 24 deletions

View File

@ -257,7 +257,7 @@ class Indicator extends PanelMenu.Button {
if ( ! col [ 'special' ] ) if ( ! col [ 'special' ] )
_child = new St.Label({ style_class: 'monito-label', text: text.toString(), }); _child = new St.Label({ style_class: 'monito-label', text: text.toString(), });
else if ( col.special == 'actions' ) else if ( col.special == 'actions' && this.serverLogic.canRecheck )
{ {
_child = new St.BoxLayout ( { x_expand: true, _child = new St.BoxLayout ( { x_expand: true,
x_align: Clutter.ActorAlign.FILL, x_align: Clutter.ActorAlign.FILL,
@ -389,6 +389,7 @@ class Indicator extends PanelMenu.Button {
infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) ); infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) );
} }
if ( this.serverLogic.canRecheck )
infoBox.add_child ( this.createBin ( entry.status, entry, column_definitions [ 'actions' ] ) ); infoBox.add_child ( this.createBin ( entry.status, entry, column_definitions [ 'actions' ] ) );
_row ++; _row ++;

View File

@ -30,6 +30,7 @@ const Preferences = Me.imports.prefs;
class GenericServer { class GenericServer {
constructor ( _server, _serverType = 'Generic' ) constructor ( _server, _serverType = 'Generic' )
{ {
log ( '>>> New %s server #%s'.format ( _serverType, _server ) ); log ( '>>> New %s server #%s'.format ( _serverType, _server ) );
@ -38,6 +39,8 @@ class GenericServer {
this._settings = Preferences.getAccountSettings ( this._server ); this._settings = Preferences.getAccountSettings ( this._server );
this._httpSession = null; this._httpSession = null;
this._url = null; this._url = null;
this.canRecheck = true;
} }
getServer ( ) getServer ( )
@ -105,6 +108,27 @@ class GenericServer {
} }
} }
handleCMDMessage ( _httpSession, message )
{
let _data;
try {
_data = this.handleMessage ( _httpSession, message );
if ( this.error )
log ( 'Parent error ' + this.error );
else
{
// if error, grep for class='errorMessage'
// else grep for class='successBox'
log ( 'Cmd output ' + _data );
}
}
catch ( e )
{
log ( e );
log ( _data );
}
}
getProcessedStatus ( ) getProcessedStatus ( )
{ {

View File

@ -105,25 +105,4 @@ class Icinga extends GenericServer {
} }
} }
handleCMDMessage ( _httpSession, message )
{
let _data;
try {
_data = super.handleMessage ( _httpSession, message );
if ( this.error )
log ( 'Parent error ' + this.error );
else
{
// if error, grep for class='errorMessage'
// else grep for class='successBox'
log ( 'Cmd output ' + _data );
}
}
catch ( e )
{
log ( e );
log ( _data );
}
}
} }

View File

@ -33,6 +33,8 @@ const GenericServer = Me.imports.servers.genericserver.GenericServer;
class Icinga2 extends GenericServer { class Icinga2 extends GenericServer {
constructor ( _server ) { constructor ( _server ) {
super(_server, 'Icinga2'); super(_server, 'Icinga2');
this.canRecheck = false;
} }
refresh ( extension ) { refresh ( extension ) {