Skip to content

Commit

Permalink
More stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 committed Nov 16, 2024
1 parent 03e9b00 commit 8ab092b
Show file tree
Hide file tree
Showing 20 changed files with 920 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@
<Loader />
</div>
<div v-else key="element2" class="flex">
<Sidebar class="hidden lg:block" />
<div class="flex flex-col w-full min-h-screen bg-gray-100">
<Sidebar class="hidden lg:block max-h-screen overflow-y-auto" />
<div class="flex flex-col w-full min-h-screen max-h-screen overflow-y-auto bg-gray-100">
<Header />
<router-view class="flex-grow" />
<Footer />
Expand Down
17 changes: 10 additions & 7 deletions src/components/profile/ActionLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
<table class="w-full text-sm text-left rtl:text-right text-gray-500">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">Entry</th>
<th scope="col" class="px-6 py-3">Date</th>
<th scope="col" class="px-6 py-3">Added By</th>
<th scope="col" class="px-6 py-3">Entry</th>
</tr>
</thead>
<tbody>
<tr v-for="(ale, idx) in actionLogEntries" :key="idx" class="bg-white border-b">
<th scope="row" class="text-wrap px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
{{ ale.entry }}
</th>
<td class="px-6 py-4">
<td class="px-6 py-2">
{{ new Date(ale.created_at).toLocaleDateString() }}
</td>
<td class="px-6 py-4">
<td class="px-6 py-2">
{{ ale.created_by }}
</td>
<th scope="row" class="text-wrap px-6 py-2 font-medium text-gray-900 whitespace-nowrap">
{{ ale.entry }}
</th>
</tr>
</tbody>
</table>
Expand All @@ -51,7 +51,10 @@ const actionLogEntries = ref<ActionLog[]>([]);
const fetching = ref<boolean>(true);
onMounted(async () => {
actionLogEntries.value = await userStore.fetchActionLog(userStore.self.cid);
actionLogEntries.value = await userStore.fetchActionLog(userStore.self!.cid);
actionLogEntries.value.sort((a, b) => {
return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
});
fetching.value = false;
});
</script>
Expand Down
64 changes: 55 additions & 9 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,82 @@ const routes = [
{
path: "management",
name: "Management",
component: () => import("@/views/controllers/Facility.vue"),
component: () => import("@/views/facility/Management.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA"],
},
},
{
path: "roster",
name: "Roster",
component: () => import("@/views/facility/Roster.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA"],
},
},
{
path: "feedback",
name: "Feedback",
component: () => import("@/views/facility/Feedback.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA"],
},
},
{
path: "engineering",
name: "Engineering",
component: () => import("@/views/controllers/MyFeedback.vue"),
component: () => import("@/views/facility/Engineering.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA", "FE", "AFE"],
},
},
{
path: "web-config",
name: "Web Config",
component: () => import("@/views/controllers/MyFeedback.vue"),
component: () => import("@/views/facility/WebConfig.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA", "WM", "AWM"],
},
},
{
path: "events",
name: "ARTCC Events",
component: () => import("@/views/controllers/MyFeedback.vue"),
component: () => import("@/views/facility/Events.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA", "EC", "AEC"],
},
},
{
path: "training/notes",
name: "Training Notes",
component: () => import("@/views/controllers/MyFeedback.vue"),
component: () => import("@/views/facility/Engineering.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA", "MTR", "INS"],
},
},
{
path: "training/calendar",
name: "Training Calendar",
component: () => import("@/views/controllers/MyFeedback.vue"),
component: () => import("@/views/facility/Engineering.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA", "MTR", "INS"],
},
},
],
meta: {
requiresAuth: true,
},
},
{
path: "/mgmt/",
children: [
{
path: "user/:cid",
name: "User",
component: () => import("@/views/management/User.vue"),
meta: {
requiresRole: ["ATM", "DATM", "TA"],
},
},
],
meta: {
Expand Down Expand Up @@ -151,10 +196,11 @@ router.beforeEach(async (to, from, next) => {
const sidebarStore = useSidebarStore();
if (!userStore.hasFetched) {
if (userStore.loading === null || userStore.loading === undefined) {
console.log("fetching user");
userStore.loading = userStore.fetchUser();
userStore.loading = userStore.fetchSelf();
await userStore.loading;
sidebarStore.updateSidebar(userStore.roles!);
if (userStore.roles) {
sidebarStore.updateSidebar(userStore.roles);
}
}
userStore.loading.then(() => {
check(to, from, next);
Expand Down
8 changes: 8 additions & 0 deletions src/stores/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ const useEventStore = defineStore({
this.fetching = false;
}
},
async fetchPreviousEvents(facility: string): Promise<Event[]> {
try {
const { data } = await API.get(`/v3/facility/${facility}/events/previous`);
return data;
} catch (e) {
return [];
}
},
async fetchEvents(facility: string): Promise<Event[]> {
try {
const { data } = await API.get(`/v3/facility/${facility}/events`);
Expand Down
9 changes: 9 additions & 0 deletions src/stores/facility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ const useFacilityStore = defineStore({
this.fetching = false;
}
},
async patchRosterRequest(facility: string, id: number, status: string): Promise<void> {
this.loading = API.patch(`/v3/facility/${facility}/roster-request/${id}`, { status });
await this.loading;
this.loading = null;
},
async regenerateApiKey(facility: string): Promise<string> {
const { data } = await API.post(`/v3/facility/${facility}/reset-api-key`);
return data.api_key;
},
},
});

Expand Down
4 changes: 4 additions & 0 deletions src/stores/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const useFeedbackStore = defineStore({
await this.loading;
this.loading = null;
},
async fetchFeedbackForFacility(facility: string): Promise<Feedback[]> {
const { data } = await API.get(`/v3/facility/${facility}/feedback`);
return data;
},
},
});

Expand Down
111 changes: 67 additions & 44 deletions src/stores/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,68 @@ const useSidebarStore = defineStore({
}, {});

Object.keys(facilityRolesMap).forEach((facility: string) => {
const seniorStaff: Link[] = [
{
title: "Management",
icon: "fa-solid fa-gear",
to: { name: "Management", params: { facility_id: facility } },
},
{
title: "Roster",
icon: "fa-solid fa-users",
to: { name: "Roster", params: { facility_id: facility } },
},
{
title: "Feedback",
icon: "fa-solid fa-users",
to: { name: "Feedback", params: { facility_id: facility } },
},
];

const fe: Link[] = [
{
title: "Engineering",
icon: "fa-solid fa-tools",
to: { name: "Engineering", params: { facility_id: facility } },
},
];

const wm: Link[] = [
{
title: "Web Config",
icon: "fa-solid fa-cogs",
to: { name: "Web Config", params: { facility_id: facility } },
},
];

const ec: Link[] = [
{
title: "Events",
icon: "fa-solid fa-calendar",
to: { name: "ARTCC Events", params: { facility_id: facility } },
},
];

const training: Link[] = [
{
title: "Training Actions",
icon: "fa-solid fa-chalkboard-user",
subLinks: [
{
title: "Calendar",
icon: "fa-solid fa-calendar",
to: { name: "Training Calendar", params: { facility_id: facility } },
},
{
title: "Notes",
icon: "fa-solid fa-book",
to: { name: "Training-Notes", params: { facility_id: facility } },
},
],
showSubLinks: true,
},
];

// If ZHQ
if (facility === "ZHQ") {
this.sidebar.push({
Expand All @@ -47,59 +109,20 @@ const useSidebarStore = defineStore({
const facRoles: string[] = facilityRolesMap[facility];
const temp: Link[] = [];
if (facRoles.includes("ATM") || facRoles.includes("DATM") || facRoles.includes("TA")) {
temp.push(
{
title: "Management",
icon: "fa-solid fa-gear",
to: { name: "Management", params: { facility_id: facility } },
},
{
title: "Roster",
icon: "fa-solid fa-users",
to: { name: "Roster", params: { facility_id: facility } },
}
);
temp.push(...seniorStaff, ...fe, ...wm, ...ec, ...training);
} else {
if (facRoles.includes("FE") || facRoles.includes("AFE")) {
temp.push({
title: "Engineering",
icon: "fa-solid fa-tools",
to: { name: "Engineering", params: { facility_id: facility } },
});
temp.push(...fe);
}
if (facRoles.includes("WM") || facRoles.includes("AWM")) {
temp.push({
title: "Web Config",
icon: "fa-solid fa-cogs",
to: { name: "Web Config", params: { facility_id: facility } },
});
temp.push(...wm);
}
if (facRoles.includes("EC") || facRoles.includes("AEC")) {
temp.push({
title: "Events",
icon: "fa-solid fa-calendar",
to: { name: "ARTCC Events", params: { facility_id: facility } },
});
temp.push(...ec);
}

if (facRoles.includes("MTR") || facRoles.includes("INS")) {
temp.push({
title: "Training Actions",
icon: "fa-solid fa-chalkboard-user",
subLinks: [
{
title: "Calendar",
icon: "fa-solid fa-calendar",
to: { name: "Training Calendar", params: { facility_id: facility } },
},
{
title: "Notes",
icon: "fa-solid fa-book",
to: { name: "Training-Notes", params: { facility_id: facility } },
},
],
showSubLinks: true,
});
temp.push(...training);
}
}

Expand Down
Loading

0 comments on commit 8ab092b

Please sign in to comment.