Skip to content

Commit 92819fd

Browse files
authored
Merge pull request #120 from nebulabroadcast/playout-plugins-in-web-interface
Playout plugins in the web interface
2 parents fe99dc6 + aacd377 commit 92819fd

File tree

30 files changed

+313
-93
lines changed

30 files changed

+313
-93
lines changed

backend/api/scheduler/scheduler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .models import SchedulerResponseModel
66
from .utils import delete_events, get_event_at_time, get_events_in_range
77

8+
89
async def scheduler(
910
id_channel: int,
1011
date: str | None = None,

backend/nebula/helpers/coalescer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
```
1818
async def fetch_data(item_id: int):
1919
print(f"Fetching data for {item_id}...")
20-
await asyncio.sleep(2) # Simulate network call
20+
await asyncio.sleep(2) # Simulate network call
2121
return f"Data for {item_id}"
2222
23+
2324
coalescer = Coalescer()
2425
2526
# These calls will be coalesced if made close together
2627
2728
task1 = asyncio.create_task(coalescer(fetch_data, item_id=1))
28-
task2 = asyncio.create_task(coalescer(fetch_data, item_id=1)) # Will use task1's future
29-
task3 = asyncio.create_task(coalescer(fetch_data, item_id=2)) # New actual call
29+
task2 = asyncio.create_task(coalescer(fetch_data, item_id=1)) # Will use task1's future
30+
task3 = asyncio.create_task(coalescer(fetch_data, item_id=2)) # New actual call
3031
3132
result1 = await task1
3233
result2 = await task2

backend/nebula/settings/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ class SSOProvider(SettingsModel):
124124
Field(
125125
title="Entrypoint",
126126
description="URL to the SSO provider configuration endpoint",
127-
examples=["https://iam.example.com/realms/nebula/.well-known/openid-configuration"],
127+
examples=[
128+
"https://iam.example.com/realms/nebula/.well-known/openid-configuration"
129+
],
128130
),
129131
] = None
130132

frontend/src/components/Layout.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ const Navbar = styled.nav`
5252
align-items: center;
5353
}
5454
`;
55+
5556
const Spacer = styled.div`
5657
flex-grow: 1;
5758
display: flex;
5859
align-items: center;
5960
justify-content: center;
6061
`;
6162

63+
const Section = styled.section`
64+
display: flex;
65+
padding: 12px;
66+
border-radius: 5px;
67+
background-color: var(--color-surface-02);
68+
border: 1px solid transparent;
69+
`;
70+
6271
const ToolbarSeparator = styled.div`
6372
border-left: 1px solid ${getTheme().colors.surface04};
6473
height: 100%;
@@ -79,4 +88,4 @@ const PanelHeader = styled.h2`
7988
gap: 8px;
8089
`;
8190

82-
export { Navbar, Spacer, ToolbarSeparator, PanelHeader };
91+
export { Navbar, Spacer, ToolbarSeparator, PanelHeader, Section };

frontend/src/components/Select.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const Select = ({
103103
);
104104
}, [dialogVisible]);
105105

