Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Admin Page frontend #67

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
169a92e
feat: initiliase admin page
Majestic9169 Jun 2, 2024
296487d
feat: initialise admin-page
Majestic9169 Jun 4, 2024
80d6869
feat: add edit functionality to questionPapers
Majestic9169 Jun 4, 2024
f257382
feat: add approve/reject functionality
Majestic9169 Jun 4, 2024
2502fdb
feat: add dropdown menu for course_codes
Majestic9169 Jun 12, 2024
3e99bc1
feat: add dropdown input to course_names
Majestic9169 Jun 12, 2024
fb7e0cd
feat: add dropdown input for years
Majestic9169 Jun 12, 2024
f25ab6a
feat: add dropdown functionailty wherever required
Majestic9169 Jun 12, 2024
2aee86f
feat: style table a little decently,
Majestic9169 Jun 12, 2024
2020b61
fix: text alignment in course name column
Majestic9169 Jun 12, 2024
bdcc5c6
feat: update file naming convention to better reflect question paper …
Majestic9169 Jun 13, 2024
c752a85
feat: added ability to sort table
Majestic9169 Jun 13, 2024
f2ed571
fix: type in CS10003 and CS19003, change progamming to programming
Majestic9169 Jun 14, 2024
cfda5c8
feat: create getCodeFromCourse function used to validate and match in…
Majestic9169 Jun 14, 2024
319e80b
feat: add some styling to identify focused element
Majestic9169 Jun 14, 2024
04b445e
rename two components to make more sense
Majestic9169 Jun 14, 2024
6573b91
feat: add efficient approve/reject mechanism
Majestic9169 Jun 14, 2024
01f08a7
fix: simplify approve/reject to boolean
Majestic9169 Jun 17, 2024
fdd6600
feat: add a navbar and a space to display the current logged in user
Majestic9169 Jun 17, 2024
42ace0c
fix: remove trash color scheme and fix disbaled element styling
Majestic9169 Jun 17, 2024
2fb2586
fix: scoped the admin page css
harshkhandeparkar Jun 19, 2024
5914320
feat: a few styling changes
harshkhandeparkar Jun 19, 2024
a9ac6e1
feat: better table styling
harshkhandeparkar Jun 19, 2024
54190b6
feat: better select styling
harshkhandeparkar Jun 19, 2024
3e0de42
feat: better pdf link styling
harshkhandeparkar Jun 19, 2024
94d1321
feat: reduced select border size and opacity
harshkhandeparkar Jun 19, 2024
12583a6
feat: better pdf icon
harshkhandeparkar Jun 19, 2024
2d3bad5
feat: better disabled styling
harshkhandeparkar Jun 19, 2024
f57c7ad
feat: better buttons ig?
harshkhandeparkar Jun 19, 2024
108c3b0
fix: the misaligned svg was triggering my ocd
harshkhandeparkar Jun 19, 2024
4feb80e
feat: i would say this is a better button
harshkhandeparkar Jun 19, 2024
5d5fc97
fix: another ocd satisfied
harshkhandeparkar Jun 19, 2024
f0155e1
feat: rounded select list
harshkhandeparkar Jun 19, 2024
2b1e25a
feat: added way to unapprove
harshkhandeparkar Jun 19, 2024
c8fdb1b
fix: another ocd fixed
harshkhandeparkar Jun 19, 2024
7a90ade
feat: colored pdf link
harshkhandeparkar Jun 19, 2024
4ee3a3e
fix: removed unnecessary caption
harshkhandeparkar Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
"vite-plugin-solid": "^2.8.2"
},
"dependencies": {
"@solid-primitives/keyboard": "^1.2.8",
"@solidjs/router": "^0.13.2",
"@vercel/analytics": "^1.2.0",
"solid-icons": "^1.1.0",
"solid-js": "^1.8.11",
"solid-toast": "^0.5.0"
}
},
"packageManager": "[email protected]+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0"
}
87 changes: 70 additions & 17 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions frontend/src/components/PDFLister.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { AiFillCloseCircle, AiFillWarning, AiOutlineFilePdf as PDFIcon } from "solid-icons/ai";
import { Component, createSignal } from "solid-js";
import { createStore } from "solid-js/store";
import { Exam, IAdminQuestionPaperResult, Semester, approvalStatus } from "../types/types";
import { IoCheckmarkCircle } from "solid-icons/io";
import { createShortcut } from "@solid-primitives/keyboard";

type props = {
questionPaper: IAdminQuestionPaperResult;
isEditMode: boolean;
}

