2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormSection v-if="!fetching" first>
|
2022-05-04 04:14:48 +03:00
|
|
|
<template #label>{{ i18n.ts.usageAmount }}</template>
|
2023-01-05 14:04:56 +02:00
|
|
|
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-05-30 04:20:06 +03:00
|
|
|
<div>
|
|
|
|
<div :class="$style.meter"><div :class="$style.meterValue" :style="meterStyle"></div></div>
|
2023-01-05 14:04:56 +02:00
|
|
|
</div>
|
|
|
|
<FormSplit>
|
|
|
|
<MkKeyValue>
|
|
|
|
<template #key>{{ i18n.ts.capacity }}</template>
|
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue>
|
|
|
|
<template #key>{{ i18n.ts.inUse }}</template>
|
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</FormSplit>
|
2021-01-23 11:14:57 +02:00
|
|
|
</div>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2022-05-04 04:14:48 +03:00
|
|
|
<template #label>{{ i18n.ts.statistics }}</template>
|
2023-05-19 14:52:15 +03:00
|
|
|
<MkChart src="per-user-drive" :args="{ user: $i }" span="day" :limit="7 * 5" :bar="true" :stacked="true" :detailed="false" :aspectRatio="6"/>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormLink @click="chooseUploadFolder()">
|
|
|
|
{{ i18n.ts.uploadFolder }}
|
|
|
|
<template #suffix>{{ uploadFolder ? uploadFolder.name : '-' }}</template>
|
2023-09-30 22:53:52 +03:00
|
|
|
<template #suffixIcon><i class="ph-folder ph-bold ph-lg"></i></template>
|
2023-01-05 14:04:56 +02:00
|
|
|
</FormLink>
|
2023-03-20 05:58:06 +02:00
|
|
|
<FormLink to="/settings/drive/cleaner">
|
|
|
|
{{ i18n.ts.drivecleaner }}
|
|
|
|
</FormLink>
|
2023-01-07 07:59:54 +02:00
|
|
|
<MkSwitch v-model="keepOriginalUploading">
|
2023-01-05 14:04:56 +02:00
|
|
|
<template #label>{{ i18n.ts.keepOriginalUploading }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.keepOriginalUploadingDescription }}</template>
|
2023-01-07 07:59:54 +02:00
|
|
|
</MkSwitch>
|
2023-05-19 14:52:15 +03:00
|
|
|
<MkSwitch v-model="alwaysMarkNsfw" @update:modelValue="saveProfile()">
|
2023-01-05 14:04:56 +02:00
|
|
|
<template #label>{{ i18n.ts.alwaysMarkSensitive }}</template>
|
2023-01-07 07:59:54 +02:00
|
|
|
</MkSwitch>
|
2023-05-19 14:52:15 +03:00
|
|
|
<MkSwitch v-model="autoSensitive" @update:modelValue="saveProfile()">
|
2023-01-05 14:04:56 +02:00
|
|
|
<template #label>{{ i18n.ts.enableAutoSensitive }}<span class="_beta">{{ i18n.ts.beta }}</span></template>
|
|
|
|
<template #caption>{{ i18n.ts.enableAutoSensitiveDescription }}</template>
|
2023-01-07 07:59:54 +02:00
|
|
|
</MkSwitch>
|
2023-01-05 14:04:56 +02:00
|
|
|
</div>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 04:14:48 +03:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 11:38:49 +03:00
|
|
|
import { computed, ref } from 'vue';
|
2022-05-30 15:09:22 +03:00
|
|
|
import tinycolor from 'tinycolor2';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2023-01-07 07:59:54 +02:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-08-30 18:24:33 +03:00
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2021-12-30 14:47:48 +02:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import bytes from '@/filters/bytes.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
2022-08-30 18:24:33 +03:00
|
|
|
import MkChart from '@/components/MkChart.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { $i } from '@/account.js';
|
2022-05-04 04:14:48 +03:00
|
|
|
|
|
|
|
const fetching = ref(true);
|
|
|
|
const usage = ref<any>(null);
|
|
|
|
const capacity = ref<any>(null);
|
|
|
|
const uploadFolder = ref<any>(null);
|
2022-07-07 15:06:37 +03:00
|
|
|
let alwaysMarkNsfw = $ref($i.alwaysMarkNsfw);
|
|
|
|
let autoSensitive = $ref($i.autoSensitive);
|
2022-05-04 04:14:48 +03:00
|
|
|
|
|
|
|
const meterStyle = computed(() => {
|
|
|
|
return {
|
|
|
|
width: `${usage.value / capacity.value * 100}%`,
|
|
|
|
background: tinycolor({
|
|
|
|
h: 180 - (usage.value / capacity.value * 180),
|
|
|
|
s: 0.7,
|
2022-06-20 11:38:49 +03:00
|
|
|
l: 0.5,
|
|
|
|
}),
|
2022-05-04 04:14:48 +03:00
|
|
|
};
|
|
|
|
});
|
2021-10-24 06:32:41 +03:00
|
|
|
|
2022-05-04 04:14:48 +03:00
|
|
|
const keepOriginalUploading = computed(defaultStore.makeGetterSetter('keepOriginalUploading'));
|
2021-01-23 11:14:57 +02:00
|
|
|
|
2022-05-04 04:14:48 +03:00
|
|
|
os.api('drive').then(info => {
|
|
|
|
capacity.value = info.capacity;
|
|
|
|
usage.value = info.usage;
|
|
|
|
fetching.value = false;
|
|
|
|
});
|
2021-01-23 11:14:57 +02:00
|
|
|
|
2022-05-04 04:14:48 +03:00
|
|
|
if (defaultStore.state.uploadFolder) {
|
|
|
|
os.api('drive/folders/show', {
|
2022-06-20 11:38:49 +03:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2022-05-04 04:14:48 +03:00
|
|
|
}).then(response => {
|
|
|
|
uploadFolder.value = response;
|
|
|
|
});
|
|
|
|
}
|
2021-01-23 11:14:57 +02:00
|
|
|
|
2022-05-04 04:14:48 +03:00
|
|
|
function chooseUploadFolder() {
|
|
|
|
os.selectDriveFolder(false).then(async folder => {
|
|
|
|
defaultStore.set('uploadFolder', folder ? folder.id : null);
|
|
|
|
os.success();
|
|
|
|
if (defaultStore.state.uploadFolder) {
|
|
|
|
uploadFolder.value = await os.api('drive/folders/show', {
|
2022-06-20 11:38:49 +03:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2020-04-21 18:34:56 +03:00
|
|
|
});
|
2022-05-04 04:14:48 +03:00
|
|
|
} else {
|
|
|
|
uploadFolder.value = null;
|
2020-04-21 18:34:56 +03:00
|
|
|
}
|
2022-05-04 04:14:48 +03:00
|
|
|
});
|
|
|
|
}
|
2021-01-23 11:14:57 +02:00
|
|
|
|
2022-07-07 15:06:37 +03:00
|
|
|
function saveProfile() {
|
|
|
|
os.api('i/update', {
|
|
|
|
alwaysMarkNsfw: !!alwaysMarkNsfw,
|
|
|
|
autoSensitive: !!autoSensitive,
|
2023-05-05 08:18:06 +03:00
|
|
|
}).catch(err => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
title: i18n.ts.error,
|
|
|
|
text: err.message,
|
|
|
|
});
|
|
|
|
alwaysMarkNsfw = true;
|
2022-07-07 15:06:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.drive,
|
2023-09-30 22:53:52 +03:00
|
|
|
icon: 'ph-cloud ph-bold ph-lg',
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-05-30 04:20:06 +03:00
|
|
|
<style lang="scss" module>
|
|
|
|
.meter {
|
2023-05-30 08:38:13 +03:00
|
|
|
height: 10px;
|
2023-05-30 04:20:06 +03:00
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-radius: 999px;
|
|
|
|
overflow: clip;
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2023-05-30 04:20:06 +03:00
|
|
|
.meterValue {
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 999px;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
</style>
|