sidebar and dashboard added

This commit is contained in:
prabidhi 2025-12-10 15:23:57 +05:45
parent 7e944ac917
commit 9f6c30541e
11 changed files with 85 additions and 24 deletions

View File

@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/initApp.ts"></script>
</body> </body>
</html> </html>

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -1,7 +1,7 @@
export const authAPI = { export const authAPI = {
csrfGenerate: "users/auth/csrf/", // csrfGenerate: "users/auth/csrf/",
login: "users/auth/login/", login: "users/login/",
refresh: "users/auth/refresh/", refresh: "users/token/refresh/",
logout: "users/auth/logout/", // logout: "users/auth/logout/",
self: "users/self/", self: "users/self/",
}; };

27
src/initApp.ts Normal file
View File

@ -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();
})();

View File

@ -38,3 +38,4 @@ export const initAPP = () => {
app.mount("#app"); app.mount("#app");
}; };
// initAPP();

View File

@ -2,6 +2,14 @@ import type { RouteRecordRaw } from "vue-router";
// import { PERMISSIONS } from "@/constants/permissions"; // import { PERMISSIONS } from "@/constants/permissions";
const authChildren: Array<RouteRecordRaw> = [ const authChildren: Array<RouteRecordRaw> = [
{
path: "/",
name: "dashboard",
component: () => import("@/views/Dashboard/Components/Dashboard.vue"),
meta: {
permission: "",
},
},
]; ];
export default authChildren; export default authChildren;

View File

@ -3,10 +3,10 @@ import { authAPI } from "@/core/endpoints/auth";
import { getCSRFTokenFromCookie } from "./utilities"; import { getCSRFTokenFromCookie } from "./utilities";
import { useUser } from "@/stores/User/User"; 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({ const api = axios.create({
baseURL: apiURL, baseURL: "http://localhost:8000/api/v3/",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@ -50,7 +50,7 @@ api.interceptors.response.use(
originalRequest.headers["X-CSRFToken"] = csrfToken; originalRequest.headers["X-CSRFToken"] = csrfToken;
} }
try { try {
await axios.post(apiURL + authAPI.refresh, null, { await axios.post("http://localhost:8000/api/v3/" + authAPI.refresh, null, {
withCredentials: true, withCredentials: true,
headers: { headers: {
"X-CSRFToken": csrfToken, "X-CSRFToken": csrfToken,

View File

@ -17,8 +17,8 @@ export const useUser = defineStore("user", {
actions: { actions: {
async fetchUserDetail() { async fetchUserDetail() {
try { try {
const response = await api.get(authAPI.self); // const response = await api.get(authAPI.self);
this.user = response.data.data; // this.user = response.data.data;
this.isAuthenticated = true; this.isAuthenticated = true;
} catch (error: any) { } catch (error: any) {
if (error.response.status == 403) { if (error.response.status == 403) {

View File

@ -1,13 +1,38 @@
import type { RouteRecordRaw } from "vue-router"; import type { SidebarItem } from "@/dtos/common/Sidebar";
const authChildren: Array<RouteRecordRaw> = [
{
path: "/",
name: "dashboard",
component: () => import("@/views/Dashboard/Components/Dashboard.vue"),
meta: {
permission: "",
},
},
]
export default authChildren; 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",
},
];
}

View File

@ -43,7 +43,7 @@
<script setup lang="ts"> <script setup lang="ts">
// import api from "@/services/API/api"; // import api from "@/services/API/api";
import { ref, onMounted } from "vue"; import { ref } from "vue";
// import VChart from "vue-echarts"; // import VChart from "vue-echarts";
// import { use } from "echarts/core"; // import { use } from "echarts/core";