mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
organizing file storage
This commit is contained in:
@@ -10,7 +10,7 @@ export const GET = async (
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getAssignment(
|
||||
const settings = await fileStorageService.assignments.getAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName
|
||||
@@ -28,7 +28,7 @@ export const PUT = async (
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const assignment = await request.json();
|
||||
await fileStorageService.updateAssignment(
|
||||
await fileStorageService.assignments.updateAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName,
|
||||
|
||||
@@ -7,7 +7,7 @@ export const GET = async (
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) => await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getAssignmentNames(
|
||||
const settings = await fileStorageService.assignments.getAssignmentNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ export const GET = async (
|
||||
}: { params: { courseName: string; moduleName: string; pageName: string } }
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getPage(
|
||||
const settings = await fileStorageService.pages.getPage(
|
||||
courseName,
|
||||
moduleName,
|
||||
pageName
|
||||
@@ -24,6 +24,6 @@ export const PUT = async (
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const page = await request.json();
|
||||
await fileStorageService.updatePage(courseName, moduleName, pageName, page);
|
||||
await fileStorageService.pages.updatePage(courseName, moduleName, pageName, page);
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ export const GET = async (
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getPageNames(
|
||||
const settings = await fileStorageService.pages.getPageNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ export const GET = async (
|
||||
params: { courseName, moduleName, quizName },
|
||||
}: { params: { courseName: string; moduleName: string; quizName: string } }
|
||||
) => await withErrorHandling(async () => {
|
||||
const quiz = await fileStorageService.getQuiz(
|
||||
const quiz = await fileStorageService.quizzes.getQuiz(
|
||||
courseName,
|
||||
moduleName,
|
||||
quizName
|
||||
@@ -22,7 +22,7 @@ export const PUT = async (
|
||||
}: { params: { courseName: string; moduleName: string; quizName: string } }
|
||||
) => await withErrorHandling(async () => {
|
||||
const quiz = await request.json()
|
||||
await fileStorageService.updateQuiz(
|
||||
await fileStorageService.quizzes.updateQuiz(
|
||||
courseName,
|
||||
moduleName,
|
||||
quizName,
|
||||
|
||||
@@ -8,7 +8,7 @@ export const GET = async (
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getQuizNames(
|
||||
const settings = await fileStorageService.quizzes.getQuizNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
|
||||
@@ -6,6 +6,16 @@ export const GET = async (
|
||||
{ params: { courseName } }: { params: { courseName: string } }
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getModuleNames(courseName);
|
||||
const settings = await fileStorageService.modules.getModuleNames(courseName);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
export const POST = async (
|
||||
request: Request,
|
||||
{ params: { courseName } }: { params: { courseName: string } }
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const { moduleName } = await request.json();
|
||||
await fileStorageService.modules.createModule(courseName, moduleName);
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ export const GET = async (
|
||||
if (courseName.includes(".js.map")) {
|
||||
return Response.json({});
|
||||
}
|
||||
const settings = await fileStorageService.getCourseSettings(courseName);
|
||||
const settings = await fileStorageService.settings.getCourseSettings(courseName);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ export const PUT = async (
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await request.json();
|
||||
|
||||
await fileStorageService.updateCourseSettings(courseName, settings);
|
||||
await fileStorageService.settings.updateCourseSettings(courseName, settings);
|
||||
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ export const GET = async () =>
|
||||
export const POST = async (request: Request) =>
|
||||
await withErrorHandling(async () => {
|
||||
const newCourse: LocalCourse = await request.json();
|
||||
await fileStorageService.updateCourseSettings(
|
||||
await fileStorageService.settings.updateCourseSettings(
|
||||
newCourse.settings.name,
|
||||
newCourse.settings
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export const GET = async () =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getAllCoursesSettings();
|
||||
const settings = await fileStorageService.settings.getAllCoursesSettings();
|
||||
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function CourseSettingsLink() {
|
||||
<div>
|
||||
{settings.name}
|
||||
|
||||
<Link href={getCourseSettingsUrl(courseName)} shallow={true}>
|
||||
<Link className="mx-3 underline" href={getCourseSettingsUrl(courseName)} shallow={true}>
|
||||
Course Settings
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
10
nextjs/src/app/course/[courseName]/CourseTitle.tsx
Normal file
10
nextjs/src/app/course/[courseName]/CourseTitle.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { useCourseContext } from "./context/courseContext"
|
||||
|
||||
export default function CourseTitle() {
|
||||
const {courseName}= useCourseContext()
|
||||
return (
|
||||
<title>{courseName}</title>
|
||||
)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
|
||||
<h3
|
||||
className={
|
||||
"text-2xl transition-all duration-500 " +
|
||||
"hover:text-slate-50 underline hover:scale-105 "
|
||||
"hover:text-slate-50 underline hover:scale-105 `"
|
||||
}
|
||||
onClick={toggleCollapse}
|
||||
role="button"
|
||||
@@ -36,7 +36,7 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {
|
||||
|
||||
<div
|
||||
id={monthName}
|
||||
className={"collapsable " + (isCollapsed ? "" : "expand")}
|
||||
className={"collapsible " + (isCollapsed ? "" : "expand")}
|
||||
>
|
||||
<div className="grid grid-cols-7 text-center fw-bold">
|
||||
{weekDaysList.map((day) => (
|
||||
|
||||
@@ -11,6 +11,9 @@ import { IModuleItem } from "@/models/local/IModuleItem";
|
||||
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
||||
import { getDayOfWeek } from "@/models/local/localCourse";
|
||||
import { getModuleItemUrl } from "@/services/urlUtils";
|
||||
import { LocalAssignment } from "@/models/local/assignment/localAssignment";
|
||||
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
||||
import { LocalCoursePage } from "@/models/local/page/localCoursePage";
|
||||
|
||||
export default function Day({ day, month }: { day: string; month: number }) {
|
||||
const dayAsDate = getDateFromStringOrThrow(
|
||||
@@ -74,9 +77,9 @@ export default function Day({ day, month }: { day: string; month: number }) {
|
||||
|
||||
function getTodaysItems(todaysModules: {
|
||||
[moduleName: string]: {
|
||||
assignments: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/assignment/localAssignment").LocalAssignment[];
|
||||
quizzes: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/quiz/localQuiz").LocalQuiz[];
|
||||
pages: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/page/localCoursePage").LocalCoursePage[];
|
||||
assignments: LocalAssignment[];
|
||||
quizzes: LocalQuiz[];
|
||||
pages: LocalCoursePage[];
|
||||
};
|
||||
}) {
|
||||
const todaysAssignments = todaysModules
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
import { ReactNode } from "react";
|
||||
import { useCourseContext } from "./courseContext";
|
||||
import {
|
||||
useAllCourseDataQuery,
|
||||
} from "@/hooks/localCourse/localCoursesHooks";
|
||||
import {
|
||||
CalendarItemsContext,
|
||||
CalendarItemsInterface,
|
||||
} from "./calendarItemsContext";
|
||||
import {
|
||||
dateToMarkdownString,
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/timeUtils";
|
||||
import { LocalAssignment } from "@/models/local/assignment/localAssignment";
|
||||
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
||||
import { LocalCoursePage } from "@/models/local/page/localCoursePage";
|
||||
import { useAllCourseDataQuery } from "@/hooks/localCourse/localCourseModuleHooks";
|
||||
|
||||
export default function CalendarItemsContextProvider({
|
||||
children,
|
||||
|
||||
36
nextjs/src/app/course/[courseName]/modules/CreateModule.tsx
Normal file
36
nextjs/src/app/course/[courseName]/modules/CreateModule.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import TextInput from "@/components/form/TextInput";
|
||||
import { useCreateModuleMutation } from "@/hooks/localCourse/localCourseModuleHooks";
|
||||
import React, { useState } from "react";
|
||||
|
||||
export default function CreateModule() {
|
||||
const createModule = useCreateModuleMutation();
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [moduleName, setModuleName] = useState("");
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => setShowForm((v) => !v)}>
|
||||
{showForm ? "Hide Form" : "Create Module"}
|
||||
</button>
|
||||
<div className={"collapsible " + (showForm ? "expand" : "")}>
|
||||
<form
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
if (moduleName) {
|
||||
await createModule.mutateAsync(moduleName);
|
||||
setModuleName("");
|
||||
}
|
||||
}}
|
||||
className="p-1 border border-slate-500 rounded-md my-1 flex flex-row gap-3 justify-between"
|
||||
>
|
||||
<TextInput
|
||||
className="flex-grow"
|
||||
value={moduleName}
|
||||
setValue={setModuleName}
|
||||
label={"New Module Name"}
|
||||
/>
|
||||
<button className="mt-auto">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
"use client";
|
||||
import { useModuleNamesQuery } from "@/hooks/localCourse/localCoursesHooks";
|
||||
import { useModuleNamesQuery } from "@/hooks/localCourse/localCourseModuleHooks";
|
||||
import ExpandableModule from "./ExpandableModule";
|
||||
import CreateModule from "./CreateModule";
|
||||
|
||||
export default function ModuleList() {
|
||||
const { data: moduleNames } = useModuleNamesQuery();
|
||||
return (
|
||||
<div>
|
||||
<CreateModule />
|
||||
{moduleNames.map((m) => (
|
||||
<ExpandableModule key={m} moduleName={m}/>
|
||||
<ExpandableModule key={m} moduleName={m} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -3,27 +3,31 @@ import CourseSettingsLink from "./CourseSettingsLink";
|
||||
import ModuleList from "./modules/ModuleList";
|
||||
import DraggingContextProvider from "./context/DraggingContextProvider";
|
||||
import Link from "next/link";
|
||||
import CourseTitle from "./CourseTitle";
|
||||
|
||||
export default async function CoursePage({}: {}) {
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
<div className="flex flex-row min-h-0">
|
||||
<DraggingContextProvider>
|
||||
<div className="flex-1 min-h-0">
|
||||
<div className="pb-1 ps-5">
|
||||
<Link href={"/"} className="btn">
|
||||
Back to Course List
|
||||
</Link>
|
||||
</div>
|
||||
<>
|
||||
<CourseTitle />
|
||||
<div className="h-full flex flex-col">
|
||||
<div className="flex flex-row min-h-0">
|
||||
<DraggingContextProvider>
|
||||
<div className="flex-1 min-h-0">
|
||||
<div className="pb-1 ps-5">
|
||||
<Link href={"/"} className="btn">
|
||||
Back to Course List
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<CourseCalendar />
|
||||
</div>
|
||||
<div className="w-96 p-3">
|
||||
<CourseSettingsLink />
|
||||
<ModuleList />
|
||||
</div>
|
||||
</DraggingContextProvider>
|
||||
<CourseCalendar />
|
||||
</div>
|
||||
<div className="w-96 p-3">
|
||||
<CourseSettingsLink />
|
||||
<ModuleList />
|
||||
</div>
|
||||
</DraggingContextProvider>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ select {
|
||||
}
|
||||
|
||||
|
||||
.collapsable {
|
||||
.collapsible {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height .5s ease-out;
|
||||
}
|
||||
|
||||
.collapsable.expand {
|
||||
.collapsible.expand {
|
||||
max-height: 100vh;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ export default function AddNewCourse() {
|
||||
<div>
|
||||
<button onClick={() => setShowForm(true)}>Add New Course</button>
|
||||
|
||||
<div className={" collapsable " + (showForm && "expand")}>
|
||||
<div className={" collapsible " + (showForm && "expand")}>
|
||||
<div className="border rounded-md p-3 m-3">
|
||||
<SuspenseAndErrorHandling>
|
||||
{showForm && <NewCourseForm />}
|
||||
|
||||
Reference in New Issue
Block a user