<template>
  <h3>Archive</h3>
  <hr>
  <div>
    selected: {{ selection }}
  </div>
  <div>
    <button class="btn btn-secondary me-2" @click="$refs.file_selector.show()">Select files</button>
    <button class="btn btn-primary" @click="start_job">Start</button>
  </div>
  <FileSelector ref="file_selector" multiple=1 :fsdriver="estor_fs" @ok="select_ok">
  </FileSelector>
</template>

<script>
import FileSelector from '@/components/file-selector.vue';
export default {
  name: 'ArchivePage',
  props: [],
  components: {
    FileSelector,
  },
  data: function () {
    return {
      selection: null,
      estor_fs: {
        list: this.$root.estor_list,
      },
    };
  },
  computed: {
  },
  methods: {
    select_ok(selection) {
      this.selection = selection;
    },
    async start_job() {
      if (!this.selection) return;
      var r = await this.$root.estor_call("CreateJob", {
        name: "archive",
        spec: {
          type: "Relocate",
          args: {
            space: this.$root.estor_space,
            recursive: true,
            files: this.selection,
            add: [],
            remove: [],
          },
        },
      });
      console.log(r);
    },
  },
  mounted() {
  },
}
</script>

<style scoped>
</style>
