feat: admin lookup files/instance
This commit is contained in:
parent
50fc292c7e
commit
c5b0b07027
@ -86,7 +86,7 @@ import MkButton from "@/components/MkButton.vue";
|
|||||||
import MkInput from "@/components/form/input.vue";
|
import MkInput from "@/components/form/input.vue";
|
||||||
import MkSelect from "@/components/form/select.vue";
|
import MkSelect from "@/components/form/select.vue";
|
||||||
import MkFileListForAdmin from "@/components/MkFileListForAdmin.vue";
|
import MkFileListForAdmin from "@/components/MkFileListForAdmin.vue";
|
||||||
import bytes from "@/filters/bytes";
|
import { lookupFile } from "@/scripts/lookup-file";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
import { i18n } from "@/i18n";
|
import { i18n } from "@/i18n";
|
||||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||||
@ -118,41 +118,11 @@ function clear() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(file) {
|
|
||||||
os.pageWindow(`/admin/file/${file.id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function find() {
|
|
||||||
const { canceled, result: q } = await os.inputText({
|
|
||||||
title: i18n.ts.fileIdOrUrl,
|
|
||||||
allowEmpty: false,
|
|
||||||
});
|
|
||||||
if (canceled) return;
|
|
||||||
|
|
||||||
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",
|
|
||||||
text: i18n.ts.notFound,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const headerActions = $computed(() => [
|
const headerActions = $computed(() => [
|
||||||
{
|
{
|
||||||
text: i18n.ts.lookup,
|
text: i18n.ts.lookup,
|
||||||
icon: "ph-magnifying-glass ph-bold ph-lg",
|
icon: "ph-magnifying-glass ph-bold ph-lg",
|
||||||
handler: find,
|
handler: lookupFile,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.clearCachedFiles,
|
text: i18n.ts.clearCachedFiles,
|
||||||
|
@ -79,6 +79,8 @@ import { version } from "@/config";
|
|||||||
import { $i } from "@/account";
|
import { $i } from "@/account";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
import { lookupUser } from "@/scripts/lookup-user";
|
import { lookupUser } from "@/scripts/lookup-user";
|
||||||
|
import { lookupFile } from "@/scripts/lookup-file";
|
||||||
|
import { lookupInstance } from "@/scripts/lookup-instance";
|
||||||
import { defaultStore } from "@/store";
|
import { defaultStore } from "@/store";
|
||||||
import { useRouter } from "@/router";
|
import { useRouter } from "@/router";
|
||||||
import {
|
import {
|
||||||
@ -371,14 +373,14 @@ const lookup = (ev) => {
|
|||||||
text: i18n.ts.file,
|
text: i18n.ts.file,
|
||||||
icon: "ph-cloud ph-bold ph-lg",
|
icon: "ph-cloud ph-bold ph-lg",
|
||||||
action: () => {
|
action: () => {
|
||||||
alert("TODO");
|
lookupFile();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.instance,
|
text: i18n.ts.instance,
|
||||||
icon: "ph-planet ph-bold ph-lg",
|
icon: "ph-planet ph-bold ph-lg",
|
||||||
action: () => {
|
action: () => {
|
||||||
alert("TODO");
|
lookupInstance();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
27
packages/client/src/scripts/lookup-file.ts
Normal file
27
packages/client/src/scripts/lookup-file.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { i18n } from "@/i18n";
|
||||||
|
import * as os from "@/os";
|
||||||
|
|
||||||
|
export async function lookupFile() {
|
||||||
|
const { canceled, result: q } = await os.inputText({
|
||||||
|
title: i18n.ts.fileIdOrUrl,
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
|
os.api(
|
||||||
|
"admin/drive/show-file",
|
||||||
|
q.startsWith("http://") || q.startsWith("https://")
|
||||||
|
? { url: q.trim() }
|
||||||
|
: { fileId: q.trim() },
|
||||||
|
)
|
||||||
|
.then((file) => {
|
||||||
|
os.pageWindow(`/admin/file/${file.id}`);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
if (err.code === "NO_SUCH_FILE") {
|
||||||
|
os.alert({
|
||||||
|
type: "error",
|
||||||
|
text: i18n.ts.notFound,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
25
packages/client/src/scripts/lookup-instance.ts
Normal file
25
packages/client/src/scripts/lookup-instance.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { i18n } from "@/i18n";
|
||||||
|
import * as os from "@/os";
|
||||||
|
|
||||||
|
export async function lookupInstance() {
|
||||||
|
const { canceled, result: q } = await os.inputText({
|
||||||
|
title: i18n.ts.instance,
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
|
os.api(
|
||||||
|
"federation/show-instance",
|
||||||
|
q.startsWith("http://") || q.startsWith("https://")
|
||||||
|
? { url: q.trim() }
|
||||||
|
: { fileId: q.trim() },
|
||||||
|
)
|
||||||
|
.then((instance) => {
|
||||||
|
os.pageWindow(`/instance-info/${instance.host}`);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
os.alert({
|
||||||
|
type: "error",
|
||||||
|
text: i18n.ts.notFound,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user