eslint codestyle

This commit is contained in:
jamesread 2021-10-18 10:42:41 +01:00
parent ad93c8e3ff
commit 437d8ccb5a
3 changed files with 28 additions and 29 deletions

View File

@ -1,8 +1,8 @@
import { marshalLogsJsonToHtml } from './marshaller.js';
import { marshalLogsJsonToHtml } from './marshaller.js'
class ActionButton extends window.HTMLButtonElement {
constructFromJson (json) {
this.updateIterationTimestamp = 0;
this.updateIterationTimestamp = 0
this.title = json.title
this.temporaryStatusMessage = null
@ -14,15 +14,15 @@ class ActionButton extends window.HTMLButtonElement {
this.onclick = () => { this.startAction() }
this.constructTemplate()
this.updateHtml()
this.setAttribute("id", "actionButton_" + json.id)
this.setAttribute('id', 'actionButton_' + json.id)
}
updateFromJson (json) {
// Fields that should not be updated
//
//
// title - as the callback URL relies on it
// actionCallbackUrl - as it's based on the title
// temporaryStatusMessage - as the button might be "waiting" on execution to finish while it's being updated.
@ -42,7 +42,7 @@ class ActionButton extends window.HTMLButtonElement {
window.fetch(this.actionCallUrl).then(res => res.json()
).then((json) => {
marshalLogsJsonToHtml({"logs": [json.logEntry]})
marshalLogsJsonToHtml({ logs: [json.logEntry] })
if (json.logEntry.timedOut) {
this.onActionResult('actionTimeout', 'Timed out')
@ -63,7 +63,7 @@ class ActionButton extends window.HTMLButtonElement {
setTimeout(() => {
this.classList.remove(cssClass)
}, 1000);
}, 1000)
}
onActionError (err) {
@ -75,7 +75,7 @@ class ActionButton extends window.HTMLButtonElement {
setTimeout(() => {
this.classList.remove('actionFailed')
}, 1000);
}, 1000)
}
constructTemplate () {

View File

@ -4,7 +4,7 @@ export function marshalActionButtonsJsonToHtml (json) {
const currentIterationTimestamp = Date.now()
for (const jsonButton of json.actions) {
var htmlButton = document.querySelector('#actionButton_' + jsonButton.id)
let htmlButton = document.querySelector('#actionButton_' + jsonButton.id)
if (htmlButton == null) {
htmlButton = document.createElement('button', { is: 'action-button' })
@ -16,12 +16,12 @@ export function marshalActionButtonsJsonToHtml (json) {
htmlButton.updateHtml()
}
htmlButton.updateIterationTimestamp = currentIterationTimestamp;
htmlButton.updateIterationTimestamp = currentIterationTimestamp
}
for (const existingButton of document.querySelector('#contentActions').querySelectorAll('button')) {
if (existingButton.updateIterationTimestamp != currentIterationTimestamp) {
existingButton.remove();
if (existingButton.updateIterationTimestamp !== currentIterationTimestamp) {
existingButton.remove()
}
}
}

View File

@ -15,23 +15,23 @@ function showBigError (type, friendlyType, message) {
}
function showSection (name) {
for (let otherName of ["Actions", "Logs"]) {
document.getElementById('show' + otherName).classList.remove('activeSection');
document.getElementById('content' + otherName).hidden = true;
for (const otherName of ['Actions', 'Logs']) {
document.getElementById('show' + otherName).classList.remove('activeSection')
document.getElementById('content' + otherName).hidden = true
}
document.getElementById('show' + name).classList.add('activeSection')
document.getElementById('content' + name).hidden = false;
document.getElementById('content' + name).hidden = false
}
function setupSections() {
document.getElementById('showActions').onclick = () => { showSection('Actions') };
function setupSections () {
document.getElementById('showActions').onclick = () => { showSection('Actions') }
document.getElementById('showLogs').onclick = () => { showSection('Logs') }
showSection('Actions');
showSection('Actions')
}
function fetchGetButtons() {
function fetchGetButtons () {
window.fetch(window.restBaseUrl + 'GetButtons', {
cors: 'cors'
}).then(res => {
@ -43,7 +43,7 @@ function fetchGetButtons() {
})
}
function fetchGetLogs() {
function fetchGetLogs () {
window.fetch(window.restBaseUrl + 'GetLogs', {
cors: 'cors'
}).then(res => {
@ -59,16 +59,16 @@ function processWebuiSettingsJson (settings) {
window.restBaseUrl = settings.Rest
if (settings.ThemeName) {
var themeCss = document.createElement('link')
themeCss.setAttribute('rel', 'stylesheet');
const themeCss = document.createElement('link')
themeCss.setAttribute('rel', 'stylesheet')
themeCss.setAttribute('type', 'text/css')
themeCss.setAttribute('href', '/themes/' + settings.ThemeName + '/theme.css');
themeCss.setAttribute('href', '/themes/' + settings.ThemeName + '/theme.css')
document.head.appendChild(themeCss);
document.head.appendChild(themeCss)
}
}
setupSections();
setupSections()
window.fetch('webUiSettings.json').then(res => {
return res.json()
@ -78,8 +78,7 @@ window.fetch('webUiSettings.json').then(res => {
fetchGetButtons()
fetchGetLogs()
window.buttonInterval = setInterval(fetchGetButtons, 3000);
window.buttonInterval = setInterval(fetchGetButtons, 3000)
}).catch(err => {
showBigError('fetch-webui-settings', 'getting webui settings', err)
})