2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2021-01-23 11:14:57 +02:00
|
|
|
<FormBase class="">
|
|
|
|
<FormGroup v-if="!fetching">
|
|
|
|
<template #label>{{ $ts.usageAmount }}</template>
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="_debobigegoItem uawsfosz">
|
|
|
|
<div class="_debobigegoPanel">
|
2021-01-23 11:14:57 +02:00
|
|
|
<div class="meter"><div :style="meterStyle"></div></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts.capacity }}</template>
|
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts.inUse }}</template>
|
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
</FormGroup>
|
|
|
|
|
2021-09-29 18:50:45 +03:00
|
|
|
<div class="_debobigegoItem">
|
|
|
|
<div class="_debobigegoLabel">{{ $ts.statistics }}</div>
|
|
|
|
<div class="_debobigegoPanel">
|
2021-01-23 11:14:57 +02:00
|
|
|
<div ref="chart"></div>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
2021-01-23 11:14:57 +02:00
|
|
|
|
|
|
|
<FormButton :center="false" @click="chooseUploadFolder()" primary>
|
|
|
|
{{ $ts.uploadFolder }}
|
|
|
|
<template #suffix>{{ uploadFolder ? uploadFolder.name : '-' }}</template>
|
2021-04-20 17:22:59 +03:00
|
|
|
<template #suffixIcon><i class="fas fa-folder-open"></i></template>
|
2021-01-23 11:14:57 +02:00
|
|
|
</FormButton>
|
|
|
|
</FormBase>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-01-23 11:14:57 +02:00
|
|
|
import * as tinycolor from 'tinycolor2';
|
2021-11-11 19:02:25 +02:00
|
|
|
import FormButton from '@/components/debobigego/button.vue';
|
|
|
|
import FormGroup from '@/components/debobigego/group.vue';
|
|
|
|
import FormKeyValueView from '@/components/debobigego/key-value-view.vue';
|
|
|
|
import FormBase from '@/components/debobigego/base.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-10-24 06:32:41 +03:00
|
|
|
// TODO: render chart
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
2021-01-23 11:14:57 +02:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
|
|
|
FormGroup,
|
|
|
|
FormKeyValueView,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
2021-01-23 11:14:57 +02:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 06:54:12 +03:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-01-23 11:14:57 +02:00
|
|
|
title: this.$ts.drive,
|
2021-09-29 18:50:45 +03:00
|
|
|
icon: 'fas fa-cloud',
|
|
|
|
bg: 'var(--bg)',
|
2021-01-23 11:14:57 +02:00
|
|
|
},
|
|
|
|
fetching: true,
|
|
|
|
usage: null,
|
|
|
|
capacity: null,
|
2020-04-21 18:34:56 +03:00
|
|
|
uploadFolder: null,
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-01-23 11:14:57 +02:00
|
|
|
computed: {
|
|
|
|
meterStyle(): any {
|
|
|
|
return {
|
|
|
|
width: `${this.usage / this.capacity * 100}%`,
|
|
|
|
background: tinycolor({
|
|
|
|
h: 180 - (this.usage / this.capacity * 180),
|
|
|
|
s: 0.7,
|
|
|
|
l: 0.5
|
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-04-21 18:34:56 +03:00
|
|
|
async created() {
|
2021-01-23 11:14:57 +02:00
|
|
|
os.api('drive').then(info => {
|
|
|
|
this.capacity = info.capacity;
|
|
|
|
this.usage = info.usage;
|
|
|
|
this.fetching = false;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.renderChart();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-12-19 03:55:52 +02:00
|
|
|
if (this.$store.state.uploadFolder) {
|
2020-10-17 14:12:00 +03:00
|
|
|
this.uploadFolder = await os.api('drive/folders/show', {
|
2020-12-19 03:55:52 +02:00
|
|
|
folderId: this.$store.state.uploadFolder
|
2020-04-21 18:34:56 +03:00
|
|
|
});
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
2021-01-23 11:14:57 +02:00
|
|
|
mounted() {
|
2021-04-10 06:54:12 +03:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2021-01-23 11:14:57 +02:00
|
|
|
},
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
methods: {
|
2020-04-21 18:34:56 +03:00
|
|
|
chooseUploadFolder() {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.selectDriveFolder(false).then(async folder => {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.$store.set('uploadFolder', folder ? folder.id : null);
|
2020-10-17 14:12:00 +03:00
|
|
|
os.success();
|
2020-12-19 03:55:52 +02:00
|
|
|
if (this.$store.state.uploadFolder) {
|
2020-10-17 14:12:00 +03:00
|
|
|
this.uploadFolder = await os.api('drive/folders/show', {
|
2020-12-19 03:55:52 +02:00
|
|
|
folderId: this.$store.state.uploadFolder
|
2020-04-21 18:34:56 +03:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.uploadFolder = null;
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
2021-01-23 11:14:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
bytes
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-06-05 08:57:52 +03:00
|
|
|
|
|
|
|
@use "sass:math";
|
|
|
|
|
2020-01-30 04:10:42 +02:00
|
|
|
.uawsfosz {
|
2021-01-23 11:14:57 +02:00
|
|
|
> div {
|
|
|
|
padding: 24px;
|
|
|
|
|
|
|
|
> .meter {
|
|
|
|
$size: 12px;
|
|
|
|
background: rgba(0, 0, 0, 0.1);
|
2021-06-05 08:57:52 +03:00
|
|
|
border-radius: math.div($size, 2);
|
2021-03-02 15:57:16 +02:00
|
|
|
overflow: hidden;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2021-01-23 11:14:57 +02:00
|
|
|
> div {
|
|
|
|
height: $size;
|
2021-06-05 08:57:52 +03:00
|
|
|
border-radius: math.div($size, 2);
|
2021-01-23 11:14:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
</style>
|