2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2022-06-20 11:38:49 +03:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-06-21 18:10:34 +03:00
|
|
|
<MkSpacer v-if="file" :content-max="500" :margin-min="16" :margin-max="32">
|
|
|
|
<div v-if="tab === 'overview'" class="cxqhhsmd _formRoot">
|
|
|
|
<a class="_formBlock thumbnail" :href="file.url" target="_blank">
|
2022-06-20 11:38:49 +03:00
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
2022-06-21 18:10:34 +03:00
|
|
|
</a>
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkKeyValue :copy="file.type" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>MIME Type</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.type }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue oneline style="margin: 1em 0;">
|
|
|
|
<template #key>Size</template>
|
|
|
|
<template #value><span class="_monospace">{{ bytes(file.size) }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue :copy="file.id" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>ID</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.id }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue :copy="file.md5" oneline style="margin: 1em 0;">
|
|
|
|
<template #key>MD5</template>
|
|
|
|
<template #value><span class="_monospace">{{ file.md5 }}</span></template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue oneline style="margin: 1em 0;">
|
|
|
|
<template #key>{{ i18n.ts.createdAt }}</template>
|
|
|
|
<template #value><span class="_monospace"><MkTime :time="file.createdAt" mode="detail" style="display: block;"/></span></template>
|
|
|
|
</MkKeyValue>
|
2022-06-20 11:38:49 +03:00
|
|
|
</div>
|
|
|
|
<div class="_formBlock">
|
|
|
|
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
|
|
|
|
</div>
|
2022-06-20 15:05:18 +03:00
|
|
|
<FormLink class="_formBlock" :to="file.url" :external="true">Open</FormLink>
|
2022-06-21 18:10:34 +03:00
|
|
|
<FormLink class="_formBlock" :to="`/user-info/${file.userId}`">{{ $ts.user }} ({{ acct(file.user) }})</FormLink>
|
2022-06-20 15:05:18 +03:00
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
<div class="_formBlock">
|
|
|
|
<MkButton full danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</MkButton>
|
|
|
|
</div>
|
2022-06-21 18:10:34 +03:00
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'raw'" class="_formRoot">
|
|
|
|
<MkObjectView v-if="info" tall :value="info">
|
|
|
|
</MkObjectView>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
2022-06-20 11:38:49 +03:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 14:12:00 +03:00
|
|
|
</template>
|
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
<script lang="ts" setup>
|
2022-06-17 09:03:02 +03:00
|
|
|
import { computed } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
2022-06-21 18:10:34 +03:00
|
|
|
import MkObjectView from '@/components/object-view.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
2022-06-21 18:10:34 +03:00
|
|
|
import MkKeyValue from '@/components/key-value.vue';
|
2022-06-20 15:05:18 +03:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
2022-05-17 19:33:21 +03:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-06-21 18:10:34 +03:00
|
|
|
import { acct } from '@/filters/user';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-06-21 18:10:34 +03:00
|
|
|
let tab = $ref('overview');
|
2022-05-17 19:33:21 +03:00
|
|
|
let file: any = $ref(null);
|
|
|
|
let info: any = $ref(null);
|
|
|
|
let isSensitive: boolean = $ref(false);
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
const props = defineProps<{
|
|
|
|
fileId: string,
|
|
|
|
}>();
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
async function fetch() {
|
|
|
|
file = await os.api('drive/files/show', { fileId: props.fileId });
|
|
|
|
info = await os.api('admin/drive/show-file', { fileId: props.fileId });
|
|
|
|
isSensitive = file.isSensitive;
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
fetch();
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
async function del() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('removeAreYouSure', { x: file.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
os.apiWithDialog('drive/files/delete', {
|
2022-06-17 09:03:02 +03:00
|
|
|
fileId: file.id,
|
2022-05-17 19:33:21 +03:00
|
|
|
});
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-17 19:33:21 +03:00
|
|
|
async function toggleIsSensitive(v) {
|
|
|
|
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v });
|
|
|
|
isSensitive = v;
|
|
|
|
}
|
2022-06-17 09:03:02 +03:00
|
|
|
|
2022-06-21 18:10:34 +03:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
text: i18n.ts.openInNewTab,
|
|
|
|
icon: 'fas fa-external-link-alt',
|
|
|
|
handler: () => {
|
|
|
|
window.open(file.url, '_blank');
|
|
|
|
},
|
|
|
|
}]);
|
2022-06-20 11:38:49 +03:00
|
|
|
|
2022-06-21 18:10:34 +03:00
|
|
|
const headerTabs = $computed(() => [{
|
|
|
|
active: tab === 'overview',
|
|
|
|
title: i18n.ts.overview,
|
|
|
|
icon: 'fas fa-info-circle',
|
|
|
|
onClick: () => { tab = 'overview'; },
|
|
|
|
}, {
|
|
|
|
active: tab === 'raw',
|
|
|
|
title: 'Raw data',
|
|
|
|
icon: 'fas fa-code',
|
|
|
|
onClick: () => { tab = 'raw'; },
|
|
|
|
}]);
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: file ? i18n.ts.file + ': ' + file.name : i18n.ts.file,
|
|
|
|
icon: 'fas fa-file',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
})));
|
2020-10-17 14:12:00 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cxqhhsmd {
|
2022-06-21 18:10:34 +03:00
|
|
|
> .thumbnail {
|
|
|
|
display: block;
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
> .thumbnail {
|
2022-06-21 18:10:34 +03:00
|
|
|
height: 300px;
|
2020-10-17 14:12:00 +03:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|