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 { class ActionButton extends window.HTMLButtonElement {
constructFromJson (json) { constructFromJson (json) {
this.updateIterationTimestamp = 0; this.updateIterationTimestamp = 0
this.title = json.title this.title = json.title
this.temporaryStatusMessage = null this.temporaryStatusMessage = null
@ -17,7 +17,7 @@ class ActionButton extends window.HTMLButtonElement {
this.updateHtml() this.updateHtml()
this.setAttribute("id", "actionButton_" + json.id) this.setAttribute('id', 'actionButton_' + json.id)
} }
updateFromJson (json) { updateFromJson (json) {
@ -42,7 +42,7 @@ class ActionButton extends window.HTMLButtonElement {
window.fetch(this.actionCallUrl).then(res => res.json() window.fetch(this.actionCallUrl).then(res => res.json()
).then((json) => { ).then((json) => {
marshalLogsJsonToHtml({"logs": [json.logEntry]}) marshalLogsJsonToHtml({ logs: [json.logEntry] })
if (json.logEntry.timedOut) { if (json.logEntry.timedOut) {
this.onActionResult('actionTimeout', 'Timed out') this.onActionResult('actionTimeout', 'Timed out')
@ -63,7 +63,7 @@ class ActionButton extends window.HTMLButtonElement {
setTimeout(() => { setTimeout(() => {
this.classList.remove(cssClass) this.classList.remove(cssClass)
}, 1000); }, 1000)
} }
onActionError (err) { onActionError (err) {
@ -75,7 +75,7 @@ class ActionButton extends window.HTMLButtonElement {
setTimeout(() => { setTimeout(() => {
this.classList.remove('actionFailed') this.classList.remove('actionFailed')
}, 1000); }, 1000)
} }
constructTemplate () { constructTemplate () {

View File

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

View File

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