From d23c2e494ff1babb2e8b05735ac0eadc6946ce74 Mon Sep 17 00:00:00 2001 From: Trenton Zimmer <66042448+trmazi@users.noreply.github.com> Date: Fri, 13 Sep 2024 23:19:45 -0400 Subject: [PATCH] Add in network admin pages, vpn exporting --- src/components/BaseIcon.vue | 7 +- src/components/FormControl.vue | 6 + src/components/IconRounded.vue | 18 +- src/components/SectionTitleLine.vue | 13 +- src/constants/pcbid.js | 12 ++ src/layouts/LayoutAuthenticated.vue | 70 ++++++- src/router/index.js | 72 +++++++ src/stores/main.js | 10 + src/views/Admin/APIView.vue | 30 +++ src/views/Admin/ArcadesView.vue | 30 +++ src/views/Admin/CardsView.vue | 30 +++ src/views/Admin/DashboardView.vue | 30 +++ src/views/Admin/EventsView.vue | 30 +++ src/views/Admin/MachinesView.vue | 30 +++ src/views/Admin/NewsView.vue | 30 +++ src/views/Admin/OnboardingView.vue | 297 ++++++++++++++++++++++++++++ src/views/Admin/UsersView.vue | 30 +++ src/views/Arcade/ArcadeView.vue | 136 +++++++++---- 18 files changed, 824 insertions(+), 57 deletions(-) create mode 100644 src/constants/pcbid.js create mode 100644 src/views/Admin/APIView.vue create mode 100644 src/views/Admin/ArcadesView.vue create mode 100644 src/views/Admin/CardsView.vue create mode 100644 src/views/Admin/DashboardView.vue create mode 100644 src/views/Admin/EventsView.vue create mode 100644 src/views/Admin/MachinesView.vue create mode 100644 src/views/Admin/NewsView.vue create mode 100644 src/views/Admin/OnboardingView.vue create mode 100644 src/views/Admin/UsersView.vue diff --git a/src/components/BaseIcon.vue b/src/components/BaseIcon.vue index 8eea6651..2788e90f 100644 --- a/src/components/BaseIcon.vue +++ b/src/components/BaseIcon.vue @@ -18,10 +18,15 @@ const props = defineProps({ type: [String, Number], default: null, }, + color: { + type: String, + default: "", + }, }); const spanClass = computed( - () => `inline-flex justify-center items-center ${props.w} ${props.h}` + () => + `inline-flex justify-center items-center ${props.w} ${props.h} ${props.color}` ); const iconSize = computed(() => props.size ?? 16); diff --git a/src/components/FormControl.vue b/src/components/FormControl.vue index 1284310c..10e14907 100644 --- a/src/components/FormControl.vue +++ b/src/components/FormControl.vue @@ -20,6 +20,10 @@ const props = defineProps({ type: String, default: null, }, + minlength: { + type: String, + default: null, + }, placeholder: { type: String, default: null, @@ -149,6 +153,7 @@ if (props.ctrlKFocus) { :class="inputElClass" :name="name" :maxlength="maxlength" + :minlength="minlength" :placeholder="placeholder" :required="required" /> @@ -159,6 +164,7 @@ if (props.ctrlKFocus) { v-model="computedValue" :name="name" :maxlength="maxlength" + :minlength="minlength" :inputmode="inputmode" :autocomplete="autocomplete" :required="required" diff --git a/src/components/IconRounded.vue b/src/components/IconRounded.vue index 2a1847b5..cb3c3fe1 100644 --- a/src/components/IconRounded.vue +++ b/src/components/IconRounded.vue @@ -1,12 +1,16 @@ diff --git a/src/components/SectionTitleLine.vue b/src/components/SectionTitleLine.vue index f6786480..7034b3fa 100644 --- a/src/components/SectionTitleLine.vue +++ b/src/components/SectionTitleLine.vue @@ -8,6 +8,10 @@ defineProps({ type: String, default: null, }, + color: { + type: String, + default: null, + }, title: { type: String, required: true, @@ -27,11 +31,18 @@ const hasSlot = computed(() => useSlots().default); - +

{{ title }}

diff --git a/src/constants/pcbid.js b/src/constants/pcbid.js new file mode 100644 index 00000000..8a564278 --- /dev/null +++ b/src/constants/pcbid.js @@ -0,0 +1,12 @@ +export function generatePCBID() { + const prefix = "01201000000000"; + const hexChars = "0123456789ABCDEF"; + let randomPart = ""; + + for (let i = 0; i < 6; i++) { + randomPart += hexChars[Math.floor(Math.random() * hexChars.length)]; + } + + const potentialPCBid = prefix + randomPart; + return potentialPCBid; +} diff --git a/src/layouts/LayoutAuthenticated.vue b/src/layouts/LayoutAuthenticated.vue index ffc5a9fd..efee27fa 100644 --- a/src/layouts/LayoutAuthenticated.vue +++ b/src/layouts/LayoutAuthenticated.vue @@ -6,6 +6,7 @@ import { mdiMonitor, mdiStoreCog, mdiGamepad, + mdiSecurity, } from "@mdi/js"; import { ref, watch, onMounted, computed } from "vue"; import { useRouter, useRoute } from "vue-router"; @@ -133,11 +134,72 @@ const menuAside = computed(() => { // ], })); - return [ - { to: "/", icon: mdiMonitor, label: "Dashboard" }, - { label: "My Arcades", icon: mdiStoreCog, menu: sortedArcades }, - { label: "Games", icon: mdiGamepad, menu: sortedGames }, + const adminMenu = [ + { + label: "Dashboard", + to: "/admin", + }, + { + label: "Onboarding", + to: "/admin/onboarding", + }, + { + label: "Events", + to: "/admin/events", + }, + { + label: "API", + to: "/admin/api", + }, + { + label: "Arcades", + to: "/admin/arcades", + }, + { + label: "Machines", + to: "/admin/machines", + }, + { + label: "Cards", + to: "/admin/cards", + }, + { + label: "Users", + to: "/admin/users", + }, + { + label: "News", + to: "/admin/news", + }, ]; + + var sideMenu = [{ to: "/", icon: mdiMonitor, label: "Dashboard" }]; + + if (mainStore.userAdmin) { + sideMenu.push({ + label: "Admin", + icon: mdiSecurity, + menu: adminMenu, + }); + } + + if (sortedGames.length) { + sideMenu.push({ + label: "Games", + icon: mdiGamepad, + menu: sortedGames, + }); + } + + if (sortedArcades.length) { + sideMenu.push({ + label: "My Arcades", + icon: mdiStoreCog, + menu: sortedArcades, + }); + } + + return sideMenu; }); diff --git a/src/router/index.js b/src/router/index.js index ef153c87..862f5bce 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -93,6 +93,78 @@ const routes = [ hotReload: true, // disables Hot Reload }, }, + { + meta: { + title: "Admin Dashboard", + }, + path: "/admin", + name: "admin_dashboard", + component: () => import("@/views/Admin/DashboardView.vue"), + }, + { + meta: { + title: "Onboarding", + }, + path: "/admin/onboarding", + name: "onboarding", + component: () => import("@/views/Admin/OnboardingView.vue"), + }, + { + meta: { + title: "Events", + }, + path: "/admin/events", + name: "admin_events", + component: () => import("@/views/Admin/EventsView.vue"), + }, + { + meta: { + title: "Data API", + }, + path: "/admin/api", + name: "data_api", + component: () => import("@/views/Admin/APIView.vue"), + }, + { + meta: { + title: "Arcades", + }, + path: "/admin/arcades", + name: "admin_arcades", + component: () => import("@/views/Admin/ArcadesView.vue"), + }, + { + meta: { + title: "Machines", + }, + path: "/admin/machines", + name: "admin_machines", + component: () => import("@/views/Admin/MachinesView.vue"), + }, + { + meta: { + title: "Cards", + }, + path: "/admin/cards", + name: "admin_cards", + component: () => import("@/views/Admin/CardsView.vue"), + }, + { + meta: { + title: "Users", + }, + path: "/admin/users", + name: "admin_users", + component: () => import("@/views/Admin/UsersView.vue"), + }, + { + meta: { + title: "News", + }, + path: "/admin/news", + name: "admin_news", + component: () => import("@/views/Admin/NewsView.vue"), + }, // { // meta: { // title: "Public Arcades", diff --git a/src/stores/main.js b/src/stores/main.js index a841c70d..047d144f 100644 --- a/src/stores/main.js +++ b/src/stores/main.js @@ -263,6 +263,16 @@ export const useMainStore = defineStore("main", { } }, + async getArcadeVPN(arcadeId) { + try { + const data = await this.callApi(`/arcade/${arcadeId}/exportVPN`); + return data; + } catch (error) { + console.log("Error fetching arcade VPN:", error); + throw error; + } + }, + async getPaseliData(arcadeId) { try { const data = await this.callApi(`/arcade/${arcadeId}/paseli`); diff --git a/src/views/Admin/APIView.vue b/src/views/Admin/APIView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/APIView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/ArcadesView.vue b/src/views/Admin/ArcadesView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/ArcadesView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/CardsView.vue b/src/views/Admin/CardsView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/CardsView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/DashboardView.vue b/src/views/Admin/DashboardView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/DashboardView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/EventsView.vue b/src/views/Admin/EventsView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/EventsView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/MachinesView.vue b/src/views/Admin/MachinesView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/MachinesView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/NewsView.vue b/src/views/Admin/NewsView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/NewsView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Admin/OnboardingView.vue b/src/views/Admin/OnboardingView.vue new file mode 100644 index 00000000..5697b925 --- /dev/null +++ b/src/views/Admin/OnboardingView.vue @@ -0,0 +1,297 @@ + + + diff --git a/src/views/Admin/UsersView.vue b/src/views/Admin/UsersView.vue new file mode 100644 index 00000000..2c61d536 --- /dev/null +++ b/src/views/Admin/UsersView.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/Arcade/ArcadeView.vue b/src/views/Arcade/ArcadeView.vue index 19c46f84..e50e1942 100644 --- a/src/views/Arcade/ArcadeView.vue +++ b/src/views/Arcade/ArcadeView.vue @@ -1,13 +1,13 @@