106-
if (selectionMode === 'single' && options.length < 10) {
106+
if (selectionMode === 'single' && options.length < 20) {
107107
return (
108108
<StyledHTMLSelect
109109
value={value || ''}
@@ -112,7 +112,7 @@ const Select = ({
112112
}}
113113
style={style}
114114
>
115-
<option value={null}></option>
115+
<option value={''}></option>
116116
{options.map((option) => (
117117
<option key={option.value} value={option.value}>
118118
{option.title}

frontend/src/components/Timestamp.jsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import styled from 'styled-components';
22

33
import { getTheme } from './theme';
4+
import { dateToDateString } from '/src/utils';
5+
import { dateToTimeString } from '/src/utils';
46

57
const TimestampWrapper = styled.div`
68
display: flex;
@@ -18,18 +20,8 @@ const TimestampWrapper = styled.div`
1820
const Timestamp = ({ timestamp, mode, ...props }) => {
1921
if (!timestamp) return <></>;
2022
const localDateTime = new Date(timestamp * 1000);
21-
22-
const yy = localDateTime.getFullYear();
23-
const mm = localDateTime.getMonth() + 1; // Months are zero-based
24-
const dd = localDateTime.getDate();
25-
26-
const hh = localDateTime.getHours();
27-
const min = localDateTime.getMinutes();
28-
const ss = localDateTime.getSeconds();
29-
30-
const pad = (n) => String(n).padStart(2, '0');
31-
const dateStr = `${yy}-${pad(mm)}-${pad(dd)}`;
32-
const timeStr = `${hh}:${pad(min)}:${pad(ss)}`;
23+
const dateStr = dateToDateString(localDateTime);
24+
const timeStr = dateToTimeString(localDateTime);
3325

3426
return (
3527
<TimestampWrapper {...props}>

frontend/src/components/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ export { default as Timestamp } from './Timestamp';
2424

2525
export { Form, FormRow } from './Form';
2626
export { Loader, LoaderWrapper } from './Loader';
27-
export { Navbar, Spacer, ToolbarSeparator, PanelHeader } from './Layout';
27+
export { Navbar, Spacer, ToolbarSeparator, PanelHeader, Section } from './Layout';

frontend/src/containers/Browser/Browser.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { debounce } from 'lodash';
55
import clsx from 'clsx';
66

77
import nebula from '/src/nebula';
8-
import { Table } from '/src/components';
8+
import { Table, Section } from '/src/components';
99
import Pagination from '/src/containers/Pagination';
1010
import { setCurrentView, setSelectedAssets, setFocusedAsset } from '/src/actions';
1111
import { useLocalStorage, useDialog } from '/src/hooks';
@@ -269,7 +269,7 @@ const BrowserTable = ({ isDragging }) => {
269269

270270
return (
271271
<>
272-
<section className="grow">
272+
<Section className="grow">
273273
<Table
274274
data={data}
275275
columns={columns}
@@ -289,7 +289,7 @@ const BrowserTable = ({ isDragging }) => {
289289
setSortDirection(sortDirection);
290290
}}
291291
/>
292-
</section>
292+
</Section>
293293
<Pagination page={page} setPage={setPage} hasMore={hasMore} />
294294
</>
295295
);

frontend/src/containers/Calendar/Calendar.jsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import drawMarks from './drawMarks';
1313
import drawEvents from './drawEvents';
1414

1515
import { useLocalStorage } from '/src/hooks';
16+
import { dateToDateString } from '/src/utils';
1617

1718
const CalendarCanvas = styled.canvas`
1819
background-color: #24202e;
@@ -91,7 +92,7 @@ const Calendar = ({
9192
return { x, y };
9293
};
9394

94-
const eventAtPos = () => {
95+
const eventAtPos = useCallback(() => {
9596
if (!cursorTime.current) return null;
9697
const currentTs = cursorTime.current.getTime() / 1000;
9798

@@ -127,7 +128,7 @@ const Calendar = ({
127128
}
128129
// no valid event under the cursor
129130
return null;
130-
};
131+
}, [events, dayStartOffsetSeconds]);
131132

132133
// Update drawParams reference
133134

@@ -139,6 +140,7 @@ const Calendar = ({
139140
drawParams.current.pos2time = pos2time;
140141
drawParams.current.time2pos = time2pos;
141142
drawParams.current.startTime = startTime;
143+
//eslint-disable-next-line react-hooks/exhaustive-deps
142144
}, [drawParams.current, dayRef.current, zoom, startTime]);
143145

144146
//
@@ -204,6 +206,7 @@ const Calendar = ({
204206

205207
useEffect(() => {
206208
drawCalendar();
209+
//eslint-disable-next-line react-hooks/exhaustive-deps
207210
}, [cursorTime.current, events]);
208211

209212
// Event handlers
@@ -256,7 +259,8 @@ const Calendar = ({
256259
const basePath = '/mam/rundown';
257260
const searchParams = new URLSearchParams(location.search);
258261
const startTs = event.start - dayStartOffsetSeconds;
259-
const targetDate = new Date(startTs * 1000).toISOString().slice(0, 10);
262+
const localDateTime = new Date(startTs * 1000);
263+
const targetDate = dateToDateString(localDateTime);
260264
searchParams.set('date', targetDate);
261265
const hash = `#${event.id}`;
262266
const fullPath = `${basePath}?${searchParams.toString()}${hash}`;
@@ -330,6 +334,7 @@ const Calendar = ({
330334
calendarRef.current.removeEventListener('mousemove', onMouseMove);
331335
document.removeEventListener('mouseup', onMouseUp);
332336
};
337+
//eslint-disable-next-line react-hooks/exhaustive-deps
333338
}, [calendarRef.current, startTime]);
334339

335340
//
@@ -408,7 +413,7 @@ const Calendar = ({
408413
const dayStartTs = weekStartTs + i * 24 * 3600;
409414
// get date in YYYY-MM-DD format
410415
const jsDate = new Date(dayStartTs * 1000);
411-
const date = jsDate.toISOString().slice(0, 10);
416+
const date = dateToDateString(jsDate);
412417
const dayName = jsDate.toLocaleDateString(nebula.locale, {
413418
day: 'numeric',
414419
month: 'short',
@@ -433,12 +438,12 @@ const Calendar = ({
433438
});
434439
}
435440
return dayStyles;
436-
}, [startTime]);
441+
}, [startTime, dayStartOffsetSeconds]);
437442

438443
// yes. this is very ugly, but i need that reference to one day
439444
// to get its width
440445
return (
441-
<CalendarWrapper scrollbarWidth={scrollbarWidth} clockWidth={CLOCK_WIDTH}>
446+
<CalendarWrapper scrollbarwidth={scrollbarWidth} clockwidth={CLOCK_WIDTH}>
442447
<div className="calendar-header">
443448
{dstyles.map((d, i) => {
444449
const r = i === 0 ? dayRef : null;

frontend/src/containers/Calendar/CalendarWrapper.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const CalendarWrapper = styled.div`
1212
user-drag: none;
1313
display: flex;
1414
margin-right: ${(props) =>
15-
props.scrollbarWidth}px; /* Dynamic padding to account for scrollbar */
15+
props.scrollbarwidth}px; /* Dynamic padding to account for scrollbar */
1616
margin-left: ${(props) =>
17-
props.clockWidth}px; /* Dynamic padding to account for scrollbar */
17+
props.clockwidth}px; /* Dynamic padding to account for scrollbar */
1818
1919
.calendar-day {
2020
flex: 1;

0 commit comments

Comments
 (0)