sidebar and dashboard added
This commit is contained in:
parent
7e944ac917
commit
9f6c30541e
|
|
@ -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>
|
||||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
|
|
@ -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
27
src/initApp.ts
Normal 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();
|
||||||
|
})();
|
||||||
|
|
@ -38,3 +38,4 @@ export const initAPP = () => {
|
||||||
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
};
|
};
|
||||||
|
// initAPP();
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user