Skip to content

Commit

Permalink
Feat/differ between multiview preset and layout (#20)
Browse files Browse the repository at this point in the history
* feat: add management lock

* fix: remove left-over file, has been renamed

* Feat/thumbnail fetch (#14)

* feat: add additional filtering

* fix: handle active + source filter, reduce code

* fix: allow multiple source type selection

* fix: linting

* fixup!

* feat: sorting ui

* fix: add ingest type to database

* feat: add sort based on lastConnected

* fix: remove duplicate handleSorting call

* fixup!

* fix: add date to source card

* fixup!

* fix: add status-not-gone check

* fix: linting error

* fix: remove unused function

* feat: updated to add additional multiviewers in the production-output-modal

* feat: updated the functions on the production-page to handle a multiview-array

* fix: changed the interface to have multiview as array

* feat: updated to handle multiview-array when fetching server and api

* fix: updated to stream-handling, not comfortable with the structure of this part

* fix: updated to handle multiview-arr

* feat: not possible to add output to same port, will cause visible error

* fix: changed find to filter and maped through the results

* fix: removed dev-logs

* fix: correct filtering

* fix: lint test fail

* fix: changed to a some-check instead of a map

* fix: multiview-arr does individual fetch for all mvs and creates unique ids for each

* fix: updated ts-error

* fix: adding and removing source from active production is working again

* fix: added duplicate-check whenever multiviews-arr update and minor fixes

* fix: updated multiview-arr-interface to be called multiviews instead of multiview, and minor fixes

* fix: bug solve for incorrect gone assignment

* fix: some cleanups

* style: redesign SourceListItem Thumbnails

* feat: imageComponent and sourceListing cleanup

* feat: editView always shows same image as listing thumbnail

* feat: general sourceList component and GlobalContext

* fix: bad main merge

* fix: lint

* chore: add refresh images to translate and make modal z-index 50

* fix: use translate for refresh thumbnails and delete duplicated code from merge

* fix: remove another duplicated line

---------

Co-authored-by: Saelmala <[email protected]>
Co-authored-by: malmen237 <[email protected]>
Co-authored-by: Linda Malm <[email protected]>

* feat: add management lock

* fix: use global context instead of state

* fix: remove duplicates

* Feat/thumbnail fetch (#14)

* feat: add additional filtering

* fix: handle active + source filter, reduce code

* fix: allow multiple source type selection

* fix: linting

* fixup!

* feat: sorting ui

* fix: add ingest type to database

* feat: add sort based on lastConnected

* fix: remove duplicate handleSorting call

* fixup!

* fix: add date to source card

* fixup!

* fix: add status-not-gone check

* fix: linting error

* fix: remove unused function

* feat: updated to add additional multiviewers in the production-output-modal

* feat: updated the functions on the production-page to handle a multiview-array

* fix: changed the interface to have multiview as array

* feat: updated to handle multiview-array when fetching server and api

* fix: updated to stream-handling, not comfortable with the structure of this part

* fix: updated to handle multiview-arr

* feat: not possible to add output to same port, will cause visible error

* fix: changed find to filter and maped through the results

* fix: removed dev-logs

* fix: correct filtering

* fix: lint test fail

* fix: changed to a some-check instead of a map

* fix: multiview-arr does individual fetch for all mvs and creates unique ids for each

* fix: updated ts-error

* fix: adding and removing source from active production is working again

* fix: added duplicate-check whenever multiviews-arr update and minor fixes

* fix: updated multiview-arr-interface to be called multiviews instead of multiview, and minor fixes

* fix: bug solve for incorrect gone assignment

* fix: some cleanups

* style: redesign SourceListItem Thumbnails

* feat: imageComponent and sourceListing cleanup

* feat: editView always shows same image as listing thumbnail

* feat: general sourceList component and GlobalContext

* fix: bad main merge

* fix: lint

* chore: add refresh images to translate and make modal z-index 50

* fix: use translate for refresh thumbnails and delete duplicated code from merge

* fix: remove another duplicated line

---------

Co-authored-by: Saelmala <[email protected]>
Co-authored-by: malmen237 <[email protected]>
Co-authored-by: Linda Malm <[email protected]>

* fix: errors after conflict solving

* fix: build error

* fix: remove leftover file, unused import

* fix: update lock

* Feat/specify multiview layout when doing production-config(#16)

* feat: added another mv-preset and updated code to be arr instead of single-object

* feat: added optional style to be added to the options-dropdown

* feat: first draft of a multiview-layout setting

* feat: possible to create new layouts as multiview-previews and add it to productions

* feat: added feedback-streams to input-choice for multiviewer-layout

* fix: removed unnecessary undefined

* fix: when added a new layout it will be chosen in output-form on save

* feat: preview and program is now selectable and restructured the way options handle value

* feat: separated db-preset into db-preset and db-layout - 'multiview-preset' and 'multiviews'

* fix: a folder had accidentily been made as a file

* feat: resolved the remaining issues, so preset is turned into a layout and saved in production

* fix: resolved rebase-conflicts

* fix: updates due to feedback and some label-fixes

---------

Co-authored-by: Saelmala <[email protected]>
Co-authored-by: Lucas Maupin <[email protected]>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent 5ae889e commit 78ea35d
Show file tree
Hide file tree
Showing 41 changed files with 710 additions and 421 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/api/manager/multiview-presets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ObjectId, WithId } from 'mongodb';
import { MultiviewPreset } from '../../interfaces/preset';
import { getDatabase } from '../mongoClient/dbClient';

export async function getMultiviewPresets(): Promise<MultiviewPreset[]> {
const db = await getDatabase();
return await db
.collection<MultiviewPreset>('multiview-presets')
.find({})
.toArray();
}

export async function getMultiviewPreset(
id: string
): Promise<WithId<MultiviewPreset>> {
const db = await getDatabase();
return (await db
.collection<MultiviewPreset>('multiview-presets')
.findOne({ _id: new ObjectId(id) })) as WithId<MultiviewPreset>;
}

// TODO Add this when possibility to update and add mv-presets are added
// export async function putMultiviewPreset(
// newMultiviewPreset: MultiviewPreset
// ): Promise<void> {
// const db = await getDatabase();
// await db
// .collection('multiview-presets')
// .insertOne({ ...newMultiviewPreset, _id: new ObjectId() });
// }
38 changes: 38 additions & 0 deletions src/api/manager/multiviews.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ObjectId, WithId } from 'mongodb';
import { MultiviewPreset } from '../../interfaces/preset';
import { getDatabase } from '../mongoClient/dbClient';

export async function getMultiviewLayouts(): Promise<MultiviewPreset[]> {
const db = await getDatabase();
return await db.collection<MultiviewPreset>('multiviews').find({}).toArray();
}

export async function getMultiviewLayout(
id: string
): Promise<WithId<MultiviewPreset>> {
const db = await getDatabase();
return (await db
.collection<MultiviewPreset>('multiviews')
.findOne({ _id: new ObjectId(id) })) as WithId<MultiviewPreset>;
}

export async function putMultiviewLayout(
newMultiviewLayout: MultiviewPreset
): Promise<void> {
const db = await getDatabase();
const collection = db.collection('multiviews');
const editLayout = await collection.findOne({
name: newMultiviewLayout.name
});
const newMultiviewLayoutWithoutID = { ...newMultiviewLayout };
delete newMultiviewLayoutWithoutID._id;

if (editLayout) {
await collection.updateOne(
{ name: newMultiviewLayout.name },
{ $set: { ...newMultiviewLayoutWithoutID } }
);
} else {
await collection.insertOne({ ...newMultiviewLayout, _id: new ObjectId() });
}
}
27 changes: 2 additions & 25 deletions src/api/manager/presets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ObjectId, WithId } from 'mongodb';
import { MultiviewPreset, PresetWithId } from '../../interfaces/preset';
import { ObjectId } from 'mongodb';
import { PresetWithId } from '../../interfaces/preset';
import { getDatabase } from '../mongoClient/dbClient';

export async function getPresets(): Promise<PresetWithId[]> {
Expand All @@ -14,29 +14,6 @@ export async function getPresetByid(id: string): Promise<PresetWithId> {
.findOne({ _id: new ObjectId(id) })) as PresetWithId;
}

export async function getMultiviewPresets(): Promise<MultiviewPreset[]> {
const db = await getDatabase();
return await db.collection<MultiviewPreset>('multiviews').find({}).toArray();
}

export async function getMultiviewPreset(
id: string
): Promise<WithId<MultiviewPreset>> {
const db = await getDatabase();
return (await db
.collection<MultiviewPreset>('multiviews')
.findOne({ _id: new ObjectId(id) })) as WithId<MultiviewPreset>;
}

export async function putMultiviewPreset(
newMultiviewPreset: MultiviewPreset
): Promise<void> {
const db = await getDatabase();
await db
.collection('multiviews')
.insertOne({ ...newMultiviewPreset, _id: new ObjectId() });
}

export async function putPreset(
id: string,
preset: PresetWithId
Expand Down
10 changes: 8 additions & 2 deletions src/api/mongoClient/dbClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ async function bootstrapDbCollections(db: Db) {
await migratePresets(db);
}

const multiviews = await db.collection('multiviews').countDocuments();
const multiviews = await db
.collection('multiview-presets')
.countDocuments();
if (multiviews === 0) {
Log().info('Bootstrapping database with default multiview');

await db.collection('multiviews').insertMany(defaultMultiview);
await db.collection('multiview-presets').insertMany(defaultMultiview);
await db.collection('multiviews').insertOne({
...defaultMultiview[0],
name: 'Default - ' + defaultMultiview[0].name
});
} else {
await migrateMultiviewPresets(db);
}
Expand Down
18 changes: 10 additions & 8 deletions src/api/mongoClient/dbMigrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function migratePresets(db: Db) {

export async function migrateMultiviewPresets(db: Db) {
const multiviewPresets = await db
.collection<MultiviewPreset>('multiviews')
.collection<MultiviewPreset>('multiview-presets')
.find({})
.toArray();
for (const preset of multiviewPresets) {
Expand All @@ -114,13 +114,15 @@ export async function migrateMultiviewPresets(db: Db) {
`Upgrading multiview preset '${migratedPreset.name}' with new SRT output settings`
);
const { _id, ...rest } = migratedPreset;
await db.collection<MultiviewPreset>('multiviews').findOneAndReplace(
{ _id: new ObjectId(_id) },
{
...rest
},
{ returnDocument: 'after' }
);
await db
.collection<MultiviewPreset>('multiview-presets')
.findOneAndReplace(
{ _id: new ObjectId(_id) },
{
...rest
},
{ returnDocument: 'after' }
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/mongoClient/dbOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function overrideMultiviewPreset(
break;
}
const { _id, ...rest } = multiviewPreset;
await db.collection<MultiviewPreset>('multiviews').findOneAndReplace(
await db.collection<MultiviewPreset>('multiview-presets').findOneAndReplace(
{ _id: new ObjectId(_id) },
{
...rest
Expand Down Expand Up @@ -131,7 +131,7 @@ export async function applyPresetOverrides(db: Db, overrideString: string) {
}
} else if (override.type === 'multiview') {
const multiviewPreset = await db
.collection<MultiviewPreset>('multiviews')
.collection<MultiviewPreset>('multiview-presets')
.findOne({ name: override.name });
if (multiviewPreset) {
await overrideMultiviewPreset(db, multiviewPreset, override);
Expand Down
22 changes: 22 additions & 0 deletions src/app/api/manager/multiview-presets/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NextRequest, NextResponse } from 'next/server';
import { Params } from 'next/dist/shared/lib/router/utils/route-matcher';
import { getMultiviewPreset } from '../../../../../api/manager/multiview-presets';
import { isAuthenticated } from '../../../../../api/manager/auth';

export async function GET(
request: NextRequest,
{ params }: { params: Params }
): Promise<NextResponse> {
if (!(await isAuthenticated())) {
return new NextResponse(`Not Authorized!`, {
status: 403
});
}
try {
return NextResponse.json(await getMultiviewPreset(params.id));
} catch (e) {
return new NextResponse(JSON.stringify(e), {
status: 500
});
}
}
48 changes: 48 additions & 0 deletions src/app/api/manager/multiview-presets/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { NextRequest, NextResponse } from 'next/server';
import { isAuthenticated } from '../../../../api/manager/auth';
import {
getMultiviewPresets
// TODO Add this when possibility to update and add mv-presets are added
// putMultiviewPreset
} from '../../../../api/manager/multiview-presets';
// TODO Add this when possibility to update and add mv-presets are added
// import { Log } from '../../../../api/logger';
// import { MultiviewPreset } from '../../../../interfaces/preset';

export async function GET(request: NextRequest): Promise<NextResponse> {
if (!(await isAuthenticated())) {
return new NextResponse(`Not Authorized!`, {
status: 403
});
}

try {
return NextResponse.json(await getMultiviewPresets());
} catch (e) {
return new NextResponse(JSON.stringify(e), {
status: 500
});
}
}

// TODO Add this when possibility to update and add mv-presets are added
// export async function PUT(request: NextRequest): Promise<NextResponse> {
// if (!(await isAuthenticated())) {
// return new NextResponse(`Not Authorized!`, {
// status: 403
// });
// }

// try {
// const body = (await request.json()) as MultiviewPreset;
// const newMultiviewPreset = await putMultiviewPreset(body);
// return await new NextResponse(JSON.stringify(newMultiviewPreset), {
// status: 200
// });
// } catch (error) {
// Log().warn('Could not update preset', error);
// return new NextResponse(`Error searching DB! Error: ${error}`, {
// status: 500
// });
// }
// }
14 changes: 8 additions & 6 deletions src/app/api/manager/multiviews/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { NextRequest, NextResponse } from 'next/server';
import { isAuthenticated } from '../../../../../api/manager/auth';
import { getMultiviewPreset } from '../../../../../api/manager/presets';
import { Params } from 'next/dist/shared/lib/router/utils/route-matcher';
import { updateMultiviewForPipeline } from '../../../../../api/ateliereLive/pipelines/multiviews/multiviews';
import { MultiviewViews } from '../../../../../interfaces/multiview';
import { getMultiviewLayout } from '../../../../../api/manager/multiviews';

type PutMultiviewRequest = {
pipelineId: string;
multiviews: MultiviewViews[];
};

export async function GET(
request: NextRequest,
Expand All @@ -15,17 +20,14 @@ export async function GET(
});
}
try {
return NextResponse.json(await getMultiviewPreset(params.id));
return NextResponse.json(await getMultiviewLayout(params.id));
} catch (e) {
return new NextResponse(JSON.stringify(e), {
status: 500
});
}
}
type PutMultiviewRequest = {
pipelineId: string;
multiviews: MultiviewViews[];
};

export async function PUT(
request: NextRequest,
{ params }: { params: Params }
Expand Down
30 changes: 28 additions & 2 deletions src/app/api/manager/multiviews/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { NextRequest, NextResponse } from 'next/server';
import { getMultiviewPresets } from '../../../../api/manager/presets';
import { isAuthenticated } from '../../../../api/manager/auth';
import {
getMultiviewLayouts,
putMultiviewLayout
} from '../../../../api/manager/multiviews';
import { MultiviewPreset } from '../../../../interfaces/preset';
import { Log } from '../../../../api/logger';

export async function GET(request: NextRequest): Promise<NextResponse> {
if (!(await isAuthenticated())) {
Expand All @@ -10,10 +15,31 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
}

try {
return NextResponse.json(await getMultiviewPresets());
return NextResponse.json(await getMultiviewLayouts());
} catch (e) {
return new NextResponse(JSON.stringify(e), {
status: 500
});
}
}

export async function PUT(request: NextRequest): Promise<NextResponse> {
if (!(await isAuthenticated())) {
return new NextResponse(`Not Authorized!`, {
status: 403
});
}

try {
const body = (await request.json()) as MultiviewPreset;
const newMultiviewLayout = await putMultiviewLayout(body);
return await new NextResponse(JSON.stringify(newMultiviewLayout), {
status: 200
});
} catch (error) {
Log().warn('Could not update layout', error);
return new NextResponse(`Error searching DB! Error: ${error}`, {
status: 500
});
}
}
28 changes: 1 addition & 27 deletions src/app/api/manager/presets/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import {
getPresets,
putMultiviewPreset
} from '../../../../api/manager/presets';
import { getPresets } from '../../../../api/manager/presets';
import { isAuthenticated } from '../../../../api/manager/auth';
import { Log } from '../../../../api/logger';
import { MultiviewPreset } from '../../../../interfaces/preset';

export async function GET(request: NextRequest): Promise<NextResponse> {
if (!(await isAuthenticated())) {
Expand All @@ -22,24 +17,3 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
});
}
}

export async function PUT(request: NextRequest): Promise<NextResponse> {
if (!(await isAuthenticated())) {
return new NextResponse(`Not Authorized!`, {
status: 403
});
}

try {
const body = (await request.json()) as MultiviewPreset;
const newMultiviewPreset = await putMultiviewPreset(body);
return await new NextResponse(JSON.stringify(newMultiviewPreset), {
status: 200
});
} catch (error) {
Log().warn('Could not update preset', error);
return new NextResponse(`Error searching DB! Error: ${error}`, {
status: 500
});
}
}
Loading

0 comments on commit 78ea35d

Please sign in to comment.