diff --git a/web/ts/api/admin-lecture-list.ts b/web/ts/api/admin-lecture-list.ts index acedbde13..185d59ec2 100644 --- a/web/ts/api/admin-lecture-list.ts +++ b/web/ts/api/admin-lecture-list.ts @@ -88,8 +88,8 @@ export type VideoSection = { startMinutes: number; startSeconds: number; - streamID?: number; - fileID?: number; + //Pseudo Fields + key: string; }; export type VideoSectionDelta = { diff --git a/web/ts/api/video-sections.ts b/web/ts/api/video-sections.ts index 9acb866c5..ffd3189c1 100644 --- a/web/ts/api/video-sections.ts +++ b/web/ts/api/video-sections.ts @@ -1,12 +1,5 @@ import { del, get, post, put } from "../utilities/fetch-wrappers"; -export class UpdateVideoSectionRequest { - Description: string; - StartHours: number; - StartMinutes: number; - StartSeconds: number; -} - export type Section = { ID?: number; description: string; @@ -29,16 +22,4 @@ export const VideoSectionAPI = { get: async function (streamId: number): Promise { return get(`/api/stream/${streamId}/sections`); }, - - add: async function (streamId: number, request: object) { - return post(`/api/stream/${streamId}/sections`, request); - }, - - update: function (streamId: number, id: number, request: UpdateVideoSectionRequest) { - return put(`/api/stream/${streamId}/sections/${id}`, request); - }, - - delete: async function (streamId: number, id: number): Promise { - return del(`/api/stream/${streamId}/sections/${id}`); - }, }; diff --git a/web/ts/data-store/video-sections.ts b/web/ts/data-store/video-sections.ts index 446de9c5a..8ca51be9e 100644 --- a/web/ts/data-store/video-sections.ts +++ b/web/ts/data-store/video-sections.ts @@ -1,6 +1,6 @@ import { Time } from "../global"; import { StreamableMapProvider } from "./provider"; -import { Section, UpdateVideoSectionRequest, VideoSectionAPI } from "../api/video-sections"; +import { Section, VideoSectionAPI } from "../api/video-sections"; export class VideoSectionProvider extends StreamableMapProvider { protected async fetcher(streamId: number): Promise { @@ -10,37 +10,4 @@ export class VideoSectionProvider extends StreamableMapProvider { - await VideoSectionAPI.add(streamId, sections); - await this.fetch(streamId, true); - await this.triggerUpdate(streamId); - } - - async delete(streamId: number, sectionId: number) { - await VideoSectionAPI.delete(streamId, sectionId); - this.data[streamId] = (await this.getData(streamId)).filter((s) => s.ID !== sectionId); - } - - async update(streamId: number, sectionId: number, request: UpdateVideoSectionRequest) { - await VideoSectionAPI.update(streamId, sectionId, request); - this.data[streamId] = (await this.getData(streamId)).map((s) => { - if (s.ID === sectionId) { - s = { - ...s, - startHours: request.StartHours, - startMinutes: request.StartMinutes, - startSeconds: request.StartSeconds, - description: request.Description, - friendlyTimestamp: new Time( - request.StartHours, - request.StartMinutes, - request.StartSeconds, - ).toString(), - }; - } - return s; - }); - await this.triggerUpdate(streamId); - } } diff --git a/web/ts/entry/admins.ts b/web/ts/entry/admins.ts index 58e9df699..6b222edaa 100644 --- a/web/ts/entry/admins.ts +++ b/web/ts/entry/admins.ts @@ -14,4 +14,3 @@ export * from "../notification-management"; export * from "../audits"; export * from "../maintenance"; export * from "../change-set"; -export { VideoSectionsAdminController, VideoSectionUpdater } from "../video-sections"; diff --git a/web/ts/entry/video.ts b/web/ts/entry/video.ts index 7d83fb7ff..094fdf963 100644 --- a/web/ts/entry/video.ts +++ b/web/ts/entry/video.ts @@ -2,7 +2,6 @@ export * from "../watch-admin"; export * from "../TUMLiveVjs"; export * from "../watch"; -export * from "../video-sections"; export * from "../splitview"; export * from "../bookmarks"; export * from "../subtitle-search"; diff --git a/web/ts/video-sections.ts b/web/ts/video-sections.ts deleted file mode 100644 index 7d73601e3..000000000 --- a/web/ts/video-sections.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { Time } from "./global"; -import { DataStore } from "./data-store/data-store"; -import { Section, UpdateVideoSectionRequest } from "./api/video-sections"; - -/** - * Admin Page VideoSection Management - * @category admin-page - */ -export class VideoSectionsAdminController { - static initiatedInstances: Map> = new Map< - string, - Promise - >(); - - private readonly streamId: number; - - existingSections: Section[]; - newSections: Section[]; - current: Section; - unsavedChanges: boolean; - - private elem: HTMLElement; - private unsub: () => void; - - constructor(streamId: number) { - this.streamId = streamId; - - this.newSections = []; - this.existingSections = []; - this.unsavedChanges = false; - this.resetCurrent(); - } - - async init(key: string, element: HTMLElement) { - if (VideoSectionsAdminController.initiatedInstances[key]) { - (await VideoSectionsAdminController.initiatedInstances[key]).unsub(); - } - - VideoSectionsAdminController.initiatedInstances[key] = new Promise((resolve) => { - this.elem = element; - const callback = (data) => this.onUpdate(data); - DataStore.videoSections.subscribe(this.streamId, callback).then(() => { - this.unsub = () => DataStore.videoSections.unsubscribe(this.streamId, callback); - resolve(this); - }); - }); - } - - onUpdate(data: Section[]) { - this.existingSections = data; - } - - pushNewSection() { - this.current.friendlyTimestamp = new Time( - this.current.startHours, - this.current.startMinutes, - this.current.startSeconds, - ).toString(); - this.newSections.push({ ...this.current }); - this.resetCurrent(); - this.unsavedChanges = true; - } - - removeNewSection(section: Section) { - this.newSections = this.newSections.filter((s) => s !== section); - this.unsavedChanges = true; - } - - async publishNewSections() { - await DataStore.videoSections.add(this.streamId, this.newSections); - this.newSections = []; - this.unsavedChanges = false; - } - - async removeExistingSection(id: number) { - await DataStore.videoSections.delete(this.streamId, id); - this.existingSections = this.existingSections.filter((s) => s.ID !== id); - } - - currentIsValid(): boolean { - return ( - this.current.description !== "" && - this.current.startHours !== null && - this.current.startHours < 32 && - this.current.startMinutes !== null && - this.current.startMinutes < 60 && - this.current.startSeconds !== null && - this.current.startSeconds < 60 - ); - } - - private resetCurrent() { - this.current = { - description: "", - startHours: 0, - startMinutes: 0, - startSeconds: 0, - streamID: this.streamId, - isCurrent: false, - }; - } -} - -/** - * Admin Page VideoSection Updater - * @category admin-page - */ -export class VideoSectionUpdater { - private readonly streamId: number; - private section: Section; - - request: UpdateVideoSectionRequest; - show: boolean; - - constructor(streamId: number, section: Section) { - this.streamId = streamId; - this.section = section; - this.reset(); - } - - async update() { - await DataStore.videoSections.update(this.streamId, this.section.ID, this.request); - this.show = false; - } - - reset() { - this.request = new UpdateVideoSectionRequest(); - this.request.Description = this.section.description; - this.request.StartHours = this.section.startHours; - this.request.StartMinutes = this.section.startMinutes; - this.request.StartSeconds = this.section.startSeconds; - this.show = false; - } -}