2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
2022-06-22 09:29:21 +02:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer v-if="file" :contentMax="600" :marginMin="16" :marginMax="32">
|
2023-01-06 05:40:17 +01:00
|
|
|
<div v-if="tab === 'overview'" class="cxqhhsmd _gaps_m">
|
2023-01-05 13:04:56 +01:00
|
|
|
<a class="thumbnail" :href="file.url" target="_blank">
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
2022-06-21 17:10:34 +02:00
|
|
|
</a>
|
2023-01-05 13:04:56 +01:00
|
|
|
<div>
|
2022-06-21 17:10:34 +02:00
|
|
|
<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 10:38:49 +02:00
|
|
|
</div>
|
2023-08-13 14:02:25 +02:00
|
|
|
<MkA v-if="file.user" class="user" :to="`/admin/user/${file.user.id}`">
|
2022-06-23 16:45:22 +02:00
|
|
|
<MkUserCardMini :user="file.user"/>
|
|
|
|
</MkA>
|
2023-01-05 13:04:56 +01:00
|
|
|
<div>
|
2023-07-20 13:18:55 +02:00
|
|
|
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">{{ i18n.ts.sensitive }}</MkSwitch>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2022-06-20 14:05:18 +02:00
|
|
|
|
2023-01-05 13:04:56 +01:00
|
|
|
<div>
|
2024-06-21 18:15:52 +02:00
|
|
|
<MkButton danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2022-06-21 17:10:34 +02:00
|
|
|
</div>
|
2023-01-06 05:40:17 +01:00
|
|
|
<div v-else-if="tab === 'ip' && info" class="_gaps_m">
|
2022-07-02 08:12:11 +02:00
|
|
|
<MkInfo v-if="!iAmAdmin" warn>{{ i18n.ts.requireAdminForView }}</MkInfo>
|
2023-01-05 13:04:56 +01:00
|
|
|
<MkKeyValue v-if="info.requestIp" class="_monospace" :copy="info.requestIp" oneline>
|
2022-07-02 08:12:11 +02:00
|
|
|
<template #key>IP</template>
|
|
|
|
<template #value>{{ info.requestIp }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<FormSection v-if="info.requestHeaders">
|
|
|
|
<template #label>Headers</template>
|
2023-01-05 13:04:56 +01:00
|
|
|
<MkKeyValue v-for="(v, k) in info.requestHeaders" :key="k" class="_monospace">
|
2022-07-02 08:12:11 +02:00
|
|
|
<template #key>{{ k }}</template>
|
|
|
|
<template #value>{{ v }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2023-01-06 05:40:17 +01:00
|
|
|
<div v-else-if="tab === 'raw'" class="_gaps_m">
|
2022-06-21 17:10:34 +02:00
|
|
|
<MkObjectView v-if="info" tall :value="info">
|
|
|
|
</MkObjectView>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { computed, ref } from 'vue';
|
2023-12-26 06:19:35 +01:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-07 06:59:54 +01:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2022-08-30 17:24:33 +02:00
|
|
|
import MkObjectView from '@/components/MkObjectView.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
|
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2022-07-02 08:12:11 +02:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-08-30 17:24:33 +02:00
|
|
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkInfo from '@/components/MkInfo.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import bytes from '@/filters/bytes.js';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { iAmAdmin, iAmModerator } from '@/account.js';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const tab = ref('overview');
|
2023-12-26 06:19:35 +01:00
|
|
|
const file = ref<Misskey.entities.DriveFile | null>(null);
|
|
|
|
const info = ref<Misskey.entities.AdminDriveShowFileResponse | null>(null);
|
2023-12-07 06:42:09 +01:00
|
|
|
const isSensitive = ref<boolean>(false);
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
fileId: string,
|
|
|
|
}>();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
async function fetch() {
|
2024-01-04 10:32:46 +01:00
|
|
|
file.value = await misskeyApi('drive/files/show', { fileId: props.fileId });
|
|
|
|
info.value = await misskeyApi('admin/drive/show-file', { fileId: props.fileId });
|
2023-12-07 06:42:09 +01:00
|
|
|
isSensitive.value = file.value.isSensitive;
|
2022-05-17 18:33:21 +02:00
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
fetch();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
async function del() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
2024-01-20 00:11:59 +01:00
|
|
|
text: i18n.tsx.removeAreYouSure({ x: file.value.name }),
|
2022-05-17 18:33:21 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
os.apiWithDialog('drive/files/delete', {
|
2023-12-07 06:42:09 +01:00
|
|
|
fileId: file.value.id,
|
2022-05-17 18:33:21 +02:00
|
|
|
});
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-17 18:33:21 +02:00
|
|
|
async function toggleIsSensitive(v) {
|
2024-01-04 10:32:46 +01:00
|
|
|
await misskeyApi('drive/files/update', { fileId: props.fileId, isSensitive: v });
|
2023-12-07 06:42:09 +01:00
|
|
|
isSensitive.value = v;
|
2022-05-17 18:33:21 +02:00
|
|
|
}
|
2022-06-17 08:03:02 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerActions = computed(() => [{
|
2022-06-21 17:10:34 +02:00
|
|
|
text: i18n.ts.openInNewTab,
|
2024-06-21 19:11:47 +02:00
|
|
|
icon: 'ti ti-external-link',
|
2022-06-21 17:10:34 +02:00
|
|
|
handler: () => {
|
2023-12-08 09:48:18 +01:00
|
|
|
window.open(file.value.url, '_blank', 'noopener');
|
2022-06-21 17:10:34 +02:00
|
|
|
},
|
|
|
|
}]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => [{
|
2022-06-22 09:29:21 +02:00
|
|
|
key: 'overview',
|
2022-06-21 17:10:34 +02:00
|
|
|
title: i18n.ts.overview,
|
2024-06-21 17:27:36 +02:00
|
|
|
icon: 'ti ti-info-circle',
|
2022-07-02 08:12:11 +02:00
|
|
|
}, iAmModerator ? {
|
|
|
|
key: 'ip',
|
|
|
|
title: 'IP',
|
2024-06-22 14:34:55 +02:00
|
|
|
icon: 'ti ti-password',
|
2022-07-02 08:12:11 +02:00
|
|
|
} : null, {
|
2022-06-22 09:29:21 +02:00
|
|
|
key: 'raw',
|
2022-06-21 17:10:34 +02:00
|
|
|
title: 'Raw data',
|
2024-06-21 15:59:21 +02:00
|
|
|
icon: 'ti ti-code',
|
2022-06-21 17:10:34 +02:00
|
|
|
}]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2024-02-16 08:17:09 +01:00
|
|
|
definePageMetadata(() => ({
|
|
|
|
title: file.value ? `${i18n.ts.file}: ${file.value.name}` : i18n.ts.file,
|
2024-06-21 18:37:08 +02:00
|
|
|
icon: 'ti ti-file',
|
2024-02-16 08:17:09 +01:00
|
|
|
}));
|
2020-10-17 13:12:00 +02:00
|
|
|
</script>
|
|
|
|
|
2022-12-27 10:29:39 +01:00
|
|
|
<style lang="scss" scoped>
|
2020-10-17 13:12:00 +02:00
|
|
|
.cxqhhsmd {
|
2022-06-21 17:10:34 +02:00
|
|
|
> .thumbnail {
|
|
|
|
display: block;
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
> .thumbnail {
|
2022-06-21 17:10:34 +02:00
|
|
|
height: 300px;
|
2020-10-17 13:12:00 +02:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
2022-06-23 16:45:22 +02:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
&:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
</style>
|