From 9f6c30541e96803c837b58db972bf47a1af97087 Mon Sep 17 00:00:00 2001 From: prabidhi Date: Wed, 10 Dec 2025 15:23:57 +0545 Subject: [PATCH] sidebar and dashboard added --- index.html | 4 +- public/{ => img}/Dolphin/dolphin-logo.png | Bin public/{ => img}/Dolphin/dolphinfav.ico | Bin src/core/endpoints/auth.ts | 8 +-- src/initApp.ts | 27 ++++++++++ src/main.ts | 1 + src/router/authChildren.ts | 8 +++ src/services/API/api.ts | 6 +-- src/stores/User/User.ts | 4 +- src/utils/setup/SidebarItems.ts | 49 ++++++++++++++----- src/views/Dashboard/Components/Dashboard.vue | 2 +- 11 files changed, 85 insertions(+), 24 deletions(-) rename public/{ => img}/Dolphin/dolphin-logo.png (100%) rename public/{ => img}/Dolphin/dolphinfav.ico (100%) create mode 100644 src/initApp.ts diff --git a/index.html b/index.html index c4e54e5..b28592b 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,6 @@
- + - + \ No newline at end of file diff --git a/public/Dolphin/dolphin-logo.png b/public/img/Dolphin/dolphin-logo.png similarity index 100% rename from public/Dolphin/dolphin-logo.png rename to public/img/Dolphin/dolphin-logo.png diff --git a/public/Dolphin/dolphinfav.ico b/public/img/Dolphin/dolphinfav.ico similarity index 100% rename from public/Dolphin/dolphinfav.ico rename to public/img/Dolphin/dolphinfav.ico diff --git a/src/core/endpoints/auth.ts b/src/core/endpoints/auth.ts index f9c67e9..fe51fd0 100644 --- a/src/core/endpoints/auth.ts +++ b/src/core/endpoints/auth.ts @@ -1,7 +1,7 @@ export const authAPI = { - csrfGenerate: "users/auth/csrf/", - login: "users/auth/login/", - refresh: "users/auth/refresh/", - logout: "users/auth/logout/", + // csrfGenerate: "users/auth/csrf/", + login: "users/login/", + refresh: "users/token/refresh/", + // logout: "users/auth/logout/", self: "users/self/", }; diff --git a/src/initApp.ts b/src/initApp.ts new file mode 100644 index 0000000..597d605 --- /dev/null +++ b/src/initApp.ts @@ -0,0 +1,27 @@ +async function loadConfig() { + try { + const response = await fetch("/config.json"); + if (!response.ok) throw new Error("Configuration Missing"); + window.APP_CONFIG = await response.json(); + document.title = window.APP_CONFIG.CLIENT_PAGE_TITLE; + + const link = document.createElement("link"); + link.rel = "icon"; + link.type = "image/png"; + link.href = "/dartachalani" + window.APP_CONFIG.CLIENT_PAGE_TITLE_LOGO; + + const existingIcons = document.querySelectorAll('link[rel*="icon"]'); + existingIcons.forEach((el: any) => el.parentNode.removeChild(el)); + + document.head.appendChild(link); + } catch (e) { + alert("Configuration Missing"); + throw e; + } +} + +(async () => { + await loadConfig(); + const { initAPP } = await import("./main"); + initAPP(); +})(); diff --git a/src/main.ts b/src/main.ts index 95f01f2..bef7d65 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,3 +38,4 @@ export const initAPP = () => { app.mount("#app"); }; +// initAPP(); \ No newline at end of file diff --git a/src/router/authChildren.ts b/src/router/authChildren.ts index ea45336..07c05ac 100644 --- a/src/router/authChildren.ts +++ b/src/router/authChildren.ts @@ -2,6 +2,14 @@ import type { RouteRecordRaw } from "vue-router"; // import { PERMISSIONS } from "@/constants/permissions"; const authChildren: Array = [ + { + path: "/", + name: "dashboard", + component: () => import("@/views/Dashboard/Components/Dashboard.vue"), + meta: { + permission: "", + }, + }, ]; export default authChildren; diff --git a/src/services/API/api.ts b/src/services/API/api.ts index d6bdb02..190eb19 100644 --- a/src/services/API/api.ts +++ b/src/services/API/api.ts @@ -3,10 +3,10 @@ import { authAPI } from "@/core/endpoints/auth"; import { getCSRFTokenFromCookie } from "./utilities"; import { useUser } from "@/stores/User/User"; -const apiURL: string = window.APP_CONFIG.API_URL; +// const apiURL: string = window.APP_CONFIG.API_URL; const api = axios.create({ - baseURL: apiURL, + baseURL: "http://localhost:8000/api/v3/", headers: { "Content-Type": "application/json", }, @@ -50,7 +50,7 @@ api.interceptors.response.use( originalRequest.headers["X-CSRFToken"] = csrfToken; } try { - await axios.post(apiURL + authAPI.refresh, null, { + await axios.post("http://localhost:8000/api/v3/" + authAPI.refresh, null, { withCredentials: true, headers: { "X-CSRFToken": csrfToken, diff --git a/src/stores/User/User.ts b/src/stores/User/User.ts index 7e24a30..36f40a8 100644 --- a/src/stores/User/User.ts +++ b/src/stores/User/User.ts @@ -17,8 +17,8 @@ export const useUser = defineStore("user", { actions: { async fetchUserDetail() { try { - const response = await api.get(authAPI.self); - this.user = response.data.data; + // const response = await api.get(authAPI.self); + // this.user = response.data.data; this.isAuthenticated = true; } catch (error: any) { if (error.response.status == 403) { diff --git a/src/utils/setup/SidebarItems.ts b/src/utils/setup/SidebarItems.ts index 738da9c..7c2a30e 100644 --- a/src/utils/setup/SidebarItems.ts +++ b/src/utils/setup/SidebarItems.ts @@ -1,13 +1,38 @@ -import type { RouteRecordRaw } from "vue-router"; -const authChildren: Array = [ - { - path: "/", - name: "dashboard", - component: () => import("@/views/Dashboard/Components/Dashboard.vue"), - meta: { - permission: "", - }, - }, -] +import type { SidebarItem } from "@/dtos/common/Sidebar"; -export default authChildren; \ No newline at end of file +export function useSidebarItems(): SidebarItem[] { + return [ + { + label: "Dashboard", + isVisible: true, + }, + { + label: "Dashboard", + icon: "Home", + isVisible: true, + to: "/", + }, + { + label: "DartaChalani", + isVisible: true, + }, + { + label: "Darta", + icon: "FileInput", + isVisible: true, + to: "/darta", + }, + { + label: "Chalani", + icon: "FileOutput", + isVisible: true, + to: "/chalani", + }, + { + label: "Tippani", + icon: "FilePenLine", + isVisible: true, + to: "/tippani", + }, + ]; +} diff --git a/src/views/Dashboard/Components/Dashboard.vue b/src/views/Dashboard/Components/Dashboard.vue index be11e25..7bc597f 100644 --- a/src/views/Dashboard/Components/Dashboard.vue +++ b/src/views/Dashboard/Components/Dashboard.vue @@ -43,7 +43,7 @@