Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions app/components/dialog/RunConfigDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@
<legend>Misc</legend>
<input
type="file"
ref="file"
ref="imageFile"
accept=".jpg"
style="display: none"
@change="imageChanged"
@change="imageUpload"
/>
<button @click="uploadTeamLogo">Upload Team Logo</button>
<input
type="file"
ref="patchFile"
accept=".zip"
style="display: none"
@change="patchUpload"
/>
<button @click="uploadPatch">Upload Patch</button>
</fieldset>
</div>
<template slot="actions">
Expand All @@ -46,6 +54,7 @@ import {
MUTATION_SET_RUN_CONFIG,
RunConfiguration,
ACTION_UPLOAD_TEAM_LOGO,
ACTION_UPLOAD_PATCH,
} from "@/store";

export default Vue.extend({
Expand All @@ -71,16 +80,29 @@ export default Vue.extend({
} as RunConfiguration);
this.$emit("close");
},
imageChanged() {
const team_logo_file = (this.$refs as any).file.files[0];
imageUpload() {
const team_logo_file = (this.$refs as any).imageFile.files[0];
if (!team_logo_file) return;

console.log(`Uploading ${team_logo_file.name}...`);
console.log(`Uploading team image ${team_logo_file.name}...`);

this.$store.dispatch(ACTION_UPLOAD_TEAM_LOGO, team_logo_file);
this.$emit("close");
},
patchUpload() {
const patch_file = (this.$refs as any).patchFile.files[0];
if (!patch_file) return;

console.log(`Uploading patch ${patch_file.name}...`);

this.$store.dispatch(ACTION_UPLOAD_PATCH, patch_file);
this.$emit("close");
},
uploadTeamLogo() {
(this.$refs as any).file.click();
(this.$refs as any).imageFile.click();
},
uploadPatch() {
(this.$refs as any).patchFile.click();
},
},
});
Expand Down
16 changes: 14 additions & 2 deletions app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -168,6 +168,7 @@ export const ACTION_INIT_CAMERA_WEBSOCKET = "INIT_CAMERA_WEBSOCKET";
export const ACTION_INIT_LOG_WEBSOCKET = "INIT_LOG_WEBSOCKET";
export const ACTION_INIT_STATUS_WEBSOCKET = "INIT_STATUS_WEBSOCKET";
export const ACTION_UPLOAD_TEAM_LOGO = "UPLOAD_TEAM_LOGO";
export const ACTION_UPLOAD_PATCH = "UPLOAD_PATCH";

// Messages which can be displayed to the user
const MESSAGE_RUN = "RUN";
Expand Down Expand Up @@ -251,7 +252,7 @@ export default new Vuex.Store<State>({
"shepherd-watch": "unknown",
"shepherd-ws": "unknown",
"shepherd-run": "unknown",
"hopper": "unknown"
hopper: "unknown",
},
},
statusOpen: false,
Expand Down Expand Up @@ -590,6 +591,17 @@ export default new Vuex.Store<State>({
});
},

/**Upload a patch file*/
[ACTION_UPLOAD_PATCH]({ state }, file: File) {
const formData = new FormData();
formData.append("patch.zip", file);

return fetch("/patch/upload", {
method: "POST",
body: formData,
});
},

/**Saves the project:
* First checks if using blockly, if so:
* - Validates that all the blocks are okay
Expand Down
Loading