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

Add configurable series selection to upload step #1143

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ further below for information on that.
# Default: 'required'.
#presenterField = 'required'

# Specifies if the series field should be 'hidden', 'optional' or 'required'.
# Default: 'optional'.
#seriesField = 'optional'


[recording]
# A list of preferred MIME types used by the media recorder. Studio uses the
# first MIME type in that list for which `MediaRecorder.isTypeSupported` returns
Expand Down
274 changes: 186 additions & 88 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"react-hotkeys-hook": "^4.4.1",
"react-i18next": "^13.2.2",
"react-icons": "^4.11.0",
"react-select": "^5.7.7",
"use-resize-observer": "^9.1.0",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
"complete-explanation": "Ihre Aufzeichnung wird nun von Opencast verarbeitet.",
"label-presenter": "Vortragende:r",
"label-title": "Titel",
"label-series": "Serie",
"series-placeholder": "Serie auswählen",
"series-none": "Keine Serien",
"series-unknown": "Unbekannte Serie",
"series-fetch-error": "Konnte verfügbare Serien nicht laden.",
"series-connection-settings-hint": "Prüfen Sie die Verbindungseinstellungen.",
"series-loading": "Lädt...",
"upload-network-error": "Upload aufgrund eines Netzwerkfehler fehlgeschlagen. Bitte prüfen Sie Ihre Internetverbindung. Weitere mögliche Ursachen: Der Opencast-Server ist nicht erreichbar oder falsch konfiguriert.",
"upload-invalid-response": "Upload fehlgeschlagen: Unerwartete Antwort vom Opencast-Server.",
"upload-not-authorized": "Upload fehlgeschlagen: Sie sind nicht berechtigt, hochzuladen.",
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
"complete-explanation": "Your recording will now be processed by Opencast.",
"label-presenter": "Presenter",
"label-title": "Title",
"label-series": "Series",
"series-placeholder": "Select a series",
"series-none": "No series",
"series-unknown": "Unknown Series",
"series-fetch-error": "Could not load available series.",
"series-connection-settings-hint": "Check connection settings below.",
"series-loading": "Loading...",
"upload-network-error": "Upload failed: network error. Please check your internet connection! Other potential causes: the Opencast server is not reachable or misconfigured.",
"upload-invalid-response": "Upload failed: an unexpected response was returned.",
"upload-not-authorized": "Upload failed: it seems like you are not authorized to upload.",
Expand Down
36 changes: 32 additions & 4 deletions src/opencast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,32 @@ export class Opencast {
return self;
}

/**
* Requests series from Opencast that the current user has write access to.
* Returns a map from series ID to title, or "error" if anything goes wrong.
*/
async getSeries(): Promise<Map<string, string>> {
if (this.#serverUrl === null) {
throw new Error("Connection not configured");
}

const series = await this.jsonRequest("studio-api/series.json");

const isProperForm = (obj: object | null): obj is { id: string; title: string }[] => (
Array.isArray(obj) && obj.every(s => typeof s === "object"
&& "id" in s
&& "title" in s
&& typeof s.id === "string"
&& typeof s.title === "string"
)
);
if (!isProperForm(series)) {
throw new InvalidJson("unexpected result from series API", null);
}

return new Map(series.map(s => [s.id, s.title]));
}

/** Updates the global OC instance from `this` to `newInstance`. */
setGlobalInstance(newInstance: Opencast) {
if (!this.updateGlobalOc) {
Expand Down Expand Up @@ -348,7 +374,7 @@ export class Opencast {
* potentially changed the `state`.
*/
async upload({
recordings, title, presenter, start, end, uploadSettings, startTime, endTime, onProgress,
recordings, title, presenter, series, start, end, uploadSettings, startTime, endTime, onProgress,
}: {
recordings: Recording[];
title: string;
Expand All @@ -357,6 +383,7 @@ export class Opencast {
end: number | null;
startTime: Date;
endTime: Date;
series: string | null;
uploadSettings: Settings["upload"];
onProgress: (p: number) => void;
}): Promise<UploadState> {
Expand Down Expand Up @@ -384,7 +411,7 @@ export class Opencast {

// Add metadata to media package
mediaPackage = await this.addDcCatalog(
{ mediaPackage, uploadSettings, title, presenter, startTime, endTime }
{ mediaPackage, uploadSettings, title, presenter, series, startTime, endTime }
);

// Set appropriate ACL unless the configuration says no.
Expand Down Expand Up @@ -440,15 +467,16 @@ export class Opencast {
* Adds the DC Catalog with the given metadata to the current ingest process
* via `ingest/addDCCatalog`. Do not call this method outside of `upload`!
*/
async addDcCatalog({ mediaPackage, uploadSettings, ...rest }: {
async addDcCatalog({ mediaPackage, uploadSettings, series, ...rest }: {
mediaPackage: string;
title: string;
presenter: string;
series: string | null;
uploadSettings: Settings["upload"];
startTime: Date;
endTime: Date;
}) {
const seriesId = uploadSettings?.seriesId;
const seriesId = series ? series : uploadSettings?.seriesId;
const template = uploadSettings?.dcc || DEFAULT_DCC_TEMPLATE;
const dcc = this.constructDcc(template, { ...rest, seriesId });

Expand Down
2 changes: 2 additions & 0 deletions src/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type Settings = {
dcc?: string;
titleField?: FormFieldState;
presenterField?: FormFieldState;
seriesField?: FormFieldState;
};
recording?: {
videoBitrate?: number;
Expand Down Expand Up @@ -582,6 +583,7 @@ const SCHEMA = {
dcc: types.string,
titleField: metaDataField,
presenterField: metaDataField,
seriesField: metaDataField,
},
recording: {
videoBitrate: types.positiveInteger,
Expand Down
Loading