diff --git a/README.md b/README.md index dbf8609..4e73783 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ Things I plan to add at some point or another: * Regexes to modify the output of services (to prune unecessary stuff) * Filters to hide services (acked ones, or depending on regexes) * Support for other (free as in free speech) monitoring servers - * Better tabular output of the services result (sorting, pagination) * Choose which columns are shown in services result * Better icinga2 support (use API because things are missing in the json output ?) diff --git a/extension.js b/extension.js index 44e525b..bc840fa 100644 --- a/extension.js +++ b/extension.js @@ -111,16 +111,18 @@ class Indicator extends PanelMenu.Button { let warning_box = new St.BoxLayout({ style_class: 'monito-warning-box monito-box' }); - warning_box.set_style ( 'background-color: ' + this.account_settings.get_string ( 'warning-color' ) ); + warning_box.set_style ( 'background-color: %s; color: %s'.format ( this.account_settings.get_string ( 'warning-color' ), this.account_settings.get_string ( 'warning-fg' ) ) ); this.account_settings.connect("changed::warning-color", Lang.bind ( { widget: warning_box }, setColor ) ); + this.account_settings.connect("changed::warning-fg", Lang.bind ( { widget: warning_box }, setColor ) ); this.warningBoxes [ this.server ] = new St.Label({ text: String(_status['WARNING']) }) warning_box.add_child ( this.warningBoxes [ this.server ] ); serverBox.add_child(warning_box); let critical_box = new St.BoxLayout({ style_class: 'monito-critical-box monito-box' }); - critical_box.set_style ( 'background-color: ' + this.account_settings.get_string ( 'critical-color' ) ); + critical_box.set_style ( 'background-color: %s; color: %s'.format ( this.account_settings.get_string ( 'critical-color' ), this.account_settings.get_string ( 'critical-fg' ) ) ); this.account_settings.connect("changed::critical-color", Lang.bind ( { widget: critical_box }, setColor ) ); + this.account_settings.connect("changed::critical-fg", Lang.bind ( { widget: critical_box }, setColor ) ); this.criticalBoxes [ this.server ] = new St.Label({ text: String(_status['CRITICAL']) }) critical_box.add_child ( this.criticalBoxes [ this.server ] ); @@ -465,6 +467,11 @@ function monitoLog ( msg ) function setColor (stgs, key) { - monitoLog ( stgs.get_string(key) ); - this.widget.set_style ( 'background-color: ' + stgs.get_string(key) ); +// monitoLog ( '> %s color %s'.format ( key, stgs.get_string(key) ) ); +// monitoLog ( '> style %s'.format ( style ) ); + let style = this.widget.get_style ( ); + if ( key.match ( /-fg$/ ) ) + this.widget.set_style ( style + ';color: ' + stgs.get_string(key) ); + else + this.widget.set_style ( style + ';background-color: ' + stgs.get_string(key) ); } diff --git a/prefs.js b/prefs.js index 6907999..f212044 100644 --- a/prefs.js +++ b/prefs.js @@ -43,15 +43,23 @@ const SETTINGS_SCHEMA_ACCOUNT = "org.gnome.shell.extensions.monito.account"; const SETTINGS_SCHEMA_ACCOUNT_PATH = "/org/gnome/shell/extensions/monito/account"; -const prefs = [ { type: Gtk.Entry, label: _('Name'), key: 'name' }, - { type: Gtk.ComboBoxText, label: _('Type'), key: 'type' }, - { type: Gtk.Entry, label: _('Username'), key: 'username' }, - { type: Gtk.Entry, label: _('Password'), key: 'password' }, - { type: Gtk.Entry, label: _('URL CGI'), key: 'urlcgi' }, - { type: Gtk.ColorButton, label: _('OK color'), key: 'ok-color', align: Gtk.Align.START }, - { type: Gtk.ColorButton, label: _('Warning color'), key: 'warning-color', align: Gtk.Align.START }, - { type: Gtk.ColorButton, label: _('Critical color'), key: 'critical-color', align: Gtk.Align.START }, - { type: Gtk.ColorButton, label: _('Unknown color'), key: 'unknown-color', align: Gtk.Align.START }, +const prefs = [ { 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.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 }, + { type: Gtk.ColorButton, category: 'Colors', label: _('Unknown background color'), key: 'unknown-color', align: Gtk.Align.START }, + { type: Gtk.ColorButton, category: 'Colors', label: _('OK color'), key: 'ok-fg', align: Gtk.Align.START }, + { type: Gtk.ColorButton, category: 'Colors', label: _('Warning color'), key: 'warning-fg', align: Gtk.Align.START }, + { type: Gtk.ColorButton, category: 'Colors', label: _('Critical color'), key: 'critical-fg', align: Gtk.Align.START }, + { type: Gtk.ColorButton, category: 'Colors', label: _('Unknown color'), key: 'unknown-fg', align: Gtk.Align.START }, + { type: Gtk.Entry, category: 'Filter', label: _('Only display hosts matching'), key: 'host-grep', align: Gtk.Align.START }, + { type: Gtk.Entry, category: 'Filter', label: _('Only display services matching'), key: 'service-grip', align: Gtk.Align.START }, + { type: Gtk.Entry, category: 'Filter', label: _('Do not display hosts matching'), key: 'host-filter-out', align: Gtk.Align.START }, + { type: Gtk.Entry, category: 'Filter', label: _('Do not display services matching'), key: 'service-filter-out', align: Gtk.Align.START }, ]; @@ -200,8 +208,31 @@ function setColumns ( server, columns ) function createAccountWidgets ( isActive ) { - // Accounts - this._accountsWidget = new Gtk.Grid ( { + this.prefWidgets = { }; + + this._accountsWidget = new Gtk.Notebook( { } ); + this._accountsWidgetContainer.pack_start(this._accountsWidget, true, true, 0); + + // Settings + this.createPrefWidgets ( _accountsWidget, 'Settings', isActive ); + this.prefWidgets['name'].connect('changed', Lang.bind(this, function () { + let _row = this.accountsChooser.get_selected_row(); + _row.get_child().label = this.prefWidgets['name'].text; + } ) ); + + // Colors + this.createPrefWidgets ( _accountsWidget, 'Colors', isActive ); + + // Filters + this.createPrefWidgets ( _accountsWidget, 'Filters', isActive ); + + this._accountsWidget.show_all(); +} + + +function createPrefWidgets ( noteBook, type, isActive ) +{ + let grid = new Gtk.Grid ( { halign: Gtk.Align.FILL, margin: 18, column_spacing: 12, @@ -209,26 +240,20 @@ function createAccountWidgets ( isActive ) visible: true, column_homogeneous: false, }); - this._accountsWidgetContainer.pack_start(this._accountsWidget, true, true, 0); + noteBook.append_page ( grid, new Gtk.Label ( { label: _(type), } ) ); - this.prefWidgets = { }; - - this._accountsWidget.attach ( new Gtk.Label({ - label: '' + _('Accounts settings') + '', - visible: true, - halign: Gtk.Align.START, - use_markup: true, - }), 0, 0, 2, 1 ); - - let y = 1; + let y = 0; for ( var prefEntry of prefs ) { + if ( prefEntry.category != type ) + continue; + let _label = new Gtk.Label({ label: prefEntry.label + ':', visible: true, halign: Gtk.Align.START, }); - this._accountsWidget.attach ( _label, 0, y, 1, 1 ); + grid.attach ( _label, 0, y, 1, 1 ); this.prefWidgets[prefEntry.key] = new prefEntry.type ( { halign: ( prefEntry.align ? prefEntry.align : Gtk.Align.FILL ), @@ -250,7 +275,7 @@ function createAccountWidgets ( isActive ) } ); } - this._accountsWidget.attach(this.prefWidgets[prefEntry.key], 1, y, 1, 1); + grid.attach(this.prefWidgets[prefEntry.key], 1, y, 1, 1); if ( prefEntry.type != Gtk.ComboBoxText ) { @@ -263,15 +288,8 @@ function createAccountWidgets ( isActive ) } y++; } - - this.prefWidgets['name'].connect('changed', Lang.bind(this, function () { - let _row = this.accountsChooser.get_selected_row(); - _row.get_child().label = this.prefWidgets['name'].text; - - } ) ); } - function activateAccountRow ( ) { if ( this._accountsWidget ) diff --git a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml index 13128c4..55dd680 100644 --- a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml +++ b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml @@ -92,6 +92,22 @@ '#e496f5' + + '#ffffff' + + + + '#ffffff' + + + + '#ffffff' + + + + '#ffffff' + + ['status','host_name','service_display_name','last_check','attempts','status_information'] diff --git a/servers/genericserver.js b/servers/genericserver.js index 24b2dd1..3069a68 100644 --- a/servers/genericserver.js +++ b/servers/genericserver.js @@ -87,6 +87,7 @@ class GenericServer { { this.status = { }; this.status.service_status = [ ]; + this.error = null; if ( message.status_code != Soup.Status.OK ) { diff --git a/servers/icinga.js b/servers/icinga.js index 4f48cff..3440c2b 100644 --- a/servers/icinga.js +++ b/servers/icinga.js @@ -88,7 +88,6 @@ class Icinga extends GenericServer { { let json = JSON.parse ( _data ); this.status = json.status; - this.error = null; } this.extension.refreshUI ( this ); diff --git a/servers/icinga2.js b/servers/icinga2.js index c523dc0..8f1df1c 100644 --- a/servers/icinga2.js +++ b/servers/icinga2.js @@ -73,7 +73,6 @@ class Icinga2 extends GenericServer { last_check: new Date ( parseInt(entry.service_last_state_change) * 1000 ) . toString(), } ); } - this.error = null; } this.extension.refreshUI ( this );