2020-10-17 04:12:00 -07:00
|
|
|
<template>
|
|
|
|
<XModalWindow ref="dialog"
|
|
|
|
:width="370"
|
|
|
|
@close="$refs.dialog.close()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
>
|
2021-11-19 02:36:12 -08:00
|
|
|
<template v-if="file" #header>{{ file.name }}</template>
|
|
|
|
<div v-if="file" class="cxqhhsmd">
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="_section">
|
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
|
|
|
<div class="info">
|
|
|
|
<span style="margin-right: 1em;">{{ file.type }}</span>
|
|
|
|
<span>{{ bytes(file.size) }}</span>
|
|
|
|
<MkTime :time="file.createdAt" mode="detail" style="display: block;"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
2021-11-19 02:36:12 -08:00
|
|
|
<MkSwitch v-model="isSensitive" @update:modelValue="toggleIsSensitive">NSFW</MkSwitch>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
2021-04-20 07:22:59 -07:00
|
|
|
<MkButton full @click="showUser"><i class="fas fa-external-link-square-alt"></i> {{ $ts.user }}</MkButton>
|
|
|
|
<MkButton full danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</MkButton>
|
2020-10-17 04:12:00 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-if="info" class="_section">
|
2020-10-17 04:12:00 -07:00
|
|
|
<details class="_content rawdata">
|
|
|
|
<pre><code>{{ JSON.stringify(info, null, 2) }}</code></pre>
|
|
|
|
</details>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</XModalWindow>
|
|
|
|
</template>
|
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-11-11 09:02:25 -08:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkSwitch from '@/components/form/switch.vue';
|
|
|
|
import XModalWindow from '@/components/ui/modal-window.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
2022-05-17 09:33:21 -07:00
|
|
|
import { i18n } from '@/i18n';
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
let file: any = $ref(null);
|
|
|
|
let info: any = $ref(null);
|
|
|
|
let isSensitive: boolean = $ref(false);
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
const props = defineProps<{
|
|
|
|
fileId: string,
|
|
|
|
}>();
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07: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 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
fetch();
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
function showUser() {
|
|
|
|
os.pageWindow(`/user-info/${file.userId}`);
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
async function del() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('removeAreYouSure', { x: file.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
os.apiWithDialog('drive/files/delete', {
|
|
|
|
fileId: file.id
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-05-17 09:33:21 -07:00
|
|
|
async function toggleIsSensitive(v) {
|
|
|
|
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v });
|
|
|
|
isSensitive = v;
|
|
|
|
}
|
2020-10-17 04:12:00 -07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cxqhhsmd {
|
|
|
|
> ._section {
|
|
|
|
> .thumbnail {
|
|
|
|
height: 150px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .info {
|
|
|
|
text-align: center;
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .rawdata {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|