Compare commits
3 Commits
4d2d0132a3
...
146ffe7b09
Author | SHA1 | Date | |
---|---|---|---|
146ffe7b09 | |||
5e8e660c7a | |||
e52a346369 |
47
extension.js
47
extension.js
@ -147,12 +147,32 @@ class Indicator extends PanelMenu.Button {
|
||||
this._mainLabel = new St.Label ( { style_class: 'monito-title', text: _('Monito Checker'), x_expand: true } );
|
||||
this._buttonMenu.actor.add_actor(this._mainLabel);
|
||||
|
||||
this._searchField = new St.Entry ( {
|
||||
x_align: Clutter.ActorAlign.END,
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
reactive: true,
|
||||
can_focus: true,
|
||||
track_hover: true,
|
||||
style_class: 'entry',
|
||||
secondary_icon: new St.Icon ( {
|
||||
style_class: 'monito-button-icon',
|
||||
icon_name: 'edit-find-symbolic',
|
||||
icon_size: 24,
|
||||
width: 24,
|
||||
height: 24,
|
||||
} ),
|
||||
});
|
||||
this._searchField.connect('secondary-icon-clicked', Lang.bind(this, this._onSearchFieldActivate ) );
|
||||
this._searchField.clutter_text.connect('activate', Lang.bind(this, this._onSearchFieldActivate ) );
|
||||
|
||||
this._buttonMenu.actor.add_child (this._searchField);
|
||||
|
||||
this._prefsButton = this._createButton ( 'preferences-system-symbolic', _('Preferences'), this._onPreferencesActivate );
|
||||
this._buttonMenu.actor.add_child (this._prefsButton);
|
||||
|
||||
if ( this.serverLogic && this.serverLogic.canRecheck )
|
||||
{
|
||||
this._recheckButton = this._createButton ( 'system-run-symbolic', _('Recheck all'), this.recheckAll );
|
||||
this._recheckButton = this._createButton ( 'mail-send-receive-symbolic', _('Recheck all'), this.recheckAll );
|
||||
this._buttonMenu.actor.add_child (this._recheckButton );
|
||||
}
|
||||
|
||||
@ -328,11 +348,11 @@ class Indicator extends PanelMenu.Button {
|
||||
height: 24,
|
||||
can_focus: true,
|
||||
} );
|
||||
_button.prevIcon = 'system-run-symbolic';
|
||||
_button.prevIcon = 'mail-send-receive-symbolic';
|
||||
_button.service = text;
|
||||
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
|
||||
_button.child = new St.Icon ( {
|
||||
icon_name: 'system-run-symbolic',
|
||||
icon_name: 'mail-send-receive-symbolic',
|
||||
icon_size: 16,
|
||||
width: 16,
|
||||
height: 16,
|
||||
@ -423,6 +443,12 @@ class Indicator extends PanelMenu.Button {
|
||||
let _row = 0;
|
||||
for ( let entry of processedStatus )
|
||||
{
|
||||
if ( this._searchString &&
|
||||
! ( entry [ 'host_name' ].includes ( this._searchString ) ||
|
||||
entry [ 'service_display_name' ].includes ( this._searchString ) ||
|
||||
entry [ 'status_information' ].includes ( this._searchString ) ) )
|
||||
continue;
|
||||
|
||||
if ( ( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) ||
|
||||
( ( _status [ 'WARNING' ] || _status [ 'CRITICAL' ] || _status [ 'UNKNOWN' ] ) && entry.status != 'OK' ) )
|
||||
{
|
||||
@ -504,6 +530,13 @@ class Indicator extends PanelMenu.Button {
|
||||
return;
|
||||
}
|
||||
|
||||
_onSearchFieldActivate ( e ) {
|
||||
monitoLog ( 'Search: ' + e.text );
|
||||
this._searchString = e.text;
|
||||
this.refreshUI ( );
|
||||
return;
|
||||
}
|
||||
|
||||
_onPreferencesActivate ( ) {
|
||||
this.menu.actor.hide();
|
||||
if (typeof ExtensionUtils.openPrefs === 'function') {
|
||||
@ -589,8 +622,12 @@ class Extension {
|
||||
|
||||
for ( let _server of Preferences.getServersList() )
|
||||
{
|
||||
this._indicators [ _server ] = new Indicator(_server);
|
||||
Main.panel.addToStatusArea ( '%s-%d'.format ( this._uuid, _server), this._indicators [ _server ] );
|
||||
let _pref = Preferences.getAccountSettings ( _server );
|
||||
if ( _pref.get_boolean ( 'active' ) )
|
||||
{
|
||||
this._indicators [ _server ] = new Indicator(_server);
|
||||
Main.panel.addToStatusArea ( '%s-%d'.format ( this._uuid, _server), this._indicators [ _server ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
prefs.js
2
prefs.js
@ -44,11 +44,13 @@ const SETTINGS_SCHEMA_ACCOUNT_PATH = "/org/gnome/shell/extensions/monito/account
|
||||
|
||||
|
||||
const prefs = [
|
||||
{ type: Gtk.Switch, category: 'Settings', label: _('Active (restart for effect)'), key: 'active', align: Gtk.Align.START },
|
||||
{ type: Gtk.Entry, category: 'Settings', label: _('Name'), key: 'name' },
|
||||
{ type: Gtk.ComboBoxText, category: 'Settings', label: _('Type'), key: 'type' },
|
||||
{ type: Gtk.Entry, category: 'Settings', label: _('Username'), key: 'username' },
|
||||
{ type: Gtk.Entry, category: 'Settings', label: _('Password'), key: 'password' },
|
||||
{ type: Gtk.Entry, category: 'Settings', label: _('URL CGI'), key: 'urlcgi' },
|
||||
{ type: Gtk.Switch, category: 'Settings', label: _('Check SSL certificate'), key: 'strict-ssl', align: Gtk.Align.START },
|
||||
{ type: Gtk.ColorButton, category: 'Colors', label: _('OK background color'), key: 'ok-color', align: Gtk.Align.START },
|
||||
{ type: Gtk.ColorButton, category: 'Colors', label: _('Warning background color'), key: 'warning-color', align: Gtk.Align.START },
|
||||
{ type: Gtk.ColorButton, category: 'Colors', label: _('Critical background color'), key: 'critical-color', align: Gtk.Align.START },
|
||||
|
@ -53,6 +53,10 @@
|
||||
<!-- Account list -->
|
||||
<schema id="org.gnome.shell.extensions.monito.account">
|
||||
|
||||
<key name="active" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
|
||||
<key name="icon" type="s">
|
||||
<default>''</default>
|
||||
</key>
|
||||
@ -77,6 +81,10 @@
|
||||
<default>''</default>
|
||||
</key>
|
||||
|
||||
<key name="strict-ssl" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
|
||||
<key name="ok-color" type="s">
|
||||
<default>'#00cc33'</default>
|
||||
</key>
|
||||
|
@ -52,14 +52,27 @@ class GenericServer {
|
||||
|
||||
buildURL ( )
|
||||
{
|
||||
if ( ! this._settings )
|
||||
this._settings = Preferences.getAccountSettings ( this._server );
|
||||
// if ( ! this._settings )
|
||||
log ( 'monito build URL' );
|
||||
|
||||
this.type = this._settings.get_string ( "type" );
|
||||
this.username = this._settings.get_string ( "username" );
|
||||
this.name = this._settings.get_string ( "name" );
|
||||
this.password = this._settings.get_string ( "password" );
|
||||
this.urlcgi = this._settings.get_string ( "urlcgi" );
|
||||
this._settings = Preferences.getAccountSettings ( this._server );
|
||||
|
||||
if ( this.type != this._settings.get_string ( "type" ) ||
|
||||
this.username != this._settings.get_string ( "username" ) ||
|
||||
this.strict_ssl != this._settings.get_boolean ( "strict-ssl" ) ||
|
||||
this.name != this._settings.get_string ( "name" ) ||
|
||||
this.password != this._settings.get_string ( "password" ) ||
|
||||
this.urlcgi != this._settings.get_string ( "urlcgi" ) )
|
||||
{
|
||||
this.type = this._settings.get_string ( "type" );
|
||||
this.username = this._settings.get_string ( "username" );
|
||||
this.strict_ssl = this._settings.get_boolean ( "strict-ssl" );
|
||||
this.name = this._settings.get_string ( "name" );
|
||||
this.password = this._settings.get_string ( "password" );
|
||||
this.urlcgi = this._settings.get_string ( "urlcgi" );
|
||||
this._httpSession = null;
|
||||
log ( 'Refreshing URL parameters' );
|
||||
}
|
||||
|
||||
// log ( 'monito server >>> ' + this._server );
|
||||
// log ( 'monito name >>> ' + this.name );
|
||||
@ -72,7 +85,9 @@ class GenericServer {
|
||||
prepareHttp ( )
|
||||
{
|
||||
if ( this._httpSession == null ) {
|
||||
log ( 'Preparing new HTTP with strict SSL ' + this.strict_ssl );
|
||||
this._httpSession = new Soup.Session();
|
||||
this._httpSession.ssl_strict = this.strict_ssl;
|
||||
this._httpSession.user_agent = Me.metadata.uuid;
|
||||
}
|
||||
}
|
||||
@ -84,6 +99,7 @@ class GenericServer {
|
||||
auth.authenticate ( this.username, this.password );
|
||||
message.request_headers.append ( "Authorization", auth.get_authorization ( message ) );
|
||||
|
||||
log ( 'Sending message' );
|
||||
this._httpSession.queue_message ( message, Lang.bind (this, callback ) );
|
||||
}
|
||||
|
||||
@ -94,6 +110,14 @@ class GenericServer {
|
||||
this.status.service_status = [ ];
|
||||
this.error = null;
|
||||
|
||||
log ( message.status_code );
|
||||
log ( message.response_body );
|
||||
message.response_headers.foreach ((name, val) => {
|
||||
log (name, val);
|
||||
});
|
||||
log ( message.response_body.data );
|
||||
|
||||
|
||||
if ( message.status_code != Soup.Status.OK )
|
||||
{
|
||||
log ( '>>> Error: ' + message.reason_phrase );
|
||||
|
@ -87,6 +87,8 @@ class Icinga2API extends GenericServer {
|
||||
|
||||
handlePollMessage ( _httpSession, message )
|
||||
{
|
||||
log ( 'handlePollMessage' );
|
||||
|
||||
let _data = super.handleMessage ( _httpSession, message );
|
||||
try
|
||||
{
|
||||
|
@ -91,7 +91,14 @@
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.entry {
|
||||
margin-right: 0px;
|
||||
min-width: 256px;
|
||||
padding: 12px !important;
|
||||
}
|
||||
|
||||
.big-button {
|
||||
margin-left: 0px;
|
||||
padding: 12px !important;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user