Apply eslinst recommandations
This commit is contained in:
parent
42d1d4f548
commit
548d9cde09
58
extension.js
58
extension.js
@ -24,29 +24,24 @@
|
||||
|
||||
const GETTEXT_DOMAIN = 'monito';
|
||||
|
||||
let _httpSession;
|
||||
let _status;
|
||||
let _ok_text;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
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 ExtensionUtils = imports.misc.extensionUtils; // eslint-disable-line no-undef
|
||||
const Lang = imports.lang; // eslint-disable-line no-undef
|
||||
const Main = imports.ui.main; // eslint-disable-line no-undef
|
||||
const Mainloop = imports.mainloop; // eslint-disable-line no-undef
|
||||
const Me = ExtensionUtils.getCurrentExtension(); // eslint-disable-line no-undef
|
||||
const PanelMenu = imports.ui.panelMenu; // eslint-disable-line no-undef
|
||||
const PopupMenu = imports.ui.popupMenu; // eslint-disable-line no-undef
|
||||
|
||||
const Gettext = imports.gettext.domain(GETTEXT_DOMAIN);
|
||||
const Gettext = imports.gettext.domain(GETTEXT_DOMAIN); // eslint-disable-line no-undef
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
const { GObject, St, Clutter, Gio, GLib, Pango } = imports.gi;
|
||||
const { GObject, St, Clutter, Gio, GLib, Pango } = imports.gi; // eslint-disable-line no-undef
|
||||
|
||||
const SETTINGS_SCHEMA = "org.gnome.shell.extensions.monito";
|
||||
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 GenericServer = Me.imports.servers.genericserver.GenericServer;
|
||||
const Icinga = Me.imports.servers.icinga.Icinga;
|
||||
const Icinga2 = Me.imports.servers.icinga2.Icinga2;
|
||||
const Icinga2API = Me.imports.servers.icinga2api.Icinga2API;
|
||||
@ -482,11 +477,11 @@ 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' ) ) . replace ( new RegExp ( "\n.*" ), "" );
|
||||
this.account_settings.get_string ( 'status-info-replace' ) ) . replace ( new RegExp ( "\\n.*" ), "" );
|
||||
else if ( _col == 'has_been_acknowledged' )
|
||||
{
|
||||
if ( entry [ _col ] )
|
||||
entry [ _col ] = '✔'; // … or ✅🗹 ?
|
||||
entry [ _col ] = '✔';
|
||||
else
|
||||
entry [ _col ] = '';
|
||||
}
|
||||
@ -550,7 +545,7 @@ class Indicator extends PanelMenu.Button {
|
||||
if (typeof ExtensionUtils.openPrefs === 'function') {
|
||||
ExtensionUtils.openPrefs();
|
||||
} else {
|
||||
Util.spawn([
|
||||
ExtensionUtils.spawn([
|
||||
"gnome-shell-extension-prefs",
|
||||
Me.uuid
|
||||
]);
|
||||
@ -560,7 +555,6 @@ class Indicator extends PanelMenu.Button {
|
||||
|
||||
_onSortColumnClick ( button ) {
|
||||
let _sortOrder = Preferences.getSortOrder ( this.server );
|
||||
let _columns = Preferences.getColumns ( this.server );
|
||||
|
||||
let _indexPlus = _sortOrder.indexOf ( button.column + '+' );
|
||||
let _indexMinus = _sortOrder.indexOf ( button.column + '-' );
|
||||
@ -587,7 +581,7 @@ class Indicator extends PanelMenu.Button {
|
||||
|
||||
_onExpandLabel ( e )
|
||||
{
|
||||
log ( "Monito: Click label " + e.original_text );
|
||||
monitoLog ( "Monito: Click label " + e.original_text );
|
||||
let temp = e.text;
|
||||
e.text = e.original_text;
|
||||
e.original_text = temp;
|
||||
@ -627,16 +621,16 @@ class Indicator extends PanelMenu.Button {
|
||||
try {
|
||||
proc.wait_finish(result);
|
||||
if ( ! proc.get_successful()) {
|
||||
log ( 'Monito: the process failed' );
|
||||
monitoLog ( 'Monito: the process failed' );
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e);
|
||||
monitoLog(e);
|
||||
} finally {
|
||||
loop.quit();
|
||||
}
|
||||
});
|
||||
} catch ( e ) {
|
||||
log ( 'Monito err: ' + e.message );
|
||||
monitoLog ( 'Monito err: ' + e.message );
|
||||
Main.notifyError ( _('Unable to execute command: %s').format ( e.message ) );
|
||||
}
|
||||
this.stopChildSpin ( e.service.button );
|
||||
@ -650,7 +644,7 @@ class Indicator extends PanelMenu.Button {
|
||||
size = 32;
|
||||
|
||||
let _text = '';
|
||||
if ( ! data instanceof Object )
|
||||
if ( ! ( data instanceof Object ) )
|
||||
_text = data;
|
||||
|
||||
let button = new St.Button({
|
||||
@ -667,8 +661,11 @@ class Indicator extends PanelMenu.Button {
|
||||
});
|
||||
button.prevIcon = icon;
|
||||
|
||||
button.toggle_mode = true;
|
||||
button.set_checked ( true );
|
||||
if ( radiobutton )
|
||||
{
|
||||
button.toggle_mode = true;
|
||||
button.set_checked ( true );
|
||||
}
|
||||
|
||||
if ( data instanceof Object )
|
||||
button.service = data;
|
||||
@ -692,7 +689,7 @@ class Extension {
|
||||
constructor(uuid) {
|
||||
this._uuid = uuid;
|
||||
|
||||
settings.connect("changed::servers", Lang.bind ( this, function(stgs, key) {
|
||||
this._connectId = settings.connect("changed::servers", Lang.bind ( this, function() {
|
||||
this.disable ( );
|
||||
this.enable ( );
|
||||
} ) );
|
||||
@ -720,19 +717,24 @@ class Extension {
|
||||
this._indicators[i].cancelTimeout();
|
||||
this._indicators[i].destroy();
|
||||
}
|
||||
if ( this._connectId )
|
||||
{
|
||||
settings.disconnect( this._connectId );
|
||||
this._connectId = null;
|
||||
}
|
||||
|
||||
this._indicators = { };
|
||||
}
|
||||
}
|
||||
|
||||
function init(meta) {
|
||||
function init(meta) { // eslint-disable-line no-unused-vars
|
||||
return new Extension(meta.uuid);
|
||||
}
|
||||
|
||||
|
||||
function monitoLog ( msg )
|
||||
{
|
||||
log ( 'Monito: ' + msg );
|
||||
log ( 'Monito: ' + msg ); // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
|
||||
|
48
prefs.js
48
prefs.js
@ -84,7 +84,6 @@ function init() {
|
||||
monitoLog('initializing ${Me.metadata.name} Preferences');
|
||||
this.settings = ExtensionUtils.getSettings(SETTINGS_SCHEMA);
|
||||
|
||||
|
||||
this.gtkVersion = Gtk.get_major_version();
|
||||
}
|
||||
|
||||
@ -96,6 +95,8 @@ function buildPrefsWidget() {
|
||||
// Copy the same GSettings code from `extension.js`
|
||||
this.settings = ExtensionUtils.getSettings(SETTINGS_SCHEMA);
|
||||
|
||||
this._columnsStores = { };
|
||||
|
||||
let mainVbox = new Gtk.Box( { orientation: Gtk.Orientation.VERTICAL } );
|
||||
|
||||
let mainWidget = new Gtk.Notebook( { } );
|
||||
@ -366,12 +367,7 @@ function createColumnsPrefTab ( noteBook, type, isActive )
|
||||
grid.margin = 18;
|
||||
noteBook.append_page ( grid, new Gtk.Label ( { label: _(type), } ) );
|
||||
|
||||
let _store = new Gtk.TreeStore();
|
||||
_store.set_column_types([GObject.TYPE_STRING, GObject.TYPE_INT]);
|
||||
_store.filter_new(null);
|
||||
|
||||
let _treeView = new Gtk.TreeView ( { model: _store,
|
||||
headers_visible: true,
|
||||
let _treeView = new Gtk.TreeView ( { headers_visible: true,
|
||||
reorderable: true,
|
||||
hexpand: true,
|
||||
vexpand: true });
|
||||
@ -394,18 +390,25 @@ function createColumnsPrefTab ( noteBook, type, isActive )
|
||||
_colSize.add_attribute(_colRenderer, 'text', 1);
|
||||
_treeView.append_column(_colSize);
|
||||
|
||||
let _item = _store.append(null);
|
||||
_store.set_value(_item, 0, 'prout' );
|
||||
_store.set_value(_item, 1, 2 );
|
||||
|
||||
_item = _store.append(null);
|
||||
_store.set_value(_item, 0, 'bar' );
|
||||
_store.set_value(_item, 1, 1 );
|
||||
|
||||
// _treeView.connect('row-activated', this._editPath.bind(this));
|
||||
|
||||
grid.attach ( _treeView, 0, 1, 1, 1 );
|
||||
|
||||
// Action Bar
|
||||
let rowsChooserActionBar = new Gtk.ActionBar ( { valign: Gtk.Align.END } );
|
||||
|
||||
let rowCreateButton = Gtk.Button.new_from_icon_name ( 'list-add',
|
||||
Gtk.IconSize.BUTTON );
|
||||
rowsChooserActionBar.add ( rowCreateButton );
|
||||
rowCreateButton.connect ( 'clicked', Lang.bind ( this, this.createColumnRow ) );
|
||||
|
||||
let rowRemoveButton = Gtk.Button.new_from_icon_name ( 'list-remove',
|
||||
Gtk.IconSize.BUTTON );
|
||||
rowsChooserActionBar.add ( rowRemoveButton );
|
||||
rowRemoveButton.connect ( 'clicked', Lang.bind ( this, this.removeColumnRow ) );
|
||||
|
||||
grid.attach ( columnsChooserActionBar, 0, 2, 1, 1 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -535,6 +538,21 @@ function setColor ( color )
|
||||
}
|
||||
|
||||
|
||||
function createColumnRow ( ) {
|
||||
monitoLog ( '> Create column row' );
|
||||
|
||||
_item = _store.append(null);
|
||||
_store.set_value(_item, 0, 'bar' );
|
||||
_store.set_value(_item, 1, 1 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
function removeColumnRow ( ) {
|
||||
monitoLog ( '> Remove column row' );
|
||||
}
|
||||
|
||||
|
||||
function monitoLog ( msg )
|
||||
{
|
||||
log ( 'Monito: ' + msg );
|
||||
|
@ -48,9 +48,11 @@ class Icinga extends GenericServer {
|
||||
super.prepareHttp ( );
|
||||
|
||||
let message = Soup.form_request_new_from_hash ( 'GET', this.urlcgi, { 'jsonoutput': '' } );
|
||||
message.request_headers.append ( 'Accept', 'application/json' );
|
||||
|
||||
this.authenticateAndSend ( message );
|
||||
if ( message )
|
||||
{
|
||||
message.request_headers.append ( 'Accept', 'application/json' );
|
||||
this.authenticateAndSend ( message );
|
||||
}
|
||||
}
|
||||
|
||||
recheck ( entry )
|
||||
|
Loading…
Reference in New Issue
Block a user