diff --git a/web/ts/api/admin-lecture-list.ts b/web/ts/api/admin-lecture-list.ts index e8bca3d71..9ef78740d 100644 --- a/web/ts/api/admin-lecture-list.ts +++ b/web/ts/api/admin-lecture-list.ts @@ -1,4 +1,13 @@ -import {del, get, patch, post, postFormData, PostFormDataListener, put, uploadFile} from "../utilities/fetch-wrappers"; +import { + del, + get, + patch, + post, + postFormData, + PostFormDataListener, + put, + uploadFile, +} from "../utilities/fetch-wrappers"; import { StatusCodes } from "http-status-codes"; export interface UpdateLectureMetaRequest { @@ -83,11 +92,11 @@ export type VideoSection = { fileID?: number; }; -export function videoSectionTimestamp(a: VideoSection) : number { +export function videoSectionTimestamp(a: VideoSection): number { return a.startHours * 3600 + a.startMinutes * 60 + a.startSeconds; } -export function videoSectionSort(a: VideoSection, b: VideoSection) : number { +export function videoSectionSort(a: VideoSection, b: VideoSection): number { return videoSectionTimestamp(a) - videoSectionTimestamp(b); } @@ -212,7 +221,7 @@ export const AdminLectureList = { * @param courseId * @param lectureId */ - saveSeriesMetadata: async (courseId: number, lectureId: number): Promise => { + saveSeriesMetadata: async (courseId: number, lectureId: number): Promise => { await post(`/api/course/${courseId}/updateLectureSeries/${lectureId}`); }, diff --git a/web/ts/edit-course.ts b/web/ts/edit-course.ts index ec9ab31ad..e71b44053 100644 --- a/web/ts/edit-course.ts +++ b/web/ts/edit-course.ts @@ -8,9 +8,11 @@ import { LectureVideoTypeCam, LectureVideoTypeComb, LectureVideoTypePres, - LectureVideoTypes, VideoSection, videoSectionSort, + LectureVideoTypes, + VideoSection, + videoSectionSort, } from "./api/admin-lecture-list"; -import {ChangeSet, comparatorPipeline, ignoreKeys, singleProperty} from "./change-set"; +import { ChangeSet, comparatorPipeline, ignoreKeys, singleProperty } from "./change-set"; import { AlpineComponent } from "./components/alpine-component"; export enum UIEditMode { @@ -116,11 +118,11 @@ export function lectureEditor(lecture: Lecture): AlpineComponent { init() { const customComparator = comparatorPipeline([ ignoreKeys(["files"]), - singleProperty("videoSections", (a: Lecture, b: Lecture): boolean|null => { + singleProperty("videoSections", (a: Lecture, b: Lecture): boolean | null => { if (a.videoSections.length !== b.videoSections.length) { return true; } - if (a.videoSections.some(({ id }) => !b.videoSections.some(({id: bId}) => id === bId))) { + if (a.videoSections.some(({ id }) => !b.videoSections.some(({ id: bId }) => id === bId))) { return true; } }), @@ -204,16 +206,14 @@ export function lectureEditor(lecture: Lecture): AlpineComponent { }, addSection(section: VideoSection) { - this.changeSet.patch("videoSections", [ - ...this.lectureData.videoSections, - section, - ].sort(videoSectionSort)); + this.changeSet.patch("videoSections", [...this.lectureData.videoSections, section].sort(videoSectionSort)); }, deleteSection(id: number) { - this.changeSet.patch("videoSections", this.lectureData.videoSections.filter( - (s) => s.id !== id, - )); + this.changeSet.patch( + "videoSections", + this.lectureData.videoSections.filter((s) => s.id !== id), + ); }, isValidVideoSection(section: VideoSection): boolean { diff --git a/web/ts/entry/admins.ts b/web/ts/entry/admins.ts index ae5dbcc20..58e9df699 100644 --- a/web/ts/entry/admins.ts +++ b/web/ts/entry/admins.ts @@ -13,5 +13,5 @@ export * from "../courseAdminManagement"; export * from "../notification-management"; export * from "../audits"; export * from "../maintenance"; -export * from "../change-set" +export * from "../change-set"; export { VideoSectionsAdminController, VideoSectionUpdater } from "../video-sections"; diff --git a/web/ts/utilities/fetch-wrappers.ts b/web/ts/utilities/fetch-wrappers.ts index 2ef7da612..0c780409e 100644 --- a/web/ts/utilities/fetch-wrappers.ts +++ b/web/ts/utilities/fetch-wrappers.ts @@ -1,4 +1,4 @@ -import {postFormData} from "../global"; +import { postFormData } from "../global"; /** * Wrapper for Javascript's fetch function for GET @@ -44,7 +44,6 @@ export async function post(url: string, body: object = {}) { }); } - export interface PostFormDataListener { onProgress?: (progress: number) => void; } @@ -56,7 +55,11 @@ export interface PostFormDataListener { * @param {PostFormDataListener} listener attached progress listeners * @return {Promise} */ -export function postFormData(url: string, body: FormData, listener: PostFormDataListener = {}): Promise { +export function postFormData( + url: string, + body: FormData, + listener: PostFormDataListener = {}, +): Promise { const xhr = new XMLHttpRequest(); return new Promise((resolve, reject) => { xhr.onloadend = () => {