jamesread 4 éve
szülő
commit
437d8ccb5a
3 módosított fájl, 28 hozzáadás és 29 törlés
  1. 8 8
      webui/js/ActionButton.js
  2. 4 4
      webui/js/marshaller.js
  3. 16 17
      webui/main.js

+ 8 - 8
webui/js/ActionButton.js

@@ -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
@@ -14,15 +14,15 @@ class ActionButton extends window.HTMLButtonElement {
     this.onclick = () => { this.startAction() }
     this.onclick = () => { this.startAction() }
 
 
     this.constructTemplate()
     this.constructTemplate()
-    
+
     this.updateHtml()
     this.updateHtml()
 
 
-    this.setAttribute("id", "actionButton_" + json.id)
+    this.setAttribute('id', 'actionButton_' + json.id)
   }
   }
 
 
   updateFromJson (json) {
   updateFromJson (json) {
     // Fields that should not be updated
     // Fields that should not be updated
-    // 
+    //
     // title - as the callback URL relies on it
     // title - as the callback URL relies on it
     // actionCallbackUrl - as it's based on the title
     // actionCallbackUrl - as it's based on the title
     // temporaryStatusMessage - as the button might be "waiting" on execution to finish while it's being updated.
     // 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()
     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 () {

+ 4 - 4
webui/js/marshaller.js

@@ -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) {
-      existingButton.remove();
+    if (existingButton.updateIterationTimestamp !== currentIterationTimestamp) {
+      existingButton.remove()
     }
     }
   }
   }
 }
 }

+ 16 - 17
webui/main.js

@@ -15,23 +15,23 @@ function showBigError (type, friendlyType, message) {
 }
 }
 
 
 function showSection (name) {
 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('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') }
   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')
-    themeCss.setAttribute('rel', 'stylesheet');
+    const themeCss = document.createElement('link')
+    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)
 })
 })
-