refactor: satisfy linter requirements

This commit is contained in:
Marcell Fülöp
2023-02-24 21:09:21 +00:00
parent baee4641db
commit 6f98fa61e4
7 changed files with 84 additions and 89 deletions

View File

@ -60,7 +60,7 @@ function fetch(verb, path, data, options) {
beforeSend: function (xhr) {
// allow unauthenticated access to OIDC configuration
if (path === "settings/oidc-config") return;
if (path === 'settings/oidc-config') return;
xhr.setRequestHeader('Authorization', 'Bearer ' + (token ? token.t : null));
},

View File

@ -9,10 +9,10 @@ module.exports = Mn.View.extend({
className: 'modal-dialog wide',
ui: {
form: 'form',
buttons: '.modal-footer button',
cancel: 'button.cancel',
save: 'button.save',
form: 'form',
buttons: '.modal-footer button',
cancel: 'button.cancel',
save: 'button.save',
},
events: {
@ -28,16 +28,16 @@ module.exports = Mn.View.extend({
let data = this.ui.form.serializeJSON();
data.id = this.model.get('id');
if (data.meta.enabled) {
data.meta.enabled = data.meta.enabled === "on" || data.meta.enabled === "true";
data.meta.enabled = data.meta.enabled === 'on' || data.meta.enabled === 'true';
}
this.ui.buttons.prop('disabled', true).addClass('btn-disabled');
App.Api.Settings.update(data)
.then(result => {
.then((result) => {
view.model.set(result);
App.UI.closeModal();
})
.catch(err => {
.catch((err) => {
alert(err.message);
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled');
});

View File

@ -31,12 +31,12 @@ module.exports = Mn.View.extend({
.then(() => {
window.location = '/';
})
.catch(err => {
.catch((err) => {
this.ui.error.text(err.message).show();
this.ui.button.removeClass('btn-loading').prop('disabled', false);
});
},
'click @ui.oidcButton': function(e) {
'click @ui.oidcButton': function() {
this.ui.identity.prop('disabled', true);
this.ui.secret.prop('disabled', true);
this.ui.button.prop('disabled', true);
@ -51,12 +51,12 @@ module.exports = Mn.View.extend({
let cookies = document.cookie.split(';'),
token, expiry, error;
for (cookie of cookies) {
let raw = cookie.split('='),
name = raw[0].trim(),
let raw = cookie.split('='),
name = raw[0].trim(),
value = raw[1];
if (name === 'npm_oidc') {
let v = value.split('---');
token = v[0];
let v = value.split('---');
token = v[0];
expiry = v[1];
}
if (name === 'npm_oidc_error') {
@ -80,7 +80,7 @@ module.exports = Mn.View.extend({
}
// fetch oidc configuration and show alternative action button if enabled
let response = await Api.Settings.getById("oidc-config");
let response = await Api.Settings.getById('oidc-config');
if (response && response.meta && response.meta.enabled === true) {
this.ui.oidcProvider.html(response.meta.name);
this.ui.oidcLogin.show();