<template>
  <h3>
    备份和恢复
  </h3>
  <hr>
  <div class="fade-in">
    <div class="alert alert-info">
      <h4>
        备份数据到阿里云OSS
      </h4>
      <hr>
      <p>Bucket: emblem-archive-prod</p>
      <p>阿里云账号: 1797148457430235</p>
      <p>范围：所有本地数据和特征</p>
      <p>OSS区域：深圳</p>
      <button class="d-block btn btn-primary" @click="backup_to_oss">开始</button>
    </div>
    <div class="alert alert-info">
      <h4>
        备份数据到Windows SMB / CIFS
      </h4>
      <hr>
      <p>IP: <input class="form-control" type="text" v-model="smb_host"/></p>
      <p>共享空间: <input class="form-control" type="text" v-model="smb_share_name"/></p>
      <p>用户名: <input class="form-control" type="text" v-model="smb_user"/></p>
      <p>密码: <input class="form-control" type="password" v-model="smb_pass"/></p>
      <button class="d-block btn btn-primary" @click="backup_to_smb">开始</button>
    </div>
    <div class="alert alert-info">
      <h4>
        备份数据到NFS
      </h4>
      <hr>
      <p>IP: <input class="form-control" type="text" v-model="nfs_host"/></p>
      <p>路径: <input class="form-control" type="text" v-model="nfs_path"/></p>
      <button class="d-block btn btn-primary" @click="backup_to_nfs">开始</button>
    </div>
    <div class="alert alert-info">
      <h4>
        备份数据到USB存储
      </h4>
      <hr>
      <p>USB设备(TODO): </p>
      <button class="d-block btn btn-primary" @click="backup_to_usb">开始</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'EstorBackupRestore',
  props: [],
  components: {
  },
  data: function () {
    return {
      smb_host: '',
      smb_share_name: '',
      smb_user: '',
      smb_pass: '',
      nfs_host: '',
      nfs_path: '',
    };
  },
  computed: {
  },
  methods: {
    async backup_to_oss() {
      var base_url = this.base_url();
      var url = base_url + '/api/v1/estor-archive/';
      var token = this.$root.token;
      await this.$root.estor_call("CreateJob", {
        name: "[备份]全部数据",
        spec: {
          type: "HttpPost",
          args: {
            space: this.$root.estor_space,
            files: [this.$root.batches_dir],
            url,
            params: {
              'Emblem-Token': token,
            },
            recursive: true,
          },
        },
      });
      this.$router.push("/estor/jobs");
    },
    async backup_to_smb() {
    },
    async backup_to_nfs() {
    },
    async backup_to_usb() {
    },
  },
  mounted() {
  },
}
</script>

<style scoped>
</style>
