<template>
  <Descriptions>
    <el-descriptions-item label="上传字节数">{{state.uploadSize | formatFileSize}}</el-descriptions-item>
    <el-descriptions-item label="写入字节数">{{state.writeSize | formatFileSize}}</el-descriptions-item>
    <el-descriptions-item label="上传文件数">{{state.numUpload}}</el-descriptions-item>
    <el-descriptions-item label="写入文件数">{{state.numWrite}}</el-descriptions-item>
    <el-descriptions-item label="处理错误数">{{state.numError}}</el-descriptions-item>
    <el-descriptions-item label="最近上传时间">{{state.lastUploadTime}}</el-descriptions-item>
    <el-descriptions-item label="最近写入时间">{{state.lastWriteTime}}</el-descriptions-item>
    <el-descriptions-item label="最近错误时间">{{state.lastErrorTime}}</el-descriptions-item>
    <el-descriptions-item label="最大上传字节数">{{state.maxUploadSize | formatFileSize}}</el-descriptions-item>
    <el-descriptions-item label="最大写入字节数">{{state.maxWriteSize | formatFileSize}}</el-descriptions-item>
    <el-descriptions-item label="最长处理时间">{{state.maxHandleDuration}}</el-descriptions-item>
  </Descriptions>
</template>

<script>

import Descriptions from "@/components/common/Descriptions.vue";
import {stateDetail} from "@/api/file/state";
import {formatFileSize} from "@/utils/file";

export default {
  name: 'ProjectState',
  components: {Descriptions},
  props: {
    token: {
      type: String,
    }
  },
  data() {
    return {
      state: {},
    };
  },
  created() {
    this.getStateDetail();
  },
  methods: {
    getStateDetail() {
      this.state = {};
      if(!this.token)
        return;
      stateDetail(this.token).then((resp) => {
        if(resp.data)
        {
          this.state = resp.data;
        }
        else
        {
          this.$message.error('暂无状态');
        }
      });
    },
  },
  watch: {
    token(newVal) {
      this.getStateDetail();
    },
  },
  filters: {
    formatFileSize,
  },
}
</script>

<style scoped lang="scss">

</style>
