Add option to save local copy of configuration to local file

This commit is contained in:
D. Berge
2023-11-13 23:18:55 +01:00
parent fd84eb1ebb
commit 8dd971ffec

View File

@@ -103,8 +103,8 @@
class="ml-2"
color="primary"
:disabled="!configuration"
:href="`/api/project/${this.$route.params.project}/configuration?mime=application/yaml`"
:download="`${this.$route.params.project}.yaml`"
@click="saveToFile"
title="Save the current configuration to a file, including any changes you might have made but not yet sent to the server."
>
<v-icon small left>mdi-cloud-download</v-icon>
Download
@@ -194,6 +194,7 @@
<script>
import YAML from 'yaml';
import { mapActions, mapGetters } from 'vuex';
import { deepSet } from '@/lib/utils';
@@ -550,6 +551,22 @@ export default {
upload () {
console.log("UPLOAD");
async saveToFile () {
const payload = YAML.stringify(this.configuration);
const blob = new Blob([payload], {type: "application/yaml"});
const url = URL.createObjectURL(blob);
const filename = `${this.$route.params.project}-configuration.yaml`;
console.log(payload);
console.log(filename);
console.log(url);
const element = document.createElement('a');
element.download = filename;
element.href = url;
element.click();
console.log("Download complete. Cleaning up.");
URL.revokeObjectURL(url);
},
closeDialog () {