From 9fc2cdf975d3db17424c4efc292715a63e78fafd Mon Sep 17 00:00:00 2001 From: Benjamin Drieu Date: Wed, 17 Nov 2021 21:01:51 +0100 Subject: [PATCH] Cosmetic changes --- extension.js | 14 +++++++------- servers/icinga.js | 15 +++++++++++---- servers/icinga2.js | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/extension.js b/extension.js index c74806a..9a17261 100644 --- a/extension.js +++ b/extension.js @@ -28,16 +28,16 @@ let _httpSession; let _status; let _ok_text; -const Gettext = imports.gettext.domain(GETTEXT_DOMAIN); -const _ = Gettext.gettext; -const Lang = imports.lang; - const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); +const Lang = imports.lang; const Main = imports.ui.main; +const Mainloop = imports.mainloop; +const Me = ExtensionUtils.getCurrentExtension(); const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; -const Mainloop = imports.mainloop; + +const Gettext = imports.gettext.domain(GETTEXT_DOMAIN); +const _ = Gettext.gettext; const { GObject, St, Clutter, Gio } = imports.gi; @@ -46,9 +46,9 @@ const SETTINGS_SCHEMA_ACCOUNT = "org.gnome.shell.extensions.monito.account"; const SETTINGS_SCHEMA_ACCOUNT_PATH = "/org/gnome/shell/extensions/monito/account"; const Convenience = Me.imports.convenience; -const Preferences = Me.imports.prefs; const Icinga = Me.imports.servers.icinga.Icinga; const Icinga2 = Me.imports.servers.icinga2.Icinga2; +const Preferences = Me.imports.prefs; let settings = Convenience.getSettings(SETTINGS_SCHEMA); let account_settings = [ ]; diff --git a/servers/icinga.js b/servers/icinga.js index fe59257..5bdb4d9 100644 --- a/servers/icinga.js +++ b/servers/icinga.js @@ -23,10 +23,10 @@ const { Soup } = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); -const Preferences = Me.imports.prefs; const Lang = imports.lang; const Main = imports.ui.main; +const Me = ExtensionUtils.getCurrentExtension(); +const Preferences = Me.imports.prefs; let _httpSession; @@ -65,9 +65,16 @@ class Icinga { _httpSession.queue_message(message, Lang.bind (this, function(_httpSession, message) { -// log ( '>>> ' + message.response_body.data ); - let json = JSON.parse(message.response_body.data); + log ( '>>> ' + message.status_code ); + + if ( message.status_code != Soup.Status.OK ) + { + log ( '>>> error: ' + message.reason_phrase ); + Main.notify ( 'Monito: ' + name, message.reason_phrase ); + return; + } + let json = JSON.parse(message.response_body.data); this.status = json.status; extension.refreshUI ( this ); diff --git a/servers/icinga2.js b/servers/icinga2.js index c00b979..cd2c3f9 100644 --- a/servers/icinga2.js +++ b/servers/icinga2.js @@ -23,10 +23,10 @@ const { Soup } = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); -const Preferences = Me.imports.prefs; const Lang = imports.lang; const Main = imports.ui.main; +const Me = ExtensionUtils.getCurrentExtension(); +const Preferences = Me.imports.prefs; let _httpSession;