2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions"/></template>
|
|
|
|
<MkSpacer :content-max="900">
|
|
|
|
<div class="xrmjdkdw">
|
|
|
|
<div>
|
|
|
|
<div class="inputs" style="display: flex; gap: var(--margin); flex-wrap: wrap;">
|
|
|
|
<MkSelect v-model="origin" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
<MkInput v-model="searchHost" :debounce="true" type="search" style="margin: 0; flex: 1;" :disabled="pagination.params.origin === 'local'">
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
|
|
|
</MkInput>
|
2022-06-16 09:05:43 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
<div class="inputs" style="display: flex; padding-top: 1.2em;">
|
|
|
|
<MkInput v-model="type" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>MIME type</template>
|
|
|
|
</MkInput>
|
2022-06-16 09:05:43 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkPagination v-slot="{items}" :pagination="pagination" class="urempief" :class="{ grid: viewMode === 'grid' }">
|
|
|
|
<button v-for="file in items" :key="file.id" v-tooltip.mfm="`${file.type}\n${bytes(file.size)}\n${new Date(file.createdAt).toLocaleString()}\nby ${file.user ? '@' + Acct.toString(file.user) : 'system'}`" class="file _button" @click="show(file, $event)">
|
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
|
|
|
<div v-if="viewMode === 'list'" class="body">
|
|
|
|
<div>
|
|
|
|
<small style="opacity: 0.7;">{{ file.name }}</small>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<MkAcct v-if="file.user" :user="file.user"/>
|
|
|
|
<div v-else>{{ $ts.system }}</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<span style="margin-right: 1em;">{{ file.type }}</span>
|
|
|
|
<span>{{ bytes(file.size) }}</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<span>{{ $ts.registeredDate }}: <MkTime :time="file.createdAt" mode="detail"/></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</MkPagination>
|
2022-06-16 09:05:43 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-02-09 05:38:54 +01:00
|
|
|
<script lang="ts" setup>
|
2022-05-01 15:51:07 +02:00
|
|
|
import { computed, defineAsyncComponent } from 'vue';
|
2022-06-16 09:05:43 +02:00
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
2022-06-20 10:38:49 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
2022-02-09 05:38:54 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-02-09 05:38:54 +01:00
|
|
|
|
|
|
|
let origin = $ref('local');
|
|
|
|
let type = $ref(null);
|
|
|
|
let searchHost = $ref('');
|
2022-06-16 09:05:43 +02:00
|
|
|
let viewMode = $ref('grid');
|
2022-02-09 05:38:54 +01:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'admin/drive/files' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
type: (type && type !== '') ? type : null,
|
|
|
|
origin: origin,
|
|
|
|
hostname: (searchHost && searchHost !== '') ? searchHost : null,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
function clear() {
|
|
|
|
os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.clearCachedFilesConfirm,
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('admin/drive/clean-remote-files', {});
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-02-09 05:38:54 +01:00
|
|
|
function show(file) {
|
2022-06-20 10:38:49 +02:00
|
|
|
os.pageWindow(`/admin/file/${file.id}`);
|
2022-02-09 05:38:54 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
async function find() {
|
|
|
|
const { canceled, result: q } = await os.inputText({
|
|
|
|
title: i18n.ts.fileIdOrUrl,
|
|
|
|
allowEmpty: false,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2022-02-09 05:38:54 +01:00
|
|
|
os.api('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
|
|
|
|
show(file);
|
|
|
|
}).catch(err => {
|
|
|
|
if (err.code === 'NO_SUCH_FILE') {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-16 09:05:43 +02:00
|
|
|
text: i18n.ts.notFound,
|
2020-10-17 13:12:00 +02:00
|
|
|
});
|
2022-02-09 05:38:54 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
text: i18n.ts.lookup,
|
|
|
|
icon: 'fas fa-search',
|
|
|
|
handler: find,
|
|
|
|
}, {
|
|
|
|
text: i18n.ts.clearCachedFiles,
|
|
|
|
icon: 'fas fa-trash-alt',
|
|
|
|
handler: clear,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.files,
|
|
|
|
icon: 'fas fa-cloud',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
})));
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xrmjdkdw {
|
2021-04-22 15:29:33 +02:00
|
|
|
margin: var(--margin);
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
.urempief {
|
|
|
|
margin-top: var(--margin);
|
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
&.list {
|
|
|
|
> .file {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
align-items: center;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
> .thumbnail {
|
|
|
|
width: 128px;
|
|
|
|
height: 128px;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
> .body {
|
|
|
|
margin-left: 0.3em;
|
|
|
|
padding: 8px;
|
|
|
|
flex: 1;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 16:11:21 +02:00
|
|
|
|
2022-06-16 09:05:43 +02:00
|
|
|
&.grid {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin) 0;
|
|
|
|
|
|
|
|
> .file {
|
|
|
|
aspect-ratio: 1;
|
|
|
|
|
|
|
|
> .thumbnail {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 16:11:21 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
</style>
|