From b4651747f84cb9582066a05551dce63288f94ad2 Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 17:55:59 -0500 Subject: [PATCH 01/42] worked on adding coaches-page --- components/OuterComponents.vue | 13 ++----------- pages/coach-preview.vue | 12 ++++++++++++ pages/users.vue | 8 ++++---- 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 pages/coach-preview.vue diff --git a/components/OuterComponents.vue b/components/OuterComponents.vue index 93ac831..1b8fa8e 100644 --- a/components/OuterComponents.vue +++ b/components/OuterComponents.vue @@ -27,19 +27,10 @@ { label: "Competitions", to: "/competitions" }, { label: "Attachments", to: "/attachments" }, ] - watch(sessionState?.value?.userCtx, () => { - console.log("ran") - if(sessionState?.value?.userCtx?.roles?.includes("_admin")){ - links.push({ label: "Users", to: "/users" }) - } - else{ - if(links.includes({ label: "Users", to: "/users" })){ - links.splice(links.indexOf({ label: "Users", to: "/users" }, 1)) - } - } - }) if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) links.push({ label: "Users", to: "/users" }) + if (sessionState?.value?.userCtx?.roles?.indexOf('Coach') != -1) + links.push({ label: "Coach Preview", to: "/coach-preview" }) diff --git a/pages/coach-preview.vue b/pages/coach-preview.vue new file mode 100644 index 0000000..1c1578b --- /dev/null +++ b/pages/coach-preview.vue @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/pages/users.vue b/pages/users.vue index fec332c..f152f52 100644 --- a/pages/users.vue +++ b/pages/users.vue @@ -33,7 +33,7 @@ resetRoles = false usersDB.getSession(function(err, response){ if(response){ - if(response.userCtx.roles?.includes("Admin") || response.userCtx.roles?.includes("_admin")){ + if(response.userCtx.roles?.includes("_admin")){ adminAccount.value = true } } @@ -43,7 +43,7 @@ async function createUser() { let sessionRoles = await usersDB.getSession() - if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("Admin") || sessionRoles.userCtx.roles.includes("_admin"))) ) return + if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("_admin"))) ) return usersDB.signUp(username.value, "temp", { metadata: { @@ -84,14 +84,14 @@ async function editRoles(username: string, newRoles: Array) { let sessionRoles = await usersDB.getSession() - if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("Admin") || sessionRoles.userCtx.roles.includes("_admin"))) ) return + if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("_admin"))) ) return await usersDB.putUser(username, {roles: newRoles}) } async function deleteUser(username: string) { let sessionRoles = await usersDB.getSession() - if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("Admin") || sessionRoles.userCtx.roles.includes("_admin"))) ) return + if(! (sessionRoles.userCtx.roles && (sessionRoles.userCtx.roles.includes("_admin"))) ) return usersDB.deleteUser(username, function (err, result) { if (err) { console.log(err.name) From ae359329f324479f7144f09902370a5728aa2aeb Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 19:33:36 -0500 Subject: [PATCH 02/42] removed unused const and fixed issue with session roles not being accessed until reload --- components/OuterComponents.vue | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/components/OuterComponents.vue b/components/OuterComponents.vue index 93ac831..4284b00 100644 --- a/components/OuterComponents.vue +++ b/components/OuterComponents.vue @@ -7,14 +7,9 @@ import type {VerticalNavigationLink} from "#ui/types"; import type {Ref} from "@vue/reactivity"; import type {UnwrapRef} from "vue"; + import {couchDBBaseURL} from "~/utils/URIs"; - const {loginState,usernameState, sessionState, logout}: { - logout: () => Promise; - loginState: Ref>; - sessionState: Ref>; - usernameState: Ref>; - updateUsernameState: () => Promise - } = inject(loginStateKey)! + const usersDB = new PouchDB(`${couchDBBaseURL}/_users`, {skip_setup: true}); let {width, height} = useWindowSize() @@ -25,21 +20,12 @@ { label: "Matches", to: "/matches" }, { label: "Teams", to: "/teams" }, { label: "Competitions", to: "/competitions" }, - { label: "Attachments", to: "/attachments" }, + { label: "Attachments", to: "/attachments" } ] - watch(sessionState?.value?.userCtx, () => { - console.log("ran") - if(sessionState?.value?.userCtx?.roles?.includes("_admin")){ - links.push({ label: "Users", to: "/users" }) - } - else{ - if(links.includes({ label: "Users", to: "/users" })){ - links.splice(links.indexOf({ label: "Users", to: "/users" }, 1)) - } - } - }) - if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) + let session = await usersDB.getSession() + if (session.userCtx.roles?.indexOf("_admin") != -1){ links.push({ label: "Users", to: "/users" }) + } From f7e11f971fa8f170602b7542dc985e7f274115f1 Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 19:37:40 -0500 Subject: [PATCH 03/42] uninstalled heic2any --- package-lock.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a913e4..6b0d7c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@vueuse/core": "10.4.1", "chart.js": "^3.9.1", "compressorjs": "1.2.1", - "heic2any": "0.0.4", "nuxt": "^3.9.1", "pouchdb": "8.0.1", "pouchdb-authentication": "1.1.3", @@ -6800,11 +6799,6 @@ "node": ">=4.5.0" } }, - "node_modules/heic2any": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/heic2any/-/heic2any-0.0.4.tgz", - "integrity": "sha512-3lLnZiDELfabVH87htnRolZ2iehX9zwpRyGNz22GKXIu0fznlblf0/ftppXKNqS26dqFSeqfIBhAmAj/uSp0cA==" - }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", From 0916ca75bbb1bda3f989da4b433a8a078cf52160 Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 19:40:30 -0500 Subject: [PATCH 04/42] added back heic2any i was being goofy --- package-lock.json | 6 ++++++ package.json | 1 + 2 files changed, 7 insertions(+) diff --git a/package-lock.json b/package-lock.json index 6b0d7c8..a6e61f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@vueuse/core": "10.4.1", "chart.js": "^3.9.1", "compressorjs": "1.2.1", + "heic2any": "^0.0.4", "nuxt": "^3.9.1", "pouchdb": "8.0.1", "pouchdb-authentication": "1.1.3", @@ -6799,6 +6800,11 @@ "node": ">=4.5.0" } }, + "node_modules/heic2any": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/heic2any/-/heic2any-0.0.4.tgz", + "integrity": "sha512-3lLnZiDELfabVH87htnRolZ2iehX9zwpRyGNz22GKXIu0fznlblf0/ftppXKNqS26dqFSeqfIBhAmAj/uSp0cA==" + }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", diff --git a/package.json b/package.json index f10fee6..faed1bf 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@vueuse/core": "10.4.1", "chart.js": "^3.9.1", "compressorjs": "1.2.1", + "heic2any": "^0.0.4", "nuxt": "^3.9.1", "pouchdb": "8.0.1", "pouchdb-authentication": "1.1.3", From 33a34fc35718c2b0354a942937ccb4edde3905da Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 21:01:54 -0500 Subject: [PATCH 05/42] made significant changes to OuterComponents.vue and Navbar.vue to remove profile picture and top bar and add a settings icon. Still needs work to make side bar not scroll with page --- components/Navbar.vue | 58 ++++++++++++++++------------------ components/OuterComponents.vue | 44 ++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/components/Navbar.vue b/components/Navbar.vue index 22e3f6a..4252fad 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -14,6 +14,10 @@ const {usernameState, sessionState, logout}: { updateUsernameState: () => Promise } = inject(loginStateKey)! +const events = ['2024test', '2024trial'] + +let selectedEvent = ref(window.localStorage.getItem("event")) + let props = defineProps({ scoutMode: { type: Boolean, @@ -33,7 +37,6 @@ let links: VerticalNavigationLink[] = [ { label: "Dashboard", to: "/dashboard" }, { label: "Matches", to: "/matches" }, { label: "Teams", to: "/teams" }, - { label: "Competitions", to: "/competitions" }, { label: "Attachments", to: "/attachments" }, { label: "Contacts", to: "/contacts" } ] @@ -41,47 +44,40 @@ console.log(sessionState?.value?.userCtx?.roles) if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) links.push({ label: "Users", to: "/users" }) -const events = ['2024test', '2024trial'] - -let selectedEvent = ref(window.localStorage.getItem("event")) - -function updateEvent(value: string){ - window.localStorage.setItem("event", value) -} diff --git a/components/OuterComponents.vue b/components/OuterComponents.vue index 4284b00..83745ee 100644 --- a/components/OuterComponents.vue +++ b/components/OuterComponents.vue @@ -10,19 +10,37 @@ import {couchDBBaseURL} from "~/utils/URIs"; const usersDB = new PouchDB(`${couchDBBaseURL}/_users`, {skip_setup: true}); + const session = await usersDB.getSession() let {width, height} = useWindowSize() let route = useRoute() + const events = ['2024test', '2024trial'] + + let selectedEvent = ref(window.localStorage.getItem("event")) + + function updateEvent(value: string){ + window.localStorage.setItem("event", value) + } + + const {usernameState, sessionState, logout}: { + logout: () => Promise; + // noinspection TypeScriptUnresolvedReference + loginState: Ref>; + // noinspection TypeScriptUnresolvedReference + sessionState: Ref>; + // noinspection TypeScriptUnresolvedReference + usernameState: Ref>; + updateUsernameState: () => Promise + } = inject(loginStateKey)! + let links: VerticalNavigationLink[] = [ { label: "Dashboard", to: "/dashboard" }, { label: "Matches", to: "/matches" }, { label: "Teams", to: "/teams" }, - { label: "Competitions", to: "/competitions" }, { label: "Attachments", to: "/attachments" } ] - let session = await usersDB.getSession() if (session.userCtx.roles?.indexOf("_admin") != -1){ links.push({ label: "Users", to: "/users" }) } @@ -34,9 +52,29 @@
-
+
+
+ + + + +
From 4dde9bb932b167eff85fb2a0eb672e4082aa4dbf Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 21:01:54 -0500 Subject: [PATCH 06/42] made significant changes to OuterComponents.vue and Navbar.vue to remove profile picture and top bar and add a settings icon. Still needs work to make side bar not scroll with page --- components/Navbar.vue | 77 ++++++++++++++++------------------ components/OuterComponents.vue | 72 ++++++++++++++++++++++--------- 2 files changed, 90 insertions(+), 59 deletions(-) diff --git a/components/Navbar.vue b/components/Navbar.vue index 22e3f6a..1912614 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -14,6 +14,10 @@ const {usernameState, sessionState, logout}: { updateUsernameState: () => Promise } = inject(loginStateKey)! +const events = ['2024test', '2024trial'] + +let selectedEvent = ref(window.localStorage.getItem("event")) + let props = defineProps({ scoutMode: { type: Boolean, @@ -33,7 +37,6 @@ let links: VerticalNavigationLink[] = [ { label: "Dashboard", to: "/dashboard" }, { label: "Matches", to: "/matches" }, { label: "Teams", to: "/teams" }, - { label: "Competitions", to: "/competitions" }, { label: "Attachments", to: "/attachments" }, { label: "Contacts", to: "/contacts" } ] @@ -41,64 +44,58 @@ console.log(sessionState?.value?.userCtx?.roles) if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) links.push({ label: "Users", to: "/users" }) -const events = ['2024test', '2024trial'] - -let selectedEvent = ref(window.localStorage.getItem("event")) - -function updateEvent(value: string){ - window.localStorage.setItem("event", value) -} \ No newline at end of file diff --git a/components/OuterComponents.vue b/components/OuterComponents.vue index 4284b00..f29ef7d 100644 --- a/components/OuterComponents.vue +++ b/components/OuterComponents.vue @@ -3,26 +3,43 @@ import LoginState from "~/utils/authorization/LoginState"; import {loginStateKey} from "~/utils/keys"; import AddButton from "~/components/AddButton.vue"; - import SessionResponse = PouchDB.Authentication.SessionResponse; import type {VerticalNavigationLink} from "#ui/types"; import type {Ref} from "@vue/reactivity"; import type {UnwrapRef} from "vue"; import {couchDBBaseURL} from "~/utils/URIs"; const usersDB = new PouchDB(`${couchDBBaseURL}/_users`, {skip_setup: true}); + const session = await usersDB.getSession() let {width, height} = useWindowSize() let route = useRoute() + const events = ['2024test', '2024trial'] + + let selectedEvent = ref(window.localStorage.getItem("event")) + + function updateEvent(value: string){ + window.localStorage.setItem("event", value) + } + + const {usernameState, sessionState, logout}: { + logout: () => Promise; + // noinspection TypeScriptUnresolvedReference + loginState: Ref>; + // noinspection TypeScriptUnresolvedReference + sessionState: Ref>; + // noinspection TypeScriptUnresolvedReference + usernameState: Ref>; + updateUsernameState: () => Promise + } = inject(loginStateKey)! + let links: VerticalNavigationLink[] = [ { label: "Dashboard", to: "/dashboard" }, { label: "Matches", to: "/matches" }, { label: "Teams", to: "/teams" }, - { label: "Competitions", to: "/competitions" }, { label: "Attachments", to: "/attachments" } ] - let session = await usersDB.getSession() if (session.userCtx.roles?.indexOf("_admin") != -1){ links.push({ label: "Users", to: "/users" }) } @@ -34,9 +51,29 @@
-
+
+
+ + + + +
@@ -49,24 +86,21 @@ \ No newline at end of file From 50260fea0f641d49b45e3c10785a85cbe4a3e1ea Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Fri, 2 Feb 2024 21:13:01 -0500 Subject: [PATCH 07/42] quick fix --- components/Navbar.vue | 27 --------------------------- components/OuterComponents.vue | 20 -------------------- 2 files changed, 47 deletions(-) diff --git a/components/Navbar.vue b/components/Navbar.vue index ed913d6..c320704 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -52,33 +52,6 @@ if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1)
- - - - -
- - - - -
-
-
+