From bf09e6af28f8c6cc1c79b94e27c66b995ba1be56 Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Sun, 12 Jul 2026 17:48:07 +0100 Subject: [PATCH] notify user on status of team image/patch upload closes #20 --- app/components/sidebar/logs/Logs.vue | 2 +- app/store.ts | 42 ++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/components/sidebar/logs/Logs.vue b/app/components/sidebar/logs/Logs.vue index 35ac4dd..75150cb 100644 --- a/app/components/sidebar/logs/Logs.vue +++ b/app/components/sidebar/logs/Logs.vue @@ -44,7 +44,7 @@ export default Vue.extend({ name: "logs", computed: mapState(["running", "currentProject", "textLog"]), watch: { - '$store.state.textLog': throttle(function (_) { + "$store.state.textLog": throttle(function (_) { this.$nextTick(() => { const wrapper = this.$refs.logsWrapper as HTMLElement; if (wrapper) { diff --git a/app/store.ts b/app/store.ts index 9098bf8..7f4fa77 100644 --- a/app/store.ts +++ b/app/store.ts @@ -95,7 +95,7 @@ export const SERVICE_NOTES = { "shepherd-run": "Code runner", "shepherd-watch": "Status information", "shepherd-ws": "Logs and images", - "hopper": "Logs and images", + hopper: "Logs and images", }; export interface StatusSummary { @@ -175,6 +175,8 @@ const MESSAGE_RUN = "RUN"; const MESSAGE_STOP = "STOP"; const MESSAGE_SAVED = "SAVED"; const MESSAGE_JSON_ERROR = "JSON_ERROR"; +const MESSAGE_TEAM_IMAGE = "TEAM_IMAGE"; +const MESSAGE_PATCH = "PATCH"; // Create a promise which resolves after a certain time export function wait(time: number): Promise { @@ -584,24 +586,54 @@ export default new Vuex.Store({ }, /**Upload a new team logo image*/ - [ACTION_UPLOAD_TEAM_LOGO]({ state }, file: File) { + [ACTION_UPLOAD_TEAM_LOGO]({ state, dispatch }, file: File) { const formData = new FormData(); formData.append("team-image.jpg", file); - return fetch("/upload/team-image", { + fetch("/upload/team-image", { method: "POST", body: formData, + }).then((resp) => { + if (!resp.ok) { + console.error(resp); + dispatch(ACTION_SHOW_MESSAGE, { + id: MESSAGE_TEAM_IMAGE, + message: "Failed to upload team image, check console for details.", + icon: "exclamation-circle", + }); + } else { + dispatch(ACTION_SHOW_MESSAGE, { + id: MESSAGE_TEAM_IMAGE, + message: "Team image uploaded", + icon: "info-circle", + }); + } }); }, /**Upload a patch file*/ - [ACTION_UPLOAD_PATCH]({ state }, file: File) { + [ACTION_UPLOAD_PATCH]({ state, dispatch }, file: File) { const formData = new FormData(); formData.append("patch.zip", file); - return fetch("/patch/upload", { + fetch("/patch/upload", { method: "POST", body: formData, + }).then((resp) => { + if (!resp.ok) { + console.error(resp); + dispatch(ACTION_SHOW_MESSAGE, { + id: MESSAGE_PATCH, + message: "Failed to upload patch, check console for details.", + icon: "exclamation-circle", + }); + } else { + dispatch(ACTION_SHOW_MESSAGE, { + id: MESSAGE_PATCH, + message: "Patching robot...", + icon: "info-circle", + }); + } }); },