mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
* feat: new dropdown-based editor switching * feat: tab based switching * feat: add icon * fix: lint * chore: i18n translations oh boy was this a 'chore'
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
<template>
|
||||
<!-- go away eslint -->
|
||||
<div />
|
||||
<!-- I don't want to localize this -->
|
||||
<!--
|
||||
<div>
|
||||
<div v-if="user" class="mx-auto max-w-2xl lg:mx-0">
|
||||
<h2
|
||||
@ -15,7 +19,6 @@
|
||||
</div>
|
||||
|
||||
<div v-if="user" class="mt-8 grid grid-cols-1 gap-6 sm:grid-cols-2">
|
||||
<!-- Account Information Card -->
|
||||
<div
|
||||
class="overflow-hidden rounded-xl border border-zinc-800 bg-zinc-900 shadow-sm transition-all duration-200 hover:shadow-lg hover:shadow-zinc-900/50"
|
||||
>
|
||||
@ -51,7 +54,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Account Actions Card -->
|
||||
<div
|
||||
class="overflow-hidden rounded-xl border border-zinc-800 bg-zinc-900 shadow-sm transition-all duration-200 hover:shadow-lg hover:shadow-zinc-900/50"
|
||||
>
|
||||
@ -78,6 +80,7 @@
|
||||
<div class="text-zinc-400">Loading account information...</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -88,7 +91,4 @@ definePageMeta({
|
||||
useHead({
|
||||
title: "Account",
|
||||
});
|
||||
|
||||
// Fetch user data
|
||||
const user = await $dropFetch("/api/v1/user");
|
||||
</script>
|
||||
|
||||
@ -1,170 +1,6 @@
|
||||
<template>
|
||||
<div v-if="false" class="grid gap-4 lg:grid-cols-3 lg:grid-rows-2">
|
||||
<div class="relative lg:row-span-2">
|
||||
<div
|
||||
class="absolute inset-px rounded-lg bg-zinc-950 lg:rounded-l-[2rem]"
|
||||
/>
|
||||
<div
|
||||
class="relative flex h-full flex-col overflow-hidden rounded-[calc(var(--radius-lg)+1px)] lg:rounded-l-[calc(2rem+1px)]"
|
||||
>
|
||||
<div class="px-8 pt-8 pb-3 sm:px-10 sm:py-10">
|
||||
<p
|
||||
class="mt-2 text-lg font-medium tracking-tight text-zinc-100 max-lg:text-center"
|
||||
>
|
||||
Library
|
||||
</p>
|
||||
<p class="mt-2 max-w-lg text-sm/6 text-zinc-400 max-lg:text-center">
|
||||
Manage your Drop library, and import new games. Your library is the
|
||||
list of all games currently configured on this instance.
|
||||
</p>
|
||||
<p class="mt-3 text-sm">
|
||||
<NuxtLink
|
||||
href="/admin/library"
|
||||
class="whitespace-nowrap font-medium text-blue-400 hover:text-blue-500"
|
||||
>
|
||||
Check it out
|
||||
<span aria-hidden="true"> →</span>
|
||||
</NuxtLink>
|
||||
</p>
|
||||
|
||||
<div v-if="toImport" class="mt-2 rounded-md bg-blue-600/10 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<InformationCircleIcon
|
||||
class="h-5 w-5 text-blue-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="ml-3 flex-1 md:flex md:justify-between">
|
||||
<p class="text-sm text-blue-400">
|
||||
Drop has detected you have new games to import.
|
||||
</p>
|
||||
<p class="mt-3 text-sm md:ml-6 md:mt-0">
|
||||
<NuxtLink
|
||||
href="/admin/library/import"
|
||||
class="whitespace-nowrap font-medium text-blue-400 hover:text-blue-500"
|
||||
>
|
||||
Import
|
||||
<span aria-hidden="true"> →</span>
|
||||
</NuxtLink>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="pointer-events-none absolute inset-px rounded-lg ring-1 shadow-sm ring-black/5 lg:rounded-l-[2rem]"
|
||||
/>
|
||||
</div>
|
||||
<div class="relative max-lg:row-start-1">
|
||||
<div
|
||||
class="absolute inset-px rounded-lg bg-zinc-950 max-lg:rounded-t-[2rem]"
|
||||
/>
|
||||
<div
|
||||
class="relative flex h-full flex-col overflow-hidden rounded-[calc(var(--radius-lg)+1px)] max-lg:rounded-t-[calc(2rem+1px)]"
|
||||
>
|
||||
<div class="px-8 py-8 sm:px-10 sm:py-10">
|
||||
<p
|
||||
class="mt-2 text-lg font-medium tracking-tight text-zinc-100 max-lg:text-center"
|
||||
>
|
||||
Users
|
||||
</p>
|
||||
<p class="mt-2 max-w-lg text-sm/6 text-zinc-400 max-lg:text-center">
|
||||
Your users are people who can access your Drop instance, download
|
||||
games from it, and configure API keys for it.
|
||||
</p>
|
||||
<p class="mt-3 text-sm">
|
||||
<NuxtLink
|
||||
href="/admin/users"
|
||||
class="whitespace-nowrap font-medium text-blue-400 hover:text-blue-500"
|
||||
>
|
||||
Check it out
|
||||
<span aria-hidden="true"> →</span>
|
||||
</NuxtLink>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="pointer-events-none absolute inset-px rounded-lg ring-1 shadow-sm ring-black/5 max-lg:rounded-t-[2rem]"
|
||||
/>
|
||||
</div>
|
||||
<div class="relative max-lg:row-start-3 lg:col-start-2 lg:row-start-2">
|
||||
<div class="absolute inset-px rounded-lg bg-white" />
|
||||
<div
|
||||
class="relative flex h-full flex-col overflow-hidden rounded-[calc(var(--radius-lg)+1px)]"
|
||||
>
|
||||
<div class="px-8 pt-8 sm:px-10 sm:pt-10">
|
||||
<p
|
||||
class="mt-2 text-lg font-medium tracking-tight text-gray-950 max-lg:text-center"
|
||||
>
|
||||
Security
|
||||
</p>
|
||||
<p class="mt-2 max-w-lg text-sm/6 text-gray-600 max-lg:text-center">
|
||||
Morbi viverra dui mi arcu sed. Tellus semper adipiscing suspendisse
|
||||
semper morbi.
|
||||
</p>
|
||||
</div>
|
||||
<div class="@container flex flex-1 items-center max-lg:py-6 lg:pb-2">
|
||||
<img
|
||||
class="h-[min(152px,40cqw)] object-cover"
|
||||
src="https://tailwindcss.com/plus-assets/img/component-images/bento-03-security.png"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="pointer-events-none absolute inset-px rounded-lg ring-1 shadow-sm ring-black/5"
|
||||
/>
|
||||
</div>
|
||||
<div class="relative lg:row-span-2">
|
||||
<div
|
||||
class="absolute inset-px rounded-lg bg-white max-lg:rounded-b-[2rem] lg:rounded-r-[2rem]"
|
||||
/>
|
||||
<div
|
||||
class="relative flex h-full flex-col overflow-hidden rounded-[calc(var(--radius-lg)+1px)] max-lg:rounded-b-[calc(2rem+1px)] lg:rounded-r-[calc(2rem+1px)]"
|
||||
>
|
||||
<div class="px-8 pt-8 pb-3 sm:px-10 sm:pt-10 sm:pb-0">
|
||||
<p
|
||||
class="mt-2 text-lg font-medium tracking-tight text-gray-950 max-lg:text-center"
|
||||
>
|
||||
Powerful APIs
|
||||
</p>
|
||||
<p class="mt-2 max-w-lg text-sm/6 text-gray-600 max-lg:text-center">
|
||||
Sit quis amet rutrum tellus ullamcorper ultricies libero dolor eget
|
||||
sem sodales gravida.
|
||||
</p>
|
||||
</div>
|
||||
<div class="relative min-h-[30rem] w-full grow">
|
||||
<div
|
||||
class="absolute top-10 right-0 bottom-0 left-10 overflow-hidden rounded-tl-xl bg-gray-900 shadow-2xl"
|
||||
>
|
||||
<div class="flex bg-gray-800/40 ring-1 ring-white/5">
|
||||
<div class="-mb-px flex text-sm/6 font-medium text-gray-400">
|
||||
<div
|
||||
class="border-r border-b border-r-white/10 border-b-white/20 bg-white/5 px-4 py-2 text-white"
|
||||
>
|
||||
NotificationSetting.jsx
|
||||
</div>
|
||||
<div class="border-r border-gray-600/10 px-4 py-2">App.jsx</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-6 pt-6 pb-14">
|
||||
<!-- Your code example -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="pointer-events-none absolute inset-px rounded-lg ring-1 shadow-sm ring-black/5 max-lg:rounded-b-[2rem] lg:rounded-r-[2rem]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template><div /></template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { InformationCircleIcon } from "@heroicons/vue/24/solid";
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
@ -172,7 +8,4 @@ definePageMeta({
|
||||
useHead({
|
||||
title: "Home",
|
||||
});
|
||||
|
||||
const libraryState = await $dropFetch("/api/v1/admin/library");
|
||||
const toImport = Object.entries(libraryState.unimportedGames).length > 0;
|
||||
</script>
|
||||
|
||||
@ -1,163 +1,132 @@
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
class="pt-8 lg:pt-0 lg:pl-20 fixed inset-0 flex flex-col overflow-auto bg-zinc-900"
|
||||
>
|
||||
<div
|
||||
v-if="game && unimportedVersions !== undefined"
|
||||
class="grow flex flex-col gap-y-8"
|
||||
class="bg-zinc-950 w-full flex flex-col sm:flex-row items-center gap-2 justify-between pr-2"
|
||||
>
|
||||
<div class="grow w-full h-full lg:pr-[30vw] px-6 py-4 flex flex-col">
|
||||
<div
|
||||
v-if="game.versions.length === 0"
|
||||
class="flex flex-col items-center justify-center h-full text-zinc-400"
|
||||
>
|
||||
<InformationCircleIcon class="w-12 h-12 mb-2 text-zinc-400" />
|
||||
<div class="font-semibold text-lg">No versions yet</div>
|
||||
<div class="text-sm mt-1">
|
||||
Import your first version to get started!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="lg:overflow-y-auto lg:border-l lg:border-zinc-800 lg:fixed lg:inset-y-0 lg:z-50 lg:w-[30vw] flex flex-col lg:right-0 gap-y-8 px-6 py-4"
|
||||
>
|
||||
<!-- toolbar -->
|
||||
<div class="inline-flex justify-end items-stretch gap-x-4">
|
||||
<!-- open in library button -->
|
||||
<NuxtLink
|
||||
:href="`/admin/metadata/games/${game.id}`"
|
||||
type="button"
|
||||
class="inline-flex w-fit items-center gap-x-2 rounded-md bg-zinc-800 px-3 py-1 text-sm font-semibold font-display text-white shadow-sm transition-all duration-200 hover:bg-zinc-700 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
{{ $t("library.admin.openInMetadata") }}
|
||||
<ArrowTopRightOnSquareIcon
|
||||
class="-mr-0.5 h-7 w-7 p-1"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NuxtLink>
|
||||
<!-- open in store button -->
|
||||
<NuxtLink
|
||||
:href="`/store/${game.id}`"
|
||||
type="button"
|
||||
class="inline-flex w-fit items-center gap-x-2 rounded-md bg-zinc-800 px-3 py-1 text-sm font-semibold font-display text-white shadow-sm transition-all duration-200 hover:bg-zinc-700 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
{{ $t("library.admin.openStore") }}
|
||||
<ArrowTopRightOnSquareIcon
|
||||
class="-mr-0.5 h-7 w-7 p-1"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
<!--start-->
|
||||
<div>
|
||||
<Listbox v-if="false" v-model="currentMode" as="div">
|
||||
<div class="relative mt-2">
|
||||
<ListboxButton
|
||||
class="min-w-[10vw] w-full cursor-default inline-flex items-center gap-x-2 rounded-md bg-zinc-900 py-1.5 pr-2 pl-3 text-left text-zinc-200 outline-1 -outline-offset-1 outline-zinc-700 focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
|
||||
>
|
||||
<span class="col-start-1 row-start-1 truncate">{{
|
||||
currentMode
|
||||
}}</span>
|
||||
|
||||
<!-- version manager -->
|
||||
<div>
|
||||
<!-- version priority -->
|
||||
<div>
|
||||
<div class="border-b border-zinc-800 pb-3">
|
||||
<div
|
||||
class="flex flex-wrap items-center justify-between sm:flex-nowrap"
|
||||
<PencilIcon class="ml-auto size-5" />
|
||||
|
||||
<ChevronUpDownIcon
|
||||
class="text-gray-500 size-5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</ListboxButton>
|
||||
|
||||
<transition
|
||||
leave-active-class="transition ease-in duration-100"
|
||||
leave-from-class="opacity-100"
|
||||
leave-to-class="opacity-0"
|
||||
>
|
||||
<ListboxOptions
|
||||
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-zinc-900 py-1 text-base shadow-lg ring-1 ring-white/5 focus:outline-hidden sm:text-sm"
|
||||
>
|
||||
<h3
|
||||
class="text-base font-semibold font-display leading-6 text-zinc-100"
|
||||
<ListboxOption
|
||||
v-for="[value] in Object.entries(components)"
|
||||
v-slot="{ active, selected }"
|
||||
:key="value"
|
||||
as="template"
|
||||
:value="value"
|
||||
>
|
||||
{{ $t("library.admin.versionPriority") }}
|
||||
|
||||
<!-- import games button -->
|
||||
|
||||
<NuxtLink
|
||||
v-if="unimportedVersions !== undefined"
|
||||
:href="
|
||||
unimportedVersions.length > 0
|
||||
? `/admin/library/${game.id}/import`
|
||||
: ''
|
||||
"
|
||||
type="button"
|
||||
<li
|
||||
:class="[
|
||||
unimportedVersions.length > 0
|
||||
? 'bg-blue-600 hover:bg-blue-700'
|
||||
: 'bg-blue-800/50',
|
||||
'inline-flex w-fit items-center gap-x-2 rounded-md px-3 py-1 text-sm font-semibold font-display text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600',
|
||||
active
|
||||
? 'bg-blue-600 text-white outline-hidden'
|
||||
: 'text-zinc-100',
|
||||
'relative cursor-default py-2 pr-9 pl-3 select-none',
|
||||
]"
|
||||
>
|
||||
{{
|
||||
unimportedVersions.length > 0
|
||||
? $t("library.admin.import.version.import")
|
||||
: $t("library.admin.import.version.noVersions")
|
||||
}}
|
||||
</NuxtLink>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
:class="[
|
||||
selected ? 'font-semibold' : 'font-normal',
|
||||
'block truncate',
|
||||
]"
|
||||
>{{ value }}</span
|
||||
>
|
||||
|
||||
<div class="mt-4 text-center w-full text-sm text-zinc-600">
|
||||
{{ $t("lowest") }}
|
||||
</div>
|
||||
<draggable
|
||||
:list="game.versions"
|
||||
handle=".handle"
|
||||
class="mt-2 space-y-4"
|
||||
@update="() => updateVersionOrder()"
|
||||
<span
|
||||
v-if="selected"
|
||||
class="text-white absolute inset-y-0 right-0 flex items-center pr-4"
|
||||
>
|
||||
<PencilIcon class="size-5" aria-hidden="true" />
|
||||
</span>
|
||||
</li>
|
||||
</ListboxOption>
|
||||
</ListboxOptions>
|
||||
</transition>
|
||||
</div>
|
||||
</Listbox>
|
||||
|
||||
<div class="pt-4 inline-flex gap-x-2">
|
||||
<div
|
||||
v-for="[value, { icon }] in Object.entries(components)"
|
||||
:key="value"
|
||||
>
|
||||
<button
|
||||
:class="[
|
||||
'inline-flex items-center gap-x-1 py-2 px-3 rounded-t-md font-semibold text-sm',
|
||||
value == currentMode
|
||||
? 'bg-zinc-900 text-zinc-100'
|
||||
: 'bg-transparent text-zinc-500',
|
||||
]"
|
||||
@click="() => (currentMode = value as GameEditorMode)"
|
||||
>
|
||||
<template #item="{ element: item }: { element: GameVersion }">
|
||||
<div
|
||||
class="w-full inline-flex items-center px-4 py-2 bg-zinc-800 rounded justify-between"
|
||||
>
|
||||
<div class="text-zinc-100 font-semibold">
|
||||
{{ item.versionName }}
|
||||
</div>
|
||||
<div class="text-zinc-400">
|
||||
{{
|
||||
item.delta
|
||||
? $t("library.admin.import.version.updateMode")
|
||||
: ""
|
||||
}}
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-x-2">
|
||||
<component
|
||||
:is="PLATFORM_ICONS[item.platform]"
|
||||
class="size-6 text-blue-600"
|
||||
/>
|
||||
<Bars3Icon
|
||||
class="cursor-move w-6 h-6 text-zinc-400 handle"
|
||||
/>
|
||||
<button @click="() => deleteVersion(item.versionName)">
|
||||
<TrashIcon class="w-5 h-5 text-red-600" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</draggable>
|
||||
<div
|
||||
v-if="game.versions.length == 0"
|
||||
class="text-center font-bold text-zinc-400 my-3"
|
||||
>
|
||||
{{ $t("library.admin.noVersionsAdded") }}
|
||||
</div>
|
||||
<div class="mt-2 text-center w-full text-sm text-zinc-600">
|
||||
{{ $t("highest") }}
|
||||
</div>
|
||||
<component :is="icon" class="size-4" />
|
||||
{{ value }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<!-- open in store button -->
|
||||
<NuxtLink
|
||||
:href="`/store/${game.id}`"
|
||||
type="button"
|
||||
class="inline-flex w-fit items-center gap-x-2 rounded-md bg-zinc-800 px-3 py-1 text-sm font-semibold font-display text-white shadow-sm hover:bg-zinc-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
{{ $t("library.admin.openStore") }}
|
||||
<ArrowTopRightOnSquareIcon
|
||||
class="-mr-0.5 h-7 w-7 p-1"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
<component
|
||||
:is="components[currentMode].editor"
|
||||
v-model="game"
|
||||
:unimported-versions="unimportedVersions"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { GameVersion } from "~/prisma/client";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
} from "@headlessui/vue";
|
||||
import { ChevronUpDownIcon } from "@heroicons/vue/16/solid";
|
||||
import { GameEditorMetadata, GameEditorVersion } from "#components";
|
||||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
Bars3Icon,
|
||||
TrashIcon,
|
||||
InformationCircleIcon,
|
||||
} from "@heroicons/vue/24/solid";
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
// TODO implement UI for this
|
||||
DocumentIcon,
|
||||
PencilIcon,
|
||||
ServerStackIcon,
|
||||
} from "@heroicons/vue/24/outline";
|
||||
import type { Component } from "vue";
|
||||
|
||||
const route = useRoute();
|
||||
const gameId = route.params.id.toString();
|
||||
@ -166,58 +135,29 @@ const { game: rawGame, unimportedVersions } = await $dropFetch(
|
||||
);
|
||||
const game = ref(rawGame);
|
||||
|
||||
async function updateVersionOrder() {
|
||||
try {
|
||||
const newVersions = await $dropFetch("/api/v1/admin/game/version", {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
id: gameId,
|
||||
versions: game.value.versions.map((e) => e.versionName),
|
||||
},
|
||||
});
|
||||
game.value.versions = newVersions;
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: t("errors.version.order.title"),
|
||||
description: t("errors.version.order.desc", {
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
error: e?.statusMessage ?? t("errors.unknown"),
|
||||
}),
|
||||
buttonText: t("close"),
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
useHead({
|
||||
// To do a title with the game name in it, we need some sort of watch
|
||||
title: "Game Editor",
|
||||
});
|
||||
|
||||
enum GameEditorMode {
|
||||
Metadata = "Metadata",
|
||||
Versions = "Versions",
|
||||
}
|
||||
|
||||
async function deleteVersion(versionName: string) {
|
||||
try {
|
||||
await $dropFetch("/api/v1/admin/game/version", {
|
||||
method: "DELETE",
|
||||
body: {
|
||||
id: gameId,
|
||||
versionName: versionName,
|
||||
},
|
||||
});
|
||||
game.value.versions.splice(
|
||||
game.value.versions.findIndex((e) => e.versionName === versionName),
|
||||
1,
|
||||
);
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: t("errors.version.delete.title"),
|
||||
description: t("errors.version.delete.desc", {
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
error: e?.statusMessage ?? t("errors.unknown"),
|
||||
}),
|
||||
buttonText: t("close"),
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}
|
||||
const components: {
|
||||
[key in GameEditorMode]: { editor: Component; icon: Component };
|
||||
} = {
|
||||
[GameEditorMode.Metadata]: { editor: GameEditorMetadata, icon: DocumentIcon },
|
||||
[GameEditorMode.Versions]: {
|
||||
editor: GameEditorVersion,
|
||||
icon: ServerStackIcon,
|
||||
},
|
||||
};
|
||||
|
||||
const currentMode = ref<GameEditorMode>(GameEditorMode.Metadata);
|
||||
</script>
|
||||
|
||||
@ -98,19 +98,13 @@
|
||||
<div class="mt-4 flex flex-col gap-y-1">
|
||||
<NuxtLink
|
||||
:href="`/admin/library/${game.id}`"
|
||||
class="w-fit rounded-md bg-blue-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm transition-all duration-200 hover:bg-blue-500 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
class="w-fit rounded-md bg-zinc-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-zinc-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
<i18n-t keypath="library.admin.openLibrary" tag="span">
|
||||
<template #arrow>
|
||||
<span aria-hidden="true">{{ $t("chars.arrow") }}</span>
|
||||
</template>
|
||||
</i18n-t>
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
:href="`/admin/metadata/games/${game.id}`"
|
||||
class="w-fit rounded-md bg-zinc-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm transition-all duration-200 hover:bg-zinc-700 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zinc-600"
|
||||
>
|
||||
<i18n-t keypath="library.admin.openMetadata" tag="span">
|
||||
<i18n-t
|
||||
keypath="library.admin.openEditor"
|
||||
tag="span"
|
||||
scope="global"
|
||||
>
|
||||
<template #arrow>
|
||||
<span aria-hidden="true">{{ $t("chars.arrow") }}</span>
|
||||
</template>
|
||||
@ -169,7 +163,7 @@
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-yellow-600">
|
||||
{{ $t("library.admin.noVersions") }}
|
||||
{{ $t("library.admin.version.noVersions") }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,754 +0,0 @@
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-if="game && unimportedVersions !== undefined"
|
||||
class="grow flex flex-col gap-y-8"
|
||||
>
|
||||
<div class="grow w-full h-full lg:pr-[30vw] px-6 py-4 flex flex-col">
|
||||
<div
|
||||
class="flex flex-col lg:flex-row lg:justify-between items-start lg:items-center gap-2"
|
||||
>
|
||||
<div class="inline-flex items-center gap-4">
|
||||
<!-- icon image -->
|
||||
<img :src="coreMetadataIconUrl" class="size-20" />
|
||||
<div>
|
||||
<h1 class="text-5xl font-bold font-display text-zinc-100">
|
||||
{{ game.mName }}
|
||||
</h1>
|
||||
<p class="mt-1 text-lg text-zinc-400">
|
||||
{{ game.mShortDescription }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="relative inline-flex gap-x-3 items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => (showEditCoreMetadata = true)"
|
||||
>
|
||||
{{ $t("edit") }} <PencilIcon class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- image carousel pick -->
|
||||
<div class="border-b border-zinc-700">
|
||||
<div class="border-b border-zinc-700 py-4">
|
||||
<div
|
||||
class="-ml-4 -mt-4 flex flex-wrap items-center justify-between sm:flex-nowrap"
|
||||
>
|
||||
<div class="ml-4 mt-4">
|
||||
<h3 class="text-base font-semibold text-zinc-100">
|
||||
Image Carousel
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-zinc-400 max-w-lg">
|
||||
Customise what images and what order are shown on the store
|
||||
page.
|
||||
</p>
|
||||
</div>
|
||||
<div class="ml-4 mt-4 shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => (showAddCarouselModal = true)"
|
||||
>
|
||||
Add from image library
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="game.mImageCarouselObjectIds.length == 0"
|
||||
class="text-zinc-400 text-center py-8"
|
||||
>
|
||||
No images added to the carousel yet.
|
||||
</div>
|
||||
|
||||
<draggable
|
||||
v-else
|
||||
:list="game.mImageCarouselObjectIds"
|
||||
class="w-full flex flex-row gap-x-4 overflow-x-auto my-2 py-4"
|
||||
@update="() => updateImageCarousel()"
|
||||
>
|
||||
<template #item="{ element }: { element: string }">
|
||||
<div class="relative group min-w-fit">
|
||||
<img :src="useObject(element)" class="h-48 w-auto" />
|
||||
<div
|
||||
class="transition-all lg:opacity-0 lg:group-hover:opacity-100 absolute inset-0 flex flex-col items-center justify-center gap-y-2 bg-zinc-950/50"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => removeImageFromCarousel(element)"
|
||||
>
|
||||
Remove image
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</draggable>
|
||||
</div>
|
||||
|
||||
<!-- description editor -->
|
||||
<div
|
||||
class="mt-4 grow flex flex-col w-full space-y-4 border border-zinc-800 rounded overflow-hidden p-2"
|
||||
>
|
||||
<!-- toolbar -->
|
||||
<div
|
||||
class="h-8 bg-zinc-800 rounded inline-flex gap-x-4 items-center justify-start p-2"
|
||||
>
|
||||
<div>
|
||||
<CheckIcon
|
||||
v-if="descriptionSaving == 0"
|
||||
class="size-5 text-zinc-100"
|
||||
/>
|
||||
<div v-else-if="descriptionSaving == 1">
|
||||
<PencilIcon class="animate-pulse size-5 text-zinc-100" />
|
||||
</div>
|
||||
<div v-else-if="descriptionSaving == 2" role="status">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-5 h-5 text-transparent animate-spin fill-white"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button @click="() => (showAddImageDescriptionModal = true)">
|
||||
<PhotoIcon
|
||||
class="transition size-5 text-zinc-100 hover:text-zinc-300"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="block lg:hidden"
|
||||
@click="
|
||||
() => (mobileShowFinalDescription = !mobileShowFinalDescription)
|
||||
"
|
||||
>
|
||||
<DocumentIcon
|
||||
v-if="!mobileShowFinalDescription"
|
||||
class="transition size-5 text-zinc-100 hover:text-zinc-300"
|
||||
/>
|
||||
<PencilIcon
|
||||
v-else
|
||||
class="transition size-5 text-zinc-100 hover:text-zinc-300"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<!-- edit area -->
|
||||
<div class="grid lg:grid-cols-2 lg:gap-x-8 grow">
|
||||
<!-- editing box -->
|
||||
<div
|
||||
:class="[
|
||||
mobileShowFinalDescription ? 'hidden' : 'block',
|
||||
'lg:block',
|
||||
]"
|
||||
>
|
||||
<textarea
|
||||
ref="descriptionEditor"
|
||||
v-model="game.mDescription"
|
||||
class="grow h-full w-full bg-zinc-950/30 text-zinc-100 border-zinc-900 rounded"
|
||||
/>
|
||||
</div>
|
||||
<!-- result box -->
|
||||
<div
|
||||
:class="[
|
||||
mobileShowFinalDescription ? 'block' : 'hidden',
|
||||
'lg:block prose prose-invert prose-blue bg-zinc-950/30 rounded px-4 py-3',
|
||||
]"
|
||||
v-html="descriptionHTML"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="lg:overflow-y-auto lg:border-l lg:border-zinc-800 lg:fixed lg:inset-y-0 lg:z-50 lg:w-[30vw] flex flex-col lg:right-0 gap-y-8 px-6 py-4"
|
||||
>
|
||||
<!-- toolbar -->
|
||||
<div class="inline-flex justify-end items-stretch gap-x-4">
|
||||
<!-- open in library button -->
|
||||
<NuxtLink
|
||||
:href="`/admin/library/${game.id}`"
|
||||
type="button"
|
||||
class="inline-flex w-fit items-center gap-x-2 rounded-md bg-zinc-800 px-3 py-1 text-sm font-semibold font-display text-white shadow-sm transition-all duration-200 hover:bg-zinc-700 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zinc-600"
|
||||
>
|
||||
Open in Library
|
||||
<ArrowTopRightOnSquareIcon
|
||||
class="-mr-0.5 h-7 w-7 p-1"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NuxtLink>
|
||||
<!-- open in store button -->
|
||||
<NuxtLink
|
||||
:href="`/store/${game.id}`"
|
||||
type="button"
|
||||
class="inline-flex w-fit items-center gap-x-2 rounded-md bg-zinc-800 px-3 py-1 text-sm font-semibold font-display text-white shadow-sm transition-all duration-200 hover:bg-zinc-700 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zinc-600"
|
||||
>
|
||||
Open in Store
|
||||
<ArrowTopRightOnSquareIcon
|
||||
class="-mr-0.5 h-7 w-7 p-1"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- image library -->
|
||||
<div>
|
||||
<div class="border-b border-zinc-800 pb-3">
|
||||
<div
|
||||
class="flex flex-wrap items-center justify-between sm:flex-nowrap gap-4"
|
||||
>
|
||||
<div>
|
||||
<h3
|
||||
class="text-base font-semibold font-display leading-6 text-zinc-100"
|
||||
>
|
||||
Image library
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-zinc-400 max-w-lg">
|
||||
Please note all images uploaded are accessible to all users
|
||||
through browser dev-tools.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => (showUploadModal = true)"
|
||||
>
|
||||
Upload
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 grid grid-cols-2 grid-flow-dense gap-8">
|
||||
<div
|
||||
v-for="(image, imageIdx) in game.mImageLibraryObjectIds"
|
||||
:key="imageIdx"
|
||||
class="group relative flex items-center bg-zinc-950/30"
|
||||
>
|
||||
<img :src="useObject(image)" class="w-full h-auto" />
|
||||
<div
|
||||
class="transition-all lg:opacity-0 lg:group-hover:opacity-100 absolute inset-0 flex flex-col items-center justify-center gap-y-2 bg-zinc-950/50"
|
||||
>
|
||||
<button
|
||||
v-if="image !== game.mBannerObjectId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => updateBannerImage(image)"
|
||||
>
|
||||
Set as banner
|
||||
</button>
|
||||
<button
|
||||
v-if="image !== game.mCoverObjectId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => updateCoverImage(image)"
|
||||
>
|
||||
Set as cover
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-red-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-red-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-red-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600"
|
||||
@click="() => deleteImage(image)"
|
||||
>
|
||||
Delete image
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
image === game.mBannerObjectId ||
|
||||
image === game.mCoverObjectId
|
||||
"
|
||||
class="absolute bottom-0 left-0 bg-zinc-950/75 text-zinc-100 text-sm font-semibold px-2 py-1 rounded-tr"
|
||||
>
|
||||
current
|
||||
{{
|
||||
[
|
||||
image === game.mBannerObjectId ? "banner" : undefined,
|
||||
image === game.mCoverObjectId ? "cover" : undefined,
|
||||
]
|
||||
.filter((e) => e)
|
||||
.join(" & ")
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<UploadFileDialog
|
||||
v-model="showUploadModal"
|
||||
:options="{ id: game.id }"
|
||||
accept="image/*"
|
||||
endpoint="/api/v1/admin/game/image"
|
||||
:multiple="true"
|
||||
@upload="(result: Game) => uploadAfterImageUpload(result)"
|
||||
/>
|
||||
<ModalTemplate v-model="showAddCarouselModal">
|
||||
<template #default>
|
||||
<div
|
||||
class="grid grid-cols-2 grid-flow-dense gap-4 max-h-[70vh] overflow-y-auto p-4"
|
||||
>
|
||||
<div
|
||||
v-for="(image, imageIdx) in validAddCarouselImages"
|
||||
:key="imageIdx"
|
||||
class="group relative flex items-center bg-zinc-950/30"
|
||||
>
|
||||
<img :src="useObject(image)" class="w-full h-auto" />
|
||||
<div
|
||||
class="transition-all lg:opacity-0 lg:group-hover:opacity-100 absolute inset-0 flex flex-col items-center justify-center gap-y-2 bg-zinc-950/50"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => addImageToCarousel(image)"
|
||||
>
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="validAddCarouselImages.length == 0"
|
||||
class="text-zinc-400 col-span-2"
|
||||
>
|
||||
No images to add.
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<button
|
||||
ref="cancelButtonRef"
|
||||
type="button"
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-900 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-950 transition-all duration-200 hover:scale-105 hover:shadow-lg active:scale-95 sm:mt-0 sm:w-auto"
|
||||
@click="showAddCarouselModal = false"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</template>
|
||||
</ModalTemplate>
|
||||
<ModalTemplate v-model="showAddImageDescriptionModal">
|
||||
<template #default>
|
||||
<div class="grid grid-cols-2 grid-flow-dense gap-4">
|
||||
<div
|
||||
v-for="(image, imageIdx) in game.mImageLibraryObjectIds"
|
||||
:key="imageIdx"
|
||||
class="group relative flex items-center bg-zinc-950/30"
|
||||
>
|
||||
<img :src="useObject(image)" class="w-full h-auto" />
|
||||
<div
|
||||
class="transition-all lg:opacity-0 lg:group-hover:opacity-100 absolute inset-0 flex flex-col items-center justify-center gap-y-2 bg-zinc-950/50"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-x-1.5 rounded-md bg-blue-600 px-1.5 py-0.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => insertImageAtCursor(image)"
|
||||
>
|
||||
Insert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="game.mImageLibraryObjectIds.length == 0"
|
||||
class="text-zinc-400 col-span-2"
|
||||
>
|
||||
No images to add.
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<button
|
||||
ref="cancelButtonRef"
|
||||
type="button"
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-900 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-950 transition-all duration-200 hover:scale-105 hover:shadow-lg active:scale-95 sm:mt-0 sm:w-auto"
|
||||
@click="showAddCarouselModal = false"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</template>
|
||||
</ModalTemplate>
|
||||
<ModalTemplate v-model="showEditCoreMetadata">
|
||||
<template #default>
|
||||
<div class="flex flex-col lg:flex-row gap-6">
|
||||
<!-- icon upload div -->
|
||||
<div class="flex flex-col items-center gap-4">
|
||||
<img :src="coreMetadataIconUrl" class="size-24 aspect-square" />
|
||||
<label for="file-upload">
|
||||
<span
|
||||
type="button"
|
||||
class="cursor-pointer relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
Upload
|
||||
</span>
|
||||
<input
|
||||
id="file-upload"
|
||||
accept="image/*"
|
||||
class="hidden"
|
||||
type="file"
|
||||
@change="(e) => coreMetadataUploadFiles(e as any)"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<!-- edit title -->
|
||||
<div class="flex flex-col gap-y-4 grow">
|
||||
<div>
|
||||
<label
|
||||
for="name"
|
||||
class="block text-sm/6 font-medium text-zinc-100"
|
||||
>Game Name</label
|
||||
>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
id="name"
|
||||
v-model="coreMetadataName"
|
||||
type="text"
|
||||
name="name"
|
||||
class="block w-full rounded-md bg-zinc-800 px-3 py-1.5 text-base text-zinc-100 outline outline-1 -outline-offset-1 outline-zinc-700 placeholder:text-zinc-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
for="description"
|
||||
class="block text-sm/6 font-medium text-zinc-100"
|
||||
>Game Description</label
|
||||
>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
id="description"
|
||||
v-model="coreMetadataDescription"
|
||||
type="text"
|
||||
name="description"
|
||||
class="block w-full rounded-md bg-zinc-800 px-3 py-1.5 text-base text-zinc-100 outline outline-1 -outline-offset-1 outline-zinc-700 placeholder:text-zinc-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #buttons>
|
||||
<LoadingButton
|
||||
type="button"
|
||||
:loading="coreMetadataLoading"
|
||||
:class="['inline-flex w-full shadow-sm sm:ml-3 sm:w-auto']"
|
||||
@click="() => coreMetadataUpdate_wrapper()"
|
||||
>
|
||||
Save
|
||||
</LoadingButton>
|
||||
<button
|
||||
ref="cancelButtonRef"
|
||||
type="button"
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-900 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-950 transition-all duration-200 hover:scale-105 hover:shadow-lg active:scale-95 sm:mt-0 sm:w-auto"
|
||||
@click="showEditCoreMetadata = false"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</template>
|
||||
</ModalTemplate>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Game } from "~/prisma/client";
|
||||
import { micromark } from "micromark";
|
||||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
CheckIcon,
|
||||
DocumentIcon,
|
||||
PencilIcon,
|
||||
PhotoIcon,
|
||||
} from "@heroicons/vue/24/solid";
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
const showUploadModal = ref(false);
|
||||
const showAddCarouselModal = ref(false);
|
||||
const showAddImageDescriptionModal = ref(false);
|
||||
const showEditCoreMetadata = ref(false);
|
||||
const mobileShowFinalDescription = ref(true);
|
||||
|
||||
const route = useRoute();
|
||||
const gameId = route.params.id.toString();
|
||||
const { game: rawGame, unimportedVersions } = await $dropFetch(
|
||||
`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`,
|
||||
);
|
||||
const game = ref(rawGame);
|
||||
|
||||
const coreMetadataName = ref(game.value.mName);
|
||||
const coreMetadataDescription = ref(game.value.mShortDescription);
|
||||
const coreMetadataIconUrl = ref(useObject(game.value.mIconObjectId));
|
||||
const coreMetadataIconFileUpload = ref<FileList | undefined>();
|
||||
const coreMetadataLoading = ref(false);
|
||||
|
||||
function coreMetadataUploadFiles(e: InputEvent) {
|
||||
if (coreMetadataIconUrl.value.startsWith("blob")) {
|
||||
console.log("freed object URL");
|
||||
URL.revokeObjectURL(coreMetadataIconUrl.value);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
coreMetadataIconFileUpload.value = (e.target as any)?.files;
|
||||
const file = coreMetadataIconFileUpload.value?.item(0);
|
||||
if (!file) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "Failed to upload file",
|
||||
description: "Drop couldn't upload this file.",
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
coreMetadataIconUrl.value = objectUrl;
|
||||
}
|
||||
async function coreMetadataUpdate() {
|
||||
const formData = new FormData();
|
||||
|
||||
const newIcon = coreMetadataIconFileUpload.value?.item(0);
|
||||
if (newIcon) {
|
||||
formData.append("icon", newIcon);
|
||||
}
|
||||
|
||||
formData.append("id", game.value.id);
|
||||
formData.append("name", coreMetadataName.value);
|
||||
formData.append("description", coreMetadataDescription.value);
|
||||
|
||||
const result = await $dropFetch(`/api/v1/admin/game/metadata`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function coreMetadataUpdate_wrapper() {
|
||||
coreMetadataLoading.value = true;
|
||||
coreMetadataUpdate()
|
||||
.catch((e) => {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "Failed to update metadata",
|
||||
description: `Drop failed to update the game's metadata: ${
|
||||
e?.statusMessage || "An unknown error occurred. "
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
})
|
||||
.then((newGame) => {
|
||||
if (!newGame) return;
|
||||
Object.assign(game.value, newGame);
|
||||
})
|
||||
.finally(() => {
|
||||
coreMetadataLoading.value = false;
|
||||
showEditCoreMetadata.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
const descriptionHTML = computed(() =>
|
||||
micromark(game.value?.mDescription ?? ""),
|
||||
);
|
||||
const descriptionEditor = ref<HTMLTextAreaElement | undefined>();
|
||||
// 0 is not loading
|
||||
// 1 is waiting for stop
|
||||
// 2 is loading
|
||||
const descriptionSaving = ref<number>(0);
|
||||
|
||||
let savingTimeout: undefined | NodeJS.Timeout;
|
||||
|
||||
type PatchGameBody = Partial<Game>;
|
||||
|
||||
watch(descriptionHTML, (_v) => {
|
||||
console.log(game.value.mDescription);
|
||||
descriptionSaving.value = 1;
|
||||
if (savingTimeout) clearTimeout(savingTimeout);
|
||||
savingTimeout = setTimeout(async () => {
|
||||
try {
|
||||
descriptionSaving.value = 2;
|
||||
await $dropFetch("/api/v1/admin/game", {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
id: gameId,
|
||||
mDescription: game.value.mDescription,
|
||||
} satisfies PatchGameBody,
|
||||
});
|
||||
descriptionSaving.value = 0;
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "Failed to update game description",
|
||||
description: `Drop failed to update the game description: ${
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown")
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
const validAddCarouselImages = computed(() =>
|
||||
game.value.mImageLibraryObjectIds.filter(
|
||||
(e) => !game.value.mImageCarouselObjectIds.includes(e),
|
||||
),
|
||||
);
|
||||
|
||||
function insertImageAtCursor(id: string) {
|
||||
showAddImageDescriptionModal.value = false;
|
||||
if (!descriptionEditor.value || !game.value) return;
|
||||
const insertPosition = descriptionEditor.value.selectionStart;
|
||||
const text = ``;
|
||||
game.value.mDescription = `${game.value.mDescription.slice(
|
||||
0,
|
||||
insertPosition,
|
||||
)}${text}${game.value.mDescription.slice(insertPosition)}`;
|
||||
}
|
||||
|
||||
async function updateBannerImage(id: string) {
|
||||
try {
|
||||
if (game.value.mBannerObjectId == id) return;
|
||||
const { mBannerObjectId } = await $dropFetch("/api/v1/admin/game", {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
id: gameId,
|
||||
mBannerObjectId: id,
|
||||
} satisfies PatchGameBody,
|
||||
});
|
||||
game.value.mBannerObjectId = mBannerObjectId;
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "There an error while updating the banner image",
|
||||
description: `Drop encountered an error while updating the banner image: ${
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown")
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateCoverImage(id: string) {
|
||||
try {
|
||||
if (game.value.mCoverObjectId == id) return;
|
||||
const { mCoverObjectId } = await $dropFetch("/api/v1/admin/game", {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
id: gameId,
|
||||
mCoverObjectId: id,
|
||||
} satisfies PatchGameBody,
|
||||
});
|
||||
game.value.mCoverObjectId = mCoverObjectId;
|
||||
coreMetadataIconUrl.value = useObject(mCoverObjectId);
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "There an error while updating the cover image",
|
||||
description: `Drop encountered an error while updating the cover image: ${
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown")
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteImage(id: string) {
|
||||
try {
|
||||
const { mBannerObjectId, mImageLibraryObjectIds } = await $dropFetch(
|
||||
"/api/v1/admin/game/image",
|
||||
{
|
||||
method: "DELETE",
|
||||
body: {
|
||||
gameId: game.value.id,
|
||||
imageId: id,
|
||||
},
|
||||
},
|
||||
);
|
||||
game.value.mImageLibraryObjectIds = mImageLibraryObjectIds;
|
||||
game.value.mBannerObjectId = mBannerObjectId;
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "There an error while deleting the image",
|
||||
description: `Drop encountered an error while deleting the image: ${
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown")
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadAfterImageUpload(result: Game) {
|
||||
if (!game.value) return;
|
||||
game.value.mImageLibraryObjectIds = result.mImageLibraryObjectIds;
|
||||
}
|
||||
|
||||
function addImageToCarousel(id: string) {
|
||||
game.value.mImageCarouselObjectIds.push(id);
|
||||
updateImageCarousel();
|
||||
}
|
||||
|
||||
function removeImageFromCarousel(id: string) {
|
||||
const imageIndex = game.value.mImageCarouselObjectIds.findIndex(
|
||||
(e) => e == id,
|
||||
);
|
||||
game.value.mImageCarouselObjectIds.splice(imageIndex, 1);
|
||||
updateImageCarousel();
|
||||
}
|
||||
|
||||
async function updateImageCarousel() {
|
||||
try {
|
||||
await $dropFetch("/api/v1/admin/game", {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
id: gameId,
|
||||
mImageCarouselObjectIds: game.value.mImageCarouselObjectIds,
|
||||
} satisfies PatchGameBody,
|
||||
});
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "There an error while updating the image carousel",
|
||||
description: `Drop encountered an error while updating image carousel: ${
|
||||
// @ts-expect-error attempt to get statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown")
|
||||
}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c(),
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1,122 +0,0 @@
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<div class="mx-auto max-w-2xl lg:mx-0">
|
||||
<h2
|
||||
class="mt-2 text-xl font-semibold tracking-tight text-zinc-100 sm:text-3xl"
|
||||
>
|
||||
Metadata Library
|
||||
</h2>
|
||||
<p
|
||||
class="mt-2 text-pretty text-sm font-medium text-gray-500 sm:text-md/8"
|
||||
>
|
||||
<span class="text-zinc-100 font-bold"
|
||||
>To import or delete games, visit the Library tab.</span
|
||||
>
|
||||
Here, you can edit and update your game's metadata.
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-2 grid grid-cols-1">
|
||||
<input
|
||||
id="search"
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
name="search"
|
||||
class="col-start-1 row-start-1 block w-full rounded-md bg-zinc-900 py-1.5 pl-10 pr-3 text-base text-zinc-100 outline outline-1 -outline-offset-1 outline-zinc-700 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:pl-9 sm:text-sm/6"
|
||||
placeholder="Search library..."
|
||||
/>
|
||||
<MagnifyingGlassIcon
|
||||
class="pointer-events-none col-start-1 row-start-1 ml-3 size-5 self-center text-zinc-400 sm:size-4"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
<ul
|
||||
role="list"
|
||||
class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4"
|
||||
>
|
||||
<li
|
||||
v-for="game in filteredLibraryGames"
|
||||
:key="game.id"
|
||||
class="col-span-1 flex flex-col justify-center divide-y divide-zinc-700 rounded-lg bg-zinc-950/20 text-left shadow"
|
||||
>
|
||||
<div class="flex flex-1 flex-row p-4 gap-x-4">
|
||||
<img
|
||||
class="h-16 w-16 flex-shrink-0 rounded-md"
|
||||
:src="useObject(game.mIconObjectId)"
|
||||
alt=""
|
||||
/>
|
||||
<div class="flex flex-col">
|
||||
<h3 class="text-sm font-medium text-zinc-100 font-display">
|
||||
{{ game.mName }}
|
||||
<span
|
||||
class="ml-2 inline-flex items-center rounded-full bg-blue-600/10 px-2 py-1 text-xs font-medium text-blue-600 ring-1 ring-inset ring-blue-600/20"
|
||||
>{{ game.metadataSource }}</span
|
||||
>
|
||||
</h3>
|
||||
<dl class="mt-1 flex flex-col justify-between">
|
||||
<dt class="sr-only">Short Description</dt>
|
||||
<dd class="text-sm text-zinc-400">
|
||||
{{ game.mShortDescription }}
|
||||
</dd>
|
||||
<dt class="sr-only">Metadata provider</dt>
|
||||
</dl>
|
||||
<div class="mt-4 flex flex-col gap-y-1">
|
||||
<NuxtLink
|
||||
:href="`/admin/metadata/games/${game.id}`"
|
||||
class="w-fit rounded-md bg-blue-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
Open with Metadata →
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
:href="`/admin/library/${game.id}`"
|
||||
class="w-fit rounded-md bg-zinc-800 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-zinc-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
Open with Library →
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<p
|
||||
v-if="filteredLibraryGames.length == 0 && libraryGames.length != 0"
|
||||
class="text-zinc-600 text-sm font-display font-bold uppercase text-center col-span-4"
|
||||
>
|
||||
No results
|
||||
</p>
|
||||
<p
|
||||
v-if="filteredLibraryGames.length == 0 && libraryGames.length == 0"
|
||||
class="text-zinc-600 text-sm font-display font-bold uppercase text-center col-span-4"
|
||||
>
|
||||
No games imported
|
||||
</p>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { MagnifyingGlassIcon } from "@heroicons/vue/24/outline";
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
useHead({
|
||||
title: "Game Library | Metadata",
|
||||
});
|
||||
|
||||
const searchQuery = ref("");
|
||||
|
||||
const libraryState = await $dropFetch("/api/v1/admin/library");
|
||||
const libraryGames = ref(libraryState.games.map((e) => e.game));
|
||||
|
||||
const filteredLibraryGames = computed(() =>
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore excessively deep ts
|
||||
libraryGames.value.filter((e) => {
|
||||
if (!searchQuery.value) return true;
|
||||
const searchQueryLower = searchQuery.value.toLowerCase();
|
||||
if (e.mName.toLowerCase().includes(searchQueryLower)) return true;
|
||||
if (e.mShortDescription.toLowerCase().includes(searchQueryLower))
|
||||
return true;
|
||||
return false;
|
||||
}),
|
||||
);
|
||||
</script>
|
||||
@ -1,60 +0,0 @@
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<div class="mx-auto max-w-2xl lg:mx-0">
|
||||
<h2
|
||||
class="mt-2 text-xl font-semibold tracking-tight text-zinc-100 sm:text-3xl"
|
||||
>
|
||||
Metadata
|
||||
</h2>
|
||||
<p
|
||||
class="mt-2 text-pretty text-sm font-medium text-gray-500 sm:text-md/8"
|
||||
>
|
||||
Manage the metadata of your library, and update relationships between
|
||||
them. Users will be able to search through this metadata to find the
|
||||
games they want.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-5 gap-8">
|
||||
<NuxtLink
|
||||
to="/admin/metadata/games"
|
||||
class="transition group aspect-[3/2] flex flex-col justify-center items-center rounded-lg bg-zinc-950 hover:bg-zinc-950/50 shadow"
|
||||
>
|
||||
<RectangleStackIcon
|
||||
class="mb-2 h-12 w-12 text-zinc-500 group-hover:text-blue-500 transition-all duration-200"
|
||||
/>
|
||||
<span
|
||||
class="transition-all text-4xl font-bold text-zinc-400 group-hover:text-zinc-100 uppercase tracking-widest"
|
||||
>Games</span
|
||||
>
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
to="/admin/metadata/companies"
|
||||
class="transition group aspect-[3/2] flex flex-col justify-center items-center rounded-lg bg-zinc-950 hover:bg-zinc-950/50 shadow"
|
||||
>
|
||||
<BuildingOffice2Icon
|
||||
class="mb-2 h-12 w-12 text-zinc-500 group-hover:text-blue-500 transition-all duration-200"
|
||||
/>
|
||||
<span
|
||||
class="transition-all text-4xl font-bold text-zinc-400 group-hover:text-zinc-100 uppercase tracking-widest"
|
||||
>Companies</span
|
||||
>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
RectangleStackIcon,
|
||||
BuildingOffice2Icon,
|
||||
} from "@heroicons/vue/24/solid";
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
useHead({
|
||||
title: "Metadata",
|
||||
});
|
||||
</script>
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="text-gray-100">Todo page</div>
|
||||
<div class="text-gray-100">{{ $t("todo") }}</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
useHead({
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
<CheckCircleIcon class="h-12 w-12 text-green-600" aria-hidden="true" />
|
||||
<div class="mt-3 text-center sm:mt-5">
|
||||
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||
Successful!
|
||||
{{ $t("task.successful") }}
|
||||
</h1>
|
||||
<div class="mt-4">
|
||||
<p class="text-sm text-zinc-400 max-w-md">
|
||||
"{{ task.name }}" completed successfully.
|
||||
{{ $t("task.successfulDescription", [task.name]) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -74,7 +74,7 @@
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
<span class="sr-only">{{ $t("common.srLoading") }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="text-gray-100">Todo page</div>
|
||||
<div class="text-gray-100">{{ $t("todo") }}</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
useHead({
|
||||
|
||||
@ -4,14 +4,12 @@
|
||||
<h2
|
||||
class="mt-2 text-xl font-semibold tracking-tight text-zinc-100 sm:text-3xl"
|
||||
>
|
||||
Authentication
|
||||
{{ $t("users.admin.authentication.title") }}
|
||||
</h2>
|
||||
<p
|
||||
class="mt-2 text-pretty text-sm font-medium text-zinc-400 sm:text-md/8"
|
||||
>
|
||||
Drop supports a variety of "authentication mechanisms". As you enable or
|
||||
disable them, they are shown on the sign in screen for users to select
|
||||
from. Click the dot menu to configure the authentication mechanism.
|
||||
{{ $t("users.admin.authentication.description") }}
|
||||
</p>
|
||||
</div>
|
||||
<ul
|
||||
@ -40,7 +38,9 @@
|
||||
<MenuButton
|
||||
class="-m-2.5 block p-2.5 text-zinc-400 hover:text-zinc-300 transition-colors duration-200"
|
||||
>
|
||||
<span class="sr-only">Open options</span>
|
||||
<span class="sr-only">{{
|
||||
$t("users.admin.authentication.srOpenOptions")
|
||||
}}</span>
|
||||
<EllipsisHorizontalIcon class="h-5 w-5" aria-hidden="true" />
|
||||
</MenuButton>
|
||||
<transition
|
||||
@ -61,9 +61,8 @@
|
||||
active ? 'bg-zinc-800 outline-none' : '',
|
||||
'block px-3 py-1 text-sm/6 text-zinc-100 transition-colors duration-200',
|
||||
]"
|
||||
>Configure<span class="sr-only"
|
||||
>, {{ authMech.name }}</span
|
||||
></NuxtLink
|
||||
>{{ $t("users.admin.authentication.configure")
|
||||
}}<span class="sr-only">{{ authMech.name }}</span></NuxtLink
|
||||
>
|
||||
</MenuItem>
|
||||
</MenuItems>
|
||||
@ -72,7 +71,9 @@
|
||||
</div>
|
||||
<dl class="-my-3 divide-y divide-zinc-700 px-6 py-4 text-sm/6">
|
||||
<div class="flex justify-between gap-x-4 py-3">
|
||||
<dt class="text-zinc-400">Enabled</dt>
|
||||
<dt class="text-zinc-400">
|
||||
{{ $t("users.admin.authentication.enabledKey") }}
|
||||
</dt>
|
||||
<dd class="flex items-center">
|
||||
<span
|
||||
:class="[
|
||||
@ -84,7 +85,11 @@
|
||||
>
|
||||
<CheckIcon v-if="authMech.enabled" class="w-4 h-4 mr-1" />
|
||||
<XMarkIcon v-else class="w-4 h-4 mr-1" />
|
||||
{{ authMech.enabled ? "Enabled" : "Disabled" }}
|
||||
{{
|
||||
authMech.enabled
|
||||
? $t("users.admin.authentication.enabled")
|
||||
: $t("users.admin.authentication.disabled")
|
||||
}}
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
@ -122,6 +127,8 @@ definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const enabledMechanisms = await $dropFetch("/api/v1/admin/auth");
|
||||
|
||||
const authenticationMechanisms: Array<{
|
||||
@ -133,13 +140,13 @@ const authenticationMechanisms: Array<{
|
||||
settings?: { [key: string]: string | undefined } | undefined | boolean;
|
||||
}> = [
|
||||
{
|
||||
name: "Simple (username/password)",
|
||||
name: t("users.admin.authentication.simple"),
|
||||
mec: "Simple" as AuthMec,
|
||||
icon: IconsSimpleAuthenticationLogo,
|
||||
route: "/admin/users/auth/simple",
|
||||
},
|
||||
{
|
||||
name: "OpenID Connect",
|
||||
name: t("users.admin.authentication.oidc"),
|
||||
mec: "OpenID" as AuthMec,
|
||||
icon: IconsSSOLogo,
|
||||
},
|
||||
|
||||
@ -4,15 +4,12 @@
|
||||
<h2
|
||||
class="mt-2 text-xl font-semibold tracking-tight text-zinc-100 sm:text-3xl"
|
||||
>
|
||||
Simple authentication
|
||||
{{ $t("users.admin.simple.title") }}
|
||||
</h2>
|
||||
<p
|
||||
class="mt-2 text-pretty text-sm font-medium text-zinc-400 sm:text-md/8"
|
||||
>
|
||||
Simple authentication uses a system of 'invitations' to create users.
|
||||
You can create an invitation, and optionally specify a username or email
|
||||
for the user, and then it will generate a magic URL that can be used to
|
||||
create an account.
|
||||
{{ $t("users.admin.simple.description") }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@ -22,7 +19,9 @@
|
||||
class="-mt-2 flex flex-wrap items-center justify-between sm:flex-nowrap"
|
||||
>
|
||||
<div class="mt-2">
|
||||
<h3 class="text-base font-semibold text-zinc-100">Invitations</h3>
|
||||
<h3 class="text-base font-semibold text-zinc-100">
|
||||
{{ $t("users.admin.simple.invitationTitle") }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="ml-4 mt-2 shrink-0">
|
||||
<button
|
||||
@ -30,7 +29,7 @@
|
||||
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm transition-all duration-200 hover:bg-blue-500 hover:scale-105 hover:shadow-lg hover:shadow-blue-500/25 active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
@click="() => (createModalOpen = true)"
|
||||
>
|
||||
Create invitation
|
||||
{{ $t("users.admin.simple.createInvitation") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -54,9 +53,14 @@
|
||||
</div>
|
||||
|
||||
<p class="mt-1 flex text-xs/5 text-gray-500">
|
||||
{{ invitation.username ?? "No username enforced." }}
|
||||
|
|
||||
{{ invitation.email ?? "No email enforced." }}
|
||||
{{
|
||||
invitation.username ??
|
||||
$t("users.admin.simple.noUsernameEnforced")
|
||||
}}
|
||||
{{ $t("common.divider") }}
|
||||
{{
|
||||
invitation.email ?? $t("users.admin.simple.noEmailEnforced")
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -64,14 +68,29 @@
|
||||
<div class="hidden sm:flex sm:flex-col sm:items-end">
|
||||
<p class="text-sm/6 text-zinc-100">
|
||||
{{
|
||||
invitation.isAdmin ? "Admin invitation" : "User invitation"
|
||||
invitation.isAdmin
|
||||
? $t("users.admin.simple.adminInvitation")
|
||||
: $t("users.admin.simple.userInvitation")
|
||||
}}
|
||||
</p>
|
||||
<p class="mt-1 text-xs/5 text-gray-500">
|
||||
Expires:
|
||||
<time :datetime="invitation.expires">{{
|
||||
new Date(invitation.expires).toLocaleString()
|
||||
}}</time>
|
||||
<p class="mt-1 text-sm text-gray-500">
|
||||
<!-- forever is relative, right? -->
|
||||
<i18n-t
|
||||
v-if="
|
||||
new Date(invitation.expires).getTime() - Date.now() <
|
||||
3.156e12 // 100 years
|
||||
"
|
||||
keypath="users.admin.simple.expires"
|
||||
tag="span"
|
||||
scope="global"
|
||||
>
|
||||
<template #expiry>
|
||||
<RelativeTime :date="invitation.expires" />
|
||||
</template>
|
||||
</i18n-t>
|
||||
<span v-else>
|
||||
{{ $t("users.admin.simple.neverExpires") }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<button @click="() => deleteInvitation(invitation.id)">
|
||||
@ -85,7 +104,7 @@
|
||||
</ul>
|
||||
|
||||
<div v-if="invitations.length == 0" class="py-4 text-zinc-400 text-sm">
|
||||
No invitations.
|
||||
{{ $t("users.admin.simple.noInvitations") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -128,13 +147,11 @@
|
||||
<DialogTitle
|
||||
as="h3"
|
||||
class="text-base font-semibold text-zinc-100"
|
||||
>Invite user to Drop
|
||||
>{{ $t("users.admin.simple.inviteTitle") }}
|
||||
</DialogTitle>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-zinc-400">
|
||||
Drop will generate a URL that you can send to the
|
||||
person you want to invite. You can optionally specify
|
||||
a username or email for them to use.
|
||||
{{ $t("users.admin.simple.inviteDescription") }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -145,7 +162,9 @@
|
||||
<label
|
||||
for="username"
|
||||
class="block text-sm font-medium leading-6 text-zinc-100"
|
||||
>Username (optional)</label
|
||||
>{{
|
||||
$t("users.admin.simple.inviteUsernameLabel")
|
||||
}}</label
|
||||
>
|
||||
<p
|
||||
:class="[
|
||||
@ -153,7 +172,7 @@
|
||||
'block text-xs font-medium leading-6',
|
||||
]"
|
||||
>
|
||||
Must be 5 or more characters
|
||||
{{ $t("users.admin.simple.inviteUsernameFormat") }}
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
@ -162,7 +181,9 @@
|
||||
name="invite-username"
|
||||
type="text"
|
||||
autocomplete="username"
|
||||
placeholder="myUsername"
|
||||
:placeholder="
|
||||
$t('users.admin.simple.inviteUsernamePlaceholder')
|
||||
"
|
||||
class="block w-full rounded-md border-0 py-1.5 px-3 bg-zinc-800 disabled:bg-zinc-900/80 text-zinc-100 disabled:text-zinc-400 shadow-sm ring-1 ring-inset ring-zinc-700 disabled:ring-zinc-800 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
</div>
|
||||
@ -172,7 +193,7 @@
|
||||
<label
|
||||
for="email"
|
||||
class="block text-sm font-medium leading-6 text-zinc-100"
|
||||
>Email address (optional)</label
|
||||
>{{ $t("users.admin.simple.inviteEmailLabel") }}</label
|
||||
>
|
||||
<p
|
||||
:class="[
|
||||
@ -180,7 +201,7 @@
|
||||
'block text-xs font-medium leading-6',
|
||||
]"
|
||||
>
|
||||
Must be in the format user@example.com
|
||||
{{ $t("users.admin.simple.inviteEmailDescription") }}
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
@ -189,7 +210,9 @@
|
||||
name="invite-email"
|
||||
type="email"
|
||||
autocomplete="email"
|
||||
placeholder="me@example.com"
|
||||
:placeholder="
|
||||
$t('users.admin.simple.inviteEmailPlaceholder')
|
||||
"
|
||||
class="block w-full rounded-md border-0 py-1.5 px-3 bg-zinc-800 disabled:bg-zinc-900/80 text-zinc-100 disabled:text-zinc-400 shadow-sm ring-1 ring-inset ring-zinc-700 disabled:ring-zinc-800 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
||||
/>
|
||||
</div>
|
||||
@ -205,13 +228,18 @@
|
||||
as="span"
|
||||
class="text-sm/6 font-medium text-zinc-100"
|
||||
passive
|
||||
>Admin invitation
|
||||
>{{
|
||||
$t("users.admin.simple.inviteAdminSwitchLabel")
|
||||
}}
|
||||
</SwitchLabel>
|
||||
<SwitchDescription
|
||||
as="span"
|
||||
class="text-sm text-zinc-400"
|
||||
>Create this user as an
|
||||
administrator</SwitchDescription
|
||||
>{{
|
||||
$t(
|
||||
"users.admin.simple.inviteAdminSwitchDescription",
|
||||
)
|
||||
}}</SwitchDescription
|
||||
>
|
||||
</span>
|
||||
<Switch
|
||||
@ -236,7 +264,9 @@
|
||||
<Listbox v-model="expiryKey" as="div">
|
||||
<ListboxLabel
|
||||
class="block text-sm/6 font-medium text-zinc-100"
|
||||
>Expires in</ListboxLabel
|
||||
>{{
|
||||
$t("users.admin.simple.inviteExpiryLabel")
|
||||
}}</ListboxLabel
|
||||
>
|
||||
<div class="relative mt-2">
|
||||
<ListboxButton
|
||||
@ -331,7 +361,7 @@
|
||||
type="submit"
|
||||
class="w-full sm:w-fit"
|
||||
>
|
||||
Invite
|
||||
{{ $t("users.admin.simple.inviteButton") }}
|
||||
</LoadingButton>
|
||||
<button
|
||||
ref="cancelButtonRef"
|
||||
@ -339,7 +369,7 @@
|
||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||
@click="createModalOpen = false"
|
||||
>
|
||||
Cancel
|
||||
{{ $t("cancel") }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -374,6 +404,8 @@ import type { SerializeObject } from "nitropack";
|
||||
import type { DurationLike } from "luxon";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
definePageMeta({
|
||||
layout: "admin",
|
||||
});
|
||||
@ -431,23 +463,23 @@ const isAdmin = ref(false);
|
||||
|
||||
// Label to parameters to moment.js .add()
|
||||
const expiry: Record<string, DurationLike> = {
|
||||
"3 days": {
|
||||
[t("users.admin.simple.invite3Days")]: {
|
||||
days: 3,
|
||||
},
|
||||
"7 days": {
|
||||
[t("users.admin.simple.inviteWeek")]: {
|
||||
days: 7,
|
||||
},
|
||||
"1 month": {
|
||||
[t("users.admin.simple.inviteMonth")]: {
|
||||
month: 1,
|
||||
},
|
||||
"6 months": {
|
||||
[t("users.admin.simple.invite6Months")]: {
|
||||
months: 6,
|
||||
},
|
||||
"1 year": {
|
||||
[t("users.admin.simple.inviteYear")]: {
|
||||
year: 1,
|
||||
},
|
||||
Never: {
|
||||
year: 3000,
|
||||
[t("users.admin.simple.inviteNever")]: {
|
||||
year: 5000,
|
||||
}, // Never is relative, right?
|
||||
};
|
||||
const expiryKey = ref<keyof typeof expiry>(Object.keys(expiry)[0]); // Cast to any because we just know it's okay
|
||||
@ -485,7 +517,7 @@ function invite_wrapper() {
|
||||
invitationUrls.value?.push(generateInvitationUrl(invitation.id));
|
||||
})
|
||||
.catch((response) => {
|
||||
const message = response.statusMessage || "An unknown error occurred";
|
||||
const message = response.statusMessage || t("errors.unknown");
|
||||
error.value = message;
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@ -6,8 +6,7 @@
|
||||
{{ $t("header.admin.users") }}
|
||||
</h1>
|
||||
<p class="mt-2 text-sm text-zinc-400">
|
||||
Manage the users on your Drop instance, and configure your
|
||||
authentication methods.
|
||||
{{ $t("users.admin.description") }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-4 sm:ml-16 sm:mt-0 sm:flex-none">
|
||||
@ -15,7 +14,11 @@
|
||||
to="/admin/users/auth"
|
||||
class="block rounded-md bg-blue-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm transition-all duration-200 hover:bg-blue-500 hover:scale-105 hover:shadow-lg active:scale-95 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
Authentication →
|
||||
<i18n-t keypath="users.admin.authLink" tag="span" scope="global">
|
||||
<template #arrow>
|
||||
<span aria-hidden="true">{{ $t("chars.arrow") }}</span>
|
||||
</template>
|
||||
</i18n-t>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
@ -32,34 +35,36 @@
|
||||
scope="col"
|
||||
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-zinc-100 sm:pl-6"
|
||||
>
|
||||
Display Name
|
||||
{{ $t("users.admin.displayNameHeader") }}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="px-3 py-3.5 text-left text-sm font-semibold text-zinc-100"
|
||||
>
|
||||
Username
|
||||
{{ $t("users.admin.usernameHeader") }}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="px-3 py-3.5 text-left text-sm font-semibold text-zinc-100"
|
||||
>
|
||||
Email
|
||||
{{ $t("users.admin.emailHeader") }}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="px-3 py-3.5 text-left text-sm font-semibold text-zinc-100"
|
||||
>
|
||||
Admin?
|
||||
{{ $t("users.admin.adminHeader") }}
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
class="px-3 py-3.5 text-left text-sm font-semibold text-zinc-100"
|
||||
>
|
||||
Auth Options
|
||||
{{ $t("users.admin.authoptionsHeader") }}
|
||||
</th>
|
||||
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-6">
|
||||
<span class="sr-only">Edit</span>
|
||||
<span class="sr-only">
|
||||
{{ $t("users.admin.srEditLabel") }}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -89,7 +94,11 @@
|
||||
: 'bg-zinc-400/10 text-zinc-400 ring-zinc-400/20',
|
||||
]"
|
||||
>
|
||||
{{ user.admin ? "Admin User" : "Normal user" }}
|
||||
{{
|
||||
user.admin
|
||||
? $t("users.admin.adminUserLabel")
|
||||
: $t("users.admin.normalUserLabel")
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-zinc-400">
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="text-gray-100">Todo page</div>
|
||||
<div class="text-gray-100">{{ $t("todo") }}</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
useHead({
|
||||
|
||||
Reference in New Issue
Block a user