Skip to content

Commit

Permalink
:)
Browse files Browse the repository at this point in the history
  • Loading branch information
mono424 committed Sep 10, 2023
1 parent b224222 commit 0a65347
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
14 changes: 3 additions & 11 deletions web/ts/api/admin-lecture-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { del, get, post, put } from "../utilities/fetch-wrappers";
import { StatusCodes } from "http-status-codes";
import {Delete, patchData, postData, postFormData, putData, uploadFile, UploadFileListener} from "../global";
import { Delete, patchData, postData, postFormData, putData, uploadFile, UploadFileListener } from "../global";

export interface UpdateLectureMetaRequest {
name?: string;
Expand Down Expand Up @@ -248,11 +248,7 @@ export const AdminLectureList = {
file: File,
listener: UploadFileListener = {},
) => {
return await uploadFile(
`/api/stream/${lectureId}/files?type=file`,
file,
listener,
);
return await uploadFile(`/api/stream/${lectureId}/files?type=file`, file, listener);
},

/**
Expand All @@ -273,11 +269,7 @@ export const AdminLectureList = {
return postFormData(`/api/stream/${lectureId}/files?type=url`, vodUploadFormData, listener);
},

deleteAttachment: async (
courseId: number,
lectureId: number,
attachmentId: number,
) => {
deleteAttachment: async (courseId: number, lectureId: number, attachmentId: number) => {
return Delete(`/api/stream/${lectureId}/files/${attachmentId}`);
},

Expand Down
4 changes: 2 additions & 2 deletions web/ts/change-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ export function ignoreKeys<T>(list: string[]): LectureComparator<T> {
return false;
}
return null;
}
}
};
}
16 changes: 8 additions & 8 deletions web/ts/data-store/admin-lecture-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StreamableMapProvider } from "./provider";
import {AdminLectureList, Lecture, LectureFile, UpdateLectureMetaRequest} from "../api/admin-lecture-list";
import { AdminLectureList, Lecture, LectureFile, UpdateLectureMetaRequest } from "../api/admin-lecture-list";
import { FileType } from "../edit-course";
import { UploadFileListener } from "../global";

Expand Down Expand Up @@ -106,34 +106,34 @@ export class AdminLectureListProvider extends StreamableMapProvider<number, Lect
const newFile = new LectureFile({
id: JSON.parse(res.responseText),
fileType: 2,
friendlyName: file.name
friendlyName: file.name,
});

this.data[courseId] = (await this.getData(courseId)).map((s) => {
if (s.lectureId === lectureId) {
return {
...s,
files: [...s.files, newFile]
files: [...s.files, newFile],
};
}
return s;
});
await this.triggerUpdate(courseId);
}

async uploadAttachmentUrl(courseId: number, lectureId: number, url: String) {
async uploadAttachmentUrl(courseId: number, lectureId: number, url: string) {
const res = await AdminLectureList.uploadAttachmentUrl(courseId, lectureId, url);
const newFile = new LectureFile({
id: JSON.parse(res.responseText),
fileType: 2,
friendlyName: url.substring(url.lastIndexOf("/") + 1) }
);
friendlyName: url.substring(url.lastIndexOf("/") + 1),
});

this.data[courseId] = (await this.getData(courseId)).map((s) => {
if (s.lectureId === lectureId) {
return {
...s,
files: [...s.files, newFile]
files: [...s.files, newFile],
};
}
return s;
Expand All @@ -148,7 +148,7 @@ export class AdminLectureListProvider extends StreamableMapProvider<number, Lect
if (s.lectureId === lectureId) {
return {
...s,
files: [...s.files.filter(((a)=> a.id !== attachmentId))],
files: [...s.files.filter((a) => a.id !== attachmentId)],
};
}
return s;
Expand Down
8 changes: 2 additions & 6 deletions web/ts/edit-course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
LectureVideoTypePres,
LectureVideoTypes,
} from "./api/admin-lecture-list";
import {ChangeSet, ignoreKeys} from "./change-set";
import { ChangeSet, ignoreKeys } from "./change-set";
import { AlpineComponent } from "./components/alpine-component";

export enum UIEditMode {
Expand Down Expand Up @@ -188,11 +188,7 @@ export function lectureEditor(lecture: Lecture): AlpineComponent {
},

deleteAttachment(id: number) {
DataStore.adminLectureList.deleteAttachment(
this.lectureData.courseId,
this.lectureData.lectureId,
id,
);
DataStore.adminLectureList.deleteAttachment(this.lectureData.courseId, this.lectureData.lectureId, id);
},

/**
Expand Down

0 comments on commit 0a65347

Please sign in to comment.