2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions"/></template>
|
2023-05-19 20:52:15 +09:00
|
|
|
<MkSpacer :contentMax="900">
|
2023-05-20 12:32:51 +09:00
|
|
|
<div class="_gaps">
|
|
|
|
<div class="inputs" style="display: flex; gap: var(--margin); flex-wrap: wrap;">
|
|
|
|
<MkSelect v-model="origin" style="margin: 0; flex: 1;">
|
|
|
|
<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>
|
|
|
|
</MkSelect>
|
|
|
|
<MkInput v-model="searchHost" :debounce="true" type="search" style="margin: 0; flex: 1;" :disabled="pagination.params.origin === 'local'">
|
|
|
|
<template #label>{{ i18n.ts.host }}</template>
|
|
|
|
</MkInput>
|
2022-06-16 16:05:43 +09:00
|
|
|
</div>
|
2023-05-20 12:32:51 +09:00
|
|
|
<div class="inputs" style="display: flex; gap: var(--margin); flex-wrap: wrap;">
|
|
|
|
<MkInput v-model="userId" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>User ID</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="type" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
|
|
|
<template #label>MIME type</template>
|
|
|
|
</MkInput>
|
|
|
|
</div>
|
|
|
|
<MkFileListForAdmin :pagination="pagination" :viewMode="viewMode"/>
|
2022-06-20 17:38:49 +09:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-02-09 13:38:54 +09:00
|
|
|
<script lang="ts" setup>
|
2023-02-16 23:09:41 +09:00
|
|
|
import { computed } from 'vue';
|
2022-06-20 17:38:49 +09:00
|
|
|
import XHeader from './_header_.vue';
|
2023-01-07 15:09:46 +09:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
|
2023-09-19 16:37:43 +09:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2022-02-09 13:38:54 +09:00
|
|
|
|
|
|
|
let origin = $ref('local');
|
|
|
|
let type = $ref(null);
|
|
|
|
let searchHost = $ref('');
|
2022-06-24 21:43:28 +09:00
|
|
|
let userId = $ref('');
|
2022-06-16 16:05:43 +09:00
|
|
|
let viewMode = $ref('grid');
|
2022-02-09 13:38:54 +09:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'admin/drive/files' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
type: (type && type !== '') ? type : null,
|
2022-06-24 21:43:28 +09:00
|
|
|
userId: (userId && userId !== '') ? userId : null,
|
2022-02-09 13:38:54 +09: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-30 04:37:25 +09:00
|
|
|
|
2022-02-09 13:38:54 +09:00
|
|
|
function show(file) {
|
2022-06-20 17:38:49 +09:00
|
|
|
os.pageWindow(`/admin/file/${file.id}`);
|
2022-02-09 13:38:54 +09:00
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-06-16 16:05:43 +09:00
|
|
|
async function find() {
|
|
|
|
const { canceled, result: q } = await os.inputText({
|
|
|
|
title: i18n.ts.fileIdOrUrl,
|
|
|
|
allowEmpty: false,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2022-02-09 13:38:54 +09: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 16:05:43 +09:00
|
|
|
text: i18n.ts.notFound,
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
2022-02-09 13:38:54 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
text: i18n.ts.lookup,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-search',
|
2022-06-20 17:38:49 +09:00
|
|
|
handler: find,
|
|
|
|
}, {
|
|
|
|
text: i18n.ts.clearCachedFiles,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-trash',
|
2022-06-20 17:38:49 +09:00
|
|
|
handler: clear,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.files,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-cloud',
|
2022-06-20 17:38:49 +09:00
|
|
|
})));
|
2020-01-30 04:37:25 +09:00
|
|
|
</script>
|