This commit is contained in:
Benjamin Drieu 2022-02-11 21:20:38 +01:00
commit 4d2d0132a3
4 changed files with 17 additions and 6 deletions

View File

@ -63,7 +63,7 @@ const column_definitions = {
last_check: { label: _('Last check'), width: 200, expand: false, type: 'date' },
attempts: { label: _('Attempts'), width: 50, expand: false, },
status_information: { label: _('Information'), width: 600, expand: false, },
actions: { label: 'Actions', width: 120, expand: false, special: 'actions' },
actions: { label: 'Actions', width: 50, expand: false, special: 'actions' },
};
@ -328,6 +328,7 @@ class Indicator extends PanelMenu.Button {
height: 24,
can_focus: true,
} );
_button.prevIcon = 'system-run-symbolic';
_button.service = text;
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
_button.child = new St.Icon ( {
@ -446,7 +447,7 @@ class Indicator extends PanelMenu.Button {
this.account_settings.get_string ( 'service-replace' ) );
else if ( _col == 'status_information' && this.account_settings.get_string ( 'status-info-match' ) )
entry [ _col ] = entry [ _col ] . replace ( new RegExp ( this.account_settings.get_string ( 'status-info-match' ), 'i' ),
this.account_settings.get_string ( 'status-info-replace' ) );
this.account_settings.get_string ( 'status-info-replace' ) ) . replace ( new RegExp ( "\n.*" ), "" );
else if ( _col == 'has_been_acknowledged' )
{
if ( entry [ _col ] )

View File

@ -53,10 +53,12 @@ const prefs = [
{ 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: _('Pending background color'), key: 'pending-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.ColorButton, category: 'Colors', label: _('Pending color'), key: 'pending-fg', align: Gtk.Align.START },
{ type: Gtk.Switch, category: 'Filters', label: _('Do <b>not</b> display acknowledged services'), key: 'acknowledged-filter-out', align: Gtk.Align.START },
{ type: Gtk.Entry, category: 'Filters', label: _('Only display hosts matching'), key: 'host-grep' },
{ type: Gtk.Entry, category: 'Filters', label: _('Only display services matching'), key: 'service-grep' },

View File

@ -93,6 +93,10 @@
<default>'#e496f5'</default>
</key>
<key name="pending-color" type="s">
<default>'#aaaaaa'</default>
</key>
<key name="ok-fg" type="s">
<default>'#ffffff'</default>
</key>
@ -109,6 +113,10 @@
<default>'#ffffff'</default>
</key>
<key name="pending-fg" type="s">
<default>'#ffffff'</default>
</key>
<key name="columns" type="as">
<default>['status','host_name','service_display_name','has_been_acknowledged','last_check','attempts','status_information']</default>
</key>

View File

@ -95,19 +95,19 @@ class Icinga2API extends GenericServer {
else
{
let json = JSON.parse ( _data );
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN', 'PENDING' ];
for ( var entry of json.results )
{
// log ( JSON.stringify(entry) );
this.status.service_status.push ( {
status: _statuses [ entry.attrs.state ],
status: _statuses[entry.attrs.state],
host_name: entry.attrs.host_name,
service_display_name: entry.attrs.display_name,
has_been_acknowledged: parseInt(entry.attrs.acknowledgement),
attempts: '%d/%d'.format(entry.attrs.check_attempt,entry.attrs.max_check_attempts),
status_information: entry.attrs.last_check_result.output,
last_check: this.formatDate(parseInt(entry.attrs.last_check)),
status_information: ( entry.attrs.last_check_result ? entry.attrs.last_check_result.output : _statuses[entry.attrs.state] ),
last_check: ( entry.attrs.last_check ? this.formatDate(parseInt(entry.attrs.last_check)) : '' ),
} );
}
}