2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection v-if="!fetching">
|
|
|
|
<template #label>{{ i18n.ts.usageAmount }}</template>
|
|
|
|
<div class="_formBlock uawsfosz">
|
|
|
|
<div class="meter"><div :style="meterStyle"></div></div>
|
|
|
|
</div>
|
|
|
|
<FormSplit>
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ i18n.ts.capacity }}</template>
|
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue class="_formBlock">
|
|
|
|
<template #key>{{ i18n.ts.inUse }}</template>
|
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</FormSplit>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.statistics }}</template>
|
|
|
|
<MkChart
|
|
|
|
src="per-user-drive"
|
|
|
|
:args="{ user: $i }"
|
|
|
|
span="day"
|
|
|
|
:limit="7 * 5"
|
|
|
|
:bar="true"
|
|
|
|
:stacked="true"
|
|
|
|
:detailed="false"
|
|
|
|
:aspect-ratio="6"
|
|
|
|
/>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormButton @click="chooseUploadFolder()">
|
|
|
|
{{ i18n.ts.uploadFolder }}
|
|
|
|
<template #suffix>{{
|
|
|
|
uploadFolder ? uploadFolder.name : "-"
|
|
|
|
}}</template>
|
|
|
|
<template #suffixIcon
|
|
|
|
><i class="ph-folder-notch-open ph-bold ph-lg"></i
|
|
|
|
></template>
|
|
|
|
</FormButton>
|
|
|
|
<FormSwitch v-model="keepOriginalUploading" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.ts.keepOriginalUploading }}</template>
|
|
|
|
<template #caption>{{
|
|
|
|
i18n.ts.keepOriginalUploadingDescription
|
|
|
|
}}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
<FormSwitch
|
|
|
|
v-model="alwaysMarkNsfw"
|
|
|
|
class="_formBlock"
|
|
|
|
@update:modelValue="saveProfile()"
|
|
|
|
>
|
|
|
|
<template #label>{{ i18n.ts.alwaysMarkSensitive }}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
<FormSwitch
|
|
|
|
v-model="autoSensitive"
|
|
|
|
class="_formBlock"
|
|
|
|
@update:modelValue="saveProfile()"
|
|
|
|
>
|
|
|
|
<template #label
|
|
|
|
>{{ i18n.ts.enableAutoSensitive
|
|
|
|
}}<span class="_beta">{{ i18n.ts.beta }}</span></template
|
|
|
|
>
|
|
|
|
<template #caption>{{
|
|
|
|
i18n.ts.enableAutoSensitiveDescription
|
|
|
|
}}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 03:14:48 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import tinycolor from "tinycolor2";
|
|
|
|
import FormLink from "@/components/form/link.vue";
|
|
|
|
import FormButton from "@/components/MkButton.vue";
|
|
|
|
import FormSwitch from "@/components/form/switch.vue";
|
|
|
|
import FormSection from "@/components/form/section.vue";
|
|
|
|
import MkKeyValue from "@/components/MkKeyValue.vue";
|
|
|
|
import FormSplit from "@/components/form/split.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import bytes from "@/filters/bytes";
|
|
|
|
import { defaultStore } from "@/store";
|
|
|
|
import MkChart from "@/components/MkChart.vue";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { $i } from "@/account";
|
2022-05-04 03:14:48 +02:00
|
|
|
|
|
|
|
const fetching = ref(true);
|
|
|
|
const usage = ref<any>(null);
|
|
|
|
const capacity = ref<any>(null);
|
|
|
|
const uploadFolder = ref<any>(null);
|
2022-07-07 14:06:37 +02:00
|
|
|
let alwaysMarkNsfw = $ref($i.alwaysMarkNsfw);
|
|
|
|
let autoSensitive = $ref($i.autoSensitive);
|
2022-05-04 03:14:48 +02:00
|
|
|
|
|
|
|
const meterStyle = computed(() => {
|
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
width: `${(usage.value / capacity.value) * 100}%`,
|
2022-05-04 03:14:48 +02:00
|
|
|
background: tinycolor({
|
2023-04-08 02:01:42 +02:00
|
|
|
h: 180 - (usage.value / capacity.value) * 180,
|
2022-05-04 03:14:48 +02:00
|
|
|
s: 0.7,
|
2022-06-20 10:38:49 +02:00
|
|
|
l: 0.5,
|
|
|
|
}),
|
2022-05-04 03:14:48 +02:00
|
|
|
};
|
|
|
|
});
|
2021-10-24 05:32:41 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const keepOriginalUploading = computed(
|
|
|
|
defaultStore.makeGetterSetter("keepOriginalUploading")
|
|
|
|
);
|
2021-01-23 10:14:57 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("drive").then((info) => {
|
2022-05-04 03:14:48 +02:00
|
|
|
capacity.value = info.capacity;
|
|
|
|
usage.value = info.usage;
|
|
|
|
fetching.value = false;
|
|
|
|
});
|
2021-01-23 10:14:57 +01:00
|
|
|
|
2022-05-04 03:14:48 +02:00
|
|
|
if (defaultStore.state.uploadFolder) {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("drive/folders/show", {
|
2022-06-20 10:38:49 +02:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2023-04-08 02:01:42 +02:00
|
|
|
}).then((response) => {
|
2022-05-04 03:14:48 +02:00
|
|
|
uploadFolder.value = response;
|
|
|
|
});
|
|
|
|
}
|
2021-01-23 10:14:57 +01:00
|
|
|
|
2022-05-04 03:14:48 +02:00
|
|
|
function chooseUploadFolder() {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.selectDriveFolder(false).then(async (folder) => {
|
|
|
|
defaultStore.set("uploadFolder", folder ? folder.id : null);
|
2022-05-04 03:14:48 +02:00
|
|
|
os.success();
|
|
|
|
if (defaultStore.state.uploadFolder) {
|
2023-04-08 02:01:42 +02:00
|
|
|
uploadFolder.value = await os.api("drive/folders/show", {
|
2022-06-20 10:38:49 +02:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2020-04-21 17:34:56 +02:00
|
|
|
});
|
2022-05-04 03:14:48 +02:00
|
|
|
} else {
|
|
|
|
uploadFolder.value = null;
|
2020-04-21 17:34:56 +02:00
|
|
|
}
|
2022-05-04 03:14:48 +02:00
|
|
|
});
|
|
|
|
}
|
2021-01-23 10:14:57 +01:00
|
|
|
|
2022-07-07 14:06:37 +02:00
|
|
|
function saveProfile() {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("i/update", {
|
2022-07-07 14:06:37 +02:00
|
|
|
alwaysMarkNsfw: !!alwaysMarkNsfw,
|
|
|
|
autoSensitive: !!autoSensitive,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.drive,
|
2023-04-08 02:01:42 +02:00
|
|
|
icon: "ph-cloud ph-bold ph-lg",
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-06-05 07:57:52 +02:00
|
|
|
@use "sass:math";
|
|
|
|
|
2020-01-30 03:10:42 +01:00
|
|
|
.uawsfosz {
|
2021-11-28 12:07:37 +01:00
|
|
|
> .meter {
|
|
|
|
$size: 12px;
|
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-radius: math.div($size, 2);
|
|
|
|
overflow: hidden;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2021-11-28 12:07:37 +01:00
|
|
|
> div {
|
|
|
|
height: $size;
|
|
|
|
border-radius: math.div($size, 2);
|
2021-01-23 10:14:57 +01:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|