-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from unovil/dashboard-complexity
Dashboard complexity
- Loading branch information
Showing
30 changed files
with
1,641 additions
and
74 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
prisma/migrations/20240419025521_changed_request_shape/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `_equipmenttorequest` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `_facilitytorequest` table. If the table is not empty, all the data it contains will be lost. | ||
- Added the required column `equipmentId` to the `Request` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `facilityId` to the `Request` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE `_equipmenttorequest` DROP FOREIGN KEY `_EquipmentToRequest_A_fkey`; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE `_equipmenttorequest` DROP FOREIGN KEY `_EquipmentToRequest_B_fkey`; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE `_facilitytorequest` DROP FOREIGN KEY `_FacilityToRequest_A_fkey`; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE `_facilitytorequest` DROP FOREIGN KEY `_FacilityToRequest_B_fkey`; | ||
|
||
-- AlterTable | ||
ALTER TABLE `request` ADD COLUMN `equipmentId` INTEGER NOT NULL, | ||
ADD COLUMN `facilityId` INTEGER NOT NULL; | ||
|
||
-- DropTable | ||
DROP TABLE `_equipmenttorequest`; | ||
|
||
-- DropTable | ||
DROP TABLE `_facilitytorequest`; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Request` ADD CONSTRAINT `Request_facilityId_fkey` FOREIGN KEY (`facilityId`) REFERENCES `Facility`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Request` ADD CONSTRAINT `Request_equipmentId_fkey` FOREIGN KEY (`equipmentId`) REFERENCES `Equipment`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240419034705_fixed_description_request/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE `request` MODIFY `description` TINYTEXT NOT NULL; |
15 changes: 15 additions & 0 deletions
15
prisma/migrations/20240419055629_changed_request_dates_json/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- DropForeignKey | ||
ALTER TABLE `request` DROP FOREIGN KEY `Request_equipmentId_fkey`; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE `request` DROP FOREIGN KEY `Request_facilityId_fkey`; | ||
|
||
-- AlterTable | ||
ALTER TABLE `request` MODIFY `equipmentId` INTEGER NULL, | ||
MODIFY `facilityId` INTEGER NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Request` ADD CONSTRAINT `Request_facilityId_fkey` FOREIGN KEY (`facilityId`) REFERENCES `Facility`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `Request` ADD CONSTRAINT `Request_equipmentId_fkey` FOREIGN KEY (`equipmentId`) REFERENCES `Equipment`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; |
10 changes: 10 additions & 0 deletions
10
prisma/migrations/20240419061409_request_status_json/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `isAllowed` on the `request` table. All the data in the column will be lost. | ||
- Added the required column `requestStatus` to the `Request` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `request` DROP COLUMN `isAllowed`, | ||
ADD COLUMN `requestStatus` JSON NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Page } from "@sveltejs/kit"; | ||
|
||
export const searchQuery = (searchTerm: string | undefined | null, category: string, page: Page<Record<string, string>, string | null>) => { | ||
if (searchTerm === null || typeof searchTerm === "undefined") return {query: "", term: ""}; | ||
if (searchTerm.trim() === "") return {query: "", term: ""}; | ||
|
||
let query = new URLSearchParams(page.url.searchParams.toString()); | ||
query.set("term", searchTerm.trim()); | ||
query.set("cat", category); | ||
|
||
return {query: query.toString() || "", term: searchTerm.trim()}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { page } from "$app/stores"; | ||
let statusMessage: string = ""; | ||
switch ($page.status) { | ||
case 404: | ||
statusMessage = "Sorry, the page you requested does not exist."; | ||
break; | ||
case 400: | ||
statusMessage = | ||
"Sorry, you may have made a bad request. Retype the URL or go back to the homepage."; | ||
break; | ||
case 401: | ||
statusMessage = "Sorry, you are not authorized to view this page."; | ||
break; | ||
default: | ||
statusMessage = $page.error?.message || ""; | ||
break; | ||
} | ||
</script> | ||
|
||
<div class="grid grid-cols-3 grid-rows-4 h-screen text-center bg-red-100 overflow-hidden" style="grid-template-columns: 25% 50% 25%;"> | ||
<div | ||
class="col-start-2 col-end-3 row-start-2 row-end-3 flex flex-col items-center justify-center" | ||
> | ||
<h1 class="text-9xl text-red-800 font-bold mb-2">{$page.status}</h1> | ||
<p class="text-xl text-red-800 font-semibold mb-10">{statusMessage}</p> | ||
</div> | ||
|
||
<img | ||
src="/error_leo.png" | ||
class="col-start-2 col-end-3 row-start-3 row-end-5 self-end object-contain m-auto" | ||
alt="" | ||
/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { LayoutServerLoad } from './$types' | ||
import { redirect, type Actions } from '@sveltejs/kit'; | ||
import { lucia } from '$lib/server/auth'; | ||
import db from '$lib/prisma'; | ||
|
||
export const load: LayoutServerLoad = async (event) => { | ||
console.log(event.locals.user); | ||
|
||
if (!event.locals.user) { | ||
return { isLoggedIn: false } | ||
} | ||
|
||
const user = await db.user.findUnique({ | ||
select: { role: true, student: true, admin: true }, | ||
where: { id: event.locals.user.id } | ||
}) | ||
|
||
if (user?.role == "STUDENT" && user?.student) { | ||
return { isStudent: true } | ||
} | ||
|
||
if (!user?.admin && !user?.student) { | ||
return { needsRegisterFollowup: true } | ||
} | ||
|
||
if (user?.role == "ADMIN" && user?.admin) { | ||
return { isAdmin: true } | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
<script> | ||
<script lang="ts"> | ||
import "../app.css"; | ||
import type { LayoutData } from "./$types"; | ||
import { page } from '$app/stores'; | ||
export let data: LayoutData; | ||
</script> | ||
|
||
{#if ($page.url.pathname === "/") || (data.isLoggedIn === false || data.needsRegisterFollowup === true)} | ||
<div></div> | ||
{:else if data.isStudent === true} | ||
<a href="/dashboard">Dashboard</a> | ||
<a href="/search">Search</a> | ||
{:else if data.isAdmin === true} | ||
<a href="/admindashboard">Dashboard</a> | ||
<a href="/approvals">Approvals</a> | ||
{/if} | ||
|
||
<br> | ||
|
||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.