2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection v-if="!fetching">
|
2021-01-23 18:14:57 +09:00
|
|
|
<template #label>{{ $ts.usageAmount }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div class="_formBlock uawsfosz">
|
|
|
|
<div class="meter"><div :style="meterStyle"></div></div>
|
2021-01-23 18:14:57 +09:00
|
|
|
</div>
|
2021-12-30 21:47:48 +09:00
|
|
|
<FormSplit>
|
2021-11-28 20:07:37 +09:00
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ $ts.capacity }}</template>
|
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ $ts.inUse }}</template>
|
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
2021-12-30 21:47:48 +09:00
|
|
|
</FormSplit>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ $ts.statistics }}</template>
|
2022-02-04 16:39:09 +09:00
|
|
|
<MkChart src="per-user-drive" :args="{ user: $i }" span="day" :limit="7 * 5" :bar="true" :stacked="true" :detailed="false" :aspect-ratio="6"/>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormLink @click="chooseUploadFolder()">
|
|
|
|
{{ $ts.uploadFolder }}
|
|
|
|
<template #suffix>{{ uploadFolder ? uploadFolder.name : '-' }}</template>
|
|
|
|
<template #suffixIcon><i class="fas fa-folder-open"></i></template>
|
|
|
|
</FormLink>
|
2022-01-30 14:11:52 +09:00
|
|
|
<FormSwitch v-model="keepOriginalUploading" class="_formBlock">{{ $ts.keepOriginalUploading }}<template #caption>{{ $ts.keepOriginalUploadingDescription }}</template></FormSwitch>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
2021-01-23 18:14:57 +09:00
|
|
|
import * as tinycolor from 'tinycolor2';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2022-01-30 14:11:52 +09:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import MkKeyValue from '@/components/key-value.vue';
|
2021-12-30 21:47:48 +09:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-01-30 14:11:52 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2022-02-04 16:39:09 +09:00
|
|
|
import MkChart from '@/components/chart.vue';
|
2021-10-24 12:32:41 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
2021-11-28 20:07:37 +09:00
|
|
|
FormLink,
|
2022-01-30 14:11:52 +09:00
|
|
|
FormSwitch,
|
2021-11-28 20:07:37 +09:00
|
|
|
FormSection,
|
|
|
|
MkKeyValue,
|
2021-12-30 21:47:48 +09:00
|
|
|
FormSplit,
|
2022-02-04 16:39:09 +09:00
|
|
|
MkChart,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
2021-01-23 18:14:57 +09:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-01-23 18:14:57 +09:00
|
|
|
title: this.$ts.drive,
|
2021-09-30 00:50:45 +09:00
|
|
|
icon: 'fas fa-cloud',
|
|
|
|
bg: 'var(--bg)',
|
2021-01-23 18:14:57 +09:00
|
|
|
},
|
|
|
|
fetching: true,
|
|
|
|
usage: null,
|
|
|
|
capacity: null,
|
2020-04-22 00:34:56 +09:00
|
|
|
uploadFolder: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-01-23 18:14:57 +09: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
|
|
|
|
})
|
|
|
|
};
|
2022-01-30 14:11:52 +09:00
|
|
|
},
|
|
|
|
keepOriginalUploading: defaultStore.makeGetterSetter('keepOriginalUploading'),
|
2021-01-23 18:14:57 +09:00
|
|
|
},
|
|
|
|
|
2020-04-22 00:34:56 +09:00
|
|
|
async created() {
|
2021-01-23 18:14:57 +09:00
|
|
|
os.api('drive').then(info => {
|
|
|
|
this.capacity = info.capacity;
|
|
|
|
this.usage = info.usage;
|
|
|
|
this.fetching = false;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.renderChart();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-12-19 10:55:52 +09:00
|
|
|
if (this.$store.state.uploadFolder) {
|
2020-10-17 20:12:00 +09:00
|
|
|
this.uploadFolder = await os.api('drive/folders/show', {
|
2020-12-19 10:55:52 +09:00
|
|
|
folderId: this.$store.state.uploadFolder
|
2020-04-22 00:34:56 +09:00
|
|
|
});
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-04-22 00:34:56 +09:00
|
|
|
chooseUploadFolder() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.selectDriveFolder(false).then(async folder => {
|
2020-12-19 10:55:52 +09:00
|
|
|
this.$store.set('uploadFolder', folder ? folder.id : null);
|
2020-10-17 20:12:00 +09:00
|
|
|
os.success();
|
2020-12-19 10:55:52 +09:00
|
|
|
if (this.$store.state.uploadFolder) {
|
2020-10-17 20:12:00 +09:00
|
|
|
this.uploadFolder = await os.api('drive/folders/show', {
|
2020-12-19 10:55:52 +09:00
|
|
|
folderId: this.$store.state.uploadFolder
|
2020-04-22 00:34:56 +09:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.uploadFolder = null;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
2021-01-23 18:14:57 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
bytes
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-06-05 14:57:52 +09:00
|
|
|
|
|
|
|
@use "sass:math";
|
|
|
|
|
2020-01-30 11:10:42 +09:00
|
|
|
.uawsfosz {
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
> .meter {
|
|
|
|
$size: 12px;
|
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-radius: math.div($size, 2);
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
> div {
|
|
|
|
height: $size;
|
|
|
|
border-radius: math.div($size, 2);
|
2021-01-23 18:14:57 +09:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
</style>
|