From 20700cdc268b9a778af70d9bd1bb6661cee6a66b Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Fri, 9 Aug 2024 17:25:53 -0700 Subject: [PATCH] Refactor Error to Dialog. Comment out Steam API key handling. We'll need some other way to get the key other than reading the environment. Separate alert from steamcmd "server output" dialog. Remove the old CSS file, as that will need to be figured out. Look into the IDE not resolving files. WIP. --- web/docroot/src/App.vue | 4 +-- web/docroot/src/components/Dialog.vue | 52 +++++++++++++++++++++++++++ web/docroot/src/components/Error.vue | 36 ------------------- web/docroot/src/components/Status.vue | 11 +++--- web/docroot/src/config.js | 8 ++--- web/docroot/src/css/index.css | 12 ------- web/docroot/src/locales/en.js | 1 + web/docroot/src/locales/pt.js | 1 + web/docroot/src/main.js | 1 - web/docroot/src/store.js | 32 ++++++++--------- web/index.js | 4 +-- web/vite.config.js | 3 +- 12 files changed, 84 insertions(+), 81 deletions(-) create mode 100644 web/docroot/src/components/Dialog.vue delete mode 100644 web/docroot/src/components/Error.vue delete mode 100644 web/docroot/src/css/index.css diff --git a/web/docroot/src/App.vue b/web/docroot/src/App.vue index 7e9fdc4..88ca8c4 100644 --- a/web/docroot/src/App.vue +++ b/web/docroot/src/App.vue @@ -1,5 +1,5 @@ + + + + diff --git a/web/docroot/src/components/Error.vue b/web/docroot/src/components/Error.vue deleted file mode 100644 index 61e0e58..0000000 --- a/web/docroot/src/components/Error.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/web/docroot/src/components/Status.vue b/web/docroot/src/components/Status.vue index 5de9d4b..5c09409 100644 --- a/web/docroot/src/components/Status.vue +++ b/web/docroot/src/components/Status.vue @@ -21,14 +21,13 @@ const test = async (type) => { } const continuous = async () => { - store.setAlert('') - store.alertLoading = true const url = '/test?type=continuous' const response = await fetch(url) + store.setStream('') for await (const chunk of response.body) { - store.alertText += new TextDecoder().decode(chunk) + store.setStream(new TextDecoder().decode(chunk), true) } - store.alertLoading = false + store.setSteamLoading(false) } @@ -72,14 +71,14 @@ const continuous = async () => {
- +
- +
diff --git a/web/docroot/src/config.js b/web/docroot/src/config.js index f16401b..64d7b4a 100644 --- a/web/docroot/src/config.js +++ b/web/docroot/src/config.js @@ -16,9 +16,9 @@ const client_appid = 221100 const serverFiles = "/serverfiles" const homeDir = "/home/user" -const steamAPIKey = process?.env["STEAMAPIKEY"] || "" - -const searchUrl = "https://api.steampowered.com/IPublishedFileService/QueryFiles/v1/?numperpage=1000&appid=221100&return_short_description=true&strip_description_bbcode=true&key=" + steamAPIKey + "&search_text=" +// const steamAPIKey = process?.env["STEAMAPIKEY"] || "" +// +// const searchUrl = "https://api.steampowered.com/IPublishedFileService/QueryFiles/v1/?numperpage=1000&appid=221100&return_short_description=true&strip_description_bbcode=true&key=" + steamAPIKey + "&search_text=" const config = { client_appid: client_appid, @@ -27,7 +27,7 @@ const config = { loginFile: homeDir + "/steamlogin", modDir: "/mods/" + client_appid, port: 8000, - searchUrl: searchUrl, + // searchUrl: searchUrl, serverFiles: serverFiles, stable_server_appid: stable_server_appid, steamUrl: 'https://steamcommunity.com/sharedfiles/filedetails/?id=', diff --git a/web/docroot/src/css/index.css b/web/docroot/src/css/index.css deleted file mode 100644 index ba5a0c9..0000000 --- a/web/docroot/src/css/index.css +++ /dev/null @@ -1,12 +0,0 @@ -.active { - background-color: cyan; -} - -.simulink { - cursor: pointer; - text-underline: blue; -} - -.simulink:hover { - background-color: green; -} diff --git a/web/docroot/src/locales/en.js b/web/docroot/src/locales/en.js index 36f898e..31ac801 100644 --- a/web/docroot/src/locales/en.js +++ b/web/docroot/src/locales/en.js @@ -25,6 +25,7 @@ export const en = { 'Server files installed': 'Server files installed', 'Server files are installed': 'Server files are installed', 'Server files were successfully installed': 'Server files were successfully installed', + 'Server Output': 'Server Output', 'Servers': 'Servers', 'Stable': 'Stable', 'Status': 'Status', diff --git a/web/docroot/src/locales/pt.js b/web/docroot/src/locales/pt.js index d2cb09c..0f95a1e 100644 --- a/web/docroot/src/locales/pt.js +++ b/web/docroot/src/locales/pt.js @@ -25,6 +25,7 @@ export const pt = { 'Server files installed': 'Arquivos de servidor instalados', 'Server files are installed': 'Arquivos de servidor estão instalados', 'Server files were successfully installed': 'Arquivos de servidor foram instalados com sucesso', + 'Server Output': 'Saída de servidor', 'Servers': 'Servidores', 'Stable': 'Estável', 'Status': 'Estado', diff --git a/web/docroot/src/main.js b/web/docroot/src/main.js index 8affd66..a1f075a 100644 --- a/web/docroot/src/main.js +++ b/web/docroot/src/main.js @@ -1,6 +1,5 @@ import 'primeicons/primeicons.css' import 'primeflex/primeflex.css' -import './css/index.css' import { createApp } from 'vue' import { createPinia } from 'pinia' diff --git a/web/docroot/src/store.js b/web/docroot/src/store.js index bd9d994..6d4f027 100644 --- a/web/docroot/src/store.js +++ b/web/docroot/src/store.js @@ -3,14 +3,11 @@ import { defineStore } from 'pinia' export const useAppStore = defineStore('app', { state: () => ({ alert: false, - alertLoading: false, alertText: '', error: false, errorText: '', - loading: false, modId: 0, modFile: false, - messageText: false, mods: [], searchText: false, servers: [], @@ -21,25 +18,29 @@ export const useAppStore = defineStore('app', { stableInstalled: false, version: '' }, + stream: false, + streamLoading: false, + streamText: '', }), actions: { - setAlert(alertText, loading = false) { + setAlert(alertText) { + this.alertText = alertText this.alert = true - this.setAlertLoading(loading) - if (loading) { - this.alertText += alertText + }, + setStream(streamText) { + this.stream = true + if (streamText) { + this.streamText += streamText } else { - this.alertText = alertText + this.streamText = '' } }, - setAlertLoading(alertLoading) { - this.alertLoading = alertLoading + setStreamLoading(streamLoading) { + this.streamLoading = streamLoading }, setError(error) { - this.error = error - }, - setLoading(loading) { - this.loading = loading + this.errorText = error + this.error = true }, setModId(modId) { this.modId = modId @@ -47,9 +48,6 @@ export const useAppStore = defineStore('app', { setModFile(modFile) { this.modFile = modFile }, - setMessageText(messageText) { - this.messageText = messageText - }, setMods(mods) { this.mods = mods }, diff --git a/web/index.js b/web/index.js index e8fe1ff..96a4153 100644 --- a/web/index.js +++ b/web/index.js @@ -320,7 +320,7 @@ app.get('/test', async (req, res) => { if (type === "error") { const ret = { "errorCode": 42, - "alert": "This is a test server error", + "error": "This is a test server error", } res.send(ret) } else if (type === "alert") { @@ -334,7 +334,7 @@ app.get('/test', async (req, res) => { res.write("data: This is a test server continuous output 1\n") await new Promise(resolve => setTimeout(resolve, 1000)); res.write("data: This is a test server continuous output 2\n") - await new Promise(resolve => setTimeout(resolve, 1000)); + await new Promise(resolve => setTimeout(resolve, 2000)); res.write("data: This is a test server continuous output 3 but it's a very long line intended to force wrapping of text because the length is so long and the girth is so gorth\n") await new Promise(resolve => setTimeout(resolve, 1000)); res.write("data: This is a test server continuous output 4\nDone!") diff --git a/web/vite.config.js b/web/vite.config.js index b5caa9c..b871b5b 100644 --- a/web/vite.config.js +++ b/web/vite.config.js @@ -1,12 +1,13 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +import path from 'path' export default defineConfig({ cacheDir: '/tmp/vite', plugins: [vue()], resolve: { alias: { - '@': './web/docroot/src/' + '@': path.resolve(__dirname, "./docroot/src/"), } }, server: {