2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2022-06-20 11:38:49 +03: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;">
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.instance }}</template>
|
|
|
|
<option value="combined">{{ i18n.ts.all }}</option>
|
|
|
|
<option value="local">{{ i18n.ts.local }}</option>
|
|
|
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
2022-06-20 11:38:49 +03:00
|
|
|
</MkSelect>
|
|
|
|
<MkInput v-model="searchHost" :debounce="true" type="search" style="margin: 0; flex: 1;" :disabled="pagination.params.origin === 'local'">
|
2022-07-20 16:24:26 +03:00
|
|
|
<template #label>{{ i18n.ts.host }}</template>
|
2022-06-20 11:38:49 +03:00
|
|
|
</MkInput>
|
2022-06-16 10:05:43 +03:00
|
|
|
</div>
|
2022-06-24 15:43:28 +03:00
|
|
|
<div class="inputs" style="display: flex; gap: var(--margin); flex-wrap: wrap; padding-top: 1.2em;">
|
|
|
|
<MkInput v-model="userId" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>User ID</template>
|
|
|
|
</MkInput>
|
2022-06-20 11:38:49 +03:00
|
|
|
<MkInput v-model="type" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>MIME type</template>
|
|
|
|
</MkInput>
|
2022-06-16 10:05:43 +03:00
|
|
|
</div>
|
2022-06-24 15:43:28 +03:00
|
|
|
<MkFileListForAdmin :pagination="pagination" :view-mode="viewMode"/>
|
2022-06-16 10:05:43 +03:00
|
|
|
</div>
|
2022-06-20 11:38:49 +03:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
2022-02-09 06:38:54 +02:00
|
|
|
<script lang="ts" setup>
|
2022-05-01 16:51:07 +03:00
|
|
|
import { computed, defineAsyncComponent } from 'vue';
|
2022-06-16 10:05:43 +03:00
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
2022-06-20 11:38:49 +03:00
|
|
|
import XHeader from './_header_.vue';
|
2022-09-06 12:21:49 +03:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
2022-08-30 18:24:33 +03:00
|
|
|
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
2022-02-09 06:38:54 +02:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-02-09 06:38:54 +02:00
|
|
|
|
|
|
|
let origin = $ref('local');
|
|
|
|
let type = $ref(null);
|
|
|
|
let searchHost = $ref('');
|
2022-06-24 15:43:28 +03:00
|
|
|
let userId = $ref('');
|
2022-06-16 10:05:43 +03:00
|
|
|
let viewMode = $ref('grid');
|
2022-02-09 06:38:54 +02:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'admin/drive/files' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
type: (type && type !== '') ? type : null,
|
2022-06-24 15:43:28 +03:00
|
|
|
userId: (userId && userId !== '') ? userId : null,
|
2022-02-09 06:38:54 +02:00
|
|
|
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 21:37:25 +02:00
|
|
|
|
2022-02-09 06:38:54 +02:00
|
|
|
function show(file) {
|
2022-06-20 11:38:49 +03:00
|
|
|
os.pageWindow(`/admin/file/${file.id}`);
|
2022-02-09 06:38:54 +02:00
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2022-06-16 10:05:43 +03:00
|
|
|
async function find() {
|
|
|
|
const { canceled, result: q } = await os.inputText({
|
|
|
|
title: i18n.ts.fileIdOrUrl,
|
|
|
|
allowEmpty: false,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2022-02-09 06:38:54 +02: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 10:05:43 +03:00
|
|
|
text: i18n.ts.notFound,
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
2022-02-09 06:38:54 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-06-20 11:38:49 +03: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',
|
|
|
|
})));
|
2020-01-29 21:37:25 +02:00
|
|
|
</script>
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xrmjdkdw {
|
2021-04-22 16:29:33 +03:00
|
|
|
margin: var(--margin);
|
2021-10-02 17:11:21 +03:00
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
</style>
|