Add option to upload the configuration to the server

This commit is contained in:
D. Berge
2023-11-13 23:25:34 +01:00
parent 69fce0e0dc
commit b64a99ab19

View File

@@ -139,6 +139,19 @@
</v-card-text>
</v-card>
</v-dialog>
<v-spacer></v-spacer>
<v-btn
class="ml-2"
color="warning"
:disabled="!configuration"
title="Save the configuration on the server. This will replace the existing configuration. The project will be set to INACTIVE. Change its state back to active once you're satisfied with your changes."
@click="upload"
>
<v-icon small left>mdi-cloud-upload</v-icon>
Upload
</v-btn>
</v-card-actions>
</v-card>
</v-col>
@@ -577,8 +590,23 @@ export default {
}
},
upload () {
console.log("UPLOAD");
async upload () {
const url = `/project/${this.$route.params.project}/configuration`;
const init = {
method: "PUT",
headers: {
//"If-Match": "" // Ensure we're not overwriting someone else's changes
"Content-Type": "application/json"
},
body: {...this.configuration, archived: true}
};
const res = await this.api([url, init]);
if (res && res.id == this.configuration.id) {
// In case the server decided to apply any changes
this.showSnack(["Configuration uploaded to server", "success"]);
this.$nextTick( () => this.configuration = res );
}
},
async loadFromFile () {
if (!this.fileInputErrors.length) {