From 1f77a12c964a2116e9a3afb7792ebad8744405e0 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Sun, 5 Jan 2025 15:20:50 +0000 Subject: [PATCH 01/12] Enhance LogCard.vue with log file selection and clipboard copy functionality --- src/components/debug_config/LogCard.vue | 112 ++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 6 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index ea206e31..0d74fb38 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -8,25 +8,55 @@ <template #actions> <openwb-base-avatar class="bg-success clickable" - @click.stop="loadLog(logFile)" + @click.stop="loadLog(logFile, selectedVariant)" > <font-awesome-icon fixed-width :class="loading ? 'fa-spin-pulse' : ''" :icon="loading ? ['fas', 'spinner'] : ['fas', 'file-download']" + title="Log laden/aktualisieren" /> </openwb-base-avatar> </template> + <openwb-base-alert + v-if="foundFiles.length > 0" + subtype="info" + > + Im {{ title }} stehen unterschiedliche Logauszüge zur Verfügung. Standardmässig werden Logs des letzten Durchaufs + geladen, für viele Fälle sollte dies ausreichen. Optional kann auch das gesamte Log geladen werden.<br /> + Wurde eine Warnung oder ein Fehler protokolliert steht zusätzlich der letzte Durchlauf mit Warnungen und Fehlern + zur Verfügung.<br /> + <openwb-base-select-input + v-model="selectedVariant" + title="Logfile" + required + :options="foundFiles.map((file) => ({ value: file.suffix, text: file.title }))" + @change="loadLog(logFile, selectedVariant)" + /> + </openwb-base-alert> + <div class="col-12 text-right"> + <a + href="#" + @click.prevent="copyToClipboard" + >Kopiere Log in die Zwischenablage</a + > + </div> <pre class="log-data mb-0">{{ logData }}</pre> + + <!-- Text with hyperlink to copy logData to clipboard --> </openwb-base-card> </template> <script> import { library } from "@fortawesome/fontawesome-svg-core"; -import { faFileDownload as fasFileDownload, faSpinner as fasSpinner } from "@fortawesome/free-solid-svg-icons"; +import { + faFileDownload as fasFileDownload, + faSpinner as fasSpinner, + faFileAlt as fasFileAlt, +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(fasFileDownload, fasSpinner); +library.add(fasFileDownload, fasSpinner, fasFileAlt); export default { name: "OpenwbLogCard", @@ -47,16 +77,25 @@ export default { return { logData: "-- noch nicht geladen --", loading: false, + foundFiles: [], // Array to store found files with title, suffix, and description + selectedVariant: "", // Selected file variant }; }, + mounted() { + this.checkLatestLog(this.logFile); + }, methods: { - async getFilePromise(myFile, ignore404 = false) { + async getFilePromise(myFile, ignore404 = false, handleError = true) { return this.axios .get(location.protocol + "//" + location.host + myFile) .then((response) => { - return response.data; + const data = response.data; + return data ? data : "-- Log ist leer --"; }) .catch((error) => { + if (!handleError) { + throw error; + } if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx @@ -83,10 +122,13 @@ export default { } }); }, - async loadLog(fileName) { + async loadLog(fileName, fileNameVariant = "") { this.logData = "wird aktualisiert..."; this.loading = true; var logContents = ""; + if (fileNameVariant) { + fileName = fileName.replace(".log", `.${fileNameVariant}.log`); + } for (let i = 4; i >= 1; i--) { const result = await this.getFilePromise(fileName + "." + i, true); @@ -99,6 +141,64 @@ export default { this.logData = logContents; this.loading = false; }, + async checkLatestLog(fileName) { + // Define file name variations + const fileVariations = [ + { suffix: "latest", title: "Letzter Durchlauf", description: "Logs des Letzten Durchlauf laden" }, + { + suffix: "latest-warning", + title: "Letzter Durchlauf mit Warnung oder Fehler", + description: "Fehlerprotokoll laden", + }, + // Add more variations as needed + ]; + // Check for the existence of the .latest log file + this.foundFiles = []; + for (const variation of fileVariations) { + const variantFileName = fileName.replace(".log", `.${variation.suffix}.log`); + try { + await this.getFilePromise(variantFileName, false, false); + this.foundFiles.push(variation); + if (variation.suffix === "latest") { + this.selectedVariant = "latest"; + } + } catch (error) { + console.log(error); + } + } + if (this.foundFiles.length > 0) { + this.foundFiles.push({ + suffix: "", + title: "Vollständiges Log", + description: "Vollständiges Log laden", + }); + } + }, + copyToClipboard() { + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard + .writeText(this.logData) + .then(() => { + alert("Logs in die Zwischenablage kopiert."); + }) + .catch((err) => { + console.error("Fehler beim Kopieren in die Zwischenablage: ", err); + }); + } else { + // Fallback method for older browsers and non-HTTPS contexts + const textArea = document.createElement("textarea"); + textArea.value = this.logData; + document.body.appendChild(textArea); + textArea.select(); + try { + document.execCommand("copy"); + alert("Logs in die Zwischenablage kopiert."); + } catch (err) { + console.error("Fehler beim Kopieren in die Zwischenablage: ", err); + } + document.body.removeChild(textArea); + } + }, }, }; </script> From 5a3c057af642f350424770b52723336033946f8e Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Sun, 5 Jan 2025 21:27:52 +0000 Subject: [PATCH 02/12] update confirmation for clipboard copy --- src/components/debug_config/LogCard.vue | 28 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 0d74fb38..f45deef9 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -34,16 +34,24 @@ @change="loadLog(logFile, selectedVariant)" /> </openwb-base-alert> - <div class="col-12 text-right"> + + <div + v-if="!copyMessage" + class="text-right" + > <a href="#" @click.prevent="copyToClipboard" >Kopiere Log in die Zwischenablage</a > </div> + <div + v-if="copyMessage" + class="copy-message text-right" + > + {{ copyMessage }} + </div> <pre class="log-data mb-0">{{ logData }}</pre> - - <!-- Text with hyperlink to copy logData to clipboard --> </openwb-base-card> </template> @@ -79,6 +87,7 @@ export default { loading: false, foundFiles: [], // Array to store found files with title, suffix, and description selectedVariant: "", // Selected file variant + copyMessage: "", // Message to show when log data is copied }; }, mounted() { @@ -179,7 +188,7 @@ export default { navigator.clipboard .writeText(this.logData) .then(() => { - alert("Logs in die Zwischenablage kopiert."); + this.showCopyMessage("Logs in Zwischenablage kopiert"); }) .catch((err) => { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); @@ -192,13 +201,19 @@ export default { textArea.select(); try { document.execCommand("copy"); - alert("Logs in die Zwischenablage kopiert."); + this.showCopyMessage("Logs in Zwischenablage kopiert"); } catch (err) { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); } document.body.removeChild(textArea); } }, + showCopyMessage(message) { + this.copyMessage = message; + setTimeout(() => { + this.copyMessage = ""; + }, 3000); // Message disappears after 3 seconds + }, }, }; </script> @@ -208,4 +223,7 @@ export default { max-height: 70vh; overflow-y: scroll; } +.copy-message { + color: green; +} </style> From 363dc1ff68c22693a3eda836558d12c599b92a4e Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 6 Jan 2025 19:56:07 +0000 Subject: [PATCH 03/12] add events for collapsed/expanded --- src/components/OpenwbBaseCard.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/OpenwbBaseCard.vue b/src/components/OpenwbBaseCard.vue index 52a78a19..9ad79103 100644 --- a/src/components/OpenwbBaseCard.vue +++ b/src/components/OpenwbBaseCard.vue @@ -97,22 +97,33 @@ export default { collapsible: { type: Boolean, default: false }, collapsed: { type: Boolean, default: false }, }, + emits: ["collapsed", "expanded"], data() { return { isCollapsed: this.collapsible && this.collapsed, }; }, + watch: { + collapsed(newVal) { + this.isCollapsed = newVal; + }, + }, methods: { toggleBody() { if (this.collapsible === true) { this.isCollapsed = !this.isCollapsed; } + if (this.isCollapsed) { + this.$emit("collapsed"); + } else { + this.$emit("expanded"); + } }, }, }; </script> -<style> +<style scoped> .card { margin-bottom: 1rem; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); From 047b11d518edab3c415b6da62bcd5f65cbfc98eb Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 6 Jan 2025 19:56:40 +0000 Subject: [PATCH 04/12] only load log when card is expaded --- src/components/debug_config/LogCard.vue | 35 +++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index f45deef9..852813f7 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -4,6 +4,7 @@ class="log-card" :collapsible="true" :collapsed="true" + @expanded="onCardExpand" > <template #actions> <openwb-base-avatar @@ -22,7 +23,7 @@ v-if="foundFiles.length > 0" subtype="info" > - Im {{ title }} stehen unterschiedliche Logauszüge zur Verfügung. Standardmässig werden Logs des letzten Durchaufs + Im {{ title }} stehen unterschiedliche Logauszüge zur Verfügung. Standardmässig werden Logs des letzten Durchlaufs geladen, für viele Fälle sollte dies ausreichen. Optional kann auch das gesamte Log geladen werden.<br /> Wurde eine Warnung oder ein Fehler protokolliert steht zusätzlich der letzte Durchlauf mit Warnungen und Fehlern zur Verfügung.<br /> @@ -49,7 +50,7 @@ v-if="copyMessage" class="copy-message text-right" > - {{ copyMessage }} + Logs in die Zwischenablage kopiert. </div> <pre class="log-data mb-0">{{ logData }}</pre> </openwb-base-card> @@ -57,14 +58,10 @@ <script> import { library } from "@fortawesome/fontawesome-svg-core"; -import { - faFileDownload as fasFileDownload, - faSpinner as fasSpinner, - faFileAlt as fasFileAlt, -} from "@fortawesome/free-solid-svg-icons"; +import { faFileDownload as fasFileDownload, faSpinner as fasSpinner } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(fasFileDownload, fasSpinner, fasFileAlt); +library.add(fasFileDownload, fasSpinner); export default { name: "OpenwbLogCard", @@ -87,12 +84,9 @@ export default { loading: false, foundFiles: [], // Array to store found files with title, suffix, and description selectedVariant: "", // Selected file variant - copyMessage: "", // Message to show when log data is copied + copyMessage: false, // Flag to show copy message }; }, - mounted() { - this.checkLatestLog(this.logFile); - }, methods: { async getFilePromise(myFile, ignore404 = false, handleError = true) { return this.axios @@ -183,12 +177,16 @@ export default { }); } }, + onCardExpand() { + this.checkLatestLog(this.logFile); + this.loadLog(this.logFile, this.selectedVariant); + }, copyToClipboard() { if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard .writeText(this.logData) .then(() => { - this.showCopyMessage("Logs in Zwischenablage kopiert"); + this.showCopyMessage(); }) .catch((err) => { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); @@ -201,17 +199,17 @@ export default { textArea.select(); try { document.execCommand("copy"); - this.showCopyMessage("Logs in Zwischenablage kopiert"); + this.showCopyMessage(); } catch (err) { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); } document.body.removeChild(textArea); } }, - showCopyMessage(message) { - this.copyMessage = message; + showCopyMessage() { + this.copyMessage = true; setTimeout(() => { - this.copyMessage = ""; + this.copyMessage = false; }, 3000); // Message disappears after 3 seconds }, }, @@ -223,7 +221,4 @@ export default { max-height: 70vh; overflow-y: scroll; } -.copy-message { - color: green; -} </style> From b6cd15152ec0dc42261baf29fc40b957035c6238 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 6 Jan 2025 20:13:15 +0000 Subject: [PATCH 05/12] validate file existence using HEAD instead of GET --- src/components/debug_config/LogCard.vue | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 852813f7..5205eb9d 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -88,23 +88,28 @@ export default { }; }, methods: { - async getFilePromise(myFile, ignore404 = false, handleError = true) { - return this.axios - .get(location.protocol + "//" + location.host + myFile) + async getFilePromise(myFile, ignore404 = false, handleError = true, useHead = false) { + const requestMethod = useHead ? "head" : "get"; + return this.axios[requestMethod](location.protocol + "//" + location.host + myFile) .then((response) => { - const data = response.data; - return data ? data : "-- Log ist leer --"; + if (useHead) { + // If the request is successful, the file exists + return true; + } else { + const data = response.data; + return data ? data : "log file is empty"; + } }) .catch((error) => { if (!handleError) { throw error; } if (error.response) { - // The request was made and the server responded with a status code + // The request was made but the server responded with a status code // that falls out of the range of 2xx if (error.response.status == 404 && ignore404) { // ignore a 404 if requested, used for rotated log files which may not exist yet - return ""; + return useHead ? false : ""; } return ( "A 404 is expected if running node.js dev server!\n" + @@ -144,7 +149,7 @@ export default { this.logData = logContents; this.loading = false; }, - async checkLatestLog(fileName) { + checkLatestLog(fileName) { // Define file name variations const fileVariations = [ { suffix: "latest", title: "Letzter Durchlauf", description: "Logs des Letzten Durchlauf laden" }, @@ -160,7 +165,7 @@ export default { for (const variation of fileVariations) { const variantFileName = fileName.replace(".log", `.${variation.suffix}.log`); try { - await this.getFilePromise(variantFileName, false, false); + this.getFilePromise(variantFileName, false, false, true); this.foundFiles.push(variation); if (variation.suffix === "latest") { this.selectedVariant = "latest"; From d1c857c09be47302d854c5da370f883cb783e95e Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 6 Jan 2025 20:36:24 +0000 Subject: [PATCH 06/12] bug fixes --- src/components/debug_config/LogCard.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 5205eb9d..6c94e006 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -149,7 +149,7 @@ export default { this.logData = logContents; this.loading = false; }, - checkLatestLog(fileName) { + async checkLatestLog(fileName) { // Define file name variations const fileVariations = [ { suffix: "latest", title: "Letzter Durchlauf", description: "Logs des Letzten Durchlauf laden" }, @@ -165,10 +165,11 @@ export default { for (const variation of fileVariations) { const variantFileName = fileName.replace(".log", `.${variation.suffix}.log`); try { - this.getFilePromise(variantFileName, false, false, true); + await this.getFilePromise(variantFileName, false, false, true); this.foundFiles.push(variation); if (variation.suffix === "latest") { this.selectedVariant = "latest"; + console.log("Found latest log file: ", variantFileName); } } catch (error) { console.log(error); @@ -182,8 +183,8 @@ export default { }); } }, - onCardExpand() { - this.checkLatestLog(this.logFile); + async onCardExpand() { + await this.checkLatestLog(this.logFile); this.loadLog(this.logFile, this.selectedVariant); }, copyToClipboard() { From 015b7711f55aba664f97157da06a3a6a3fceec24 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 20 Jan 2025 08:08:45 +0000 Subject: [PATCH 07/12] udpate v-if to v-else for better readability --- src/components/debug_config/LogCard.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 6c94e006..45219641 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -47,7 +47,7 @@ > </div> <div - v-if="copyMessage" + v-else class="copy-message text-right" > Logs in die Zwischenablage kopiert. From 957f59a53865cfdb552700ff479aac29badc0ce3 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Mon, 20 Jan 2025 08:20:07 +0000 Subject: [PATCH 08/12] adress review comments --- src/components/OpenwbBaseCard.vue | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/components/OpenwbBaseCard.vue b/src/components/OpenwbBaseCard.vue index 9ad79103..afea0ac0 100644 --- a/src/components/OpenwbBaseCard.vue +++ b/src/components/OpenwbBaseCard.vue @@ -103,20 +103,12 @@ export default { isCollapsed: this.collapsible && this.collapsed, }; }, - watch: { - collapsed(newVal) { - this.isCollapsed = newVal; - }, - }, + methods: { toggleBody() { if (this.collapsible === true) { this.isCollapsed = !this.isCollapsed; - } - if (this.isCollapsed) { - this.$emit("collapsed"); - } else { - this.$emit("expanded"); + this.$emit(this.isCollapsed ? "collapsed" : "expanded"); } }, }, From d5a452465865182a2448b60b7ca1cda8e8613af1 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Wed, 26 Feb 2025 08:54:23 +0000 Subject: [PATCH 09/12] add posting logs to paste.openwb.de from LogCard --- src/components/debug_config/LogCard.vue | 105 +++++++++++++++++++----- 1 file changed, 84 insertions(+), 21 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 45219641..469561da 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -36,21 +36,48 @@ /> </openwb-base-alert> - <div - v-if="!copyMessage" - class="text-right" - > - <a - href="#" - @click.prevent="copyToClipboard" - >Kopiere Log in die Zwischenablage</a - > - </div> - <div - v-else - class="copy-message text-right" - > - Logs in die Zwischenablage kopiert. + <div class="row"> + <div class="col-auto"> + <div + v-if="!copyMessage" + class="text-right" + > + <a + href="#" + @click.prevent="copyToClipboard(logData)" + >Kopiere Log in die Zwischenablage</a + > + </div> + <div + v-else + class="copy-message text-right" + > + Logs in die Zwischenablage kopiert. + </div> + </div> + <div class="col-auto"> + <div + v-if="!pastebinLink" + class="text-right" + > + <a + href="#" + @click.prevent="postToPastebin" + >Poste Logs auf paste.openwb.de</a + > + </div> + <div + v-else + class="copy-message text-right" + > + Logs geposted. + <a + :href="pastebinLink" + target="_blank" + >Link in die Zwischenablage kopiert.</a + > + </div> + </div> </div> <pre class="log-data mb-0">{{ logData }}</pre> </openwb-base-card> @@ -60,6 +87,7 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faFileDownload as fasFileDownload, faSpinner as fasSpinner } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; +import axios from "axios"; library.add(fasFileDownload, fasSpinner); @@ -85,12 +113,13 @@ export default { foundFiles: [], // Array to store found files with title, suffix, and description selectedVariant: "", // Selected file variant copyMessage: false, // Flag to show copy message + pastebinLink: "", // Link to the pastebin entry }; }, methods: { async getFilePromise(myFile, ignore404 = false, handleError = true, useHead = false) { const requestMethod = useHead ? "head" : "get"; - return this.axios[requestMethod](location.protocol + "//" + location.host + myFile) + return axios[requestMethod](location.protocol + "//" + location.host + myFile) .then((response) => { if (useHead) { // If the request is successful, the file exists @@ -133,6 +162,7 @@ export default { async loadLog(fileName, fileNameVariant = "") { this.logData = "wird aktualisiert..."; this.loading = true; + this.pastebinLink = ""; // Clear the pastebin link var logContents = ""; if (fileNameVariant) { fileName = fileName.replace(".log", `.${fileNameVariant}.log`); @@ -187,12 +217,14 @@ export default { await this.checkLatestLog(this.logFile); this.loadLog(this.logFile, this.selectedVariant); }, - copyToClipboard() { + copyToClipboard(text = this.logData, showMessage = true) { if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard - .writeText(this.logData) + .writeText(text) .then(() => { - this.showCopyMessage(); + if (showMessage) { + this.showCopyMessage(); + } }) .catch((err) => { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); @@ -200,12 +232,14 @@ export default { } else { // Fallback method for older browsers and non-HTTPS contexts const textArea = document.createElement("textarea"); - textArea.value = this.logData; + textArea.value = text; document.body.appendChild(textArea); textArea.select(); try { document.execCommand("copy"); - this.showCopyMessage(); + if (showMessage) { + this.showCopyMessage(); + } } catch (err) { console.error("Fehler beim Kopieren in die Zwischenablage: ", err); } @@ -218,6 +252,35 @@ export default { this.copyMessage = false; }, 3000); // Message disappears after 3 seconds }, + async postToPastebin() { + try { + const response = await fetch("https://bytebin.openwb.de/post", { + method: "POST", + headers: { + "Content-Type": "text/log", + }, + body: this.logData, + }); + + if (!response.ok) { + throw new Error("Network response was not ok"); + } + + const responseData = await response.json(); + const pastebinKey = responseData.key; + if (!pastebinKey) { + console.log(responseData); + throw new Error("Key is missing in the response"); + } + console.log(responseData); + + this.pastebinLink = `https://paste.openwb.de/${pastebinKey}`; + console.log("Pastebin link:", this.pastebinLink); + this.copyToClipboard(this.pastebinLink, false); + } catch (error) { + console.error("Fehler beim Posten auf paste.openwb.de: ", error); + } + }, }, }; </script> From ddfb5f0bb76d4d12b4b9b63d8e35e53a6e19d25d Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Wed, 26 Feb 2025 20:59:30 +0000 Subject: [PATCH 10/12] add icons --- src/components/debug_config/LogCard.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index 469561da..f79a420f 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -45,7 +45,7 @@ <a href="#" @click.prevent="copyToClipboard(logData)" - >Kopiere Log in die Zwischenablage</a + ><font-awesome-icon icon="clipboard" /> Log in die Zwischenablage</a > </div> <div @@ -63,14 +63,14 @@ <a href="#" @click.prevent="postToPastebin" - >Poste Logs auf paste.openwb.de</a + ><font-awesome-icon :icon="['fas', 'share-nodes']" /> Logs auf paste.openwb.de teilen</a > </div> <div v-else class="copy-message text-right" > - Logs geposted. + Logs geteilt. <a :href="pastebinLink" target="_blank" @@ -85,11 +85,16 @@ <script> import { library } from "@fortawesome/fontawesome-svg-core"; -import { faFileDownload as fasFileDownload, faSpinner as fasSpinner } from "@fortawesome/free-solid-svg-icons"; +import { + faClipboard as fasClipboard, + faFileDownload as fasFileDownload, + faSpinner as fasSpinner, + faShareNodes as fasShareNodes, +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import axios from "axios"; -library.add(fasFileDownload, fasSpinner); +library.add(fasFileDownload, fasSpinner, fasClipboard, fasShareNodes); export default { name: "OpenwbLogCard", From e12aebfe969d7f691243ff2cc0763628d9121cc4 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Thu, 6 Mar 2025 20:36:59 +0000 Subject: [PATCH 11/12] use gzip for upload --- package.json | 1 + src/components/debug_config/LogCard.vue | 22 +++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4cfeda55..3c60ddb4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "lodash": "^4.17.21", "luxon": "^3.5.0", "mqtt": "^4.3.8", + "pako": "^2.1.0", "popper.js": "^1.16.1", "stream-browserify": "^3.0.0", "url": "^0.11.4", diff --git a/src/components/debug_config/LogCard.vue b/src/components/debug_config/LogCard.vue index f79a420f..a34e8611 100644 --- a/src/components/debug_config/LogCard.vue +++ b/src/components/debug_config/LogCard.vue @@ -93,6 +93,7 @@ import { } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import axios from "axios"; +import pako from "pako"; library.add(fasFileDownload, fasSpinner, fasClipboard, fasShareNodes); @@ -259,26 +260,21 @@ export default { }, async postToPastebin() { try { - const response = await fetch("https://bytebin.openwb.de/post", { - method: "POST", + // Compress the log data using gzip + const compressedData = pako.gzip(this.logData); + + const response = await axios.post("https://bytebin.openwb.de/post", compressedData, { headers: { - "Content-Type": "text/log", + "Content-Type": "application/octet-stream", + "Content-Encoding": "gzip", }, - body: this.logData, }); - if (!response.ok) { - throw new Error("Network response was not ok"); - } - - const responseData = await response.json(); - const pastebinKey = responseData.key; - if (!pastebinKey) { - console.log(responseData); + if (!response.data.key) { throw new Error("Key is missing in the response"); } - console.log(responseData); + const pastebinKey = response.data.key; this.pastebinLink = `https://paste.openwb.de/${pastebinKey}`; console.log("Pastebin link:", this.pastebinLink); this.copyToClipboard(this.pastebinLink, false); From bf648ee7166f1d0663dec5ef60f1ff0219c21c74 Mon Sep 17 00:00:00 2001 From: MartinRinas <martrin@microsoft.com> Date: Fri, 7 Mar 2025 19:46:24 +0000 Subject: [PATCH 12/12] fix build --- package-lock.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7be3813..f8068fae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "lodash": "^4.17.21", "luxon": "^3.5.0", "mqtt": "^4.3.8", + "pako": "^2.1.0", "popper.js": "^1.16.1", "stream-browserify": "^3.0.0", "url": "^0.11.4", @@ -2996,6 +2997,12 @@ "pako": "~1.0.5" } }, + "node_modules/browserify-zlib/node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "license": "(MIT AND Zlib)" + }, "node_modules/browserify/node_modules/buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", @@ -5948,9 +5955,10 @@ } }, "node_modules/pako": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "license": "(MIT AND Zlib)" }, "node_modules/parent-module": { "version": "1.0.1",