chore: lint ./app/client/src/js/index.js #242
This commit is contained in:
parent
f157984036
commit
9adfa5ae22
2 changed files with 31 additions and 26 deletions
File diff suppressed because one or more lines are too long
|
|
@ -3,8 +3,6 @@
|
||||||
import * as io from 'socket.io-client/dist/socket.io.js'
|
import * as io from 'socket.io-client/dist/socket.io.js'
|
||||||
import { Terminal } from 'xterm'
|
import { Terminal } from 'xterm'
|
||||||
import { FitAddon } from 'xterm-addon-fit'
|
import { FitAddon } from 'xterm-addon-fit'
|
||||||
/* import * as fit from 'xterm/dist/addons/fit/fit'
|
|
||||||
*/
|
|
||||||
import { library, dom } from '@fortawesome/fontawesome-svg-core'
|
import { library, dom } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faBars, faClipboard, faDownload, faKey, faCog } from '@fortawesome/free-solid-svg-icons'
|
import { faBars, faClipboard, faDownload, faKey, faCog } from '@fortawesome/free-solid-svg-icons'
|
||||||
library.add(faBars, faClipboard, faDownload, faKey, faCog)
|
library.add(faBars, faClipboard, faDownload, faKey, faCog)
|
||||||
|
|
@ -14,21 +12,21 @@ require('xterm/css/xterm.css')
|
||||||
require('../css/style.css')
|
require('../css/style.css')
|
||||||
|
|
||||||
/* global Blob, logBtn, credentialsBtn, reauthBtn, downloadLogBtn */
|
/* global Blob, logBtn, credentialsBtn, reauthBtn, downloadLogBtn */
|
||||||
var sessionLogEnable = false
|
let sessionLogEnable = false
|
||||||
var loggedData = false
|
let loggedData = false
|
||||||
var allowreplay = false
|
let allowreplay = false
|
||||||
var allowreauth = false
|
let allowreauth = false
|
||||||
var sessionLog, sessionFooter, logDate, currentDate, myFile, errorExists
|
let sessionLog, sessionFooter, logDate, currentDate, myFile, errorExists
|
||||||
var socket, termid // eslint-disable-line
|
let socket, termid // eslint-disable-line
|
||||||
const term = new Terminal()
|
const term = new Terminal()
|
||||||
// DOM properties
|
// DOM properties
|
||||||
var status = document.getElementById('status')
|
const status = document.getElementById('status')
|
||||||
var header = document.getElementById('header')
|
const header = document.getElementById('header')
|
||||||
var dropupContent = document.getElementById('dropupContent')
|
const dropupContent = document.getElementById('dropupContent')
|
||||||
var footer = document.getElementById('footer')
|
const footer = document.getElementById('footer')
|
||||||
var countdown = document.getElementById('countdown')
|
const countdown = document.getElementById('countdown')
|
||||||
var fitAddon = new FitAddon()
|
const fitAddon = new FitAddon()
|
||||||
var terminalContainer = document.getElementById('terminal-container')
|
const terminalContainer = document.getElementById('terminal-container')
|
||||||
term.loadAddon(fitAddon)
|
term.loadAddon(fitAddon)
|
||||||
term.open(terminalContainer)
|
term.open(terminalContainer)
|
||||||
term.focus()
|
term.focus()
|
||||||
|
|
@ -148,18 +146,19 @@ socket.on('error', function (err) {
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('reauth', function () {
|
socket.on('reauth', function () {
|
||||||
(allowreauth) && reauthSession()
|
if (allowreauth) {
|
||||||
|
reauthSession()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// safe shutdown
|
// safe shutdown
|
||||||
var hasCountdownStarted = false
|
let hasCountdownStarted = false
|
||||||
|
|
||||||
socket.on('shutdownCountdownUpdate', function (remainingSeconds) {
|
socket.on('shutdownCountdownUpdate', function (remainingSeconds) {
|
||||||
if (!hasCountdownStarted) {
|
if (!hasCountdownStarted) {
|
||||||
countdown.classList.add('active')
|
countdown.classList.add('active')
|
||||||
hasCountdownStarted = true
|
hasCountdownStarted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
countdown.innerText = 'Shutting down in ' + remainingSeconds + 's'
|
countdown.innerText = 'Shutting down in ' + remainingSeconds + 's'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -172,9 +171,15 @@ term.onTitleChange(function (title) {
|
||||||
function drawMenu (data) {
|
function drawMenu (data) {
|
||||||
dropupContent.innerHTML = data
|
dropupContent.innerHTML = data
|
||||||
logBtn.addEventListener('click', toggleLog)
|
logBtn.addEventListener('click', toggleLog)
|
||||||
allowreauth && reauthBtn.addEventListener('click', reauthSession)
|
if (allowreauth) {
|
||||||
allowreplay && credentialsBtn.addEventListener('click', replayCredentials)
|
reauthBtn.addEventListener('click', reauthSession)
|
||||||
loggedData && downloadLogBtn.addEventListener('click', downloadLog)
|
}
|
||||||
|
if (allowreplay) {
|
||||||
|
credentialsBtn.addEventListener('click', replayCredentials)
|
||||||
|
}
|
||||||
|
if (loggedData) {
|
||||||
|
downloadLogBtn.addEventListener('click', downloadLog)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reauthenticate
|
// reauthenticate
|
||||||
|
|
@ -231,16 +236,16 @@ function toggleLog () { // eslint-disable-line
|
||||||
function downloadLog () { // eslint-disable-line
|
function downloadLog () { // eslint-disable-line
|
||||||
if (loggedData === true) {
|
if (loggedData === true) {
|
||||||
myFile = 'WebSSH2-' + logDate.getFullYear() + (logDate.getMonth() + 1) +
|
myFile = 'WebSSH2-' + logDate.getFullYear() + (logDate.getMonth() + 1) +
|
||||||
logDate.getDate() + '_' + logDate.getHours() + logDate.getMinutes() +
|
logDate.getDate() + '_' + logDate.getHours() + logDate.getMinutes() +
|
||||||
logDate.getSeconds() + '.log'
|
logDate.getSeconds() + '.log'
|
||||||
// regex should eliminate escape sequences from being logged.
|
// regex should eliminate escape sequences from being logged.
|
||||||
var blob = new Blob([sessionLog.replace(/[\u001b\u009b][[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><;]/g, '')], { // eslint-disable-line no-control-regex
|
const blob = new Blob([sessionLog.replace(/[\u001b\u009b][[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><;]/g, '')], { // eslint-disable-line no-control-regex
|
||||||
type: 'text/plain'
|
type: 'text/plain'
|
||||||
})
|
})
|
||||||
if (window.navigator.msSaveOrOpenBlob) {
|
if (window.navigator.msSaveOrOpenBlob) {
|
||||||
window.navigator.msSaveBlob(blob, myFile)
|
window.navigator.msSaveBlob(blob, myFile)
|
||||||
} else {
|
} else {
|
||||||
var elem = window.document.createElement('a')
|
const elem = window.document.createElement('a')
|
||||||
elem.href = window.URL.createObjectURL(blob)
|
elem.href = window.URL.createObjectURL(blob)
|
||||||
elem.download = myFile
|
elem.download = myFile
|
||||||
document.body.appendChild(elem)
|
document.body.appendChild(elem)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue