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._mainLabel = new St.Label ( { style_class: 'monito-title', text: _('Monito Checker'), x_expand: true } );
|
||||||
this._buttonMenu.actor.add_actor(this._mainLabel);
|
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._prefsButton = this._createButton ( 'preferences-system-symbolic', _('Preferences'), this._onPreferencesActivate );
|
||||||
this._buttonMenu.actor.add_child (this._prefsButton);
|
this._buttonMenu.actor.add_child (this._prefsButton);
|
||||||
|
|
||||||
if ( this.serverLogic && this.serverLogic.canRecheck )
|
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 );
|
this._buttonMenu.actor.add_child (this._recheckButton );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,11 +348,11 @@ class Indicator extends PanelMenu.Button {
|
|||||||
height: 24,
|
height: 24,
|
||||||
can_focus: true,
|
can_focus: true,
|
||||||
} );
|
} );
|
||||||
_button.prevIcon = 'system-run-symbolic';
|
_button.prevIcon = 'mail-send-receive-symbolic';
|
||||||
_button.service = text;
|
_button.service = text;
|
||||||
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
|
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
|
||||||
_button.child = new St.Icon ( {
|
_button.child = new St.Icon ( {
|
||||||
icon_name: 'system-run-symbolic',
|
icon_name: 'mail-send-receive-symbolic',
|
||||||
icon_size: 16,
|
icon_size: 16,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
@ -423,6 +443,12 @@ class Indicator extends PanelMenu.Button {
|
|||||||
let _row = 0;
|
let _row = 0;
|
||||||
for ( let entry of processedStatus )
|
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' ) ||
|
if ( ( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) ||
|
||||||
( ( _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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onSearchFieldActivate ( e ) {
|
||||||
|
monitoLog ( 'Search: ' + e.text );
|
||||||
|
this._searchString = e.text;
|
||||||
|
this.refreshUI ( );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_onPreferencesActivate ( ) {
|
_onPreferencesActivate ( ) {
|
||||||
this.menu.actor.hide();
|
this.menu.actor.hide();
|
||||||
if (typeof ExtensionUtils.openPrefs === 'function') {
|
if (typeof ExtensionUtils.openPrefs === 'function') {
|
||||||
@ -589,8 +622,12 @@ class Extension {
|
|||||||
|
|
||||||
for ( let _server of Preferences.getServersList() )
|
for ( let _server of Preferences.getServersList() )
|
||||||
{
|
{
|
||||||
this._indicators [ _server ] = new Indicator(_server);
|
let _pref = Preferences.getAccountSettings ( _server );
|
||||||
Main.panel.addToStatusArea ( '%s-%d'.format ( this._uuid, _server), this._indicators [ _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 = [
|
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.Entry, category: 'Settings', label: _('Name'), key: 'name' },
|
||||||
{ type: Gtk.ComboBoxText, category: 'Settings', label: _('Type'), key: 'type' },
|
{ type: Gtk.ComboBoxText, category: 'Settings', label: _('Type'), key: 'type' },
|
||||||
{ type: Gtk.Entry, category: 'Settings', label: _('Username'), key: 'username' },
|
{ type: Gtk.Entry, category: 'Settings', label: _('Username'), key: 'username' },
|
||||||
{ type: Gtk.Entry, category: 'Settings', label: _('Password'), key: 'password' },
|
{ type: Gtk.Entry, category: 'Settings', label: _('Password'), key: 'password' },
|
||||||
{ type: Gtk.Entry, category: 'Settings', label: _('URL CGI'), key: 'urlcgi' },
|
{ 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: _('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: _('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 },
|
{ type: Gtk.ColorButton, category: 'Colors', label: _('Critical background color'), key: 'critical-color', align: Gtk.Align.START },
|
||||||
|
@ -53,6 +53,10 @@
|
|||||||
<!-- Account list -->
|
<!-- Account list -->
|
||||||
<schema id="org.gnome.shell.extensions.monito.account">
|
<schema id="org.gnome.shell.extensions.monito.account">
|
||||||
|
|
||||||
|
<key name="active" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
<key name="icon" type="s">
|
<key name="icon" type="s">
|
||||||
<default>''</default>
|
<default>''</default>
|
||||||
</key>
|
</key>
|
||||||
@ -77,6 +81,10 @@
|
|||||||
<default>''</default>
|
<default>''</default>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="strict-ssl" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
<key name="ok-color" type="s">
|
<key name="ok-color" type="s">
|
||||||
<default>'#00cc33'</default>
|
<default>'#00cc33'</default>
|
||||||
</key>
|
</key>
|
||||||
|
@ -52,14 +52,27 @@ class GenericServer {
|
|||||||
|
|
||||||
buildURL ( )
|
buildURL ( )
|
||||||
{
|
{
|
||||||
if ( ! this._settings )
|
// if ( ! this._settings )
|
||||||
this._settings = Preferences.getAccountSettings ( this._server );
|
log ( 'monito build URL' );
|
||||||
|
|
||||||
this.type = this._settings.get_string ( "type" );
|
this._settings = Preferences.getAccountSettings ( this._server );
|
||||||
this.username = this._settings.get_string ( "username" );
|
|
||||||
this.name = this._settings.get_string ( "name" );
|
if ( this.type != this._settings.get_string ( "type" ) ||
|
||||||
this.password = this._settings.get_string ( "password" );
|
this.username != this._settings.get_string ( "username" ) ||
|
||||||
this.urlcgi = this._settings.get_string ( "urlcgi" );
|
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 server >>> ' + this._server );
|
||||||
// log ( 'monito name >>> ' + this.name );
|
// log ( 'monito name >>> ' + this.name );
|
||||||
@ -72,7 +85,9 @@ class GenericServer {
|
|||||||
prepareHttp ( )
|
prepareHttp ( )
|
||||||
{
|
{
|
||||||
if ( this._httpSession == null ) {
|
if ( this._httpSession == null ) {
|
||||||
|
log ( 'Preparing new HTTP with strict SSL ' + this.strict_ssl );
|
||||||
this._httpSession = new Soup.Session();
|
this._httpSession = new Soup.Session();
|
||||||
|
this._httpSession.ssl_strict = this.strict_ssl;
|
||||||
this._httpSession.user_agent = Me.metadata.uuid;
|
this._httpSession.user_agent = Me.metadata.uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,6 +99,7 @@ class GenericServer {
|
|||||||
auth.authenticate ( this.username, this.password );
|
auth.authenticate ( this.username, this.password );
|
||||||
message.request_headers.append ( "Authorization", auth.get_authorization ( message ) );
|
message.request_headers.append ( "Authorization", auth.get_authorization ( message ) );
|
||||||
|
|
||||||
|
log ( 'Sending message' );
|
||||||
this._httpSession.queue_message ( message, Lang.bind (this, callback ) );
|
this._httpSession.queue_message ( message, Lang.bind (this, callback ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +110,14 @@ class GenericServer {
|
|||||||
this.status.service_status = [ ];
|
this.status.service_status = [ ];
|
||||||
this.error = null;
|
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 )
|
if ( message.status_code != Soup.Status.OK )
|
||||||
{
|
{
|
||||||
log ( '>>> Error: ' + message.reason_phrase );
|
log ( '>>> Error: ' + message.reason_phrase );
|
||||||
|
@ -87,6 +87,8 @@ class Icinga2API extends GenericServer {
|
|||||||
|
|
||||||
handlePollMessage ( _httpSession, message )
|
handlePollMessage ( _httpSession, message )
|
||||||
{
|
{
|
||||||
|
log ( 'handlePollMessage' );
|
||||||
|
|
||||||
let _data = super.handleMessage ( _httpSession, message );
|
let _data = super.handleMessage ( _httpSession, message );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,14 @@
|
|||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.entry {
|
||||||
|
margin-right: 0px;
|
||||||
|
min-width: 256px;
|
||||||
|
padding: 12px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.big-button {
|
.big-button {
|
||||||
|
margin-left: 0px;
|
||||||
padding: 12px !important;
|
padding: 12px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user