From 6b5e48d6fe53f52706d41a95a394b523d81aaa2d Mon Sep 17 00:00:00 2001 From: DecDuck Date: Wed, 9 Oct 2024 15:43:55 +1100 Subject: [PATCH] admin ui shell --- README.md | 5 +- components/HeaderUserWidget.vue | 131 +++++++++++++---------- composables/current-page-engine.ts | 28 +++++ layouts/admin.vue | 112 ++++++++++++++++++- pages/admin/index.vue | 13 ++- pages/admin/libraries.vue | 11 ++ pages/signin.vue | 4 +- server/api/v1/auth/signup/simple.post.ts | 1 + 8 files changed, 240 insertions(+), 65 deletions(-) create mode 100644 composables/current-page-engine.ts create mode 100644 pages/admin/libraries.vue diff --git a/README.md b/README.md index ec84d97..3e960c6 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,9 @@ Drop uses a utility package called droplet that's written in Rust. It has builts Steps: 1. Copy the `.env.example` to `.env` and add your GiantBomb metadata key (more metadata providers coming) -2. Open up a terminal and navigate to `dev-tools`, and run `docker compose up` -3. Open up a terminal in the root directory of the project and run `yarn` and then `yarn dev` to start the dev server +2. Create the `.data` directory with `mkdir .data` +3. Open up a terminal and navigate to `dev-tools`, and run `docker compose up` +4. Open up a terminal in the root directory of the project and run `yarn` and then `yarn dev` to start the dev server To create an account: Head over to the `/register` page. It's currently a temporary development form for creating a username + password log in. diff --git a/components/HeaderUserWidget.vue b/components/HeaderUserWidget.vue index eb827a0..073181c 100644 --- a/components/HeaderUserWidget.vue +++ b/components/HeaderUserWidget.vue @@ -1,67 +1,88 @@ \ No newline at end of file + } + : undefined, + { + label: "Account settings", + route: "/account", + prefix: "", + }, + { + label: "Sign out", + route: "/signout", + prefix: "", + }, +].filter((e) => e !== undefined); + diff --git a/composables/current-page-engine.ts b/composables/current-page-engine.ts new file mode 100644 index 0000000..6142949 --- /dev/null +++ b/composables/current-page-engine.ts @@ -0,0 +1,28 @@ +import type { RouteLocationNormalized } from "vue-router"; +import type { NavigationItem } from "./types"; + +export const useCurrentNavigationIndex = (navigation: Array) => { + const router = useRouter(); + const route = useRoute(); + + const currentNavigation = ref(-1); + + function calculateCurrentNavIndex(to: RouteLocationNormalized) { + const validOptions = navigation + .map((e, i) => ({ ...e, index: i })) + .filter((e) => to.fullPath.startsWith(e.prefix)); + const bestOption = validOptions + .sort((a, b) => b.route.length - a.route.length) + .at(0); + + return bestOption?.index ?? -1; + } + + currentNavigation.value = calculateCurrentNavIndex(route); + + router.afterEach((to) => { + currentNavigation.value = calculateCurrentNavIndex(to); + }); + + return currentNavigation; +}; diff --git a/layouts/admin.vue b/layouts/admin.vue index ba53413..5a08267 100644 --- a/layouts/admin.vue +++ b/layouts/admin.vue @@ -1,2 +1,112 @@ \ No newline at end of file +
+ + + +
+ +
+ +
+
+
+ + +
+
+
+
+ + + diff --git a/pages/admin/index.vue b/pages/admin/index.vue index ad33254..ca6a7ec 100644 --- a/pages/admin/index.vue +++ b/pages/admin/index.vue @@ -1,8 +1,11 @@ - + \ No newline at end of file + layout: "admin", +}); + +useHead({ + title: "Home", +}); + diff --git a/pages/admin/libraries.vue b/pages/admin/libraries.vue new file mode 100644 index 0000000..5159503 --- /dev/null +++ b/pages/admin/libraries.vue @@ -0,0 +1,11 @@ + + + diff --git a/pages/signin.vue b/pages/signin.vue index 7e5fb8d..88cb499 100644 --- a/pages/signin.vue +++ b/pages/signin.vue @@ -64,7 +64,7 @@ name="remember-me" type="checkbox" v-model="rememberMe" - class="h-4 w-4 rounded border-zinc-300 text-blue-600 focus:ring-blue-600" + class="h-4 w-4 rounded bg-zinc-800 border-zinc-700 text-blue-600 focus:ring-blue-600" />