mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-13 09:35:37 +00:00
fmt: Cleanup terminal code (#381)
* fmt: Clean up OutputTerminal code * fmt: Clean up OutputTerminal code
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { ActionStatusDisplay } from './ActionStatusDisplay.js'
|
import { ActionStatusDisplay } from './ActionStatusDisplay.js'
|
||||||
|
import { OutputTerminal } from './OutputTerminal.js'
|
||||||
|
|
||||||
// This ExecutionDialog is NOT a custom HTML element, but rather just picks up
|
// This ExecutionDialog is NOT a custom HTML element, but rather just picks up
|
||||||
// the <dialog /> element out of index.html and just re-uses that - as only
|
// the <dialog /> element out of index.html and just re-uses that - as only
|
||||||
@@ -23,6 +24,7 @@ export class ExecutionDialog {
|
|||||||
this.domExecutionBasics = document.getElementById('execution-dialog-basics')
|
this.domExecutionBasics = document.getElementById('execution-dialog-basics')
|
||||||
this.domExecutionDetails = document.getElementById('execution-dialog-details')
|
this.domExecutionDetails = document.getElementById('execution-dialog-details')
|
||||||
|
|
||||||
|
window.terminal = new OutputTerminal()
|
||||||
window.terminal.open(this.domOutput)
|
window.terminal.open(this.domOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ export class ExecutionDialog {
|
|||||||
this.dlg.classList.add('big')
|
this.dlg.classList.add('big')
|
||||||
}
|
}
|
||||||
|
|
||||||
window.terminal.fit.fit()
|
window.terminal.fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
reset () {
|
reset () {
|
||||||
@@ -64,7 +66,7 @@ export class ExecutionDialog {
|
|||||||
this.domExecutionDetails.hidden = true
|
this.domExecutionDetails.hidden = true
|
||||||
|
|
||||||
window.terminal.reset()
|
window.terminal.reset()
|
||||||
window.terminal.fit.fit()
|
window.terminal.fit()
|
||||||
}
|
}
|
||||||
|
|
||||||
show (actionButton) {
|
show (actionButton) {
|
||||||
@@ -113,7 +115,7 @@ export class ExecutionDialog {
|
|||||||
executionTick () {
|
executionTick () {
|
||||||
this.executionSeconds++
|
this.executionSeconds++
|
||||||
|
|
||||||
this.updateDuration(this.executionSeconds + ' seconds ago', '')
|
this.updateDuration(this.executionSeconds + ' seconds', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
hideEverythingApartFromOutput () {
|
hideEverythingApartFromOutput () {
|
||||||
@@ -198,7 +200,7 @@ export class ExecutionDialog {
|
|||||||
|
|
||||||
window.terminal.reset()
|
window.terminal.reset()
|
||||||
window.terminal.write(res.logEntry.output, () => {
|
window.terminal.write(res.logEntry.output, () => {
|
||||||
window.terminal.fit.fit()
|
window.terminal.fit()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
webui.dev/js/OutputTerminal.js
Normal file
30
webui.dev/js/OutputTerminal.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { Terminal } from '@xterm/xterm'
|
||||||
|
import { FitAddon } from '@xterm/addon-fit'
|
||||||
|
|
||||||
|
export class OutputTerminal {
|
||||||
|
constructor () {
|
||||||
|
this.terminal = new Terminal({
|
||||||
|
convertEol: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const fitAddon = new FitAddon()
|
||||||
|
this.terminal.loadAddon(fitAddon)
|
||||||
|
this.terminal.fit = fitAddon
|
||||||
|
}
|
||||||
|
|
||||||
|
write (out, then) {
|
||||||
|
this.terminal.write(out, then)
|
||||||
|
}
|
||||||
|
|
||||||
|
fit () {
|
||||||
|
this.terminal.fit.fit()
|
||||||
|
}
|
||||||
|
|
||||||
|
open (el) {
|
||||||
|
this.terminal.open(el)
|
||||||
|
}
|
||||||
|
|
||||||
|
reset () {
|
||||||
|
this.terminal.reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import './ActionButton.js' // To define action-button
|
import './ActionButton.js' // To define action-button
|
||||||
import { ExecutionDialog } from './ExecutionDialog.js'
|
import { ExecutionDialog } from './ExecutionDialog.js'
|
||||||
import { Terminal } from '@xterm/xterm'
|
|
||||||
import { FitAddon } from '@xterm/addon-fit'
|
|
||||||
import { ActionStatusDisplay } from './ActionStatusDisplay.js'
|
import { ActionStatusDisplay } from './ActionStatusDisplay.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,14 +9,6 @@ export function initMarshaller () {
|
|||||||
window.changeDirectory = changeDirectory
|
window.changeDirectory = changeDirectory
|
||||||
window.showSection = showSection
|
window.showSection = showSection
|
||||||
|
|
||||||
window.terminal = new Terminal({
|
|
||||||
convertEol: true
|
|
||||||
})
|
|
||||||
|
|
||||||
const fitAddon = new FitAddon()
|
|
||||||
window.terminal.loadAddon(fitAddon)
|
|
||||||
window.terminal.fit = fitAddon
|
|
||||||
|
|
||||||
window.executionDialog = new ExecutionDialog()
|
window.executionDialog = new ExecutionDialog()
|
||||||
|
|
||||||
window.logEntries = {}
|
window.logEntries = {}
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ function processWebuiSettingsJson (settings) {
|
|||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
initMarshaller()
|
initMarshaller()
|
||||||
|
|
||||||
setupLogSearchBox()
|
setupLogSearchBox()
|
||||||
|
|
||||||
window.addEventListener('EventConfigChanged', fetchGetDashboardComponents)
|
window.addEventListener('EventConfigChanged', fetchGetDashboardComponents)
|
||||||
|
|||||||
Reference in New Issue
Block a user