export const ListElement: Component<props> = (props) => {
const [questionPaperDetails, setQuestionPaperDetails] = createStore<IAdminQuestionPaperResult>(props.questionPaper);

function approvalStatus(approvalStatus: approvalStatus) {
if (approvalStatus == null) {
return (<AiFillWarning/>);
} else if (approvalStatus) {
return (<IoCheckmarkCircle/>);
} else {
return (<AiFillCloseCircle/>);
}
};

function paperApprove(approvalStatus: approvalStatus){
if (approvalStatus == null) {setQuestionPaperDetails("approval", true)}
else {
setQuestionPaperDetails("approval", null)
}
};

function paperReject(approvalStatus: approvalStatus){
if (approvalStatus == null) {setQuestionPaperDetails("approval", false)}
else {
setQuestionPaperDetails("approval", null)
}
}

// createShortcut(
Majestic9169 marked this conversation as resolved.
Show resolved Hide resolved
// ["Alt", "V"],
// () => {
// paperApprove(questionPaperDetails.approval);
// },
// { preventDefault: true},
// )

return (
<tr>
<td><input type="number" value={questionPaperDetails.year} onInput={(e) => setQuestionPaperDetails("year", parseInt(e.target.value))} readonly={!props.isEditMode}/></td>
<td><input type="string" value={questionPaperDetails.course_code} onInput={(e) => setQuestionPaperDetails("course_code", e.target.value)} readonly={!props.isEditMode}/></td>
Majestic9169 marked this conversation as resolved.
Show resolved Hide resolved
<td><input type="string" value={questionPaperDetails.course_name} onInput={(e) => setQuestionPaperDetails("course_name", e.target.value)} readonly={!props.isEditMode}/></td>
<td><input type="string" value={questionPaperDetails.exam} onInput={(e) => setQuestionPaperDetails("exam", e.target.value)} readonly={!props.isEditMode}/></td>
<td><input type="string" value={questionPaperDetails.semester} onInput={(e) => setQuestionPaperDetails("semester", e.target.value)} readonly={!props.isEditMode}/></td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make these select inputs since they only have a few options.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, however I haven't been able validate that the course_code and course_name match

one idea I had was to have the course_name display the value from the courses.json file for the corresponding key, this should be doable using the format method in solid-select, however I wasn't able to figure it out. some help with that would be quite nice

<td><PDFIcon/><a href={props.questionPaper.filelink} target="_blank">{questionPaperDetails.course_code}.pdf</a></td>
<td><button onClick={(e) => {e.preventDefault();if (props.isEditMode) {paperApprove(questionPaperDetails.approval)}}} onContextMenu={(e) => {e.preventDefault();if (props.isEditMode){paperReject(questionPaperDetails.approval)}}}>{approvalStatus(questionPaperDetails.approval)} </button></td>
</tr>
)
}
51 changes: 51 additions & 0 deletions frontend/src/components/PDFTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Component, createSignal, For } from "solid-js";
import { IAdminQuestionPaperResult } from "../types/types";
import { ListElement } from "./PDFLister";
import { IoPencil } from "solid-icons/io";
import { createShortcut } from "@solid-primitives/keyboard";
import { createStore } from "solid-js/store";

type props = {
QuestionPapers: IAdminQuestionPaperResult[];
}

export const PDFLister: Component<props> = (props) => {
const [reviewList, setReviewList] = createStore<IAdminQuestionPaperResult[]>(props.QuestionPapers);
const [isEditMode, setIsEditMode] = createSignal<boolean>(true)

function toggleEditMode(){
setIsEditMode(!isEditMode());
}

createShortcut(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need an "edit mode" for the entire page. We can have an edit button per paper that opens a modal that will have a form for editing.

Copy link
Author

@Majestic9169 Majestic9169 Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll implement this once i make the modal to view the pdf, until then if we're just using the new tab link functionality i feel like being able to see all the question papers together will make the process faster

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see all the question papers together will make the process faster

Hmm, true. In that case, instead of an edit mode, make an edit button that becomes enabled if something is changed. Clicking on it will update the data on the backend.

Copy link
Author

@Majestic9169 Majestic9169 Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isEditMode is removed

i'm still not very happy with my current approve/reject functionality, what other methods would you suggest, keeping in mind speed of approval?
is a button fine?
do we need further confirmation before approval?
how can i make this process faster and error free?
these are some questions I need to answer before I completely fix this, until then I'll make the table sortable

["Alt", "Z"],
() => {
toggleEditMode();
},
{ preventDefault: true},
);

return (
<div>
<span><button onclick={toggleEditMode}><IoPencil/></button> is editable = {isEditMode().toString()}</span>
<table>
<thead>
<tr>
<th>Year</th>
<th>Code</th>
<th>Course Name</th>
<th>Exam</th>
<th>Semester</th>
<th>File</th>
<th>Approval</th>
</tr>
</thead>

<For each={reviewList}>{(item) => (
<ListElement questionPaper={item} isEditMode={isEditMode()}/>
)}
</For>
</table>
</div>
)
}
Loading