mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-08 07:49:12 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c96151fe2f | |||
| 6d79764ffe | |||
| a67dbd8a59 | |||
| 361b6eb875 |
@@ -1,46 +0,0 @@
|
|||||||
---
|
|
||||||
name: code-review
|
|
||||||
description: Review Ontime changes for concrete correctness, architecture, testing, routing, security, and maintenance issues. For GitHub Copilot review.
|
|
||||||
---
|
|
||||||
|
|
||||||
# Review Ontime changes
|
|
||||||
|
|
||||||
Review as a maintainer. Find material defects, not speculative advice, style preferences, or generic checklists. Approve when no material issue remains.
|
|
||||||
|
|
||||||
## Load relevant context
|
|
||||||
|
|
||||||
Read the full diff, PR description, linked issue, tests, and nearby owning code. Then load only applicable guides:
|
|
||||||
|
|
||||||
- Every non-trivial review: [change assessment](../../../docs/agent-guides/change-assessment.md)
|
|
||||||
- Module placement, server layers, client state, shared packages: [architecture](../../../docs/agent-guides/architecture.md)
|
|
||||||
- Tests or changed behaviour: [testing](../../../docs/agent-guides/testing.md)
|
|
||||||
- Comments, abstractions, naming, complexity: [code quality](../../../docs/agent-guides/code-quality.md)
|
|
||||||
- Authentication, external input, files, integrations, assets, secrets: [security](../../../docs/agent-guides/security.md)
|
|
||||||
- Routes, URLs, websockets, authentication, cookies, presets, assets: [routing and cloud](../../../docs/agent-guides/routing-and-cloud.md)
|
|
||||||
- Rundowns, timers, persistence, imports, cache, realtime: [domain invariants](../../../docs/agent-guides/domain-invariants.md)
|
|
||||||
- Commands, imports, dependencies, formatting, CI claims: [workflow](../../../docs/agent-guides/workflow.md)
|
|
||||||
|
|
||||||
Check a guide and nearby canonical code before citing an Ontime convention. Skip unrelated guides.
|
|
||||||
|
|
||||||
## Review order
|
|
||||||
|
|
||||||
1. Establish intent and affected runtime surfaces.
|
|
||||||
2. Read tests first. Identify claimed behaviour and coverage.
|
|
||||||
3. Trace implementation, errors, and state transitions.
|
|
||||||
4. Check correctness/data integrity, security, architecture/testability, cloud routing, lifecycle/performance, maintainability.
|
|
||||||
5. Verify claimed checks. Never claim unobserved results.
|
|
||||||
|
|
||||||
Passing tests do not prove architecture, routing, comments, or error paths. Review changed behaviour only; include existing problems only when the diff worsens or relies on them.
|
|
||||||
|
|
||||||
## Findings
|
|
||||||
|
|
||||||
Report only concrete, actionable issues. Each finding: tight line range, direct defect, impact and trigger, smallest viable remedy when unclear.
|
|
||||||
|
|
||||||
- **P0 — Critical:** data loss, exploitable vulnerability, broadly broken production. Blocks merge.
|
|
||||||
- **P1 — High:** likely correctness failure or major supported-deployment regression. Blocks merge.
|
|
||||||
- **P2 — Medium:** real edge-case defect, architecture regression, missing business-rule test, stale comment, meaningful maintenance risk. Normally blocks merge.
|
|
||||||
- **P3 — Low:** local improvement with limited impact. No subjective style or tool-managed formatting.
|
|
||||||
|
|
||||||
Order by priority. Prefer few high-confidence findings. No praise or checklist before findings. If none, say so and note verification gaps or residual risk.
|
|
||||||
|
|
||||||
Then give one concise PR-level value/risk/complexity assessment. Never repeat it per finding.
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# Ontime agent guide
|
|
||||||
|
|
||||||
Make the smallest maintainable change. Keep scope narrow. Inspect nearby code first. Reuse helpers and boundaries when semantics match.
|
|
||||||
|
|
||||||
## Load only relevant guides
|
|
||||||
|
|
||||||
- Commands, validation, formatting, imports, PRs: [workflow](docs/agent-guides/workflow.md).
|
|
||||||
- Non-trivial planning, implementation, review: [change assessment](docs/agent-guides/change-assessment.md).
|
|
||||||
- Module placement, server layers, client state, shared packages: [architecture](docs/agent-guides/architecture.md).
|
|
||||||
- Tests or changed behaviour: [testing](docs/agent-guides/testing.md).
|
|
||||||
- Comments, naming, abstractions, maintainability: [code quality](docs/agent-guides/code-quality.md).
|
|
||||||
- Authentication, external input, files, integrations, assets, secrets: [security](docs/agent-guides/security.md).
|
|
||||||
- Navigation, URLs, API paths, websockets, redirects, cookies, static assets: [routing and cloud](docs/agent-guides/routing-and-cloud.md).
|
|
||||||
- Rundowns, timers, imports, persistence, cache, websockets: [domain invariants](docs/agent-guides/domain-invariants.md).
|
|
||||||
|
|
||||||
Load multiple guides when needed. Skip unrelated guides for mechanical work.
|
|
||||||
|
|
||||||
## Before handoff
|
|
||||||
|
|
||||||
- Check the final diff for scope, stale comments, temporary code, redundant tests, generated files.
|
|
||||||
- If work reveals a missing, stable, reusable system, domain, or product invariant, update its owning guide. Exclude guesses, one-off bugs, and implementation details.
|
|
||||||
- Follow [workflow verification](docs/agent-guides/workflow.md). Report only observed results.
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@getontime/cli",
|
"name": "@getontime/cli",
|
||||||
"version": "4.13.0",
|
"version": "4.12.0",
|
||||||
"author": "Carlos Valente",
|
"author": "Carlos Valente",
|
||||||
"description": "Time keeping for live events",
|
"description": "Time keeping for live events",
|
||||||
"repository": "https://github.com/cpvalente/ontime",
|
"repository": "https://github.com/cpvalente/ontime",
|
||||||
|
|||||||
@@ -7,15 +7,13 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||||
<meta name="theme-color" content="#101010" />
|
<meta name="theme-color" content="#101010" />
|
||||||
<meta name="ontime" content="ontime - time keeping for live events" />
|
<meta name="ontime" content="ontime - time keeping for live events" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="apple-mobile-web-app-title" content="Ontime" />
|
|
||||||
<link rel="apple-touch-icon" href="ontime-logo.png" />
|
<link rel="apple-touch-icon" href="ontime-logo.png" />
|
||||||
<link rel="icon" type="image/png" href="ontime-logo.png" />
|
<link rel="icon" type="image/png" href="ontime-logo.png" />
|
||||||
|
<link rel="manifest" href="site.webmanifest" />
|
||||||
<link rel="manifest" href="manifest.json" />
|
<link rel="manifest" href="manifest.json" />
|
||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
<title>Ontime</title>
|
<title>ontime</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "ontime-ui",
|
"name": "ontime-ui",
|
||||||
"version": "4.13.0",
|
"version": "4.12.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "1.7.0",
|
"@base-ui/react": "1.6.0",
|
||||||
"@codemirror/commands": "^6.0.0",
|
"@codemirror/commands": "^6.0.0",
|
||||||
"@codemirror/lang-css": "^6.0.0",
|
"@codemirror/lang-css": "^6.0.0",
|
||||||
"@codemirror/state": "^6.0.0",
|
"@codemirror/state": "^6.0.0",
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@fontsource/open-sans": "^5.2.7",
|
"@fontsource/open-sans": "^5.2.7",
|
||||||
"@mantine/hooks": "^9.5.1",
|
"@mantine/hooks": "^8.3.7",
|
||||||
"@sentry/react": "^10.59.0",
|
"@sentry/react": "^10.59.0",
|
||||||
"@table-nav/react": "^0.0.7",
|
"@table-nav/react": "^0.0.7",
|
||||||
"@tanstack/react-query": "^5.101.0",
|
"@tanstack/react-query": "^5.101.0",
|
||||||
"@tanstack/react-query-devtools": "^5.101.0",
|
"@tanstack/react-query-devtools": "^5.101.0",
|
||||||
"@tanstack/react-table": "^9.1.2",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@uiw/codemirror-theme-vscode": "^4.25.10",
|
"@uiw/codemirror-theme-vscode": "^4.25.10",
|
||||||
"autosize": "^6.0.1",
|
"autosize": "^6.0.1",
|
||||||
"axios": "^1.18.0",
|
"axios": "^1.18.0",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"react-dom": "^19.2.7",
|
"react-dom": "^19.2.7",
|
||||||
"react-fast-compare": "^3.2.2",
|
"react-fast-compare": "^3.2.2",
|
||||||
"react-hook-form": "^7.80.0",
|
"react-hook-form": "^7.80.0",
|
||||||
"react-icons": "5.7.0",
|
"react-icons": "5.6.0",
|
||||||
"react-router": "^8.0.1",
|
"react-router": "^8.0.1",
|
||||||
"react-virtuoso": "^4.18.7",
|
"react-virtuoso": "^4.18.7",
|
||||||
"zustand": "^5.0.14"
|
"zustand": "^5.0.14"
|
||||||
@@ -60,8 +60,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sentry/vite-plugin": "5.4.0",
|
"@sentry/vite-plugin": "5.1.1",
|
||||||
"@types/node": "catalog:",
|
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@types/react": "^19.1.12",
|
"@types/react": "^19.1.12",
|
||||||
"@types/react-dom": "^19.1.9",
|
"@types/react-dom": "^19.1.9",
|
||||||
@@ -73,8 +72,8 @@
|
|||||||
"ontime-utils": "workspace:*",
|
"ontime-utils": "workspace:*",
|
||||||
"sass": "^1.57.1",
|
"sass": "^1.57.1",
|
||||||
"typescript": "catalog:",
|
"typescript": "catalog:",
|
||||||
"vite": "8.2.1",
|
"vite": "8.0.1",
|
||||||
"vite-plugin-compression2": "2.5.3",
|
"vite-plugin-compression2": "2.5.1",
|
||||||
"vite-plugin-svgr": "4.5.0",
|
"vite-plugin-svgr": "4.5.0",
|
||||||
"vitest": "catalog:"
|
"vitest": "catalog:"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "Ontime",
|
"name": "ontime",
|
||||||
"short_name": "Ontime",
|
"short_name": "ontime",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "ontime-logo-192.png",
|
"src": "favicon.ico",
|
||||||
"sizes": "192x192",
|
"type": "image/x-icon"
|
||||||
"type": "image/png"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "ontime-logo-512.png",
|
"src": "ontime-logo.png",
|
||||||
"sizes": "512x512",
|
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scope": "./",
|
"scope": "./",
|
||||||
"start_url": "./",
|
"start_url": "./",
|
||||||
"display": "standalone",
|
"display": "",
|
||||||
"theme_color": "#101010",
|
"theme_color": "#121212",
|
||||||
"background_color": "#101010"
|
"background_color": "#101010"
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 84 KiB |
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"short_name": "",
|
||||||
|
"icons": [{ "src": "ontime-logo.png", "sizes": "295x295", "type": "image/png" }],
|
||||||
|
"theme_color": "#121212",
|
||||||
|
"background_color": "#101010",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import type { ReportData } from 'ontime-types';
|
import { OntimeReport } from 'ontime-types';
|
||||||
|
|
||||||
import { ontimeQueryClient } from '../../common/queryClient';
|
import { ontimeQueryClient } from '../../common/queryClient';
|
||||||
import { REPORT, apiEntryUrl } from './constants';
|
import { REPORT, apiEntryUrl } from './constants';
|
||||||
@@ -8,13 +8,18 @@ import type { RequestOptions } from './requestOptions';
|
|||||||
export const reportUrl = `${apiEntryUrl}/report`;
|
export const reportUrl = `${apiEntryUrl}/report`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP request to fetch the report
|
* HTTP request to fetch all reports
|
||||||
*/
|
*/
|
||||||
export async function fetchReport(options?: RequestOptions): Promise<ReportData> {
|
export async function fetchReport(options?: RequestOptions): Promise<OntimeReport> {
|
||||||
const res = await axios.get(reportUrl, { signal: options?.signal });
|
const res = await axios.get(reportUrl, { signal: options?.signal });
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deleteReport(id: string) {
|
||||||
|
await axios.delete(`${reportUrl}/${id}`);
|
||||||
|
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteAllReport() {
|
export async function deleteAllReport() {
|
||||||
await axios.delete(`${reportUrl}/all`);
|
await axios.delete(`${reportUrl}/all`);
|
||||||
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import { ComponentProps } from 'react';
|
|
||||||
|
|
||||||
import Button from './Button';
|
|
||||||
|
|
||||||
type ToggleButtonProps = Omit<ComponentProps<typeof Button>, 'variant'> & {
|
|
||||||
/** whether the option this button controls is currently on */
|
|
||||||
pressed: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A button which carries an on / off state.
|
|
||||||
*
|
|
||||||
* Keeps the pressed styling and the accessible state together, so that a toggle
|
|
||||||
* cannot end up looking active without also announcing that it is.
|
|
||||||
*/
|
|
||||||
export default function ToggleButton({ pressed, ...buttonProps }: ToggleButtonProps) {
|
|
||||||
return <Button variant={pressed ? 'primary' : 'subtle'} aria-pressed={pressed} {...buttonProps} />;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
.eyebrow {
|
|
||||||
font-size: $aux-text-size;
|
|
||||||
font-weight: 400;
|
|
||||||
letter-spacing: 0.06em;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import { PropsWithChildren } from 'react';
|
|
||||||
|
|
||||||
import { cx } from '../../utils/styleUtils';
|
|
||||||
|
|
||||||
import style from './Eyebrow.module.scss';
|
|
||||||
|
|
||||||
interface EyebrowProps {
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Eyebrow({ children, className }: PropsWithChildren<EyebrowProps>) {
|
|
||||||
return <span className={cx([style.eyebrow, className])}>{children}</span>;
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.separator {
|
||||||
|
border-color: $border-color-ondark;
|
||||||
|
}
|
||||||
|
|
||||||
.backdrop {
|
.backdrop {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -19,15 +23,14 @@
|
|||||||
|
|
||||||
width: 22rem;
|
width: 22rem;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
height: 100dvh;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding-block: 1rem;
|
||||||
|
|
||||||
background-color: $gray-1250;
|
background-color: $gray-1250;
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
border-right: 1px solid $gray-1100;
|
border-right: 1px solid $gray-1100;
|
||||||
box-shadow: $box-shadow-right;
|
|
||||||
|
|
||||||
&[data-open] {
|
&[data-open] {
|
||||||
transform: translateX(0%);
|
transform: translateX(0%);
|
||||||
@@ -47,51 +50,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
flex: 0 0 auto;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 1rem;
|
height: 3.5rem;
|
||||||
min-height: 4rem;
|
padding-inline: 1.5rem;
|
||||||
padding: 0.75rem 1rem 0.75rem 1.25rem;
|
|
||||||
border-bottom: 1px solid $white-10;
|
|
||||||
}
|
|
||||||
|
|
||||||
.headerText {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clientName {
|
|
||||||
font-size: $aux-text-size;
|
|
||||||
color: $gray-600;
|
|
||||||
@include ellipsis-text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
.body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-block: 0.5rem 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.group {
|
.note {
|
||||||
display: flex;
|
margin-left: auto;
|
||||||
flex-direction: column;
|
color: $white-20;
|
||||||
|
|
||||||
&:not(:first-child) {
|
|
||||||
margin-top: 0.75rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupLabel {
|
|
||||||
padding: 0.5rem 1.25rem 0.25rem;
|
|
||||||
color: $gray-700;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Dialog } from '@base-ui/react/dialog';
|
import { Dialog } from '@base-ui/react/dialog';
|
||||||
import { useDisclosure, useFullscreenDocument } from '@mantine/hooks';
|
import { useDisclosure, useFullscreen } from '@mantine/hooks';
|
||||||
import { memo, PropsWithChildren } from 'react';
|
import { memo } from 'react';
|
||||||
import { IoClose, IoExpand, IoLockClosedOutline, IoPencilOutline, IoSwapVertical } from 'react-icons/io5';
|
import { IoClose, IoContract, IoExpand, IoLockClosedOutline, IoSwapVertical } from 'react-icons/io5';
|
||||||
import { LuCoffee } from 'react-icons/lu';
|
import { LuCoffee } from 'react-icons/lu';
|
||||||
import { useLocation } from 'react-router';
|
import { useLocation } from 'react-router';
|
||||||
|
|
||||||
@@ -14,11 +14,9 @@ import { useClientStore } from '../../stores/clientStore';
|
|||||||
import { useViewOptionsStore } from '../../stores/viewOptions';
|
import { useViewOptionsStore } from '../../stores/viewOptions';
|
||||||
import IconButton from '../buttons/IconButton';
|
import IconButton from '../buttons/IconButton';
|
||||||
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
||||||
import Eyebrow from '../eyebrow/Eyebrow';
|
|
||||||
import ClientLink from './client-link/ClientLink';
|
import ClientLink from './client-link/ClientLink';
|
||||||
import EditorNavigation from './editor-navigation/EditorNavigation';
|
import EditorNavigation from './editor-navigation/EditorNavigation';
|
||||||
import NavigationMenuItem from './navigation-menu-item/NavigationMenuItem';
|
import NavigationMenuItem from './navigation-menu-item/NavigationMenuItem';
|
||||||
import NavigationMenuToggle from './navigation-menu-item/NavigationMenuToggle';
|
|
||||||
import OtherAddresses from './other-addresses/OtherAddresses';
|
import OtherAddresses from './other-addresses/OtherAddresses';
|
||||||
|
|
||||||
import style from './NavigationMenu.module.scss';
|
import style from './NavigationMenu.module.scss';
|
||||||
@@ -35,7 +33,7 @@ function NavigationMenu({ isOpen, onClose }: NavigationMenuProps) {
|
|||||||
const isSmallScreen = useIsSmallScreen();
|
const isSmallScreen = useIsSmallScreen();
|
||||||
|
|
||||||
const [isRenameOpen, handlers] = useDisclosure(false);
|
const [isRenameOpen, handlers] = useDisclosure(false);
|
||||||
const { fullscreen, toggle } = useFullscreenDocument();
|
const { fullscreen, toggle } = useFullscreen();
|
||||||
const { mirror, toggleMirror } = useViewOptionsStore();
|
const { mirror, toggleMirror } = useViewOptionsStore();
|
||||||
const { keepAwake, toggleKeepAwake } = useKeepAwakeOptions();
|
const { keepAwake, toggleKeepAwake } = useKeepAwakeOptions();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -54,93 +52,75 @@ function NavigationMenu({ isOpen, onClose }: NavigationMenuProps) {
|
|||||||
<RenameClientModal id={id} name={name} isOpen={isRenameOpen} onClose={handlers.close} />
|
<RenameClientModal id={id} name={name} isOpen={isRenameOpen} onClose={handlers.close} />
|
||||||
<Dialog.Popup className={style.drawer}>
|
<Dialog.Popup className={style.drawer}>
|
||||||
<div className={style.header}>
|
<div className={style.header}>
|
||||||
<div className={style.headerText}>
|
<Dialog.Title>Ontime</Dialog.Title>
|
||||||
<Dialog.Title className={style.title}>Ontime</Dialog.Title>
|
<IconButton variant='subtle-white' size='large' onClick={onClose}>
|
||||||
{name && <span className={style.clientName}>{name}</span>}
|
|
||||||
</div>
|
|
||||||
<IconButton variant='subtle-white' size='large' aria-label='Close menu' onClick={onClose}>
|
|
||||||
<IoClose />
|
<IoClose />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.body}>
|
<div className={style.body}>
|
||||||
<MenuGroup label='This screen'>
|
{supportsFullscreen && (
|
||||||
{supportsFullscreen && (
|
<NavigationMenuItem active={fullscreen} onClick={toggle}>
|
||||||
<NavigationMenuToggle checked={fullscreen} icon={<IoExpand />} label='Fullscreen' onToggle={toggle} />
|
Toggle Fullscreen
|
||||||
)}
|
{fullscreen ? <IoContract /> : <IoExpand />}
|
||||||
<NavigationMenuToggle
|
|
||||||
checked={mirror}
|
|
||||||
icon={<IoSwapVertical />}
|
|
||||||
label='Flip Screen'
|
|
||||||
onToggle={() => toggleMirror()}
|
|
||||||
/>
|
|
||||||
{canUseWakeLock && (
|
|
||||||
<NavigationMenuToggle
|
|
||||||
checked={keepAwake}
|
|
||||||
icon={<LuCoffee />}
|
|
||||||
label='Keep Awake'
|
|
||||||
onToggle={toggleKeepAwake}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<NavigationMenuItem onClick={handlers.open}>
|
|
||||||
<IoPencilOutline />
|
|
||||||
Rename Client
|
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
</MenuGroup>
|
)}
|
||||||
|
<NavigationMenuItem active={mirror} onClick={() => toggleMirror()}>
|
||||||
|
Flip Screen
|
||||||
|
<IoSwapVertical />
|
||||||
|
{mirror && <span className={style.note}>Active</span>}
|
||||||
|
</NavigationMenuItem>
|
||||||
|
{canUseWakeLock && (
|
||||||
|
<NavigationMenuItem active={keepAwake} onClick={toggleKeepAwake}>
|
||||||
|
Keep Awake
|
||||||
|
<LuCoffee />
|
||||||
|
{keepAwake && <span className={style.note}>Active</span>}
|
||||||
|
</NavigationMenuItem>
|
||||||
|
)}
|
||||||
|
<NavigationMenuItem onClick={handlers.open}>Rename Client</NavigationMenuItem>
|
||||||
|
|
||||||
<MenuGroup label='Ontime app'>
|
<hr className={style.separator} />
|
||||||
<EditorNavigation />
|
|
||||||
|
<EditorNavigation />
|
||||||
|
<ClientLink
|
||||||
|
to='cuesheet'
|
||||||
|
current={location.pathname === '/cuesheet'}
|
||||||
|
postAction={isSmallScreen ? onClose : undefined}
|
||||||
|
>
|
||||||
|
<IoLockClosedOutline />
|
||||||
|
Cuesheet
|
||||||
|
</ClientLink>
|
||||||
|
<ClientLink to='op' current={location.pathname === '/op'} postAction={isSmallScreen ? onClose : undefined}>
|
||||||
|
<IoLockClosedOutline />
|
||||||
|
Operator
|
||||||
|
</ClientLink>
|
||||||
|
|
||||||
|
<hr className={style.separator} />
|
||||||
|
|
||||||
|
{navigatorConstants.map((route) => (
|
||||||
<ClientLink
|
<ClientLink
|
||||||
to='cuesheet'
|
key={route.url}
|
||||||
current={location.pathname === '/cuesheet'}
|
to={route.url}
|
||||||
|
current={location.pathname === `/${route.url}`}
|
||||||
postAction={isSmallScreen ? onClose : undefined}
|
postAction={isSmallScreen ? onClose : undefined}
|
||||||
>
|
>
|
||||||
<IoLockClosedOutline />
|
{route.label}
|
||||||
Cuesheet
|
|
||||||
</ClientLink>
|
</ClientLink>
|
||||||
<ClientLink
|
))}
|
||||||
to='op'
|
|
||||||
current={location.pathname === '/op'}
|
|
||||||
postAction={isSmallScreen ? onClose : undefined}
|
|
||||||
>
|
|
||||||
<IoLockClosedOutline />
|
|
||||||
Operator
|
|
||||||
</ClientLink>
|
|
||||||
</MenuGroup>
|
|
||||||
|
|
||||||
<MenuGroup label='Views'>
|
|
||||||
{navigatorConstants.map((route) => (
|
|
||||||
<ClientLink
|
|
||||||
key={route.url}
|
|
||||||
to={route.url}
|
|
||||||
current={location.pathname === `/${route.url}`}
|
|
||||||
postAction={isSmallScreen ? onClose : undefined}
|
|
||||||
>
|
|
||||||
{route.label}
|
|
||||||
</ClientLink>
|
|
||||||
))}
|
|
||||||
</MenuGroup>
|
|
||||||
|
|
||||||
<PresetNavigation isSmallScreen={isSmallScreen} onClose={onClose} />
|
<PresetNavigation isSmallScreen={isSmallScreen} onClose={onClose} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isLocalhost && <OtherAddresses currentLocation={location.pathname} />}
|
{isLocalhost && (
|
||||||
|
<div>
|
||||||
|
<OtherAddresses currentLocation={location.pathname} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Dialog.Popup>
|
</Dialog.Popup>
|
||||||
</Dialog.Portal>
|
</Dialog.Portal>
|
||||||
</Dialog.Root>
|
</Dialog.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MenuGroup({ label, children }: PropsWithChildren<{ label: string }>) {
|
|
||||||
return (
|
|
||||||
<div className={style.group}>
|
|
||||||
<div className={style.groupLabel}>
|
|
||||||
<Eyebrow>{label}</Eyebrow>
|
|
||||||
</div>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PresetNavigation({ isSmallScreen, onClose }: { isSmallScreen: boolean; onClose: () => void }) {
|
function PresetNavigation({ isSmallScreen, onClose }: { isSmallScreen: boolean; onClose: () => void }) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { data: urlPresets } = useUrlPresets();
|
const { data: urlPresets } = useUrlPresets();
|
||||||
@@ -149,7 +129,8 @@ function PresetNavigation({ isSmallScreen, onClose }: { isSmallScreen: boolean;
|
|||||||
if (navPresets.length === 0) return null;
|
if (navPresets.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuGroup label='Presets'>
|
<>
|
||||||
|
<hr className={style.separator} />
|
||||||
{navPresets.map((preset) => (
|
{navPresets.map((preset) => (
|
||||||
<ClientLink
|
<ClientLink
|
||||||
key={preset.alias}
|
key={preset.alias}
|
||||||
@@ -160,6 +141,6 @@ function PresetNavigation({ isSmallScreen, onClose }: { isSmallScreen: boolean;
|
|||||||
{preset.alias}
|
{preset.alias}
|
||||||
</ClientLink>
|
</ClientLink>
|
||||||
))}
|
))}
|
||||||
</MenuGroup>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useHotkeys } from '@mantine/hooks';
|
import { useDisclosure, useHotkeys } from '@mantine/hooks';
|
||||||
import { memo, useCallback, useState } from 'react';
|
import { memo } from 'react';
|
||||||
import { useSearchParams } from 'react-router';
|
import { useSearchParams } from 'react-router';
|
||||||
|
|
||||||
import { hasCustomParams } from '../../stores/savedViewParams';
|
import { hasCustomParams } from '../../stores/savedViewParams';
|
||||||
@@ -15,37 +15,21 @@ interface ViewNavigationMenuProps {
|
|||||||
suppressSettings?: boolean;
|
suppressSettings?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInteractiveKeyboardAction(target: EventTarget | null): boolean {
|
|
||||||
if (!(target instanceof HTMLElement)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
target.closest(
|
|
||||||
'button, a, input, textarea, select, [role="button"], [role="checkbox"], [role="switch"], [contenteditable]:not([contenteditable="false"])',
|
|
||||||
) !== null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default memo(ViewNavigationMenu);
|
export default memo(ViewNavigationMenu);
|
||||||
function ViewNavigationMenu({ isNavigationLocked, suppressSettings }: ViewNavigationMenuProps) {
|
function ViewNavigationMenu({ isNavigationLocked, suppressSettings }: ViewNavigationMenuProps) {
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
const [isMenuOpen, menuHandler] = useDisclosure();
|
||||||
const { open: showEditFormDrawer } = useViewParamsEditorStore();
|
const { open: showEditFormDrawer } = useViewParamsEditorStore();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const hasSavedChanges = hasCustomParams(searchParams);
|
const hasSavedChanges = hasCustomParams(searchParams);
|
||||||
|
|
||||||
const toggleMenu = useCallback(() => setIsMenuOpen((prev) => !prev), []);
|
|
||||||
const closeMenu = useCallback(() => setIsMenuOpen(false), []);
|
|
||||||
|
|
||||||
useHotkeys([
|
useHotkeys([
|
||||||
[
|
[
|
||||||
'Space',
|
'Space',
|
||||||
(event) => {
|
() => {
|
||||||
if (isNavigationLocked || isInteractiveKeyboardAction(event.target)) return;
|
if (isNavigationLocked) return;
|
||||||
event.preventDefault();
|
menuHandler.toggle();
|
||||||
toggleMenu();
|
|
||||||
},
|
},
|
||||||
{ preventDefault: false },
|
{ preventDefault: true },
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'mod + ,',
|
'mod + ,',
|
||||||
@@ -64,11 +48,11 @@ function ViewNavigationMenu({ isNavigationLocked, suppressSettings }: ViewNaviga
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FloatingNavigation
|
<FloatingNavigation
|
||||||
toggleMenu={isNavigationLocked ? undefined : toggleMenu}
|
toggleMenu={isNavigationLocked ? undefined : menuHandler.toggle}
|
||||||
toggleSettings={suppressSettings ? undefined : showEditFormDrawer}
|
toggleSettings={suppressSettings ? undefined : showEditFormDrawer}
|
||||||
hasSavedChanges={hasSavedChanges}
|
hasSavedChanges={hasSavedChanges}
|
||||||
/>
|
/>
|
||||||
{!isNavigationLocked && <NavigationMenu isOpen={isMenuOpen} onClose={closeMenu} />}
|
{!isNavigationLocked && <NavigationMenu isOpen={isMenuOpen} onClose={menuHandler.close} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-45
@@ -2,68 +2,35 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
padding: 0.625rem 1.25rem;
|
padding: 0.75rem 1.5rem;
|
||||||
gap: 0.625rem;
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
border-left: 3px solid transparent;
|
border-left: 4px solid transparent;
|
||||||
color: $gray-200;
|
color: $action-text-color;
|
||||||
font-size: $text-body-size;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
transition-property: color, background-color;
|
transition-property: color;
|
||||||
transition-duration: $transition-time-action;
|
transition-duration: $transition-time-action;
|
||||||
|
|
||||||
// keep icons on a fixed box so labels align regardless of the glyph
|
|
||||||
> svg {
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 1.125rem;
|
|
||||||
height: 1.125rem;
|
|
||||||
color: $gray-500;
|
|
||||||
transition: color $transition-time-action;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: $white-3;
|
color: $ontime-color;
|
||||||
color: $ui-white;
|
background-color: $gray-1350;
|
||||||
|
|
||||||
> svg {
|
|
||||||
color: $gray-300;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
background-color: $white-7;
|
background-color: $border-color-ondark;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible {
|
&:focus {
|
||||||
outline: 2px solid $blue-500;
|
outline: 2px solid $blue-500;
|
||||||
outline-offset: -2px;
|
background-color: $gray-1350;
|
||||||
background-color: $white-3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// toggle rows are labels, the focusable control sits inside them
|
|
||||||
&:focus-within {
|
|
||||||
background-color: $white-3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.current {
|
&.current {
|
||||||
background-color: $bg-active;
|
background-color: $gray-1300;
|
||||||
border-left-color: $blue-400;
|
border-left: 4px solid $action-text-color;
|
||||||
color: $ui-white;
|
|
||||||
font-weight: 600;
|
|
||||||
|
|
||||||
> svg {
|
|
||||||
color: $blue-300;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
@include ellipsis-text;
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-5
@@ -1,6 +1,6 @@
|
|||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
|
|
||||||
import { isKeyEnter, isKeySpace } from '../../../utils/keyEvent';
|
import { isKeyEnter } from '../../../utils/keyEvent';
|
||||||
import { cx } from '../../../utils/styleUtils';
|
import { cx } from '../../../utils/styleUtils';
|
||||||
|
|
||||||
import style from './NavigationMenuItem.module.scss';
|
import style from './NavigationMenuItem.module.scss';
|
||||||
@@ -11,7 +11,6 @@ interface NavigationMenuItemProps {
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A row in the navigation menu, and the single place which decides how a row reacts to input */
|
|
||||||
export default function NavigationMenuItem({
|
export default function NavigationMenuItem({
|
||||||
active,
|
active,
|
||||||
className,
|
className,
|
||||||
@@ -25,9 +24,7 @@ export default function NavigationMenuItem({
|
|||||||
role='button'
|
role='button'
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (isKeyEnter(event) || isKeySpace(event)) {
|
if (isKeyEnter(event)) {
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
onClick();
|
onClick();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
|
|
||||||
import Switch from '../../switch/Switch';
|
|
||||||
|
|
||||||
import style from './NavigationMenuItem.module.scss';
|
|
||||||
|
|
||||||
interface NavigationMenuToggleProps {
|
|
||||||
checked: boolean;
|
|
||||||
icon: ReactNode;
|
|
||||||
label: string;
|
|
||||||
onToggle: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A menu row which reflects, and toggles, an on/off state */
|
|
||||||
export default function NavigationMenuToggle({ checked, icon, label, onToggle }: NavigationMenuToggleProps) {
|
|
||||||
return (
|
|
||||||
<label className={style.link}>
|
|
||||||
{icon}
|
|
||||||
<span className={style.label}>{label}</span>
|
|
||||||
<Switch checked={checked} onCheckedChange={onToggle} />
|
|
||||||
</label>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+4
-34
@@ -1,52 +1,22 @@
|
|||||||
.footer {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
padding: 0.75rem 0;
|
|
||||||
border-top: 1px solid $white-10;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
padding: 0 1.25rem 0.25rem;
|
font-size: calc(1rem - 2px);
|
||||||
|
margin-left: 1rem;
|
||||||
color: $gray-700;
|
color: $gray-700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.interfaces {
|
.interfaces {
|
||||||
padding: 0.25rem 1.25rem 0;
|
padding: 0.5rem 0.5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.25rem;
|
gap: 0.5rem;
|
||||||
}
|
|
||||||
|
|
||||||
.interface {
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
> div {
|
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
> button:first-child {
|
|
||||||
min-width: 0;
|
|
||||||
max-width: calc(100% - 1.5rem);
|
|
||||||
justify-content: flex-start;
|
|
||||||
padding-inline: 0.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.interfaceCopy {
|
.interfaceCopy {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.address {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.goIcon {
|
.goIcon {
|
||||||
flex: 0 0 auto;
|
|
||||||
@include rotate-fourty-five;
|
@include rotate-fourty-five;
|
||||||
margin-left: 0.25rem;
|
margin-left: 0.25rem;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
|
|||||||
+15
-18
@@ -3,8 +3,6 @@ import { IoArrowUp } from 'react-icons/io5';
|
|||||||
import useInfo from '../../../hooks-query/useInfo';
|
import useInfo from '../../../hooks-query/useInfo';
|
||||||
import { linkToOtherHost, openLink } from '../../../utils/linkUtils';
|
import { linkToOtherHost, openLink } from '../../../utils/linkUtils';
|
||||||
import CopyTag from '../../copy-tag/CopyTag';
|
import CopyTag from '../../copy-tag/CopyTag';
|
||||||
import Eyebrow from '../../eyebrow/Eyebrow';
|
|
||||||
import { getExternalInterfaces } from './otherAddresses.utils';
|
|
||||||
|
|
||||||
import style from './OtherAddresses.module.scss';
|
import style from './OtherAddresses.module.scss';
|
||||||
|
|
||||||
@@ -14,33 +12,32 @@ interface OtherAddressesProps {
|
|||||||
|
|
||||||
export default function OtherAddresses({ currentLocation }: OtherAddressesProps) {
|
export default function OtherAddresses({ currentLocation }: OtherAddressesProps) {
|
||||||
const { data } = useInfo();
|
const { data } = useInfo();
|
||||||
const externalInterfaces = getExternalInterfaces(data.networkInterfaces);
|
|
||||||
|
|
||||||
if (externalInterfaces.length === 0) {
|
// there is no point showing this if we only have one interface
|
||||||
|
if (data.networkInterfaces.length < 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.footer}>
|
<>
|
||||||
<div className={style.header}>
|
<div className={style.header}>Accessible on external networks</div>
|
||||||
<Eyebrow>Also available at</Eyebrow>
|
|
||||||
</div>
|
|
||||||
<div className={style.interfaces}>
|
<div className={style.interfaces}>
|
||||||
{externalInterfaces.map((nif) => {
|
{data?.networkInterfaces?.map((nif) => {
|
||||||
|
if (nif.name === 'localhost') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const address = linkToOtherHost(nif.address, currentLocation);
|
const address = linkToOtherHost(nif.address, currentLocation);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={nif.name} className={style.interface}>
|
<CopyTag key={nif.name} copyValue={address} onClick={() => openLink(address)} size='small'>
|
||||||
<CopyTag copyValue={address} onClick={() => openLink(address)} size='small'>
|
<span className={style.interfaceCopy}>
|
||||||
<span className={style.interfaceCopy}>
|
{nif.address} <IoArrowUp className={style.goIcon} />
|
||||||
<span className={style.address}>{nif.address}</span>
|
</span>
|
||||||
<IoArrowUp className={style.goIcon} />
|
</CopyTag>
|
||||||
</span>
|
|
||||||
</CopyTag>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
import { describe, expect, test } from 'vitest';
|
|
||||||
|
|
||||||
import { getExternalInterfaces } from '../otherAddresses.utils';
|
|
||||||
|
|
||||||
describe('getExternalInterfaces', () => {
|
|
||||||
test('returns no alternatives when localhost is the only interface', () => {
|
|
||||||
expect(getExternalInterfaces([{ name: 'localhost', address: '127.0.0.1' }])).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('does not treat an interface name as deployment information', () => {
|
|
||||||
expect(
|
|
||||||
getExternalInterfaces([
|
|
||||||
{ name: 'localhost', address: '127.0.0.1' },
|
|
||||||
{ name: 'cloud', address: '192.168.1.42' },
|
|
||||||
]),
|
|
||||||
).toEqual([{ name: 'cloud', address: '192.168.1.42' }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('returns non-local interfaces when local and external interfaces are available', () => {
|
|
||||||
expect(
|
|
||||||
getExternalInterfaces([
|
|
||||||
{ name: 'localhost', address: '127.0.0.1' },
|
|
||||||
{ name: 'Wi-Fi', address: '192.168.1.42' },
|
|
||||||
{ name: 'Ethernet', address: '10.0.0.42' },
|
|
||||||
]),
|
|
||||||
).toEqual([
|
|
||||||
{ name: 'Wi-Fi', address: '192.168.1.42' },
|
|
||||||
{ name: 'Ethernet', address: '10.0.0.42' },
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
import { type NetworkInterface } from 'ontime-types';
|
|
||||||
|
|
||||||
/** Returns network addresses other than the localhost address injected by the info endpoint. */
|
|
||||||
export function getExternalInterfaces(interfaces: NetworkInterface[]) {
|
|
||||||
return interfaces.filter((networkInterface) => networkInterface.name !== 'localhost');
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|
||||||
> span {
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
text-align: right;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to match with ontimeTextInputs
|
// attempt to match with ontimeTextInputs
|
||||||
|
|||||||
@@ -1,77 +1,37 @@
|
|||||||
.multiOptionList {
|
.inline {
|
||||||
overflow-y: auto;
|
display: inline-flex;
|
||||||
max-height: 12rem;
|
align-items: center;
|
||||||
background: $gray-1200;
|
flex-wrap: wrap;
|
||||||
border: 1px solid $gray-1100;
|
gap: 1rem;
|
||||||
border-radius: $component-border-radius-md;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// styles from subtle button
|
||||||
.toggleSelect {
|
.toggleSelect {
|
||||||
box-sizing: border-box;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.75rem;
|
gap: 0.25rem;
|
||||||
min-height: 2.5rem;
|
padding-inline: 0.5rem;
|
||||||
padding: 0.5rem 0.75rem;
|
height: 2.5rem;
|
||||||
background: transparent;
|
background: $gray-1050;
|
||||||
border: 0;
|
color: $ui-white;
|
||||||
color: $gray-300;
|
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
cursor: pointer;
|
border-radius: $component-border-radius-md;
|
||||||
transition:
|
|
||||||
background-color $transition-time-action,
|
|
||||||
border-color $transition-time-action,
|
|
||||||
color $transition-time-action;
|
|
||||||
|
|
||||||
&:hover {
|
&:hover:not(:disabled):not(:active) {
|
||||||
background: $gray-1000;
|
background: $gray-1000;
|
||||||
color: $ui-white;
|
color: $blue-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active:not(:disabled) {
|
||||||
background: $gray-1100;
|
background: $gray-1100;
|
||||||
}
|
border-color: $gray-1250;
|
||||||
|
|
||||||
&:focus-within {
|
|
||||||
outline: 2px solid $blue-500;
|
|
||||||
outline-offset: -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.selected {
|
|
||||||
background: $bg-active;
|
|
||||||
box-shadow: inset 3px 0 $blue-400;
|
|
||||||
color: $ui-white;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:not(:last-child) {
|
|
||||||
border-bottom: 1px solid $white-7;
|
|
||||||
}
|
|
||||||
|
|
||||||
> [role='checkbox'] {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
width: 1.125rem;
|
|
||||||
height: 1.125rem;
|
|
||||||
border: 1px solid $gray-400;
|
|
||||||
|
|
||||||
&[data-unchecked] {
|
|
||||||
background: $gray-1100;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-checked] {
|
|
||||||
border-color: $blue-400;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
flex: 0 0 auto;
|
margin-left: 0.25rem;
|
||||||
margin-left: auto;
|
width: 0.75em;
|
||||||
width: 0.625rem;
|
height: 0.75em;
|
||||||
height: 0.625rem;
|
|
||||||
background: var(--user-bg, $gray-900);
|
background: var(--user-bg, $gray-900);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { ComponentProps, useEffect, useState } from 'react';
|
|||||||
import { useSearchParams } from 'react-router';
|
import { useSearchParams } from 'react-router';
|
||||||
|
|
||||||
import { isStringBoolean } from '../../../views/common/viewUtils';
|
import { isStringBoolean } from '../../../views/common/viewUtils';
|
||||||
import { cx } from '../../utils/styleUtils';
|
|
||||||
import Checkbox from '../checkbox/Checkbox';
|
import Checkbox from '../checkbox/Checkbox';
|
||||||
import Input from '../input/input/Input';
|
import Input from '../input/input/Input';
|
||||||
import Select, { SelectOption } from '../select/Select';
|
import Select, { SelectOption } from '../select/Select';
|
||||||
@@ -108,20 +107,18 @@ function MultiOption({ paramField, options }: EditFormMultiOptionProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<input name={id} hidden readOnly value={paramState.join(',')} />
|
<input name={id} hidden readOnly value={paramState.join(',')} />
|
||||||
<div className={style.multiOptionList}>
|
<div className={style.inline}>
|
||||||
{values.map((option) => {
|
{values.map((option) => {
|
||||||
const selected = paramState.includes(option.value);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label
|
<label
|
||||||
key={option.value}
|
key={option.value}
|
||||||
className={cx([style.toggleSelect, selected && style.selected])}
|
className={style.toggleSelect}
|
||||||
style={{
|
style={{
|
||||||
'--user-bg': option.colour,
|
'--user-bg': option.colour,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={selected}
|
checked={paramState.includes(option.value)}
|
||||||
onCheckedChange={(checked) => toggleValue(option.value, checked as boolean)}
|
onCheckedChange={(checked) => toggleValue(option.value, checked as boolean)}
|
||||||
/>
|
/>
|
||||||
{option.label}
|
{option.label}
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
.drawerFooter {
|
||||||
|
display: flex;
|
||||||
|
justify-content: end;
|
||||||
|
gap: $section-spacing;
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 0 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.backdrop {
|
.backdrop {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -24,11 +34,11 @@
|
|||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding-block: 1rem 1.5rem;
|
||||||
|
|
||||||
background-color: $ui-black;
|
background-color: $gray-1250;
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
border-left: 1px solid $gray-1100;
|
border-left: 1px solid $gray-1100;
|
||||||
box-shadow: $box-shadow-l1;
|
|
||||||
|
|
||||||
&[data-open] {
|
&[data-open] {
|
||||||
transform: translateX(0%);
|
transform: translateX(0%);
|
||||||
@@ -48,54 +58,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
flex: 0 0 auto;
|
padding-inline: 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 1rem;
|
height: 3.5rem;
|
||||||
min-height: 4rem;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.headerText {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.target {
|
|
||||||
font-size: $aux-text-size;
|
|
||||||
color: $gray-600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
.body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 1rem;
|
padding-inline: 1rem;
|
||||||
|
padding-bottom: 10vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
flex: 0 0 auto;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.75rem 1rem;
|
padding-inline: 1rem;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
background-color: $ui-black;
|
|
||||||
border-top: 1px solid $white-10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sectionList {
|
.sectionList {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.75rem;
|
gap: 2rem;
|
||||||
|
padding-right: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { FormEvent, memo } from 'react';
|
|||||||
import { IoClose } from 'react-icons/io5';
|
import { IoClose } from 'react-icons/io5';
|
||||||
import { useSearchParams } from 'react-router';
|
import { useSearchParams } from 'react-router';
|
||||||
|
|
||||||
import { viewLabels } from '../../../viewerConfig';
|
|
||||||
import useViewSettings from '../../hooks-query/useViewSettings';
|
import useViewSettings from '../../hooks-query/useViewSettings';
|
||||||
import { useIsSmallScreen } from '../../hooks/useIsSmallScreen';
|
import { useIsSmallScreen } from '../../hooks/useIsSmallScreen';
|
||||||
import { useSavedViewParams } from '../../stores/savedViewParams';
|
import { useSavedViewParams } from '../../stores/savedViewParams';
|
||||||
@@ -72,17 +71,8 @@ function ViewParamsEditor({ target, viewOptions }: EditFormDrawerProps) {
|
|||||||
<Dialog.Backdrop className={style.backdrop} />
|
<Dialog.Backdrop className={style.backdrop} />
|
||||||
<Dialog.Popup className={style.drawer}>
|
<Dialog.Popup className={style.drawer}>
|
||||||
<div className={style.header}>
|
<div className={style.header}>
|
||||||
<div className={style.headerText}>
|
<Dialog.Title>Customise</Dialog.Title>
|
||||||
<Dialog.Title className={style.title}>Customise</Dialog.Title>
|
<IconButton variant='subtle-white' size='large' data-testid='close-view-params' onClick={handleClose}>
|
||||||
<span className={style.target}>{viewLabels[target]}</span>
|
|
||||||
</div>
|
|
||||||
<IconButton
|
|
||||||
variant='subtle-white'
|
|
||||||
size='large'
|
|
||||||
aria-label='Close'
|
|
||||||
data-testid='close-view-params'
|
|
||||||
onClick={handleClose}
|
|
||||||
>
|
|
||||||
<IoClose />
|
<IoClose />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
.presetSection {
|
.presetSection {
|
||||||
background-color: $gray-1350;
|
background-color: $gray-1350;
|
||||||
border: 1px solid $white-10;
|
|
||||||
border-radius: $component-border-radius-md;
|
|
||||||
margin-bottom: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
min-height: 2.25rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
|
gap: 0.25rem;
|
||||||
color: $gray-300;
|
padding: 1rem 0.5rem;
|
||||||
}
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
.presetList {
|
|
||||||
border-top: 1px solid $white-7;
|
|
||||||
max-height: 10rem;
|
max-height: 10rem;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
scrollbar-gutter: stable;
|
scrollbar-gutter: stable;
|
||||||
@@ -25,39 +14,12 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
min-height: 2.5rem;
|
|
||||||
padding: 0.375rem 1rem;
|
|
||||||
font-size: $inner-section-text-size;
|
|
||||||
|
|
||||||
&:not(:last-child) {
|
|
||||||
border-bottom: 1px solid $white-7;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background-color: $bg-active;
|
color: $blue-500;
|
||||||
box-shadow: inset 3px 0 $blue-400;
|
|
||||||
color: $ui-white;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.presetName {
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.presetActions {
|
.presetActions {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.current {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.25rem;
|
|
||||||
margin-left: auto;
|
|
||||||
color: $blue-400;
|
|
||||||
font-size: $aux-text-size;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useSearchParams } from 'react-router';
|
|||||||
import { useViewUrlPresets } from '../../hooks-query/useUrlPresets';
|
import { useViewUrlPresets } from '../../hooks-query/useUrlPresets';
|
||||||
import { cx } from '../../utils/styleUtils';
|
import { cx } from '../../utils/styleUtils';
|
||||||
import Button from '../buttons/Button';
|
import Button from '../buttons/Button';
|
||||||
import Eyebrow from '../eyebrow/Eyebrow';
|
|
||||||
|
|
||||||
import style from './ViewParamsPresets.module.scss';
|
import style from './ViewParamsPresets.module.scss';
|
||||||
|
|
||||||
@@ -27,31 +26,22 @@ export function ViewParamsPresets({ target }: { target: OntimeView }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.presetSection}>
|
<div className={style.presetSection}>
|
||||||
<div className={style.header}>
|
{viewPresets.map((preset) => {
|
||||||
<Eyebrow>Saved presets</Eyebrow>
|
const active = searchParams.get('alias') === preset.alias;
|
||||||
</div>
|
return (
|
||||||
<div className={style.presetList}>
|
<div key={preset.alias} className={cx([style.preset, active && style.active])}>
|
||||||
{viewPresets.map((preset) => {
|
<div>{preset.alias}</div>
|
||||||
const active = searchParams.get('alias') === preset.alias;
|
<Button
|
||||||
return (
|
variant={active ? 'ghosted' : 'subtle-white'}
|
||||||
<div key={preset.alias} className={cx([style.preset, active && style.active])}>
|
onClick={() => handleRecall(preset)}
|
||||||
<span className={style.presetName}>{preset.alias}</span>
|
disabled={active}
|
||||||
{active ? (
|
className={style.presetActions}
|
||||||
<span className={style.current}>Current</span>
|
>
|
||||||
) : (
|
{active ? 'Applied' : 'Apply'}
|
||||||
<Button
|
</Button>
|
||||||
variant='ghosted'
|
</div>
|
||||||
size='small'
|
);
|
||||||
onClick={() => handleRecall(preset)}
|
})}
|
||||||
className={style.presetActions}
|
|
||||||
>
|
|
||||||
Apply
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-92
@@ -1,118 +1,48 @@
|
|||||||
.section {
|
.section {
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
background-color: $white-3;
|
|
||||||
border: 1px solid $gray-1100;
|
|
||||||
border-radius: $component-border-radius-md;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sectionHeader {
|
.sectionHeader {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
height: 2rem;
|
||||||
width: 100%;
|
|
||||||
min-height: 2.75rem;
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
font: inherit;
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
color: $gray-300;
|
|
||||||
|
|
||||||
&.collapsible {
|
&.collapsible {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition-property: color, background-color;
|
|
||||||
transition-duration: $transition-time-action;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $white-3;
|
|
||||||
color: $ui-white;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 2px solid $blue-500;
|
|
||||||
outline-offset: -2px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sectionTitle {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** marks a section which holds values coming from the URL */
|
|
||||||
.customised {
|
|
||||||
width: 0.4rem;
|
|
||||||
height: 0.4rem;
|
|
||||||
border-radius: 50%;
|
|
||||||
background-color: $active-indicator;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chevron {
|
|
||||||
flex-shrink: 0;
|
|
||||||
rotate: 180deg;
|
|
||||||
transition: rotate 300ms cubic-bezier(0.45, 1.005, 0, 1.005);
|
|
||||||
|
|
||||||
&.closed {
|
|
||||||
rotate: 0deg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.options {
|
|
||||||
padding-inline: 1rem;
|
|
||||||
border-top: 1px solid $white-7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
display: grid;
|
margin-top: $section-spacing;
|
||||||
grid-template-columns: minmax(0, 1fr);
|
|
||||||
row-gap: 0.25rem;
|
|
||||||
padding: 0.75rem 0;
|
|
||||||
font-size: $inner-section-text-size;
|
font-size: $inner-section-text-size;
|
||||||
|
color: $label-gray;
|
||||||
&:not(:last-child) {
|
display: flex;
|
||||||
border-bottom: 1px solid $white-7;
|
flex-direction: column;
|
||||||
}
|
gap: 0.25rem;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compact controls sit beside their label instead of below it.
|
|
||||||
* Placement is done with grid areas so that the markup stays flat.
|
|
||||||
*/
|
|
||||||
.inline {
|
|
||||||
grid-template-columns: minmax(0, 1fr) auto;
|
|
||||||
align-items: center;
|
|
||||||
column-gap: 1rem;
|
|
||||||
|
|
||||||
> .title {
|
|
||||||
grid-area: 1 / 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .description {
|
|
||||||
grid-area: 2 / 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
> *:last-child {
|
|
||||||
grid-area: 1 / 2 / span 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
color: $ui-white;
|
font-size: $inner-section-text-size;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
color: $gray-400;
|
font-size: $inner-section-text-size;
|
||||||
font-size: $aux-text-size;
|
display: block;
|
||||||
line-height: 1.4;
|
color: $modal-note-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.closed {
|
||||||
|
transition: rotate 300ms cubic-bezier(0.45, 1.005, 0, 1.005);
|
||||||
|
rotate: 0deg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.open {
|
||||||
|
transition: rotate 300ms cubic-bezier(0.45, 1.005, 0, 1.005);
|
||||||
|
rotate: 180deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { useLocalStorage } from '@mantine/hooks';
|
import { useLocalStorage } from '@mantine/hooks';
|
||||||
import { IoChevronDown } from 'react-icons/io5';
|
import { IoChevronDown } from 'react-icons/io5';
|
||||||
import { useSearchParams } from 'react-router';
|
|
||||||
|
|
||||||
import { cx } from '../../utils/styleUtils';
|
import { cx } from '../../utils/styleUtils';
|
||||||
import Eyebrow from '../eyebrow/Eyebrow';
|
|
||||||
import { OptionTitle } from './constants';
|
import { OptionTitle } from './constants';
|
||||||
import ParamInput from './ParamInput';
|
import ParamInput from './ParamInput';
|
||||||
import { type ParamField } from './viewParams.types';
|
import { type ParamField } from './viewParams.types';
|
||||||
@@ -16,74 +14,50 @@ interface ViewParamsSectionProps {
|
|||||||
options: ParamField[];
|
options: ParamField[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fields which are compact enough to share a row with their label */
|
|
||||||
function isInlineField(option: ParamField): boolean {
|
|
||||||
return option.type === 'boolean' || option.type === 'colour';
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ViewParamsSection({ title, collapsible, options }: ViewParamsSectionProps) {
|
export default function ViewParamsSection({ title, collapsible, options }: ViewParamsSectionProps) {
|
||||||
const [collapsed, setCollapsed] = useLocalStorage({ key: `params-${title}`, defaultValue: false });
|
const [collapsed, setCollapsed] = useLocalStorage({ key: `params-${title}`, defaultValue: false });
|
||||||
const [searchParams] = useSearchParams();
|
|
||||||
|
|
||||||
// hidden options are inputs without a UI, there is nothing to frame them with
|
const handleCollapse = () => {
|
||||||
if (title === OptionTitle.Hidden) {
|
if (collapsible) {
|
||||||
return <HiddenContents options={options} />;
|
setCollapsed((prev) => !prev);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
const isCollapsed = Boolean(collapsible && collapsed);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={style.section}>
|
<section className={style.section}>
|
||||||
<SectionHeader
|
{title === OptionTitle.Hidden ? (
|
||||||
title={title}
|
<HiddenContents options={options} />
|
||||||
isCustomised={options.some((option) => searchParams.has(option.id))}
|
) : (
|
||||||
collapsed={isCollapsed}
|
<>
|
||||||
onToggle={collapsible ? () => setCollapsed((prev) => !prev) : undefined}
|
<div className={cx([style.sectionHeader, collapsible && style.collapsible])} onClick={handleCollapse}>
|
||||||
/>
|
{title}
|
||||||
{/* collapsed options stay mounted: the form reads its values from the DOM */}
|
{collapsible && <IoChevronDown className={cx([collapsed ? style.closed : style.open])} />}
|
||||||
<div className={cx([style.options, isCollapsed && style.hidden])}>
|
</div>
|
||||||
{options.map((option) => (
|
<SectionContents options={options} collapsed={collapsed} />
|
||||||
<label key={option.title} className={cx([style.label, isInlineField(option) && style.inline])}>
|
</>
|
||||||
<span className={style.title}>{option.title}</span>
|
)}
|
||||||
<span className={style.description}>{option.description}</span>
|
|
||||||
<ParamInput paramField={option} />
|
|
||||||
</label>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SectionHeaderProps {
|
interface SectionContentsProps {
|
||||||
title: string;
|
options: ParamField[];
|
||||||
isCustomised: boolean;
|
|
||||||
collapsed: boolean;
|
collapsed: boolean;
|
||||||
/** a header without a toggle belongs to a section which cannot collapse */
|
|
||||||
onToggle?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SectionHeader({ title, isCustomised, collapsed, onToggle }: SectionHeaderProps) {
|
function SectionContents({ options, collapsed }: SectionContentsProps) {
|
||||||
const label = (
|
|
||||||
<Eyebrow className={style.sectionTitle}>
|
|
||||||
{title}
|
|
||||||
{isCustomised && <span className={style.customised} title='Contains custom values' />}
|
|
||||||
</Eyebrow>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!onToggle) {
|
|
||||||
return <div className={style.sectionHeader}>{label}</div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<>
|
||||||
type='button'
|
{options.map((option) => {
|
||||||
className={cx([style.sectionHeader, style.collapsible])}
|
return (
|
||||||
aria-expanded={!collapsed}
|
<label key={option.title} className={cx([style.label, collapsed && style.hidden])}>
|
||||||
onClick={onToggle}
|
<span className={style.title}>{option.title}</span>
|
||||||
>
|
<span className={style.description}>{option.description}</span>
|
||||||
{label}
|
<ParamInput paramField={option} />
|
||||||
<IoChevronDown className={cx([style.chevron, collapsed && style.closed])} />
|
</label>
|
||||||
</button>
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,17 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import type { ReportData } from 'ontime-types';
|
import { OntimeReport } from 'ontime-types';
|
||||||
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
||||||
|
|
||||||
import { REPORT } from '../api/constants';
|
import { REPORT } from '../api/constants';
|
||||||
import { fetchReport } from '../api/report';
|
import { fetchReport } from '../api/report';
|
||||||
|
|
||||||
const emptyReport: ReportData = {
|
|
||||||
eventReports: {},
|
|
||||||
rundown: null,
|
|
||||||
show: {
|
|
||||||
plannedStart: null,
|
|
||||||
plannedEnd: null,
|
|
||||||
plannedDuration: null,
|
|
||||||
actualStart: null,
|
|
||||||
actualEnd: null,
|
|
||||||
actualDuration: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function useReport() {
|
export default function useReport() {
|
||||||
const { data: report, refetch } = useQuery<ReportData>({
|
const { data, refetch } = useQuery<OntimeReport>({
|
||||||
queryKey: REPORT,
|
queryKey: REPORT,
|
||||||
queryFn: ({ signal }) => fetchReport({ signal }),
|
queryFn: ({ signal }) => fetchReport({ signal }),
|
||||||
placeholderData: (previousData) => previousData,
|
placeholderData: (previousData, _previousQuery) => previousData,
|
||||||
staleTime: MILLIS_PER_HOUR,
|
staleTime: MILLIS_PER_HOUR,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return { data: data ?? {}, refetch };
|
||||||
data: report?.eventReports ?? emptyReport.eventReports,
|
|
||||||
report: report ?? emptyReport,
|
|
||||||
refetch,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { MaybeString } from 'ontime-types';
|
|||||||
import { RefObject, useCallback, useEffect } from 'react';
|
import { RefObject, useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
function scrollToComponent<ComponentRef extends HTMLElement, ScrollRef extends HTMLElement>(
|
function scrollToComponent<ComponentRef extends HTMLElement, ScrollRef extends HTMLElement>(
|
||||||
componentRef: RefObject<ComponentRef | null>,
|
componentRef: RefObject<ComponentRef>,
|
||||||
scrollRef: RefObject<ScrollRef | null>,
|
scrollRef: RefObject<ScrollRef>,
|
||||||
topOffset: number,
|
topOffset: number,
|
||||||
) {
|
) {
|
||||||
if (!componentRef.current || !scrollRef.current) {
|
if (!componentRef.current || !scrollRef.current) {
|
||||||
@@ -21,16 +21,18 @@ interface UseFollowComponentProps {
|
|||||||
followRef: RefObject<HTMLElement | null>;
|
followRef: RefObject<HTMLElement | null>;
|
||||||
scrollRef: RefObject<HTMLElement | null>;
|
scrollRef: RefObject<HTMLElement | null>;
|
||||||
doFollow: boolean;
|
doFollow: boolean;
|
||||||
followTrigger: MaybeString; // this would be an entry id or null
|
topOffset?: number;
|
||||||
getTopOffset: () => number;
|
setScrollFlag?: (newValue: boolean) => void;
|
||||||
|
followTrigger?: MaybeString; // this would be an entry id or null
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useFollowComponent({
|
export default function useFollowComponent({
|
||||||
followRef,
|
followRef,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
doFollow,
|
doFollow,
|
||||||
|
topOffset = 100,
|
||||||
|
setScrollFlag,
|
||||||
followTrigger,
|
followTrigger,
|
||||||
getTopOffset,
|
|
||||||
}: UseFollowComponentProps) {
|
}: UseFollowComponentProps) {
|
||||||
// when trigger moves, view should follow
|
// when trigger moves, view should follow
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -39,17 +41,25 @@ export default function useFollowComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (followRef.current && scrollRef.current) {
|
if (followRef.current && scrollRef.current) {
|
||||||
|
setScrollFlag?.(true);
|
||||||
// Use requestAnimationFrame to ensure the component is fully loaded
|
// Use requestAnimationFrame to ensure the component is fully loaded
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
// resolve the offset after layout, so that measured values are up to date
|
scrollToComponent(followRef as RefObject<HTMLElement>, scrollRef as RefObject<HTMLElement>, topOffset);
|
||||||
scrollToComponent(followRef, scrollRef, getTopOffset());
|
setScrollFlag?.(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [followTrigger, doFollow, followRef, scrollRef, getTopOffset]);
|
}, [followTrigger, doFollow, followRef, scrollRef, setScrollFlag, topOffset]);
|
||||||
|
|
||||||
const scrollToRefComponent = useCallback(() => {
|
const scrollToRefComponent = useCallback(
|
||||||
scrollToComponent(followRef, scrollRef, getTopOffset());
|
(componentRef = followRef, containerRef = scrollRef, offset = topOffset) => {
|
||||||
}, [followRef, scrollRef, getTopOffset]);
|
if (componentRef && containerRef) {
|
||||||
|
// @ts-expect-error -- we know this are not null
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
scrollToComponent(componentRef!, containerRef!, offset);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[followRef, scrollRef, topOffset],
|
||||||
|
);
|
||||||
|
|
||||||
return scrollToRefComponent;
|
return scrollToRefComponent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ import { useEffect } from 'react';
|
|||||||
*/
|
*/
|
||||||
export function useWindowTitle(title: string) {
|
export function useWindowTitle(title: string) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = `Ontime - ${title}`;
|
document.title = `ontime - ${title}`;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import type { OntimeEventReport } from 'ontime-types';
|
|
||||||
import { dayInMs, MILLIS_PER_MINUTE } from 'ontime-utils';
|
|
||||||
|
|
||||||
import { getEventVariance } from '../report';
|
|
||||||
|
|
||||||
it('uses captured days when measuring an event across midnight', () => {
|
|
||||||
const report: OntimeEventReport = {
|
|
||||||
startedAt: dayInMs - 5 * MILLIS_PER_MINUTE,
|
|
||||||
startedAtDay: 0,
|
|
||||||
endedAt: 5 * MILLIS_PER_MINUTE,
|
|
||||||
endedAtDay: 1,
|
|
||||||
scheduledStart: dayInMs - 5 * MILLIS_PER_MINUTE,
|
|
||||||
scheduledDay: 0,
|
|
||||||
scheduledDuration: 10 * MILLIS_PER_MINUTE,
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(getEventVariance(report)).toMatchObject({
|
|
||||||
actualDuration: 10 * MILLIS_PER_MINUTE,
|
|
||||||
delta: 0,
|
|
||||||
status: 'ontime',
|
|
||||||
});
|
|
||||||
expect(getEventVariance({ ...report, endedAt: null })).toMatchObject({ status: 'not-run' });
|
|
||||||
});
|
|
||||||
@@ -58,16 +58,4 @@ describe('formatDuration()', () => {
|
|||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 6 * MILLIS_PER_MINUTE + 45 * MILLIS_PER_SECOND, false)).toBe('2h6m45s');
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 6 * MILLIS_PER_MINUTE + 45 * MILLIS_PER_SECOND, false)).toBe('2h6m45s');
|
||||||
expect(formatDuration(599702, false)).toBe('9m59s');
|
expect(formatDuration(599702, false)).toBe('9m59s');
|
||||||
});
|
});
|
||||||
it('formats durations differently with and without seconds', () => {
|
|
||||||
expect(formatDuration(0, false)).toBe('0m');
|
|
||||||
expect(formatDuration(0, true)).toBe('0m');
|
|
||||||
expect(formatDuration(30 * MILLIS_PER_SECOND, false)).toBe('30s');
|
|
||||||
expect(formatDuration(30 * MILLIS_PER_SECOND, true)).toBe('');
|
|
||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, false)).toBe('2h30s');
|
|
||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, true)).toBe('2h');
|
|
||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, false)).toBe(
|
|
||||||
'2h10m30s',
|
|
||||||
);
|
|
||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, true)).toBe('2h10m');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ export function isKeyEnter<T>(event: KeyboardEvent<T>): boolean {
|
|||||||
return event.key === 'Enter';
|
return event.key === 'Enter';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isKeySpace<T>(event: KeyboardEvent<T>): boolean {
|
|
||||||
return event.key === ' ' || event.code === 'Space';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isKeyEscape<T>(event: KeyboardEvent<T>): boolean {
|
export function isKeyEscape<T>(event: KeyboardEvent<T>): boolean {
|
||||||
return event.key === 'Escape';
|
return event.key === 'Escape';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
import type { MaybeNumber, OntimeEventReport } from 'ontime-types';
|
|
||||||
import { dayInMs, MILLIS_PER_SECOND } from 'ontime-utils';
|
|
||||||
|
|
||||||
type EventVariance = {
|
|
||||||
actualDuration: MaybeNumber;
|
|
||||||
delta: number;
|
|
||||||
status: 'ontime' | 'over' | 'under' | 'not-run';
|
|
||||||
};
|
|
||||||
|
|
||||||
const notRun: EventVariance = { actualDuration: null, delta: 0, status: 'not-run' };
|
|
||||||
|
|
||||||
export function getReportTimePosition(time: number, day: number): number;
|
|
||||||
export function getReportTimePosition(time: MaybeNumber, day: number | null): MaybeNumber;
|
|
||||||
export function getReportTimePosition(time: MaybeNumber, day: number | null): MaybeNumber {
|
|
||||||
return time === null || day === null ? null : day * dayInMs + time;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getEventVariance(entry: OntimeEventReport | undefined): EventVariance {
|
|
||||||
if (!entry) return notRun;
|
|
||||||
|
|
||||||
const start = getReportTimePosition(entry.startedAt, entry.startedAtDay);
|
|
||||||
const end = getReportTimePosition(entry.endedAt, entry.endedAtDay);
|
|
||||||
if (start === null || end === null) return notRun;
|
|
||||||
|
|
||||||
const actualDuration = end - start;
|
|
||||||
const delta = actualDuration - entry.scheduledDuration;
|
|
||||||
if (Math.abs(delta) < MILLIS_PER_SECOND) return { actualDuration, delta, status: 'ontime' };
|
|
||||||
return { actualDuration, delta, status: delta > 0 ? 'over' : 'under' };
|
|
||||||
}
|
|
||||||
+35
@@ -1,3 +1,5 @@
|
|||||||
|
import { AppMode } from '../ontimeConfig';
|
||||||
|
|
||||||
declare module '*.scss' {
|
declare module '*.scss' {
|
||||||
const content: Record<string, string>;
|
const content: Record<string, string>;
|
||||||
export default content;
|
export default content;
|
||||||
@@ -30,6 +32,39 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare custom data we pass to the table
|
||||||
|
* - `handleUpdate` callback to update the entry when the user edits a cell
|
||||||
|
* - `handleUpdateTimer` callback to update the timer for a specific event
|
||||||
|
* - `options-showDelayedTimes` whether to show or hide delayed times
|
||||||
|
* - `options-hideTableSeconds` whether to hide seconds in the table
|
||||||
|
* - `options-hideIndexColumn` whether to hide the index column
|
||||||
|
* - `options-cuesheetMode` run or edit mode
|
||||||
|
*
|
||||||
|
* And metadata specific for each column
|
||||||
|
* - `canWrite` whether the user can write to this column
|
||||||
|
* - `colour` background colour associated with a custom field
|
||||||
|
*/
|
||||||
|
declare module '@tanstack/react-table' {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface TableMeta<TData extends RowData> {
|
||||||
|
handleUpdate: (rowIndex: number, accessor: string, payload: string, isCustom: boolean) => void;
|
||||||
|
handleUpdateTimer: (eventId: string, field: TimeField, payload: string) => void;
|
||||||
|
options: {
|
||||||
|
showDelayedTimes: boolean;
|
||||||
|
hideTableSeconds: boolean;
|
||||||
|
hideIndexColumn: boolean;
|
||||||
|
cuesheetMode: AppMode;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface ColumnMeta<TData extends RowData, TValue> {
|
||||||
|
canWrite: boolean;
|
||||||
|
colour?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow passing CSS Properties
|
* Allow passing CSS Properties
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ ul {
|
|||||||
&.active {
|
&.active {
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
border-left-color: $blue-400;
|
border-left-color: $blue-400;
|
||||||
background-color: $bg-active;
|
background-color: rgba($blue-500, 0.16);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ ul {
|
|||||||
&.active {
|
&.active {
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
border-left-color: $blue-400;
|
border-left-color: $blue-400;
|
||||||
background-color: $bg-active;
|
background-color: rgba($blue-500, 0.16);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ $card-padding: 2rem;
|
|||||||
// active rows use a panel-local class today; keep the treatment here so all
|
// active rows use a panel-local class today; keep the treatment here so all
|
||||||
// settings tables share the same state without each panel owning its colours
|
// settings tables share the same state without each panel owning its colours
|
||||||
tr[class*='current'] {
|
tr[class*='current'] {
|
||||||
background-color: $bg-active;
|
background-color: rgba($blue-500, 0.16);
|
||||||
|
|
||||||
> td:first-child {
|
> td:first-child {
|
||||||
box-shadow: inset 3px 0 $blue-400;
|
box-shadow: inset 3px 0 $blue-400;
|
||||||
@@ -200,7 +200,8 @@ $card-padding: 2rem;
|
|||||||
.overlay {
|
.overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: $zindex-backdrop;
|
z-index: $zindex-backdrop;
|
||||||
inset: 0;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
display: grid;
|
display: grid;
|
||||||
place-content: center;
|
place-content: center;
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
.updateIndicator {
|
|
||||||
width: 0.5em;
|
|
||||||
height: 0.5em;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
border-radius: 99px;
|
|
||||||
background-color: $red-400;
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ import useAppVersion from '../../../../common/hooks-query/useAppVersion';
|
|||||||
import { appVersion, isOntimeCloud, websiteUrl } from '../../../../externals';
|
import { appVersion, isOntimeCloud, websiteUrl } from '../../../../externals';
|
||||||
import * as Panel from '../../panel-utils/PanelUtils';
|
import * as Panel from '../../panel-utils/PanelUtils';
|
||||||
|
|
||||||
import style from './AppVersion.module.scss';
|
|
||||||
|
|
||||||
export default function AppVersion() {
|
export default function AppVersion() {
|
||||||
const { data, isError } = useAppVersion();
|
const { data, isError } = useAppVersion();
|
||||||
|
|
||||||
@@ -20,12 +18,7 @@ export default function AppVersion() {
|
|||||||
return (
|
return (
|
||||||
<Panel.ListItem>
|
<Panel.ListItem>
|
||||||
<Panel.Field
|
<Panel.Field
|
||||||
title={
|
title={`Ontime ${appVersion}`}
|
||||||
<>
|
|
||||||
<span className={style.updateIndicator} aria-hidden='true' />
|
|
||||||
{`Ontime ${appVersion}`}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
description={
|
description={
|
||||||
isOntimeCloud
|
isOntimeCloud
|
||||||
? `Version ${data.version} is available. Restart your stage to update.`
|
? `Version ${data.version} is available. Restart your stage to update.`
|
||||||
@@ -33,7 +26,7 @@ export default function AppVersion() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{!isOntimeCloud && (
|
{!isOntimeCloud && (
|
||||||
<ExternalLink href={websiteUrl}>Download the latest version from Ontime's page</ExternalLink>
|
<ExternalLink href={websiteUrl}>Visit Ontime's page to download the latest version.</ExternalLink>
|
||||||
)}
|
)}
|
||||||
</Panel.ListItem>
|
</Panel.ListItem>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
th.over {
|
||||||
|
color: $playback-over;
|
||||||
|
}
|
||||||
|
|
||||||
|
th.under {
|
||||||
|
color: $playback-under;
|
||||||
|
}
|
||||||
@@ -1,72 +1,103 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { IoDownloadOutline, IoTrashBin } from 'react-icons/io5';
|
import { IoTrashBin } from 'react-icons/io5';
|
||||||
|
|
||||||
import { deleteAllReport } from '../../../../common/api/report';
|
import { deleteAllReport } from '../../../../common/api/report';
|
||||||
import { createBlob, downloadBlob } from '../../../../common/api/utils';
|
import { createBlob, downloadBlob } from '../../../../common/api/utils';
|
||||||
import Button from '../../../../common/components/buttons/Button';
|
import Button from '../../../../common/components/buttons/Button';
|
||||||
import useReport from '../../../../common/hooks-query/useReport';
|
import useReport from '../../../../common/hooks-query/useReport';
|
||||||
|
import useRundown from '../../../../common/hooks-query/useRundown';
|
||||||
|
import { cx } from '../../../../common/utils/styleUtils';
|
||||||
|
import { formatTime } from '../../../../common/utils/time';
|
||||||
import * as Panel from '../../panel-utils/PanelUtils';
|
import * as Panel from '../../panel-utils/PanelUtils';
|
||||||
import ReportShowSummary from './composite/ReportShowSummary';
|
import { CombinedReport, getCombinedReport, makeReportCSV } from './reportSettings.utils';
|
||||||
import ReportTable from './composite/ReportTable';
|
|
||||||
import { getCombinedReport, getGroupReports, getRunSummary, makeReportCSV } from './reportSettings.utils';
|
import style from './ReportSettings.module.scss';
|
||||||
|
|
||||||
export default function ReportSettings() {
|
export default function ReportSettings() {
|
||||||
const { report } = useReport();
|
const { data: reportData } = useReport();
|
||||||
const { eventReports, rundown, show } = report;
|
const { data } = useRundown();
|
||||||
|
|
||||||
const { combinedReport, groups, summary } = useMemo(() => {
|
|
||||||
const entries = rundown?.entries ?? {};
|
|
||||||
return {
|
|
||||||
combinedReport: rundown ? getCombinedReport(eventReports, entries, rundown.flatOrder) : [],
|
|
||||||
groups: rundown ? getGroupReports(eventReports, entries, rundown.order) : [],
|
|
||||||
summary: getRunSummary(eventReports, entries, rundown?.flatOrder ?? []),
|
|
||||||
};
|
|
||||||
}, [eventReports, rundown]);
|
|
||||||
|
|
||||||
const hasReport = rundown !== null && Object.keys(eventReports).length > 0;
|
|
||||||
const downloadCSV = () => {
|
|
||||||
if (!hasReport) return;
|
|
||||||
|
|
||||||
|
const clearReport = async () => await deleteAllReport();
|
||||||
|
const downloadCSV = (combinedReport: CombinedReport[]) => {
|
||||||
|
if (!combinedReport) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const csv = makeReportCSV(combinedReport);
|
const csv = makeReportCSV(combinedReport);
|
||||||
const blob = createBlob(csv, 'text/csv;charset=utf-8;');
|
const blob = createBlob(csv, 'text/csv;charset=utf-8;');
|
||||||
downloadBlob(blob, 'ontime-report.csv');
|
downloadBlob(blob, 'ontime-report.csv');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const combinedReport = useMemo(() => {
|
||||||
|
return getCombinedReport(reportData, data.entries, data.flatOrder);
|
||||||
|
}, [reportData, data.entries, data.flatOrder]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel.Section>
|
<Panel.Section>
|
||||||
<Panel.Card>
|
<Panel.Card>
|
||||||
<Panel.SubHeader>
|
<Panel.SubHeader>Report</Panel.SubHeader>
|
||||||
Report
|
|
||||||
<Panel.InlineElements>
|
|
||||||
<Button onClick={downloadCSV} disabled={!hasReport}>
|
|
||||||
<IoDownloadOutline />
|
|
||||||
Export CSV
|
|
||||||
</Button>
|
|
||||||
<Button variant='subtle-destructive' onClick={deleteAllReport} disabled={!hasReport}>
|
|
||||||
<IoTrashBin />
|
|
||||||
Clear Report
|
|
||||||
</Button>
|
|
||||||
</Panel.InlineElements>
|
|
||||||
</Panel.SubHeader>
|
|
||||||
<Panel.Divider />
|
<Panel.Divider />
|
||||||
|
<Panel.Section>
|
||||||
|
<Panel.Title>
|
||||||
|
Manage report
|
||||||
|
<Panel.InlineElements>
|
||||||
|
<Button onClick={() => downloadCSV(combinedReport)} disabled={combinedReport.length === 0}>
|
||||||
|
<IoTrashBin />
|
||||||
|
Export CSV
|
||||||
|
</Button>
|
||||||
|
<Button variant='subtle-destructive' onClick={clearReport} disabled={combinedReport.length === 0}>
|
||||||
|
<IoTrashBin />
|
||||||
|
Clear All
|
||||||
|
</Button>
|
||||||
|
</Panel.InlineElements>
|
||||||
|
</Panel.Title>
|
||||||
|
</Panel.Section>
|
||||||
|
<Panel.Section>
|
||||||
|
<Panel.Table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>Cue</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Scheduled Start</th>
|
||||||
|
<th>Actual Start</th>
|
||||||
|
<th>Scheduled End</th>
|
||||||
|
<th>Actual End</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{combinedReport.length === 0 && (
|
||||||
|
<Panel.TableEmpty
|
||||||
|
title='No report data yet'
|
||||||
|
description='Reports are generated as you run through the show, comparing scheduled times against what actually happened.'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{!hasReport ? (
|
{combinedReport.map((entry) => {
|
||||||
<Panel.Section>
|
const start = (() => {
|
||||||
<Panel.EmptyState
|
if (entry.actualStart === null) return null;
|
||||||
title='No report yet'
|
if (entry.actualStart <= entry.scheduledStart) return 'under';
|
||||||
description='Start an event to record actual timings against the schedule.'
|
return 'over';
|
||||||
/>
|
})();
|
||||||
</Panel.Section>
|
const end = (() => {
|
||||||
) : (
|
if (entry.actualEnd === null) return null;
|
||||||
<>
|
if (entry.actualEnd <= entry.scheduledEnd) return 'under';
|
||||||
<Panel.Section>
|
return 'over';
|
||||||
<ReportShowSummary rundownTitle={rundown.title} show={show} summary={summary} />
|
})();
|
||||||
</Panel.Section>
|
return (
|
||||||
<Panel.Section>
|
<tr key={entry.id}>
|
||||||
<ReportTable rows={combinedReport} groups={groups} />
|
<th>{entry.index}</th>
|
||||||
</Panel.Section>
|
<th>{entry.cue}</th>
|
||||||
</>
|
<th>{entry.title}</th>
|
||||||
)}
|
<th className={cx([start && style[start]])}>{formatTime(entry.scheduledStart)}</th>
|
||||||
|
<th className={cx([start && style[start]])}>{formatTime(entry.actualStart)}</th>
|
||||||
|
<th className={cx([end && style[end]])}>{formatTime(entry.scheduledEnd)}</th>
|
||||||
|
<th className={cx([end && style[end]])}>{formatTime(entry.actualEnd)}</th>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</Panel.Table>
|
||||||
|
</Panel.Section>
|
||||||
</Panel.Card>
|
</Panel.Card>
|
||||||
</Panel.Section>
|
</Panel.Section>
|
||||||
);
|
);
|
||||||
|
|||||||
-156
@@ -1,156 +0,0 @@
|
|||||||
import type { OntimeEventReport, OntimeReport } from 'ontime-types';
|
|
||||||
import {
|
|
||||||
createDelay,
|
|
||||||
createEvent,
|
|
||||||
createGroup,
|
|
||||||
dayInMs,
|
|
||||||
MILLIS_PER_HOUR,
|
|
||||||
MILLIS_PER_MINUTE,
|
|
||||||
MILLIS_PER_SECOND,
|
|
||||||
} from 'ontime-utils';
|
|
||||||
|
|
||||||
import {
|
|
||||||
formatOffset,
|
|
||||||
getCombinedReport,
|
|
||||||
getGroupReports,
|
|
||||||
getRunSummary,
|
|
||||||
getShowOffsets,
|
|
||||||
makeReportCSV,
|
|
||||||
} from '../reportSettings.utils';
|
|
||||||
|
|
||||||
function makeEvent(id: string, patch = {}) {
|
|
||||||
const event = createEvent({ id, title: id, ...patch });
|
|
||||||
if (!event) throw new Error('Failed to create test event');
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeReport(patch: Partial<OntimeEventReport> = {}): OntimeEventReport {
|
|
||||||
return {
|
|
||||||
startedAt: 5 * MILLIS_PER_MINUTE,
|
|
||||||
startedAtDay: 1,
|
|
||||||
endedAt: 15 * MILLIS_PER_MINUTE,
|
|
||||||
endedAtDay: 1,
|
|
||||||
scheduledStart: dayInMs - 5 * MILLIS_PER_MINUTE,
|
|
||||||
scheduledDay: 0,
|
|
||||||
scheduledDuration: 10 * MILLIS_PER_MINUTE,
|
|
||||||
...patch,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('getCombinedReport()', () => {
|
|
||||||
it('uses the captured schedule and absolute day when calculating offsets', () => {
|
|
||||||
const entry = makeEvent('a', { timeStart: 0, duration: 99 * MILLIS_PER_MINUTE });
|
|
||||||
const rows = getCombinedReport({ a: makeReport() }, { a: entry }, ['a']);
|
|
||||||
|
|
||||||
expect(rows[0]).toMatchObject({
|
|
||||||
scheduledStart: dayInMs - 5 * MILLIS_PER_MINUTE,
|
|
||||||
scheduledEnd: dayInMs + 5 * MILLIS_PER_MINUTE,
|
|
||||||
startOffset: 10 * MILLIS_PER_MINUTE,
|
|
||||||
endOffset: 10 * MILLIS_PER_MINUTE,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('includes unplayed events but excludes skipped and non-event entries', () => {
|
|
||||||
const ran = makeEvent('ran');
|
|
||||||
const unplayed = makeEvent('unplayed', { timeStart: 20 * MILLIS_PER_MINUTE });
|
|
||||||
const skipped = makeEvent('skipped', { skip: true });
|
|
||||||
const delay = createDelay({ id: 'delay' });
|
|
||||||
const report: OntimeReport = { ran: makeReport({ scheduledStart: 0, scheduledDay: 0 }) };
|
|
||||||
|
|
||||||
const rows = getCombinedReport(report, { ran, unplayed, skipped, delay }, ['ran', 'unplayed', 'skipped', 'delay']);
|
|
||||||
|
|
||||||
expect(rows.map(({ id }) => id)).toEqual(['ran', 'unplayed']);
|
|
||||||
expect(rows[1]).toMatchObject({ scheduledStart: unplayed.timeStart, actualStart: null, actualEnd: null });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('report calculations', () => {
|
|
||||||
it('keeps finishing time separate from running time', () => {
|
|
||||||
const offsets = getShowOffsets({
|
|
||||||
plannedStart: 19 * MILLIS_PER_HOUR,
|
|
||||||
plannedEnd: 21 * MILLIS_PER_HOUR,
|
|
||||||
plannedDuration: 2 * MILLIS_PER_HOUR,
|
|
||||||
actualStart: 19 * MILLIS_PER_HOUR - 10 * MILLIS_PER_MINUTE,
|
|
||||||
actualEnd: 21 * MILLIS_PER_HOUR - 6 * MILLIS_PER_MINUTE,
|
|
||||||
actualDuration: 2 * MILLIS_PER_HOUR + 4 * MILLIS_PER_MINUTE,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(offsets).toMatchObject({
|
|
||||||
startOffset: -10 * MILLIS_PER_MINUTE,
|
|
||||||
endOffset: -6 * MILLIS_PER_MINUTE,
|
|
||||||
durationOffset: 4 * MILLIS_PER_MINUTE,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('measures completed groups against their target', () => {
|
|
||||||
const group = createGroup({ id: 'group', entries: ['a', 'b'], targetDuration: 30 * MILLIS_PER_MINUTE });
|
|
||||||
const entries = {
|
|
||||||
group,
|
|
||||||
a: makeEvent('a', { parent: group.id, duration: 10 * MILLIS_PER_MINUTE }),
|
|
||||||
b: makeEvent('b', { parent: group.id, duration: 10 * MILLIS_PER_MINUTE }),
|
|
||||||
};
|
|
||||||
const report: OntimeReport = {
|
|
||||||
a: makeReport({ startedAt: 0, startedAtDay: 0, endedAt: 10 * MILLIS_PER_MINUTE, endedAtDay: 0 }),
|
|
||||||
b: makeReport({
|
|
||||||
startedAt: 15 * MILLIS_PER_MINUTE,
|
|
||||||
startedAtDay: 0,
|
|
||||||
endedAt: 25 * MILLIS_PER_MINUTE,
|
|
||||||
endedAtDay: 0,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(getGroupReports(report, entries, [group.id])[0]).toMatchObject({
|
|
||||||
elapsed: 25 * MILLIS_PER_MINUTE,
|
|
||||||
variance: -5 * MILLIS_PER_MINUTE,
|
|
||||||
eventsRun: 2,
|
|
||||||
eventsPlanned: 2,
|
|
||||||
});
|
|
||||||
expect(getGroupReports({ a: report.a }, entries, [group.id])[0].variance).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('summarises completed events and excludes skipped events from the plan', () => {
|
|
||||||
const entries = { a: makeEvent('a'), b: makeEvent('b', { skip: true }) };
|
|
||||||
const report = {
|
|
||||||
a: makeReport({ startedAt: 0, startedAtDay: 0, endedAt: 15 * MILLIS_PER_MINUTE, endedAtDay: 0 }),
|
|
||||||
b: makeReport({ startedAt: 0, startedAtDay: 0, endedAt: 30 * MILLIS_PER_MINUTE, endedAtDay: 0 }),
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(getRunSummary(report, entries, ['a', 'b'])).toEqual({ eventsRun: 2, eventsPlanned: 1 });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('report formatting', () => {
|
|
||||||
it.each([
|
|
||||||
[null, '–'],
|
|
||||||
[MILLIS_PER_SECOND / 2, 'On time'],
|
|
||||||
[4 * MILLIS_PER_MINUTE + 12 * MILLIS_PER_SECOND, '+4m12s'],
|
|
||||||
[-MILLIS_PER_MINUTE, '-1m'],
|
|
||||||
])('formats offset %s', (value, expected) => {
|
|
||||||
expect(formatOffset(value)).toBe(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('exports group context and leaves missing actual times empty', () => {
|
|
||||||
const csv = makeReportCSV([
|
|
||||||
{
|
|
||||||
id: 'a',
|
|
||||||
index: 1,
|
|
||||||
title: 'Welcome',
|
|
||||||
cue: '1',
|
|
||||||
parent: 'act1',
|
|
||||||
groupTitle: 'Act 1',
|
|
||||||
scheduledStart: 0,
|
|
||||||
scheduledEnd: 10 * MILLIS_PER_MINUTE,
|
|
||||||
actualStart: null,
|
|
||||||
startOffset: null,
|
|
||||||
actualEnd: null,
|
|
||||||
endOffset: null,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const fields = csv.trim().split('\n')[1].split(',');
|
|
||||||
expect(csv).toContain('Group');
|
|
||||||
expect(fields[1]).toBe('Act 1');
|
|
||||||
expect(fields[5]).toBe('');
|
|
||||||
expect(fields[7]).toBe('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
-104
@@ -1,104 +0,0 @@
|
|||||||
// Panel.Table nests its own padding inside the section it sits in, so the
|
|
||||||
// summary takes the same inset to keep one left edge down the whole panel
|
|
||||||
.inset {
|
|
||||||
padding: 0 var(--panel-card-padding, 2rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary {
|
|
||||||
padding: 1.25rem;
|
|
||||||
background-color: $gray-1200;
|
|
||||||
border-radius: 3px;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
margin: 0;
|
|
||||||
color: $ui-white;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.body {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: space-between;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 1rem 2.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.headline {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.25rem;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.headlineLabel,
|
|
||||||
.metricLabel {
|
|
||||||
color: $gray-300;
|
|
||||||
font-size: calc(1rem - 2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.headlineValue {
|
|
||||||
font-size: 1.75rem;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.1;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.unavailable {
|
|
||||||
max-width: 32rem;
|
|
||||||
color: $warning-orange;
|
|
||||||
font-size: calc(1rem - 2px);
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metrics {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto auto auto;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 0.375rem 1.5rem;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metricValue,
|
|
||||||
.metricOffset {
|
|
||||||
margin: 0;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metricValue {
|
|
||||||
display: flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.planned,
|
|
||||||
.arrow {
|
|
||||||
color: $gray-300;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actual {
|
|
||||||
color: $ui-white;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metricOffset {
|
|
||||||
justify-self: end;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.over {
|
|
||||||
color: $playback-over;
|
|
||||||
}
|
|
||||||
|
|
||||||
.under {
|
|
||||||
color: $playback-under;
|
|
||||||
}
|
|
||||||
|
|
||||||
.none {
|
|
||||||
color: $gray-300;
|
|
||||||
}
|
|
||||||
-118
@@ -1,118 +0,0 @@
|
|||||||
import type { MaybeNumber, ShowReport } from 'ontime-types';
|
|
||||||
|
|
||||||
import { cx, enDash } from '../../../../../common/utils/styleUtils';
|
|
||||||
import { formatDuration, formatTime } from '../../../../../common/utils/time';
|
|
||||||
import { formatOffset, getShowOffsets, offsetTone } from '../reportSettings.utils';
|
|
||||||
import type { RunSummary } from '../reportSettings.utils';
|
|
||||||
|
|
||||||
import style from './ReportShowSummary.module.scss';
|
|
||||||
|
|
||||||
interface ReportShowSummaryProps {
|
|
||||||
rundownTitle: string;
|
|
||||||
show: ShowReport;
|
|
||||||
summary: RunSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Leads the report with whether the show ran to the length it was planned for.
|
|
||||||
*
|
|
||||||
* Running time is the headline rather than finishing time because it is the
|
|
||||||
* part the team controls and the part that carries into the next run of the
|
|
||||||
* same rundown. Finishing time is the other question a report is asked, and
|
|
||||||
* the two can point opposite ways, so it stays beside it as its own row
|
|
||||||
* rather than being folded into a single figure.
|
|
||||||
*/
|
|
||||||
export default function ReportShowSummary({ rundownTitle, show, summary }: ReportShowSummaryProps) {
|
|
||||||
const offsets = getShowOffsets(show);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A show that stopped early has no meaningful end: its last event is simply
|
|
||||||
* where it got to. Measuring that against the plan would report a show which
|
|
||||||
* never finished as having come in comfortably short.
|
|
||||||
*/
|
|
||||||
const didReachEnd = summary.eventsRun > 0 && summary.eventsRun === summary.eventsPlanned;
|
|
||||||
const hasPlan = offsets.startOffset !== null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={style.inset}>
|
|
||||||
<section className={style.summary} aria-labelledby='report-summary-title'>
|
|
||||||
<h4 id='report-summary-title' className={style.title}>
|
|
||||||
{rundownTitle || 'Untitled rundown'}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<div className={style.body}>
|
|
||||||
<div className={style.headline}>
|
|
||||||
<span className={style.headlineLabel}>{didReachEnd ? 'Show duration' : 'Show incomplete'}</span>
|
|
||||||
{didReachEnd && offsets.durationOffset !== null ? (
|
|
||||||
<span className={cx([style.headlineValue, style[offsetTone(offsets.durationOffset)]])}>
|
|
||||||
{formatOffset(offsets.durationOffset)}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className={style.unavailable}>The show did not reach the end of the rundown.</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<dl className={style.metrics}>
|
|
||||||
{hasPlan && (
|
|
||||||
<Metric
|
|
||||||
label='Started'
|
|
||||||
planned={formatMaybeTime(show.plannedStart)}
|
|
||||||
actual={formatMaybeTime(show.actualStart)}
|
|
||||||
offset={offsets.startOffset}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{hasPlan && didReachEnd && (
|
|
||||||
<Metric
|
|
||||||
label='Ended'
|
|
||||||
planned={formatMaybeTime(show.plannedEnd)}
|
|
||||||
actual={formatMaybeTime(show.actualEnd)}
|
|
||||||
offset={offsets.endOffset}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{didReachEnd && (
|
|
||||||
<Metric
|
|
||||||
label='Duration'
|
|
||||||
planned={formatMaybeDuration(show.plannedDuration)}
|
|
||||||
actual={formatMaybeDuration(show.actualDuration)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Metric({
|
|
||||||
label,
|
|
||||||
planned,
|
|
||||||
actual,
|
|
||||||
offset,
|
|
||||||
}: {
|
|
||||||
label: string;
|
|
||||||
planned: string;
|
|
||||||
actual: string;
|
|
||||||
offset?: MaybeNumber;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<dt className={style.metricLabel}>{label}</dt>
|
|
||||||
<dd className={style.metricValue}>
|
|
||||||
<span className={style.planned}>{planned}</span>
|
|
||||||
<span className={style.arrow}>→</span>
|
|
||||||
<span className={style.actual}>{actual}</span>
|
|
||||||
</dd>
|
|
||||||
<dd className={cx([style.metricOffset, offset !== undefined && style[offsetTone(offset)]])}>
|
|
||||||
{offset === undefined ? '' : formatOffset(offset)}
|
|
||||||
</dd>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatMaybeTime(value: MaybeNumber): string {
|
|
||||||
return value === null ? enDash : formatTime(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatMaybeDuration(value: MaybeNumber): string {
|
|
||||||
return value === null ? enDash : formatDuration(value, false);
|
|
||||||
}
|
|
||||||
-144
@@ -1,144 +0,0 @@
|
|||||||
$rail: var(--user-bg, #{$gray-500});
|
|
||||||
$event-wash: var(--event-bg, transparent);
|
|
||||||
|
|
||||||
// event rows carry their values in td, not th: the panel's th styling is meant
|
|
||||||
// for column headings and renders whatever it holds small, bold and upper case
|
|
||||||
td.over {
|
|
||||||
color: $playback-over;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.under {
|
|
||||||
color: $playback-under;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eventRow td {
|
|
||||||
background-color: color-mix(in srgb, #{$gray-1300} 96%, #{$event-wash} 4%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupedRow td:first-child {
|
|
||||||
box-shadow: inset 2px 0 $rail;
|
|
||||||
// clear the rail rather than sitting against it
|
|
||||||
padding-left: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupRow > * {
|
|
||||||
background-color: color-mix(in srgb, #{$gray-1300} 88%, #{$rail} 12%);
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupSpacer {
|
|
||||||
height: 0.75rem;
|
|
||||||
background: transparent !important;
|
|
||||||
|
|
||||||
td {
|
|
||||||
height: 0.75rem;
|
|
||||||
padding: 0;
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
th.groupSummary {
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
box-shadow: inset 4px 0 $rail;
|
|
||||||
|
|
||||||
text-align: left;
|
|
||||||
text-transform: none;
|
|
||||||
letter-spacing: normal;
|
|
||||||
|
|
||||||
> * {
|
|
||||||
text-transform: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupTitle,
|
|
||||||
.groupLabel,
|
|
||||||
.groupValues {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupTitle {
|
|
||||||
color: $ui-white;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupBody {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 0.75rem 2.5rem;
|
|
||||||
margin-top: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupHeadline {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupLabel,
|
|
||||||
.groupMetrics dt {
|
|
||||||
color: $gray-400;
|
|
||||||
font-size: calc(1rem - 3px);
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupHeadlineValue {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.1;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupMetrics {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto auto;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 0.375rem 1.5rem;
|
|
||||||
margin: 0;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupMetrics dd {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.groupValues {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
color: $gray-300;
|
|
||||||
|
|
||||||
b {
|
|
||||||
color: $ui-white;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.unavailable {
|
|
||||||
color: $gray-400;
|
|
||||||
font-size: calc(1rem - 3px);
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.arrow {
|
|
||||||
color: $gray-500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.over {
|
|
||||||
color: $playback-over;
|
|
||||||
}
|
|
||||||
|
|
||||||
.under {
|
|
||||||
color: $playback-under;
|
|
||||||
}
|
|
||||||
|
|
||||||
.none {
|
|
||||||
color: $ui-white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eventCue,
|
|
||||||
.eventIndex {
|
|
||||||
color: $gray-300;
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
import type { EntryId } from 'ontime-types';
|
|
||||||
import { useMemo } from 'react';
|
|
||||||
|
|
||||||
import { cx, enDash } from '../../../../../common/utils/styleUtils';
|
|
||||||
import { formatDuration, formatTime } from '../../../../../common/utils/time';
|
|
||||||
import * as Panel from '../../../panel-utils/PanelUtils';
|
|
||||||
import { formatOffset, offsetTone } from '../reportSettings.utils';
|
|
||||||
import type { CombinedReport, GroupReport } from '../reportSettings.utils';
|
|
||||||
|
|
||||||
import style from './ReportTable.module.scss';
|
|
||||||
|
|
||||||
interface ReportTableProps {
|
|
||||||
rows: CombinedReport[];
|
|
||||||
groups: GroupReport[];
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReportColourStyle = React.CSSProperties & Partial<Record<'--event-bg' | '--user-bg', string | undefined>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The report laid out the way the show was planned: blocks, then the events
|
|
||||||
* inside them. Each block carries how it ran against the budget set for it.
|
|
||||||
*/
|
|
||||||
export default function ReportTable({ rows, groups }: ReportTableProps) {
|
|
||||||
// groups are rendered where their first event appears, so the table follows
|
|
||||||
// the rundown rather than a separate ordering
|
|
||||||
const sections = useMemo(() => makeSections(rows, groups), [rows, groups]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Panel.Table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>#</th>
|
|
||||||
<th>Cue</th>
|
|
||||||
<th>Title</th>
|
|
||||||
<th>Scheduled Start</th>
|
|
||||||
<th>Actual Start</th>
|
|
||||||
<th>Scheduled End</th>
|
|
||||||
<th>Actual End</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
{sections.map((section, index) => (
|
|
||||||
<tbody key={section.key}>
|
|
||||||
{section.group && index > 0 && <GroupSpacer />}
|
|
||||||
{section.group && <GroupRow group={section.group} />}
|
|
||||||
{section.rows.map((entry) => (
|
|
||||||
<EventRow
|
|
||||||
key={entry.id}
|
|
||||||
entry={entry}
|
|
||||||
groupColour={section.group?.colour}
|
|
||||||
grouped={section.group !== null}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
))}
|
|
||||||
</Panel.Table>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function GroupSpacer() {
|
|
||||||
return (
|
|
||||||
<tr aria-hidden='true' className={style.groupSpacer}>
|
|
||||||
<td colSpan={7} />
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A group read the same way as the show above it: what it was measured
|
|
||||||
* against, what it actually did, and how much of it ran.
|
|
||||||
*/
|
|
||||||
function GroupRow({ group }: { group: GroupReport }) {
|
|
||||||
const hasTarget = group.targetDuration !== null;
|
|
||||||
const measuredAgainst = group.targetDuration ?? group.scheduledDuration;
|
|
||||||
const unavailableReason = group.eventsRun === 0 ? 'Did not run' : 'Still running';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<tr className={style.groupRow} style={groupColourStyle(group.colour)}>
|
|
||||||
<th scope='rowgroup' colSpan={7} className={style.groupSummary}>
|
|
||||||
<span className={style.groupTitle}>{group.title || 'Untitled group'}</span>
|
|
||||||
<div className={style.groupBody}>
|
|
||||||
<div className={style.groupHeadline}>
|
|
||||||
<span className={style.groupLabel}>{hasTarget ? 'Against target' : 'Against schedule'}</span>
|
|
||||||
{group.variance === null ? (
|
|
||||||
<span className={style.unavailable}>{unavailableReason}</span>
|
|
||||||
) : (
|
|
||||||
<span className={cx([style.groupHeadlineValue, style[offsetTone(group.variance)]])}>
|
|
||||||
{formatOffset(group.variance)}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<dl className={style.groupMetrics}>
|
|
||||||
<dt>{hasTarget ? 'Target' : 'Scheduled'}</dt>
|
|
||||||
<dd className={style.groupValues}>
|
|
||||||
<span>{formatDuration(measuredAgainst, false)}</span>
|
|
||||||
<span className={style.arrow}>→</span>
|
|
||||||
<b>{group.elapsed === null ? enDash : formatDuration(group.elapsed, false)}</b>
|
|
||||||
</dd>
|
|
||||||
{group.actualStart !== null && group.actualEnd !== null && (
|
|
||||||
<>
|
|
||||||
<dt>Ran</dt>
|
|
||||||
<dd className={style.groupValues}>
|
|
||||||
<span>{formatTime(group.actualStart)}</span>
|
|
||||||
<span className={style.arrow}>→</span>
|
|
||||||
<b>{formatTime(group.actualEnd)}</b>
|
|
||||||
</dd>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function EventRow({ entry, groupColour, grouped }: { entry: CombinedReport; groupColour?: string; grouped: boolean }) {
|
|
||||||
const start = offsetTone(entry.startOffset);
|
|
||||||
const end = offsetTone(entry.endOffset);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<tr className={cx([style.eventRow, grouped && style.groupedRow])} style={eventColours(entry.colour, groupColour)}>
|
|
||||||
<td className={style.eventIndex}>{entry.index}</td>
|
|
||||||
<td className={style.eventCue}>{entry.cue}</td>
|
|
||||||
<td>{entry.title}</td>
|
|
||||||
<td>{formatTime(entry.scheduledStart)}</td>
|
|
||||||
<td className={cx([style[start]])}>{formatTime(entry.actualStart)}</td>
|
|
||||||
<td>{formatTime(entry.scheduledEnd)}</td>
|
|
||||||
<td className={cx([style[end]])}>{formatTime(entry.actualEnd)}</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses the cuesheet's custom property for group colour. Left unset when the
|
|
||||||
* group has none so the stylesheet can provide a neutral edge.
|
|
||||||
*/
|
|
||||||
function groupColourStyle(colour?: string): ReportColourStyle {
|
|
||||||
const style: ReportColourStyle = {};
|
|
||||||
if (colour) style['--user-bg'] = colour;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Keeps the event wash distinct from its parent group's identifying rail. */
|
|
||||||
function eventColours(eventColour: string, groupColour?: string): ReportColourStyle {
|
|
||||||
const style: ReportColourStyle = {};
|
|
||||||
if (eventColour) style['--event-bg'] = eventColour;
|
|
||||||
if (groupColour) style['--user-bg'] = groupColour;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Section = {
|
|
||||||
key: string;
|
|
||||||
group: GroupReport | null;
|
|
||||||
rows: CombinedReport[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits the rows into the blocks they belong to, keeping rundown order and
|
|
||||||
* leaving ungrouped events in their own run of rows.
|
|
||||||
*/
|
|
||||||
function makeSections(rows: CombinedReport[], groups: GroupReport[]): Section[] {
|
|
||||||
const byId = new Map<EntryId, GroupReport>(groups.map((group) => [group.id, group]));
|
|
||||||
const sections: Section[] = [];
|
|
||||||
let current: Section | null = null;
|
|
||||||
|
|
||||||
let currentParent: EntryId | null | undefined;
|
|
||||||
|
|
||||||
for (const row of rows) {
|
|
||||||
if (current === null || row.parent !== currentParent) {
|
|
||||||
currentParent = row.parent;
|
|
||||||
// index keeps the key unique even if a group were to appear twice
|
|
||||||
current = {
|
|
||||||
key: `${row.parent ?? 'ungrouped'}-${sections.length}`,
|
|
||||||
group: row.parent ? (byId.get(row.parent) ?? null) : null,
|
|
||||||
rows: [],
|
|
||||||
};
|
|
||||||
sections.push(current);
|
|
||||||
}
|
|
||||||
current.rows.push(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sections;
|
|
||||||
}
|
|
||||||
+8
-9
@@ -12,21 +12,20 @@ import { useUpdateUrlPreset } from '../../../../../common/hooks-query/useUrlPres
|
|||||||
import { isUrlSafe } from '../../../../../common/utils/regex';
|
import { isUrlSafe } from '../../../../../common/utils/regex';
|
||||||
import { enDash } from '../../../../../common/utils/styleUtils';
|
import { enDash } from '../../../../../common/utils/styleUtils';
|
||||||
import { generateUrlPresetOptions } from '../../../../../common/utils/urlPresets';
|
import { generateUrlPresetOptions } from '../../../../../common/utils/urlPresets';
|
||||||
import { viewLabels } from '../../../../../viewerConfig';
|
|
||||||
import CuesheetLinkOptions, { CuesheetPermissionValues } from '../../../../sharing/composite/CuesheetLinkOptions';
|
import CuesheetLinkOptions, { CuesheetPermissionValues } from '../../../../sharing/composite/CuesheetLinkOptions';
|
||||||
import * as Panel from '../../../panel-utils/PanelUtils';
|
import * as Panel from '../../../panel-utils/PanelUtils';
|
||||||
|
|
||||||
import style from './URLPresetForm.module.scss';
|
import style from './URLPresetForm.module.scss';
|
||||||
|
|
||||||
const targetOptions: SelectOption<OntimeViewPresettable>[] = [
|
const targetOptions: SelectOption<OntimeViewPresettable>[] = [
|
||||||
{ value: OntimeView.Cuesheet, label: viewLabels[OntimeView.Cuesheet] },
|
{ value: OntimeView.Cuesheet, label: 'Cuesheet' },
|
||||||
{ value: OntimeView.Operator, label: viewLabels[OntimeView.Operator] },
|
{ value: OntimeView.Operator, label: 'Operator' },
|
||||||
{ value: OntimeView.Timer, label: viewLabels[OntimeView.Timer] },
|
{ value: OntimeView.Timer, label: 'Timer' },
|
||||||
{ value: OntimeView.Backstage, label: viewLabels[OntimeView.Backstage] },
|
{ value: OntimeView.Backstage, label: 'Backstage' },
|
||||||
{ value: OntimeView.Timeline, label: viewLabels[OntimeView.Timeline] },
|
{ value: OntimeView.Timeline, label: 'Timeline' },
|
||||||
{ value: OntimeView.StudioClock, label: viewLabels[OntimeView.StudioClock] },
|
{ value: OntimeView.StudioClock, label: 'Studio Clock' },
|
||||||
{ value: OntimeView.Countdown, label: viewLabels[OntimeView.Countdown] },
|
{ value: OntimeView.Countdown, label: 'Countdown' },
|
||||||
{ value: OntimeView.ProjectInfo, label: viewLabels[OntimeView.ProjectInfo] },
|
{ value: OntimeView.ProjectInfo, label: 'Project Info' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const formId = 'url-preset-form';
|
const formId = 'url-preset-form';
|
||||||
|
|||||||
+49
-201
@@ -1,241 +1,89 @@
|
|||||||
import type { EntryId, MaybeNumber, OntimeGroup, OntimeReport, RundownEntries, ShowReport } from 'ontime-types';
|
import { EntryId, MaybeNumber, OntimeReport, RundownEntries, isOntimeEvent } from 'ontime-types';
|
||||||
import { isOntimeEvent, isOntimeGroup } from 'ontime-types';
|
|
||||||
import { dayInMs, MILLIS_PER_SECOND } from 'ontime-utils';
|
|
||||||
|
|
||||||
import { makeCSVFromArrayOfArrays } from '../../../../common/utils/csv';
|
import { makeCSVFromArrayOfArrays } from '../../../../common/utils/csv';
|
||||||
import { getEventVariance, getReportTimePosition } from '../../../../common/utils/report';
|
import { formatTime } from '../../../../common/utils/time';
|
||||||
import { enDash } from '../../../../common/utils/styleUtils';
|
|
||||||
import { formatDuration, formatTime } from '../../../../common/utils/time';
|
|
||||||
|
|
||||||
export type CombinedReport = {
|
export type CombinedReport = {
|
||||||
id: EntryId;
|
id: EntryId;
|
||||||
index: number;
|
index: number;
|
||||||
title: string;
|
title: string;
|
||||||
cue: string;
|
cue: string;
|
||||||
colour: string;
|
|
||||||
/** the group this event belongs to, so the report can mirror the rundown */
|
|
||||||
parent: EntryId | null;
|
|
||||||
groupTitle: string;
|
|
||||||
scheduledStart: number;
|
scheduledStart: number;
|
||||||
actualStart: MaybeNumber;
|
actualStart: MaybeNumber;
|
||||||
startOffset: MaybeNumber;
|
|
||||||
scheduledEnd: number;
|
scheduledEnd: number;
|
||||||
actualEnd: MaybeNumber;
|
actualEnd: MaybeNumber;
|
||||||
endOffset: MaybeNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ShowOffsets = {
|
|
||||||
startOffset: MaybeNumber;
|
|
||||||
endOffset: MaybeNumber;
|
|
||||||
durationOffset: MaybeNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GroupReport = {
|
|
||||||
id: EntryId;
|
|
||||||
title: string;
|
|
||||||
colour: string;
|
|
||||||
targetDuration: MaybeNumber;
|
|
||||||
scheduledDuration: number;
|
|
||||||
actualStart: MaybeNumber;
|
|
||||||
actualEnd: MaybeNumber;
|
|
||||||
elapsed: MaybeNumber;
|
|
||||||
variance: MaybeNumber;
|
|
||||||
eventsRun: number;
|
|
||||||
eventsPlanned: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RunSummary = {
|
|
||||||
eventsRun: number;
|
|
||||||
eventsPlanned: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a combined report with the rundown data.
|
* Creates a combined report with the rundown data
|
||||||
*
|
|
||||||
* Events that ran are measured against the schedule recorded at the time,
|
|
||||||
* not the rundown's current values, so editing the rundown afterwards does
|
|
||||||
* not change how a show that already happened is reported. Events that never
|
|
||||||
* ran have no snapshot and fall back to the rundown.
|
|
||||||
*/
|
*/
|
||||||
export function getCombinedReport(
|
export function getCombinedReport(
|
||||||
report: OntimeReport,
|
report: OntimeReport,
|
||||||
rundown: RundownEntries,
|
rundown: RundownEntries,
|
||||||
flatOrder: EntryId[],
|
flatOrder: EntryId[],
|
||||||
): CombinedReport[] {
|
): CombinedReport[] {
|
||||||
if (Object.keys(report).length === 0 || flatOrder.length === 0) return [];
|
if (Object.keys(report).length === 0) return [];
|
||||||
|
if (flatOrder.length === 0) return [];
|
||||||
|
|
||||||
const combinedReport: CombinedReport[] = [];
|
const combinedReport: CombinedReport[] = [];
|
||||||
|
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (const id of flatOrder) {
|
for (let i = 0; i < flatOrder.length; i++) {
|
||||||
|
const id = flatOrder[i];
|
||||||
const entry = rundown[id];
|
const entry = rundown[id];
|
||||||
// skipped events were never meant to run, listing them alongside events
|
if (!entry || !isOntimeEvent(entry)) continue;
|
||||||
// that did would also disagree with the summary, which excludes them
|
|
||||||
if (!entry || !isOntimeEvent(entry) || entry.skip) continue;
|
|
||||||
|
|
||||||
const parent = entry.parent;
|
if (!(id in report)) {
|
||||||
const group = parent ? rundown[parent] : undefined;
|
combinedReport.push({
|
||||||
const reported = report[id];
|
id: id,
|
||||||
const scheduledStart = reported?.scheduledStart ?? entry.timeStart;
|
index: index,
|
||||||
const scheduledDay = reported?.scheduledDay ?? entry.dayOffset;
|
title: entry.title,
|
||||||
const scheduledStartPosition = getReportTimePosition(scheduledStart, scheduledDay);
|
cue: entry.cue,
|
||||||
const actualStartPosition = reported ? getReportTimePosition(reported.startedAt, reported.startedAtDay) : null;
|
scheduledStart: entry.timeStart,
|
||||||
const actualEndPosition = reported ? getReportTimePosition(reported.endedAt, reported.endedAtDay) : null;
|
actualEnd: null,
|
||||||
const scheduledDuration = reported?.scheduledDuration ?? entry.duration;
|
scheduledEnd: entry.timeEnd,
|
||||||
|
actualStart: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
combinedReport.push({
|
if (id in report) {
|
||||||
id,
|
combinedReport.push({
|
||||||
index,
|
id: id,
|
||||||
title: entry.title,
|
index: index,
|
||||||
cue: entry.cue,
|
title: entry.title,
|
||||||
colour: entry.colour,
|
cue: entry.cue,
|
||||||
parent,
|
scheduledStart: entry.timeStart,
|
||||||
groupTitle: group && isOntimeGroup(group) ? group.title : '',
|
actualEnd: report[id].endedAt,
|
||||||
// an event that ran is measured against the plan it ran on, one that
|
scheduledEnd: entry.timeEnd,
|
||||||
// did not has no snapshot and falls back to the rundown
|
actualStart: report[id].startedAt,
|
||||||
scheduledStart,
|
});
|
||||||
scheduledEnd: scheduledStart + scheduledDuration,
|
}
|
||||||
actualStart: reported?.startedAt ?? null,
|
|
||||||
startOffset: getOffset(actualStartPosition, scheduledStartPosition),
|
|
||||||
actualEnd: reported?.endedAt ?? null,
|
|
||||||
endOffset: getOffset(actualEndPosition, scheduledStartPosition + scheduledDuration),
|
|
||||||
});
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return combinedReport;
|
return combinedReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOffset(actual: MaybeNumber, scheduled: number): MaybeNumber {
|
const csvHeader = ['Index', 'Title', 'Cue', 'Scheduled Start', 'Actual Start', 'Scheduled End', 'Actual End'];
|
||||||
return actual === null ? null : actual - scheduled;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getShowOffsets(show: ShowReport): ShowOffsets {
|
|
||||||
const { plannedDuration, actualDuration } = show;
|
|
||||||
return {
|
|
||||||
startOffset: getWallClockOffset(show.plannedStart, show.actualStart),
|
|
||||||
endOffset: getWallClockOffset(show.plannedEnd, show.actualEnd),
|
|
||||||
durationOffset: plannedDuration === null || actualDuration === null ? null : actualDuration - plannedDuration,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getWallClockOffset(planned: MaybeNumber, actual: MaybeNumber): MaybeNumber {
|
|
||||||
if (planned === null || actual === null) return null;
|
|
||||||
|
|
||||||
const offset = actual - planned;
|
|
||||||
if (offset < -dayInMs / 2) return offset + dayInMs;
|
|
||||||
if (offset > dayInMs / 2) return offset - dayInMs;
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getGroupReports(report: OntimeReport, entries: RundownEntries, order: EntryId[]): GroupReport[] {
|
|
||||||
const groups: GroupReport[] = [];
|
|
||||||
for (const id of order) {
|
|
||||||
const group = entries[id];
|
|
||||||
if (group && isOntimeGroup(group)) groups.push(getGroupReport(group, report, entries));
|
|
||||||
}
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGroupReport(group: OntimeGroup, report: OntimeReport, entries: RundownEntries): GroupReport {
|
|
||||||
let scheduledDuration = 0;
|
|
||||||
let eventsPlanned = 0;
|
|
||||||
let eventsRun = 0;
|
|
||||||
let firstStart = Number.POSITIVE_INFINITY;
|
|
||||||
let lastEnd = Number.NEGATIVE_INFINITY;
|
|
||||||
let actualStart: MaybeNumber = null;
|
|
||||||
let actualEnd: MaybeNumber = null;
|
|
||||||
|
|
||||||
for (const childId of group.entries) {
|
|
||||||
const child = entries[childId];
|
|
||||||
if (!child || !isOntimeEvent(child) || child.skip) continue;
|
|
||||||
|
|
||||||
eventsPlanned += 1;
|
|
||||||
const reported = report[childId];
|
|
||||||
scheduledDuration += reported?.scheduledDuration ?? child.duration;
|
|
||||||
|
|
||||||
const variance = getEventVariance(reported);
|
|
||||||
if (variance.actualDuration === null || !reported) continue;
|
|
||||||
|
|
||||||
eventsRun += 1;
|
|
||||||
const start = getReportTimePosition(reported.startedAt, reported.startedAtDay);
|
|
||||||
const end = getReportTimePosition(reported.endedAt, reported.endedAtDay);
|
|
||||||
if (start !== null && start < firstStart) {
|
|
||||||
firstStart = start;
|
|
||||||
actualStart = reported.startedAt;
|
|
||||||
}
|
|
||||||
if (end !== null && end > lastEnd) {
|
|
||||||
lastEnd = end;
|
|
||||||
actualEnd = reported.endedAt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const elapsed = actualStart === null || actualEnd === null ? null : lastEnd - firstStart;
|
|
||||||
const measuredAgainst = group.targetDuration ?? scheduledDuration;
|
|
||||||
const isComplete = eventsRun > 0 && eventsRun === eventsPlanned;
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: group.id,
|
|
||||||
title: group.title,
|
|
||||||
colour: group.colour,
|
|
||||||
targetDuration: group.targetDuration,
|
|
||||||
scheduledDuration,
|
|
||||||
actualStart,
|
|
||||||
actualEnd,
|
|
||||||
elapsed,
|
|
||||||
variance: elapsed === null || !isComplete ? null : elapsed - measuredAgainst,
|
|
||||||
eventsRun,
|
|
||||||
eventsPlanned,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getRunSummary(report: OntimeReport, entries: RundownEntries, order: EntryId[]): RunSummary {
|
|
||||||
const eventsPlanned = order.filter((id) => {
|
|
||||||
const entry = entries[id];
|
|
||||||
return entry && isOntimeEvent(entry) && !entry.skip;
|
|
||||||
}).length;
|
|
||||||
const eventsRun = Object.values(report).filter((entry) => getEventVariance(entry).status !== 'not-run').length;
|
|
||||||
return { eventsRun, eventsPlanned };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signed offset, eg "+4m12s" / "-1m", following Ontime's convention that
|
* Transforms a CombinedReport into a CSV string
|
||||||
* positive means behind schedule.
|
|
||||||
*/
|
|
||||||
export function formatOffset(value: MaybeNumber): string {
|
|
||||||
if (value === null) return enDash;
|
|
||||||
if (Math.abs(value) < MILLIS_PER_SECOND) return 'On time';
|
|
||||||
return `${value > 0 ? '+' : '-'}${formatDuration(Math.abs(value), false)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function offsetTone(value: MaybeNumber): 'over' | 'under' | 'none' {
|
|
||||||
if (value === null || Math.abs(value) < MILLIS_PER_SECOND) return 'none';
|
|
||||||
return value > 0 ? 'over' : 'under';
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatCsvTime(value: MaybeNumber): string {
|
|
||||||
return value === null ? '' : formatTime(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const csvHeader = ['Index', 'Group', 'Cue', 'Title', 'Scheduled Start', 'Actual Start', 'Scheduled End', 'Actual End'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transforms a CombinedReport into a CSV string.
|
|
||||||
*
|
|
||||||
* Exported as one row per event with its group named, rather than with
|
|
||||||
* rollups baked in, so it stays the dataset a report is built from.
|
|
||||||
*/
|
*/
|
||||||
export function makeReportCSV(combinedReport: CombinedReport[]) {
|
export function makeReportCSV(combinedReport: CombinedReport[]) {
|
||||||
const csv = combinedReport.map((entry) => [
|
const csv: string[][] = [];
|
||||||
String(entry.index),
|
csv.push(csvHeader);
|
||||||
entry.groupTitle,
|
|
||||||
entry.cue,
|
|
||||||
entry.title,
|
|
||||||
formatTime(entry.scheduledStart),
|
|
||||||
formatCsvTime(entry.actualStart),
|
|
||||||
formatTime(entry.scheduledEnd),
|
|
||||||
formatCsvTime(entry.actualEnd),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return makeCSVFromArrayOfArrays([csvHeader, ...csv]);
|
for (const entry of combinedReport) {
|
||||||
|
csv.push([
|
||||||
|
String(entry.index),
|
||||||
|
entry.title,
|
||||||
|
entry.cue,
|
||||||
|
formatTime(entry.scheduledStart),
|
||||||
|
formatTime(entry.actualStart),
|
||||||
|
formatTime(entry.scheduledEnd),
|
||||||
|
formatTime(entry.actualEnd),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return makeCSVFromArrayOfArrays(csv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ export default function ServerPortSettings() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Panel.InlineElements>
|
</Panel.InlineElements>
|
||||||
</Panel.SubHeader>
|
</Panel.SubHeader>
|
||||||
|
<Panel.Loader isLoading={status === 'pending'} />
|
||||||
{rootError && <Panel.Error>{rootError}</Panel.Error>}
|
{rootError && <Panel.Error>{rootError}</Panel.Error>}
|
||||||
<Panel.Divider />
|
<Panel.Divider />
|
||||||
<Panel.Section>
|
<Panel.Section>
|
||||||
<Panel.Loader isLoading={status === 'pending'} />
|
|
||||||
{data.pendingRestart && (
|
{data.pendingRestart && (
|
||||||
<Info type='warning'>A port change is pending and will happen on the next restart.</Info>
|
<Info type='warning'>A port change is pending and will happen on the next restart.</Info>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default function ShutdownPanel() {
|
|||||||
{!isOntimeCloud && (
|
{!isOntimeCloud && (
|
||||||
<Panel.Section>
|
<Panel.Section>
|
||||||
<Button variant='destructive' onClick={handler.open} disabled={!canShutdown}>
|
<Button variant='destructive' onClick={handler.open} disabled={!canShutdown}>
|
||||||
Shutdown Ontime
|
Shutdown ontime
|
||||||
</Button>
|
</Button>
|
||||||
{!canShutdown && <Panel.Description>Only available from the machine running Ontime.</Panel.Description>}
|
{!canShutdown && <Panel.Description>Only available from the machine running Ontime.</Panel.Description>}
|
||||||
</Panel.Section>
|
</Panel.Section>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useCallback, useState } from 'react';
|
|||||||
import { IoClose } from 'react-icons/io5';
|
import { IoClose } from 'react-icons/io5';
|
||||||
|
|
||||||
import Button from '../../common/components/buttons/Button';
|
import Button from '../../common/components/buttons/Button';
|
||||||
import ToggleButton from '../../common/components/buttons/ToggleButton';
|
|
||||||
import { clearLogs, useLogData } from '../../common/stores/logger';
|
import { clearLogs, useLogData } from '../../common/stores/logger';
|
||||||
import { cx } from '../../common/utils/styleUtils';
|
import { cx } from '../../common/utils/styleUtils';
|
||||||
import * as Panel from '../app-settings/panel-utils/PanelUtils';
|
import * as Panel from '../app-settings/panel-utils/PanelUtils';
|
||||||
@@ -56,60 +55,72 @@ export default function Log() {
|
|||||||
<div className={cx([style.container, isExtracted && style.extracted])}>
|
<div className={cx([style.container, isExtracted && style.extracted])}>
|
||||||
<Panel.InlineElements className={style.buttonBar}>
|
<Panel.InlineElements className={style.buttonBar}>
|
||||||
<span className={style.filterLabel}>Filter by</span>
|
<span className={style.filterLabel}>Filter by</span>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showUser}
|
variant={showUser ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showUser}
|
||||||
|
aria-label={`${showUser ? 'Hide' : 'Show'} ${LogOrigin.User} events`}
|
||||||
onClick={() => setShowUser((s) => !s)}
|
onClick={() => setShowUser((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.User)}
|
onAuxClick={() => disableOthers(LogOrigin.User)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.User}
|
{LogOrigin.User}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showClient}
|
variant={showClient ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showClient}
|
||||||
|
aria-label={`${showClient ? 'Hide' : 'Show'} ${LogOrigin.Client} events`}
|
||||||
onClick={() => setShowClient((s) => !s)}
|
onClick={() => setShowClient((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.Client)}
|
onAuxClick={() => disableOthers(LogOrigin.Client)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.Client}
|
{LogOrigin.Client}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showServer}
|
variant={showServer ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showServer}
|
||||||
|
aria-label={`${showServer ? 'Hide' : 'Show'} ${LogOrigin.Server} events`}
|
||||||
onClick={() => setShowServer((s) => !s)}
|
onClick={() => setShowServer((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.Server)}
|
onAuxClick={() => disableOthers(LogOrigin.Server)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.Server}
|
{LogOrigin.Server}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showPlayback}
|
variant={showPlayback ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showPlayback}
|
||||||
|
aria-label={`${showPlayback ? 'Hide' : 'Show'} ${LogOrigin.Playback} events`}
|
||||||
onClick={() => setShowPlayback((s) => !s)}
|
onClick={() => setShowPlayback((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.Playback)}
|
onAuxClick={() => disableOthers(LogOrigin.Playback)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.Playback}
|
{LogOrigin.Playback}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showRx}
|
variant={showRx ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showRx}
|
||||||
|
aria-label={`${showRx ? 'Hide' : 'Show'} ${LogOrigin.Rx} events`}
|
||||||
onClick={() => setShowRx((s) => !s)}
|
onClick={() => setShowRx((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.Rx)}
|
onAuxClick={() => disableOthers(LogOrigin.Rx)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.Rx}
|
{LogOrigin.Rx}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<ToggleButton
|
<Button
|
||||||
pressed={showTx}
|
variant={showTx ? 'primary' : 'subtle'}
|
||||||
size='small'
|
size='small'
|
||||||
|
aria-pressed={showTx}
|
||||||
|
aria-label={`${showTx ? 'Hide' : 'Show'} ${LogOrigin.Tx} events`}
|
||||||
onClick={() => setShowTx((s) => !s)}
|
onClick={() => setShowTx((s) => !s)}
|
||||||
onAuxClick={() => disableOthers(LogOrigin.Tx)}
|
onAuxClick={() => disableOthers(LogOrigin.Tx)}
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
{LogOrigin.Tx}
|
{LogOrigin.Tx}
|
||||||
</ToggleButton>
|
</Button>
|
||||||
<Button variant='subtle-destructive' size='small' onClick={clearLogs} className={style.apart}>
|
<Button variant='subtle-destructive' size='small' onClick={clearLogs} className={style.apart}>
|
||||||
<IoClose /> Clear
|
<IoClose /> Clear
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -18,12 +18,6 @@
|
|||||||
padding-bottom: 95vh;
|
padding-bottom: 95vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.groupSection {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editPrompt {
|
.editPrompt {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: $zindex-dialog;
|
z-index: $zindex-dialog;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { OntimeView, isOntimeEvent, isOntimeGroup } from 'ontime-types';
|
import { OntimeView, isOntimeEvent, isOntimeGroup } from 'ontime-types';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
import EmptyFill from '../../common/components/state/EmptyFill';
|
import EmptyFill from '../../common/components/state/EmptyFill';
|
||||||
import EmptyPage from '../../common/components/state/EmptyPage';
|
import EmptyPage from '../../common/components/state/EmptyPage';
|
||||||
@@ -25,10 +25,7 @@ import { OperatorData, useOperatorData } from './useOperatorData';
|
|||||||
|
|
||||||
import style from './Operator.module.scss';
|
import style from './Operator.module.scss';
|
||||||
|
|
||||||
/** Keeps the running event clear of the list edge when no group header is pinned above it */
|
const selectedOffset = 50;
|
||||||
const edgeOffset = 50;
|
|
||||||
/** How far the running event may drift from where we placed it before we stop following */
|
|
||||||
const followTolerance = 50;
|
|
||||||
|
|
||||||
export default function OperatorLoader() {
|
export default function OperatorLoader() {
|
||||||
const { data, status } = useOperatorData();
|
const { data, status } = useOperatorData();
|
||||||
@@ -57,20 +54,11 @@ function Operator({ rundown, rundownMetadata, customFields, settings }: Operator
|
|||||||
const [lockAutoScroll, setLockAutoScroll] = useState(false);
|
const [lockAutoScroll, setLockAutoScroll] = useState(false);
|
||||||
const selectedRef = useRef<HTMLDivElement | null>(null);
|
const selectedRef = useRef<HTMLDivElement | null>(null);
|
||||||
const scrollRef = useRef<HTMLDivElement | null>(null);
|
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||||
const stickyHeaderRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
|
|
||||||
// The header height varies with the viewport, so measure it at scroll time.
|
|
||||||
const getTopOffset = useCallback(() => {
|
|
||||||
const header = stickyHeaderRef.current;
|
|
||||||
// Sit right under the pinned header, so it covers the previous event instead of half of it.
|
|
||||||
return header ? header.offsetHeight + 2 : edgeOffset;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const scrollToComponent = useFollowComponent({
|
const scrollToComponent = useFollowComponent({
|
||||||
followRef: selectedRef,
|
followRef: selectedRef,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
doFollow: !lockAutoScroll,
|
doFollow: !lockAutoScroll,
|
||||||
getTopOffset,
|
topOffset: selectedOffset,
|
||||||
followTrigger: selectedEventId,
|
followTrigger: selectedEventId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,16 +82,15 @@ function Operator({ rundown, rundownMetadata, customFields, settings }: Operator
|
|||||||
|
|
||||||
// prevent considering automated scrolls as user scrolls
|
// prevent considering automated scrolls as user scrolls
|
||||||
const handleUserScroll = () => {
|
const handleUserScroll = () => {
|
||||||
if (!selectedRef.current || !scrollRef.current) {
|
if (selectedRef?.current && scrollRef?.current) {
|
||||||
return;
|
const selectedRect = selectedRef.current.getBoundingClientRect();
|
||||||
|
const scrollerRect = scrollRef.current.getBoundingClientRect();
|
||||||
|
if (selectedRect && scrollerRect) {
|
||||||
|
const distanceFromTop = selectedRect.top - scrollerRect.top;
|
||||||
|
const hasScrolledOutOfThreshold = distanceFromTop < -8 || distanceFromTop > selectedOffset;
|
||||||
|
setLockAutoScroll(hasScrolledOutOfThreshold);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedRect = selectedRef.current.getBoundingClientRect();
|
|
||||||
const scrollerRect = scrollRef.current.getBoundingClientRect();
|
|
||||||
// Measure the drift from where an automated scroll would place the event.
|
|
||||||
const distanceFromTop = selectedRect.top - scrollerRect.top - getTopOffset();
|
|
||||||
const hasScrolledOutOfThreshold = distanceFromTop < -8 || distanceFromTop > followTolerance;
|
|
||||||
setLockAutoScroll(hasScrolledOutOfThreshold);
|
|
||||||
};
|
};
|
||||||
const throttledHandleScroll = throttle(handleUserScroll, 1000);
|
const throttledHandleScroll = throttle(handleUserScroll, 1000);
|
||||||
|
|
||||||
@@ -199,9 +186,9 @@ function Operator({ rundown, rundownMetadata, customFields, settings }: Operator
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.groupSection} key={entry.id}>
|
<Fragment key={entry.id}>
|
||||||
<OperatorGroup
|
<OperatorGroup
|
||||||
ref={isCurrentParent ? stickyHeaderRef : undefined}
|
key={entry.id}
|
||||||
title={entry.title}
|
title={entry.title}
|
||||||
colour={entry.colour}
|
colour={entry.colour}
|
||||||
count={entry.entries.length}
|
count={entry.entries.length}
|
||||||
@@ -252,7 +239,7 @@ function Operator({ rundown, rundownMetadata, customFields, settings }: Operator
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
.group {
|
.group {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
/* Padding is kept under the min-height so a single line fits without the list having to shrink the header,
|
|
||||||
while a taller title still grows the row. */
|
|
||||||
min-height: 2.5rem;
|
min-height: 2.5rem;
|
||||||
padding: 0.25rem 0.75rem;
|
padding: 0.4rem 0.75rem;
|
||||||
border-left: 0.35rem solid var(--group-colour, $gray-500);
|
border-left: 0.35rem solid var(--group-colour, $gray-500);
|
||||||
background-color: $gray-1350;
|
background-color: $gray-1350;
|
||||||
background: color-mix(in srgb, transparent 88%, var(--group-colour, $gray-500) 12%);
|
background: color-mix(in srgb, transparent 88%, var(--group-colour, $gray-500) 12%);
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
position: sticky;
|
|
||||||
/* Cover the list padding so rows cannot scroll above the header. */
|
|
||||||
top: -0.25rem;
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { type CSSProperties, type Ref, memo } from 'react';
|
import { CSSProperties, memo } from 'react';
|
||||||
|
|
||||||
import { getAccessibleColour } from '../../../common/utils/styleUtils';
|
import { getAccessibleColour } from '../../../common/utils/styleUtils';
|
||||||
import { formatDuration } from '../../../common/utils/time';
|
import { formatDuration } from '../../../common/utils/time';
|
||||||
@@ -10,16 +10,15 @@ interface OperatorGroup {
|
|||||||
colour: string;
|
colour: string;
|
||||||
count: number;
|
count: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
ref?: Ref<HTMLDivElement>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(OperatorGroup);
|
export default memo(OperatorGroup);
|
||||||
function OperatorGroup({ title, colour, count, duration, ref }: OperatorGroup) {
|
function OperatorGroup({ title, colour, count, duration }: OperatorGroup) {
|
||||||
const groupColour = colour || '#929292';
|
const groupColour = colour || '#929292';
|
||||||
const groupColours = getAccessibleColour(groupColour);
|
const groupColours = getAccessibleColour(groupColour);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.group} style={{ ...groupColours, '--group-colour': groupColour } as CSSProperties} ref={ref}>
|
<div className={style.group} style={{ ...groupColours, '--group-colour': groupColour } as CSSProperties}>
|
||||||
<span className={style.title}>{title}</span>
|
<span className={style.title}>{title}</span>
|
||||||
<span className={style.meta}>
|
<span className={style.meta}>
|
||||||
<span>{`${count} ${count === 1 ? 'event' : 'events'}`}</span>
|
<span>{`${count} ${count === 1 ? 'event' : 'events'}`}</span>
|
||||||
|
|||||||
@@ -8,16 +8,10 @@ export default memo(FinderPlacement);
|
|||||||
function FinderPlacement() {
|
function FinderPlacement() {
|
||||||
const [isOpen, handler] = useDisclosure();
|
const [isOpen, handler] = useDisclosure();
|
||||||
|
|
||||||
/**
|
useHotkeys([
|
||||||
* The empty tagsToIgnore is significant: by default the hook skips input elements,
|
['mod + f', handler.toggle, { preventDefault: true }],
|
||||||
* which would make the shortcut dead while editing an entry.
|
['Escape', handler.close, { preventDefault: true }],
|
||||||
*
|
]);
|
||||||
* This opens rather than toggles. Toggling on a key that also mounts and unmounts the
|
|
||||||
* dialog races against it, and browsers treat a repeated find shortcut as "focus the
|
|
||||||
* search again" rather than "close it". The finder selects its input instead, and
|
|
||||||
* Escape closes.
|
|
||||||
*/
|
|
||||||
useHotkeys([['mod + f', handler.open, { preventDefault: true }]], []);
|
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
return <Finder isOpen={isOpen} onClose={handler.close} />;
|
return <Finder isOpen={isOpen} onClose={handler.close} />;
|
||||||
|
|||||||
@@ -312,7 +312,6 @@ export default function RundownEvent({
|
|||||||
onClick={handleFocusClick}
|
onClick={handleFocusClick}
|
||||||
onContextMenu={onContextMenu}
|
onContextMenu={onContextMenu}
|
||||||
data-testid='rundown-event'
|
data-testid='rundown-event'
|
||||||
data-selected={isSelected}
|
|
||||||
{...(isPlaying ? { 'data-running': true } : {})}
|
{...(isPlaying ? { 'data-running': true } : {})}
|
||||||
>
|
>
|
||||||
<RundownIndicators timeStart={timeStart} delay={delay} gap={gap} isNextDay={isNextDay} />
|
<RundownIndicators timeStart={timeStart} delay={delay} gap={gap} isNextDay={isNextDay} />
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ function RundownEventInner({
|
|||||||
isPast={isPast}
|
isPast={isPast}
|
||||||
isLoaded={loaded}
|
isLoaded={loaded}
|
||||||
totalGap={totalGap}
|
totalGap={totalGap}
|
||||||
|
duration={duration}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={style.statusElements} id='entry-status' data-timertype={timerType}>
|
<div className={style.statusElements} id='entry-status' data-timertype={timerType}>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { IoCheckmarkCircle } from 'react-icons/io5';
|
|||||||
import Tooltip from '../../../../common/components/tooltip/Tooltip';
|
import Tooltip from '../../../../common/components/tooltip/Tooltip';
|
||||||
import useReport from '../../../../common/hooks-query/useReport';
|
import useReport from '../../../../common/hooks-query/useReport';
|
||||||
import { usePlayback } from '../../../../common/hooks/useSocket';
|
import { usePlayback } from '../../../../common/hooks/useSocket';
|
||||||
import { getEventVariance } from '../../../../common/utils/report';
|
|
||||||
import { cx } from '../../../../common/utils/styleUtils';
|
import { cx } from '../../../../common/utils/styleUtils';
|
||||||
import { formatDuration, useTimeUntilExpectedStart } from '../../../../common/utils/time';
|
import { formatDuration, useTimeUntilExpectedStart } from '../../../../common/utils/time';
|
||||||
|
|
||||||
@@ -21,6 +20,7 @@ interface RundownEventChipProps {
|
|||||||
isLoaded: boolean;
|
isLoaded: boolean;
|
||||||
className: string;
|
className: string;
|
||||||
totalGap: number;
|
totalGap: number;
|
||||||
|
duration: number;
|
||||||
isLinkedToLoaded: boolean;
|
isLinkedToLoaded: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ export default function RundownEventChip({
|
|||||||
className,
|
className,
|
||||||
totalGap,
|
totalGap,
|
||||||
id,
|
id,
|
||||||
|
duration,
|
||||||
isLinkedToLoaded,
|
isLinkedToLoaded,
|
||||||
}: RundownEventChipProps) {
|
}: RundownEventChipProps) {
|
||||||
const playback = usePlayback();
|
const playback = usePlayback();
|
||||||
@@ -44,20 +45,25 @@ export default function RundownEventChip({
|
|||||||
const playbackActive = isPlaybackActive(playback);
|
const playbackActive = isPlaybackActive(playback);
|
||||||
|
|
||||||
if (!playbackActive || isPast) {
|
if (!playbackActive || isPast) {
|
||||||
return <EventReport className={className} id={id} />;
|
return <EventReport className={className} id={id} duration={duration} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
if (playbackActive) {
|
||||||
<Tooltip text='Expected time until start' render={<span />} className={className}>
|
// we extracted the component to avoid unnecessary calculations and re-renders
|
||||||
<EventUntil
|
return (
|
||||||
timeStart={timeStart}
|
<Tooltip text='Expected time until start' render={<span />} className={className}>
|
||||||
delay={delay}
|
<EventUntil
|
||||||
dayOffset={dayOffset}
|
timeStart={timeStart}
|
||||||
totalGap={totalGap}
|
delay={delay}
|
||||||
isLinkedToLoaded={isLinkedToLoaded}
|
dayOffset={dayOffset}
|
||||||
/>
|
totalGap={totalGap}
|
||||||
</Tooltip>
|
isLinkedToLoaded={isLinkedToLoaded}
|
||||||
);
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EventUntilProps {
|
interface EventUntilProps {
|
||||||
@@ -80,30 +86,41 @@ function EventUntil({ timeStart, delay, dayOffset, totalGap, isLinkedToLoaded }:
|
|||||||
interface EventReportProps {
|
interface EventReportProps {
|
||||||
className: string;
|
className: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
duration: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function EventReport({ className, id }: EventReportProps) {
|
function EventReport(props: EventReportProps) {
|
||||||
|
const { className, id, duration } = props;
|
||||||
const { data } = useReport();
|
const { data } = useReport();
|
||||||
const currentReport = data[id];
|
const currentReport = data[id];
|
||||||
|
|
||||||
const [value, overUnderStyle, tooltip] = useMemo(() => {
|
const [value, overUnderStyle, tooltip] = useMemo(() => {
|
||||||
// Use the schedule recorded when the event ran so later rundown edits do
|
if (!currentReport) {
|
||||||
// not change its report.
|
|
||||||
const variance = getEventVariance(currentReport);
|
|
||||||
if (variance.status === 'not-run') {
|
|
||||||
return [null, 'none', ''];
|
return [null, 'none', ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variance.status === 'ontime') {
|
const { startedAt, endedAt } = currentReport;
|
||||||
|
if (!startedAt || !endedAt) {
|
||||||
|
return [null, 'none', ''];
|
||||||
|
}
|
||||||
|
|
||||||
|
const actualDuration = endedAt - startedAt;
|
||||||
|
const difference = actualDuration - duration;
|
||||||
|
const absDifference = Math.abs(difference);
|
||||||
|
|
||||||
|
if (absDifference < MILLIS_PER_SECOND) {
|
||||||
return ['ontime', 'under', 'Event finished on time'];
|
return ['ontime', 'under', 'Event finished on time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const absDifference = Math.abs(variance.delta);
|
const isOver = difference > 0;
|
||||||
const isOver = variance.status === 'over';
|
|
||||||
const tooltip = `Event ran ${isOver ? 'over' : 'under'} time by ${millisToString(absDifference)}`;
|
const fullTimeValue = millisToString(absDifference);
|
||||||
|
|
||||||
|
const tooltip = `Event ran ${isOver ? 'over' : 'under'} time by ${fullTimeValue}`;
|
||||||
|
|
||||||
const value = `${isOver ? '+' : '-'}${formatDuration(absDifference, absDifference > 2 * MILLIS_PER_MINUTE)}`;
|
const value = `${isOver ? '+' : '-'}${formatDuration(absDifference, absDifference > 2 * MILLIS_PER_MINUTE)}`;
|
||||||
return [value, variance.status, tooltip];
|
return [value, isOver ? 'over' : 'under', tooltip];
|
||||||
}, [currentReport]);
|
}, [currentReport, duration]);
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
|
import type { ColumnDef } from '@tanstack/react-table';
|
||||||
import type { CustomFields } from 'ontime-types';
|
import type { CustomFields } from 'ontime-types';
|
||||||
|
|
||||||
|
import type { ExtendedEntry } from '../../../common/utils/rundownMetadata';
|
||||||
import { AppMode } from '../../../ontimeConfig';
|
import { AppMode } from '../../../ontimeConfig';
|
||||||
import { makeCuesheetColumns } from '../../../views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory';
|
import { makeCuesheetColumns } from '../../../views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory';
|
||||||
import type { CuesheetColumnDef } from '../../../views/cuesheet/cuesheet-table/cuesheetTable.features';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates column definitions for the rundown table
|
* Creates column definitions for the rundown table
|
||||||
* Reuses cuesheetColsFactory with preset=undefined for full access
|
* Reuses cuesheetColsFactory with preset=undefined for full access
|
||||||
*/
|
*/
|
||||||
export function makeRundownColumns(customFields: CustomFields): CuesheetColumnDef[] {
|
export function makeRundownColumns(customFields: CustomFields): ColumnDef<ExtendedEntry>[] {
|
||||||
// When preset=undefined, factory defaults to fullRead=true, fullWrite=true
|
// When preset=undefined, factory defaults to fullRead=true, fullWrite=true
|
||||||
// canWrite is determined by editorMode (AppMode.Edit vs AppMode.Run)
|
// canWrite is determined by editorMode (AppMode.Edit vs AppMode.Run)
|
||||||
return makeCuesheetColumns(customFields, AppMode.Edit, undefined);
|
return makeCuesheetColumns(customFields, AppMode.Edit, undefined);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ $playback-under: $green-500;
|
|||||||
// interface panels
|
// interface panels
|
||||||
$bg-container-l1: $gray-1350;
|
$bg-container-l1: $gray-1350;
|
||||||
$bg-container-l2: $gray-1300;
|
$bg-container-l2: $gray-1300;
|
||||||
$bg-active: rgba($action-blue, 0.16);
|
|
||||||
|
|
||||||
$backdrop-color: rgba(0, 0, 0, 0.7);
|
$backdrop-color: rgba(0, 0, 0, 0.7);
|
||||||
$box-shadow-l1: rgba(0, 0, 0, 0.15) 0 3px 3px 0;
|
$box-shadow-l1: rgba(0, 0, 0, 0.15) 0 3px 3px 0;
|
||||||
|
|||||||
@@ -1,30 +1,12 @@
|
|||||||
import { OntimeView } from 'ontime-types';
|
export const navigatorConstants = [
|
||||||
|
{ url: 'timer', label: 'Timer' },
|
||||||
/** User facing name of each view, the single source for view naming in the UI */
|
{ url: 'backstage', label: 'Backstage' },
|
||||||
export const viewLabels: Record<OntimeView, string> = {
|
{ url: 'timeline', label: 'Timeline' },
|
||||||
[OntimeView.Editor]: 'Editor',
|
{ url: 'studio', label: 'Studio Clock' },
|
||||||
[OntimeView.Cuesheet]: 'Cuesheet',
|
{ url: 'countdown', label: 'Countdown' },
|
||||||
[OntimeView.Operator]: 'Operator',
|
{ url: 'info', label: 'Project Info' },
|
||||||
[OntimeView.Timer]: 'Timer',
|
|
||||||
[OntimeView.Backstage]: 'Backstage',
|
|
||||||
[OntimeView.Timeline]: 'Timeline',
|
|
||||||
[OntimeView.StudioClock]: 'Studio Clock',
|
|
||||||
[OntimeView.Countdown]: 'Countdown',
|
|
||||||
[OntimeView.ProjectInfo]: 'Project Info',
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Views offered in the navigation menu, in the order they are shown. Their value is also their route */
|
|
||||||
const navigatorViews = [
|
|
||||||
OntimeView.Timer,
|
|
||||||
OntimeView.Backstage,
|
|
||||||
OntimeView.Timeline,
|
|
||||||
OntimeView.StudioClock,
|
|
||||||
OntimeView.Countdown,
|
|
||||||
OntimeView.ProjectInfo,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const navigatorConstants = navigatorViews.map((view) => ({ url: view, label: viewLabels[view] }));
|
|
||||||
|
|
||||||
// default time format to use for users in 12 hour clocks
|
// default time format to use for users in 12 hour clocks
|
||||||
export const FORMAT_12 = 'h:mm:ss a';
|
export const FORMAT_12 = 'h:mm:ss a';
|
||||||
// default time format to use for users in 24 hour clocks
|
// default time format to use for users in 24 hour clocks
|
||||||
|
|||||||
@@ -100,20 +100,7 @@ $item-height: 3.5rem;
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
padding-bottom: 95vh;
|
padding-bottom: max(8rem, calc(5rem + env(safe-area-inset-bottom)));
|
||||||
}
|
|
||||||
|
|
||||||
/* Flex prevents row margins collapsing and bounds the sticky header to its group. */
|
|
||||||
.sub-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
/* The select view renders the same cards in a flat list. */
|
|
||||||
.sub--group {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ====================== LIST-ITEM ======================*/
|
/* ====================== LIST-ITEM ======================*/
|
||||||
@@ -209,14 +196,9 @@ $item-height: 3.5rem;
|
|||||||
|
|
||||||
.sub--group {
|
.sub--group {
|
||||||
box-shadow: inset 0 0 0 1px var(--user-color, $gray-1325);
|
box-shadow: inset 0 0 0 1px var(--user-color, $gray-1325);
|
||||||
/* The opaque base prevents rows showing through; background shorthand cannot layer this colour. */
|
background:
|
||||||
background-color: var(--background-color-override, $viewer-background-color);
|
|
||||||
background-image:
|
|
||||||
linear-gradient(90deg, color-mix(in srgb, var(--user-color, transparent) 18%, transparent), transparent 42%),
|
linear-gradient(90deg, color-mix(in srgb, var(--user-color, transparent) 18%, transparent), transparent 42%),
|
||||||
linear-gradient(
|
var(--card-background-color-override, $viewer-card-bg-color);
|
||||||
var(--card-background-color-override, $viewer-card-bg-color),
|
|
||||||
var(--card-background-color-override, $viewer-card-bg-color)
|
|
||||||
);
|
|
||||||
|
|
||||||
.sub__binder {
|
.sub__binder {
|
||||||
background: var(--user-color, var(--card-background-color-override, $viewer-card-bg-color));
|
background: var(--user-color, var(--card-background-color-override, $viewer-card-bg-color));
|
||||||
@@ -248,16 +230,6 @@ $item-height: 3.5rem;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reserve the green fill for the running event. */
|
|
||||||
.sub--group.sub--live {
|
|
||||||
box-shadow: inset 0 0 0 2px $active-green;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keep the armed state quieter than the live ring. */
|
|
||||||
.sub--group.sub--armed {
|
|
||||||
box-shadow: inset 0 0 0 2px $gray-1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sub__title {
|
.sub__title {
|
||||||
grid-area: title;
|
grid-area: title;
|
||||||
padding-bottom: 0.5rem;
|
padding-bottom: 0.5rem;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MaybeNumber, OntimeEvent } from 'ontime-types';
|
import { MaybeNumber, OntimeEvent } from 'ontime-types';
|
||||||
import { dayInMs } from 'ontime-utils';
|
import { dayInMs } from 'ontime-utils';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { IoPencil } from 'react-icons/io5';
|
import { IoPencil } from 'react-icons/io5';
|
||||||
|
|
||||||
import Button from '../../common/components/buttons/Button';
|
import Button from '../../common/components/buttons/Button';
|
||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
CountdownTarget,
|
CountdownTarget,
|
||||||
extendEventData,
|
extendEventData,
|
||||||
getIsLive,
|
getIsLive,
|
||||||
groupSubscriptionTargets,
|
|
||||||
isOutsideRange,
|
isOutsideRange,
|
||||||
preferredFormat12,
|
preferredFormat12,
|
||||||
preferredFormat24,
|
preferredFormat24,
|
||||||
@@ -49,22 +48,11 @@ export default function CountdownSubscriptions({ subscribedEvents, goToEditMode
|
|||||||
const [lockAutoScroll, setLockAutoScroll] = useState(false);
|
const [lockAutoScroll, setLockAutoScroll] = useState(false);
|
||||||
const selectedRef = useRef<HTMLDivElement | null>(null);
|
const selectedRef = useRef<HTMLDivElement | null>(null);
|
||||||
const scrollRef = useRef<HTMLDivElement | null>(null);
|
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||||
const stickyHeaderRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
|
|
||||||
const sections = useMemo(() => groupSubscriptionTargets(subscribedEvents), [subscribedEvents]);
|
|
||||||
|
|
||||||
// Responsive sizing and wrapped titles make the sticky header height variable, so measure it at scroll time.
|
|
||||||
const getStickyOffset = useCallback(() => {
|
|
||||||
const header = stickyHeaderRef.current;
|
|
||||||
// Preserve the combined margins between the header and running event.
|
|
||||||
return header ? header.offsetHeight + 4 : 0;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const scrollToComponent = useFollowComponent({
|
const scrollToComponent = useFollowComponent({
|
||||||
followRef: selectedRef,
|
followRef: selectedRef,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
doFollow: !lockAutoScroll,
|
doFollow: !lockAutoScroll,
|
||||||
getTopOffset: getStickyOffset,
|
topOffset: 0,
|
||||||
followTrigger: selectedEventId,
|
followTrigger: selectedEventId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,16 +75,15 @@ export default function CountdownSubscriptions({ subscribedEvents, goToEditMode
|
|||||||
|
|
||||||
// prevent considering automated scrolls as user scrolls
|
// prevent considering automated scrolls as user scrolls
|
||||||
const handleUserScroll = () => {
|
const handleUserScroll = () => {
|
||||||
if (!selectedRef.current || !scrollRef.current) {
|
if (selectedRef?.current && scrollRef?.current) {
|
||||||
return;
|
const selectedRect = selectedRef.current.getBoundingClientRect();
|
||||||
|
const scrollerRect = scrollRef.current.getBoundingClientRect();
|
||||||
|
if (selectedRect && scrollerRect) {
|
||||||
|
const distanceFromTop = selectedRect.top - scrollerRect.top;
|
||||||
|
const hasScrolledOutOfThreshold = distanceFromTop < -8 || distanceFromTop > 50;
|
||||||
|
setLockAutoScroll(hasScrolledOutOfThreshold);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedRect = selectedRef.current.getBoundingClientRect();
|
|
||||||
const scrollerRect = scrollRef.current.getBoundingClientRect();
|
|
||||||
// Keep the threshold relative to the visible rows below the sticky header.
|
|
||||||
const distanceFromTop = selectedRect.top - scrollerRect.top - getStickyOffset();
|
|
||||||
const hasScrolledOutOfThreshold = distanceFromTop < -8 || distanceFromTop > 50;
|
|
||||||
setLockAutoScroll(hasScrolledOutOfThreshold);
|
|
||||||
};
|
};
|
||||||
const throttledHandleScroll = throttle(handleUserScroll, 1000);
|
const throttledHandleScroll = throttle(handleUserScroll, 1000);
|
||||||
|
|
||||||
@@ -111,63 +98,41 @@ export default function CountdownSubscriptions({ subscribedEvents, goToEditMode
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='list-container' onWheel={handleScroll} onTouchMove={handleScroll} ref={scrollRef}>
|
<div className='list-container' onWheel={handleScroll} onTouchMove={handleScroll} ref={scrollRef}>
|
||||||
{sections.map((section) => {
|
{subscribedEvents.map((event) => {
|
||||||
const rows = section.group ? [section.group, ...section.events] : section.events;
|
// while a group is live, surface the running event's title as the secondary line
|
||||||
// the running event anchors the scroll, the group header stays pinned above it
|
const liveTitle = event.isGroup && event.liveEntry ? event.liveEntry.title : undefined;
|
||||||
const anchorId = section.events.find((event) => getIsLive(event.id, selectedEventId, playback))?.id ?? null;
|
const secondaryData = liveTitle ?? getPropertyValue(event, secondarySource);
|
||||||
|
const isGroupedEvent = !event.isGroup && Boolean(event.parent);
|
||||||
|
const activeEntryId = event.isGroup ? (event.liveEntry?.id ?? event.targetId) : event.id;
|
||||||
|
// a subscribed group is live when any of its children is the selected/running event
|
||||||
|
const isLive = activeEntryId ? getIsLive(activeEntryId, selectedEventId, playback) : false;
|
||||||
|
const isArmed = !isLive && activeEntryId === selectedEventId;
|
||||||
|
const countdownEvent = extendEventData(event, currentDay, actualStart, plannedStart, offset, mode, reportData);
|
||||||
|
const displayTitle = getPropertyValue(event, mainSource ?? 'title');
|
||||||
return (
|
return (
|
||||||
<div key={section.group?.id ?? rows[0].id} className='sub-section'>
|
<div
|
||||||
{rows.map((event) => {
|
key={event.id}
|
||||||
// while a group is live, surface the running event's title as the secondary line
|
ref={isLive ? selectedRef : undefined}
|
||||||
const liveTitle = event.isGroup && event.liveEntry ? event.liveEntry.title : undefined;
|
className={cx([
|
||||||
const secondaryData = liveTitle ?? getPropertyValue(event, secondarySource);
|
'sub',
|
||||||
const isGroupedEvent = !event.isGroup && Boolean(event.parent);
|
isLive && 'sub--live',
|
||||||
const activeEntryId = event.isGroup ? (event.liveEntry?.id ?? event.targetId) : event.id;
|
isArmed && 'sub--armed',
|
||||||
// a subscribed group is live when any of its children is the selected/running event
|
event.isGroup && 'sub--group',
|
||||||
const isLive = activeEntryId ? getIsLive(activeEntryId, selectedEventId, playback) : false;
|
isGroupedEvent && 'sub--in-group',
|
||||||
const isArmed = !isLive && activeEntryId === selectedEventId;
|
])}
|
||||||
// only ever hand the ref to a single row, sharing it would null it out on the next commit
|
data-testid={event.cue}
|
||||||
const isAnchor = isLive && (anchorId === null || event.id === anchorId);
|
>
|
||||||
const rowRef = isAnchor ? selectedRef : event.isGroup && anchorId ? stickyHeaderRef : undefined;
|
<div
|
||||||
const countdownEvent = extendEventData(
|
className='sub__binder'
|
||||||
event,
|
style={{ '--user-color': event.colour, '--group-color': event.groupColour ?? 'transparent' }}
|
||||||
currentDay,
|
/>
|
||||||
actualStart,
|
<ScheduleTime event={countdownEvent} showExpected={showExpected} />
|
||||||
plannedStart,
|
<SubscriptionStatus event={countdownEvent} />
|
||||||
offset,
|
<div className={cx(['sub__title', !displayTitle && 'subdued'])}>
|
||||||
mode,
|
{event.isGroup && <span className='sub__eyebrow'>Group</span>}
|
||||||
reportData,
|
{displayTitle}
|
||||||
);
|
</div>
|
||||||
const displayTitle = getPropertyValue(event, mainSource ?? 'title');
|
{secondaryData && <div className='sub__secondary'>{secondaryData}</div>}
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={event.id}
|
|
||||||
ref={rowRef}
|
|
||||||
className={cx([
|
|
||||||
'sub',
|
|
||||||
isLive && 'sub--live',
|
|
||||||
isArmed && 'sub--armed',
|
|
||||||
event.isGroup && 'sub--group',
|
|
||||||
isGroupedEvent && 'sub--in-group',
|
|
||||||
])}
|
|
||||||
data-testid={event.cue}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className='sub__binder'
|
|
||||||
style={{ '--user-color': event.colour, '--group-color': event.groupColour ?? 'transparent' }}
|
|
||||||
/>
|
|
||||||
<ScheduleTime event={countdownEvent} showExpected={showExpected} />
|
|
||||||
<SubscriptionStatus event={countdownEvent} />
|
|
||||||
<div className={cx(['sub__title', !displayTitle && 'subdued'])}>
|
|
||||||
{event.isGroup && <span className='sub__eyebrow'>Group</span>}
|
|
||||||
{displayTitle}
|
|
||||||
</div>
|
|
||||||
{secondaryData && <div className='sub__secondary'>{secondaryData}</div>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { OntimeEntry, OntimeEvent, OntimeGroup, SupportedEntry } from 'ontime-types';
|
import { OntimeEntry, OntimeEvent, OntimeGroup, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { ExtendedEntry } from '../../common/utils/rundownMetadata';
|
import { ExtendedEntry } from '../../common/utils/rundownMetadata';
|
||||||
import { CountdownTarget, groupSubscriptionTargets, resolveSubscriptionTarget } from './countdown.utils';
|
import { resolveSubscriptionTarget } from './countdown.utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal builders for the extended (metadata enriched) entries the countdown view consumes.
|
* Minimal builders for the extended (metadata enriched) entries the countdown view consumes.
|
||||||
@@ -126,89 +126,3 @@ describe('resolveSubscriptionTarget()', () => {
|
|||||||
expect(result?.liveEntry).toBeNull();
|
expect(result?.liveEntry).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('groupSubscriptionTargets()', () => {
|
|
||||||
/**
|
|
||||||
* Resolves a group the same way the view does, so that the tests exercise the real target shape
|
|
||||||
* (a resolved group carries type Event, so the helper cannot rely on the entry type)
|
|
||||||
*/
|
|
||||||
function resolveGroup(group: ExtendedEntry<OntimeGroup>, flat: ExtendedEntry<OntimeEntry>[]): CountdownTarget {
|
|
||||||
const resolved = resolveSubscriptionTarget(group, flat);
|
|
||||||
if (resolved === null) {
|
|
||||||
throw new Error('test setup: group has no playable children');
|
|
||||||
}
|
|
||||||
return resolved;
|
|
||||||
}
|
|
||||||
|
|
||||||
it('returns no sections for an empty subscription list', () => {
|
|
||||||
expect(groupSubscriptionTargets([])).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gives each ungrouped event its own section', () => {
|
|
||||||
const e1 = makeEvent({ id: 'e1' });
|
|
||||||
const e2 = makeEvent({ id: 'e2' });
|
|
||||||
|
|
||||||
expect(groupSubscriptionTargets([e1, e2])).toEqual([
|
|
||||||
{ group: null, events: [e1] },
|
|
||||||
{ group: null, events: [e2] },
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('absorbs the children of a subscribed group into its section', () => {
|
|
||||||
const group = makeGroup({ id: 'g1' });
|
|
||||||
const c1 = makeEvent({ id: 'c1', parent: 'g1' });
|
|
||||||
const c2 = makeEvent({ id: 'c2', parent: 'g1' });
|
|
||||||
const resolved = resolveGroup(group, [group, c1, c2]);
|
|
||||||
|
|
||||||
expect(groupSubscriptionTargets([resolved, c1, c2])).toEqual([{ group: resolved, events: [c1, c2] }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps a subscribed group with no subscribed children as an empty section', () => {
|
|
||||||
const group = makeGroup({ id: 'g1' });
|
|
||||||
const c1 = makeEvent({ id: 'c1', parent: 'g1' });
|
|
||||||
const resolved = resolveGroup(group, [group, c1]);
|
|
||||||
|
|
||||||
expect(groupSubscriptionTargets([resolved])).toEqual([{ group: resolved, events: [] }]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not absorb an event which belongs to a different group', () => {
|
|
||||||
const group1 = makeGroup({ id: 'g1' });
|
|
||||||
const c1 = makeEvent({ id: 'c1', parent: 'g1' });
|
|
||||||
const group2 = makeGroup({ id: 'g2' });
|
|
||||||
const c2 = makeEvent({ id: 'c2', parent: 'g2' });
|
|
||||||
const flat = [group1, c1, group2, c2];
|
|
||||||
const resolved1 = resolveGroup(group1, flat);
|
|
||||||
const resolved2 = resolveGroup(group2, flat);
|
|
||||||
|
|
||||||
expect(groupSubscriptionTargets([resolved1, c1, resolved2, c2])).toEqual([
|
|
||||||
{ group: resolved1, events: [c1] },
|
|
||||||
{ group: resolved2, events: [c2] },
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not absorb an event whose parent group is not subscribed', () => {
|
|
||||||
const group1 = makeGroup({ id: 'g1' });
|
|
||||||
const c1 = makeEvent({ id: 'c1', parent: 'g1' });
|
|
||||||
const group2 = makeGroup({ id: 'g2' });
|
|
||||||
const c2 = makeEvent({ id: 'c2', parent: 'g2' });
|
|
||||||
const resolved1 = resolveGroup(group1, [group1, c1, group2, c2]);
|
|
||||||
|
|
||||||
// only the first group is subscribed, so the second group's child stands alone
|
|
||||||
expect(groupSubscriptionTargets([resolved1, c1, c2])).toEqual([
|
|
||||||
{ group: resolved1, events: [c1] },
|
|
||||||
{ group: null, events: [c2] },
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('closes a section when an ungrouped event follows a group', () => {
|
|
||||||
const group = makeGroup({ id: 'g1' });
|
|
||||||
const c1 = makeEvent({ id: 'c1', parent: 'g1' });
|
|
||||||
const e1 = makeEvent({ id: 'e1' });
|
|
||||||
const resolved = resolveGroup(group, [group, c1]);
|
|
||||||
|
|
||||||
expect(groupSubscriptionTargets([resolved, c1, e1])).toEqual([
|
|
||||||
{ group: resolved, events: [c1] },
|
|
||||||
{ group: null, events: [e1] },
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -252,42 +252,6 @@ export function resolveSubscriptionTarget(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A subscribed group along with the subscribed events which belong to it.
|
|
||||||
* Events without a subscribed parent group form their own section with no group.
|
|
||||||
*/
|
|
||||||
export type CountdownSection = {
|
|
||||||
group: CountdownTarget | null;
|
|
||||||
events: CountdownTarget[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Folds the flat, rundown ordered subscription targets into sections.
|
|
||||||
* A group opens a section which absorbs the following targets that declare it as parent,
|
|
||||||
* which allows the group to be rendered as a sticky header for its own events.
|
|
||||||
*/
|
|
||||||
export function groupSubscriptionTargets(targets: CountdownTarget[]): CountdownSection[] {
|
|
||||||
const sections: CountdownSection[] = [];
|
|
||||||
|
|
||||||
for (const target of targets) {
|
|
||||||
// resolveSubscriptionTarget spreads the first child, so we cannot rely on the entry type here
|
|
||||||
if (target.isGroup) {
|
|
||||||
sections.push({ group: target, events: [] });
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const previousSection = sections.at(-1);
|
|
||||||
if (previousSection?.group?.id === target.parent) {
|
|
||||||
previousSection.events.push(target);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sections.push({ group: null, events: [target] });
|
|
||||||
}
|
|
||||||
|
|
||||||
return sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function extendEventData(
|
export function extendEventData(
|
||||||
event: CountdownTarget,
|
event: CountdownTarget,
|
||||||
currentDay: number,
|
currentDay: number,
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import {
|
|||||||
useSensor,
|
useSensor,
|
||||||
useSensors,
|
useSensors,
|
||||||
} from '@dnd-kit/core';
|
} from '@dnd-kit/core';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
|
|
||||||
import type { CuesheetColumnDef } from '../cuesheet-table/cuesheetTable.features';
|
import type { ExtendedEntry } from '../../../common/utils/rundownMetadata';
|
||||||
import { useColumnOrder } from '../cuesheet-table/useColumnManager';
|
import { useColumnOrder } from '../cuesheet-table/useColumnManager';
|
||||||
|
|
||||||
interface CuesheetDndProps {
|
interface CuesheetDndProps {
|
||||||
columns: CuesheetColumnDef[];
|
columns: ColumnDef<ExtendedEntry>[];
|
||||||
tableRoot?: 'editor' | 'cuesheet';
|
tableRoot?: 'editor' | 'cuesheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useTableNav } from '@table-nav/react';
|
import { useTableNav } from '@table-nav/react';
|
||||||
import { useTable } from '@tanstack/react-table';
|
import { ColumnDef, Table, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
||||||
import { OntimeEntry, SupportedEntry, TimeField, isOntimeDelay, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
|
import { OntimeEntry, SupportedEntry, TimeField, isOntimeDelay, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
|
||||||
import { ComponentProps, ReactNode, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
import { ComponentProps, ReactNode, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -29,17 +29,12 @@ import GroupRow from './cuesheet-table-elements/GroupRow';
|
|||||||
import MilestoneRow from './cuesheet-table-elements/MilestoneRow';
|
import MilestoneRow from './cuesheet-table-elements/MilestoneRow';
|
||||||
import TableMenu from './cuesheet-table-menu/TableMenu';
|
import TableMenu from './cuesheet-table-menu/TableMenu';
|
||||||
import CuesheetTableHeaderToolbar from './cuesheet-table-settings/CuesheetTableHeaderToolbar';
|
import CuesheetTableHeaderToolbar from './cuesheet-table-settings/CuesheetTableHeaderToolbar';
|
||||||
import {
|
|
||||||
CuesheetColumnDef,
|
|
||||||
CuesheetTable as CuesheetTableInstance,
|
|
||||||
cuesheetTableFeatures,
|
|
||||||
} from './cuesheetTable.features';
|
|
||||||
import { useColumnOrder, useColumnSizes, useColumnVisibility } from './useColumnManager';
|
import { useColumnOrder, useColumnSizes, useColumnVisibility } from './useColumnManager';
|
||||||
|
|
||||||
import style from './CuesheetTable.module.scss';
|
import style from './CuesheetTable.module.scss';
|
||||||
|
|
||||||
type CuesheetTableBaseProps = {
|
type CuesheetTableBaseProps = {
|
||||||
columns: CuesheetColumnDef[];
|
columns: ColumnDef<ExtendedEntry>[];
|
||||||
cuesheetMode: AppMode;
|
cuesheetMode: AppMode;
|
||||||
source: RundownSource;
|
source: RundownSource;
|
||||||
insertElement?: ReactNode;
|
insertElement?: ReactNode;
|
||||||
@@ -125,8 +120,7 @@ export default function CuesheetTable({
|
|||||||
const { columnSizing, setColumnSizing } = useColumnSizes(tableRoot);
|
const { columnSizing, setColumnSizing } = useColumnSizes(tableRoot);
|
||||||
const { columnVisibility, setColumnVisibility } = useColumnVisibility(tableRoot);
|
const { columnVisibility, setColumnVisibility } = useColumnVisibility(tableRoot);
|
||||||
|
|
||||||
const table = useTable({
|
const table = useReactTable({
|
||||||
features: cuesheetTableFeatures,
|
|
||||||
data: flatRundown,
|
data: flatRundown,
|
||||||
columns,
|
columns,
|
||||||
columnResizeMode: 'onChange',
|
columnResizeMode: 'onChange',
|
||||||
@@ -137,6 +131,7 @@ export default function CuesheetTable({
|
|||||||
},
|
},
|
||||||
onColumnVisibilityChange: setColumnVisibility,
|
onColumnVisibilityChange: setColumnVisibility,
|
||||||
onColumnSizingChange: setColumnSizing,
|
onColumnSizingChange: setColumnSizing,
|
||||||
|
getCoreRowModel: getCoreRowModel(),
|
||||||
meta,
|
meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,7 +195,7 @@ export default function CuesheetTable({
|
|||||||
return colSizes;
|
return colSizes;
|
||||||
// eslint-disable-next-line react-compiler/react-compiler -- unfortunately this is what we need
|
// eslint-disable-next-line react-compiler/react-compiler -- unfortunately this is what we need
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- this works well and follows documentation
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- this works well and follows documentation
|
||||||
}, [columns, table.state.columnResizing, table.state.columnSizing]);
|
}, [table.getState().columnSizingInfo, table.getState().columnSizing]);
|
||||||
|
|
||||||
const allLeafColumns = table.getAllLeafColumns();
|
const allLeafColumns = table.getAllLeafColumns();
|
||||||
const { rows } = table.getRowModel();
|
const { rows } = table.getRowModel();
|
||||||
@@ -219,7 +214,9 @@ export default function CuesheetTable({
|
|||||||
const computeItemKey = useCallback((_: number, item: ExtendedEntry) => item.id, []);
|
const computeItemKey = useCallback((_: number, item: ExtendedEntry) => item.id, []);
|
||||||
const fixedHeaderContent = useCallback(() => {
|
const fixedHeaderContent = useCallback(() => {
|
||||||
return table.getHeaderGroups().map((headerGroup) => {
|
return table.getHeaderGroups().map((headerGroup) => {
|
||||||
const HeaderComponent = table.state.columnResizing.isResizingColumn ? CuesheetHeader : SortableCuesheetHeader;
|
const HeaderComponent = table.getState().columnSizingInfo.isResizingColumn
|
||||||
|
? CuesheetHeader
|
||||||
|
: SortableCuesheetHeader;
|
||||||
|
|
||||||
// if the table is being resized, we render non-sortable headers to avoid performance issues
|
// if the table is being resized, we render non-sortable headers to avoid performance issues
|
||||||
return (
|
return (
|
||||||
@@ -282,8 +279,8 @@ interface CuesheetVirtuosoContext {
|
|||||||
columnSizeVars: { [key: string]: number };
|
columnSizeVars: { [key: string]: number };
|
||||||
cursor: string | null;
|
cursor: string | null;
|
||||||
listeners: ReturnType<typeof useTableNav>['listeners'];
|
listeners: ReturnType<typeof useTableNav>['listeners'];
|
||||||
rows: ReturnType<CuesheetTableInstance['getRowModel']>['rows'];
|
rows: ReturnType<Table<ExtendedEntry>['getRowModel']>['rows'];
|
||||||
table: CuesheetTableInstance;
|
table: Table<ExtendedEntry>;
|
||||||
handleAddNew?: (type: SupportedEntry) => void;
|
handleAddNew?: (type: SupportedEntry) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import { SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
import { SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
||||||
import { FlexRender } from '@tanstack/react-table';
|
import { HeaderGroup, flexRender } from '@tanstack/react-table';
|
||||||
import { CSSProperties } from 'react';
|
import { CSSProperties } from 'react';
|
||||||
|
|
||||||
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
import { getAccessibleColour } from '../../../../common/utils/styleUtils';
|
import { getAccessibleColour } from '../../../../common/utils/styleUtils';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import type { CuesheetHeaderGroup } from '../cuesheetTable.features';
|
|
||||||
import { Draggable, SortableCell, TableCell } from './SortableCell';
|
import { Draggable, SortableCell, TableCell } from './SortableCell';
|
||||||
|
|
||||||
import style from '../CuesheetTable.module.scss';
|
import style from '../CuesheetTable.module.scss';
|
||||||
|
|
||||||
interface CuesheetHeaderProps {
|
interface CuesheetHeaderProps {
|
||||||
headerGroup: CuesheetHeaderGroup;
|
headerGroup: HeaderGroup<ExtendedEntry>;
|
||||||
cuesheetMode: AppMode;
|
cuesheetMode: AppMode;
|
||||||
hideIndexColumn: boolean;
|
hideIndexColumn: boolean;
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ export function SortableCuesheetHeader({ headerGroup, cuesheetMode, hideIndexCol
|
|||||||
injectedStyles={{ width: `calc(var(--header-${header?.id}-size) * 1px)`, ...customStyles }}
|
injectedStyles={{ width: `calc(var(--header-${header?.id}-size) * 1px)`, ...customStyles }}
|
||||||
draggable={<Draggable header={header} />}
|
draggable={<Draggable header={header} />}
|
||||||
>
|
>
|
||||||
{header.isPlaceholder ? null : <FlexRender header={header} />}
|
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
</SortableCell>
|
</SortableCell>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -85,7 +85,7 @@ export function CuesheetHeader({ headerGroup, cuesheetMode, hideIndexColumn }: C
|
|||||||
injectedStyles={{ width: `calc(var(--header-${header?.id}-size) * 1px)`, ...customStyles }}
|
injectedStyles={{ width: `calc(var(--header-${header?.id}-size) * 1px)`, ...customStyles }}
|
||||||
draggable={<Draggable header={header} />}
|
draggable={<Draggable header={header} />}
|
||||||
>
|
>
|
||||||
{header.isPlaceholder ? null : <FlexRender header={header} />}
|
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { FlexRender } from '@tanstack/react-table';
|
import { Table, flexRender } from '@tanstack/react-table';
|
||||||
import { EntryId, RGBColour, SupportedEntry } from 'ontime-types';
|
import { EntryId, OntimeEntry, RGBColour, SupportedEntry } from 'ontime-types';
|
||||||
import { colourToHex, cssOrHexToColour } from 'ontime-utils';
|
import { colourToHex, cssOrHexToColour } from 'ontime-utils';
|
||||||
import { CSSProperties, memo, useMemo } from 'react';
|
import { CSSProperties, memo, useMemo } from 'react';
|
||||||
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
||||||
|
|
||||||
import IconButton from '../../../../common/components/buttons/IconButton';
|
import IconButton from '../../../../common/components/buttons/IconButton';
|
||||||
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
import { cx, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
import { cx, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
||||||
import type { CuesheetTable } from '../cuesheetTable.features';
|
|
||||||
|
|
||||||
import style from './EventRow.module.scss';
|
import style from './EventRow.module.scss';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ interface EventRowProps {
|
|||||||
skip: boolean;
|
skip: boolean;
|
||||||
parent: EntryId | null;
|
parent: EntryId | null;
|
||||||
rowIndex: number;
|
rowIndex: number;
|
||||||
table: CuesheetTable;
|
table: Table<ExtendedEntry<OntimeEntry>>;
|
||||||
injectedStyles?: CSSProperties;
|
injectedStyles?: CSSProperties;
|
||||||
hasCursor?: boolean;
|
hasCursor?: boolean;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ function EventRow({
|
|||||||
data-testid={`cuesheet-cell-${cell.column.id}`}
|
data-testid={`cuesheet-cell-${cell.column.id}`}
|
||||||
data-column-id={cell.column.id}
|
data-column-id={cell.column.id}
|
||||||
>
|
>
|
||||||
<FlexRender cell={cell} />
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { FlexRender } from '@tanstack/react-table';
|
import { Table, flexRender } from '@tanstack/react-table';
|
||||||
import { EntryId, SupportedEntry } from 'ontime-types';
|
import { EntryId, SupportedEntry } from 'ontime-types';
|
||||||
import { CSSProperties, memo } from 'react';
|
import { CSSProperties, memo } from 'react';
|
||||||
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
||||||
|
|
||||||
import IconButton from '../../../../common/components/buttons/IconButton';
|
import IconButton from '../../../../common/components/buttons/IconButton';
|
||||||
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
||||||
import type { CuesheetTable } from '../cuesheetTable.features';
|
|
||||||
|
|
||||||
import style from './GroupRow.module.scss';
|
import style from './GroupRow.module.scss';
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ interface GroupRowProps {
|
|||||||
colour: string;
|
colour: string;
|
||||||
rowId: string;
|
rowId: string;
|
||||||
rowIndex: number;
|
rowIndex: number;
|
||||||
table: CuesheetTable;
|
table: Table<ExtendedEntry>;
|
||||||
injectedStyles?: CSSProperties;
|
injectedStyles?: CSSProperties;
|
||||||
hasCursor?: boolean;
|
hasCursor?: boolean;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ function GroupRow({
|
|||||||
}}
|
}}
|
||||||
role='cell'
|
role='cell'
|
||||||
>
|
>
|
||||||
<FlexRender cell={cell} />
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
import { FlexRender } from '@tanstack/react-table';
|
import { Table, flexRender } from '@tanstack/react-table';
|
||||||
import { EntryId, SupportedEntry } from 'ontime-types';
|
import { EntryId, SupportedEntry } from 'ontime-types';
|
||||||
import { colourToHex, cssOrHexToColour } from 'ontime-utils';
|
import { colourToHex, cssOrHexToColour } from 'ontime-utils';
|
||||||
import { CSSProperties, memo, useMemo } from 'react';
|
import { CSSProperties, memo, useMemo } from 'react';
|
||||||
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
import { IoEllipsisHorizontal } from 'react-icons/io5';
|
||||||
|
|
||||||
import IconButton from '../../../../common/components/buttons/IconButton';
|
import IconButton from '../../../../common/components/buttons/IconButton';
|
||||||
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
import { cx, enDash, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
import { cx, enDash, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu';
|
||||||
import type { CuesheetTable } from '../cuesheetTable.features';
|
|
||||||
|
|
||||||
import style from './MilestoneRow.module.scss';
|
import style from './MilestoneRow.module.scss';
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ interface MilestoneRowProps {
|
|||||||
colour: string;
|
colour: string;
|
||||||
rowId: string;
|
rowId: string;
|
||||||
rowIndex: number;
|
rowIndex: number;
|
||||||
table: CuesheetTable;
|
table: Table<ExtendedEntry>;
|
||||||
injectedStyles?: CSSProperties;
|
injectedStyles?: CSSProperties;
|
||||||
hasCursor?: boolean;
|
hasCursor?: boolean;
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ function MilestoneRow({
|
|||||||
}}
|
}}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
>
|
>
|
||||||
{canRender && <FlexRender cell={cell} />}
|
{canRender && flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
+3
-2
@@ -1,8 +1,9 @@
|
|||||||
import { useSortable } from '@dnd-kit/sortable';
|
import { useSortable } from '@dnd-kit/sortable';
|
||||||
import { CSS } from '@dnd-kit/utilities';
|
import { CSS } from '@dnd-kit/utilities';
|
||||||
|
import { Header } from '@tanstack/react-table';
|
||||||
import { CSSProperties, ReactNode } from 'react';
|
import { CSSProperties, ReactNode } from 'react';
|
||||||
|
|
||||||
import type { CuesheetHeaderCell } from '../cuesheetTable.features';
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
|
|
||||||
import style from '../CuesheetTable.module.scss';
|
import style from '../CuesheetTable.module.scss';
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ export function TableCell({ colSpan, injectedStyles, children, draggable }: Sort
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface DraggableProps {
|
interface DraggableProps {
|
||||||
header: CuesheetHeaderCell;
|
header: Header<ExtendedEntry, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Draggable({ header }: DraggableProps) {
|
export function Draggable({ header }: DraggableProps) {
|
||||||
|
|||||||
+15
-15
@@ -1,3 +1,4 @@
|
|||||||
|
import { CellContext, ColumnDef } from '@tanstack/react-table';
|
||||||
import { CustomFields, TimeStrategy, URLPreset, isOntimeDelay, isOntimeEvent } from 'ontime-types';
|
import { CustomFields, TimeStrategy, URLPreset, isOntimeDelay, isOntimeEvent } from 'ontime-types';
|
||||||
import { millisToString } from 'ontime-utils';
|
import { millisToString } from 'ontime-utils';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
@@ -7,7 +8,6 @@ import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
|||||||
import { formatDuration, formatTime } from '../../../../common/utils/time';
|
import { formatDuration, formatTime } from '../../../../common/utils/time';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import { getCuesheetColumnAccessPolicy } from '../../cuesheet.policies';
|
import { getCuesheetColumnAccessPolicy } from '../../cuesheet.policies';
|
||||||
import type { CuesheetCellContext, CuesheetColumnDef } from '../cuesheetTable.features';
|
|
||||||
import DurationInput from './DurationInput';
|
import DurationInput from './DurationInput';
|
||||||
import EditableImage from './EditableImage';
|
import EditableImage from './EditableImage';
|
||||||
import FlagCell from './FlagCell';
|
import FlagCell from './FlagCell';
|
||||||
@@ -17,11 +17,11 @@ import MutedText from './MutedText';
|
|||||||
import SingleLineCell from './SingleLineCell';
|
import SingleLineCell from './SingleLineCell';
|
||||||
import TimeInput from './TimeInput';
|
import TimeInput from './TimeInput';
|
||||||
|
|
||||||
function getColumnLabel(column: CuesheetCellContext['column']): string {
|
function getColumnLabel(column: CellContext<ExtendedEntry, unknown>['column']): string {
|
||||||
return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
|
return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeStart({ getValue, row, table, column }: CuesheetCellContext) {
|
function MakeStart({ getValue, row, table, column }: CellContext<ExtendedEntry, unknown>) {
|
||||||
if (!table.options.meta) {
|
if (!table.options.meta) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ function MakeStart({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeEnd({ getValue, row, table, column }: CuesheetCellContext) {
|
function MakeEnd({ getValue, row, table, column }: CellContext<ExtendedEntry, unknown>) {
|
||||||
if (!table.options.meta) {
|
if (!table.options.meta) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -100,15 +100,15 @@ function MakeEnd({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) {
|
function MakeDuration({ getValue, row, table, column }: CellContext<ExtendedEntry, unknown>) {
|
||||||
if (!table.options.meta) {
|
if (!table.options.meta) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { hideTableSeconds } = table.options.meta.options;
|
||||||
const event = row.original;
|
const event = row.original;
|
||||||
if (!isOntimeEvent(event)) {
|
if (!isOntimeEvent(event)) {
|
||||||
const duration = getValue() as number;
|
return <MutedText numeric>{formatDuration(getValue() as number, hideTableSeconds)}</MutedText>;
|
||||||
return <MutedText numeric>{formatDuration(duration, false)}</MutedText>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { handleUpdateTimer } = table.options.meta;
|
const { handleUpdateTimer } = table.options.meta;
|
||||||
@@ -117,7 +117,7 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
|
|
||||||
const duration = getValue() as number;
|
const duration = getValue() as number;
|
||||||
const isDurationLocked = event.timeStrategy === TimeStrategy.LockDuration;
|
const isDurationLocked = event.timeStrategy === TimeStrategy.LockDuration;
|
||||||
const formattedDuration = formatDuration(duration, false);
|
const formattedDuration = formatDuration(duration, hideTableSeconds);
|
||||||
|
|
||||||
const canWrite = column.columnDef.meta?.canWrite;
|
const canWrite = column.columnDef.meta?.canWrite;
|
||||||
if (!canWrite) {
|
if (!canWrite) {
|
||||||
@@ -131,7 +131,7 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeMultiLineField({ row, column, table }: CuesheetCellContext) {
|
function MakeMultiLineField({ row, column, table }: CellContext<ExtendedEntry, unknown>) {
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
table.options.meta?.handleUpdate(row.index, column.id, newValue, false);
|
table.options.meta?.handleUpdate(row.index, column.id, newValue, false);
|
||||||
@@ -160,7 +160,7 @@ function MakeMultiLineField({ row, column, table }: CuesheetCellContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LazyImage({ row, column, table }: CuesheetCellContext) {
|
function LazyImage({ row, column, table }: CellContext<ExtendedEntry, unknown>) {
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
table.options.meta?.handleUpdate(row.index, column.id, newValue, true);
|
table.options.meta?.handleUpdate(row.index, column.id, newValue, true);
|
||||||
@@ -178,7 +178,7 @@ function LazyImage({ row, column, table }: CuesheetCellContext) {
|
|||||||
return <EditableImage initialValue={initialValue} updateValue={update} readOnly={!canWrite} />;
|
return <EditableImage initialValue={initialValue} updateValue={update} readOnly={!canWrite} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeSingleLineField({ row, column, table }: CuesheetCellContext) {
|
function MakeSingleLineField({ row, column, table }: CellContext<ExtendedEntry, unknown>) {
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
table.options.meta?.handleUpdate(row.index, column.id, newValue, false);
|
table.options.meta?.handleUpdate(row.index, column.id, newValue, false);
|
||||||
@@ -207,7 +207,7 @@ function MakeSingleLineField({ row, column, table }: CuesheetCellContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeFlagField({ row }: CuesheetCellContext) {
|
function MakeFlagField({ row }: CellContext<ExtendedEntry, unknown>) {
|
||||||
const event = row.original;
|
const event = row.original;
|
||||||
if (!isOntimeEvent(event) || !event.flag) {
|
if (!isOntimeEvent(event) || !event.flag) {
|
||||||
return null;
|
return null;
|
||||||
@@ -215,7 +215,7 @@ function MakeFlagField({ row }: CuesheetCellContext) {
|
|||||||
return <FlagCell />;
|
return <FlagCell />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeCustomField({ row, column, table }: CuesheetCellContext) {
|
function MakeCustomField({ row, column, table }: CellContext<ExtendedEntry, unknown>) {
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
table.options.meta?.handleUpdate(row.index, column.id, newValue, true);
|
table.options.meta?.handleUpdate(row.index, column.id, newValue, true);
|
||||||
@@ -255,8 +255,8 @@ export function makeCuesheetColumns(
|
|||||||
customFields: CustomFields,
|
customFields: CustomFields,
|
||||||
cuesheetMode: AppMode,
|
cuesheetMode: AppMode,
|
||||||
preset: URLPreset | undefined,
|
preset: URLPreset | undefined,
|
||||||
): CuesheetColumnDef[] {
|
): ColumnDef<ExtendedEntry>[] {
|
||||||
const columnsDef: CuesheetColumnDef[] = [];
|
const columnsDef: ColumnDef<ExtendedEntry>[] = [];
|
||||||
const { canRead, canWrite } = getCuesheetColumnAccessPolicy(preset, cuesheetMode);
|
const { canRead, canWrite } = getCuesheetColumnAccessPolicy(preset, cuesheetMode);
|
||||||
|
|
||||||
if (canRead('flag')) {
|
if (canRead('flag')) {
|
||||||
|
|||||||
+5
-4
@@ -2,6 +2,7 @@ import { Popover } from '@base-ui/react/popover';
|
|||||||
import { Toggle } from '@base-ui/react/toggle';
|
import { Toggle } from '@base-ui/react/toggle';
|
||||||
import { ToggleGroup } from '@base-ui/react/toggle-group';
|
import { ToggleGroup } from '@base-ui/react/toggle-group';
|
||||||
import { Toolbar } from '@base-ui/react/toolbar';
|
import { Toolbar } from '@base-ui/react/toolbar';
|
||||||
|
import type { Column } from '@tanstack/react-table';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { IoBookOutline, IoChevronDown, IoOptions } from 'react-icons/io5';
|
import { IoBookOutline, IoChevronDown, IoOptions } from 'react-icons/io5';
|
||||||
|
|
||||||
@@ -9,9 +10,9 @@ import Button from '../../../../common/components/buttons/Button';
|
|||||||
import Checkbox from '../../../../common/components/checkbox/Checkbox';
|
import Checkbox from '../../../../common/components/checkbox/Checkbox';
|
||||||
import * as Editor from '../../../../common/components/editor-utils/EditorUtils';
|
import * as Editor from '../../../../common/components/editor-utils/EditorUtils';
|
||||||
import PopoverContents from '../../../../common/components/popover/Popover';
|
import PopoverContents from '../../../../common/components/popover/Popover';
|
||||||
|
import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata';
|
||||||
import { AppMode } from '../../../../ontimeConfig';
|
import { AppMode } from '../../../../ontimeConfig';
|
||||||
import { useCuesheetPermissions } from '../../useTablePermissions';
|
import { useCuesheetPermissions } from '../../useTablePermissions';
|
||||||
import type { CuesheetColumn } from '../cuesheetTable.features';
|
|
||||||
import CuesheetShareModal from './CuesheetShareModal';
|
import CuesheetShareModal from './CuesheetShareModal';
|
||||||
|
|
||||||
import style from './CuesheetTableSettings.module.scss';
|
import style from './CuesheetTableSettings.module.scss';
|
||||||
@@ -36,7 +37,7 @@ type TableModeControls = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface CuesheetTableHeaderToolbarProps {
|
interface CuesheetTableHeaderToolbarProps {
|
||||||
columns: CuesheetColumn[];
|
columns: Column<ExtendedEntry, unknown>[];
|
||||||
optionsStore: TableHeaderOptionsStore;
|
optionsStore: TableHeaderOptionsStore;
|
||||||
handleResetResizing: () => void;
|
handleResetResizing: () => void;
|
||||||
handleResetReordering: () => void;
|
handleResetReordering: () => void;
|
||||||
@@ -110,7 +111,7 @@ interface ViewSettingsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ColumnSettingsProps {
|
interface ColumnSettingsProps {
|
||||||
columns: CuesheetColumn[];
|
columns: Column<ExtendedEntry, unknown>[];
|
||||||
handleResetResizing: () => void;
|
handleResetResizing: () => void;
|
||||||
handleResetReordering: () => void;
|
handleResetReordering: () => void;
|
||||||
handleClearToggles: () => void;
|
handleClearToggles: () => void;
|
||||||
@@ -202,7 +203,7 @@ function ColumnSettings({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Editor.Label key={`${column.id}-${visible}`} className={style.option}>
|
<Editor.Label key={`${column.id}-${visible}`} className={style.option}>
|
||||||
<Checkbox defaultChecked={visible} onCheckedChange={(checked) => column.toggleVisibility(checked)} />
|
<Checkbox defaultChecked={visible} onCheckedChange={column.toggleVisibility} />
|
||||||
{columnHeader as ReactNode}
|
{columnHeader as ReactNode}
|
||||||
</Editor.Label>
|
</Editor.Label>
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
transition: background-color 0.2s ease-in-out;
|
transition: background-color 0.2s ease-in-out;
|
||||||
|
|
||||||
&[data-background-rundown='true'] {
|
&[data-background-rundown='true'] {
|
||||||
background-color: $bg-active;
|
background-color: rgba($ontime-color, 0.5);
|
||||||
|
|
||||||
.apart::before {
|
.apart::before {
|
||||||
content: 'BACKGROUND EDIT';
|
content: 'BACKGROUND EDIT';
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
import {
|
|
||||||
columnOrderingFeature,
|
|
||||||
columnResizingFeature,
|
|
||||||
columnSizingFeature,
|
|
||||||
columnVisibilityFeature,
|
|
||||||
metaHelper,
|
|
||||||
tableFeatures,
|
|
||||||
} from '@tanstack/react-table';
|
|
||||||
import type { CellContext, Column, ColumnDef, Header, HeaderGroup, Table } from '@tanstack/react-table';
|
|
||||||
import type { TimeField } from 'ontime-types';
|
|
||||||
|
|
||||||
import type { ExtendedEntry } from '../../../common/utils/rundownMetadata';
|
|
||||||
import type { AppMode } from '../../../ontimeConfig';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom data we pass to the table
|
|
||||||
* - `handleUpdate` callback to update the entry when the user edits a cell
|
|
||||||
* - `handleUpdateTimer` callback to update the timer for a specific event
|
|
||||||
* - `options-showDelayedTimes` whether to show or hide delayed times
|
|
||||||
* - `options-hideTableSeconds` whether to hide seconds in the table
|
|
||||||
* - `options-hideIndexColumn` whether to hide the index column
|
|
||||||
* - `options-cuesheetMode` run or edit mode
|
|
||||||
*/
|
|
||||||
export interface CuesheetTableMeta {
|
|
||||||
handleUpdate: (rowIndex: number, accessor: string, payload: string, isCustom: boolean) => void;
|
|
||||||
handleUpdateTimer: (eventId: string, field: TimeField, payload: string) => void;
|
|
||||||
options: {
|
|
||||||
showDelayedTimes: boolean;
|
|
||||||
hideTableSeconds: boolean;
|
|
||||||
hideIndexColumn: boolean;
|
|
||||||
cuesheetMode: AppMode;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata specific for each column
|
|
||||||
* - `canWrite` whether the user can write to this column
|
|
||||||
* - `colour` background colour associated with a custom field
|
|
||||||
*/
|
|
||||||
export interface CuesheetColumnMeta {
|
|
||||||
canWrite: boolean;
|
|
||||||
colour?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Features registered in the cuesheet and rundown tables.
|
|
||||||
* In v9 an API only exists once its feature is registered, so this list is the
|
|
||||||
* source of truth for what the table can do:
|
|
||||||
* - `columnOrderingFeature`: user reorders columns by dragging the headers
|
|
||||||
* - `columnVisibilityFeature`: user toggles columns in the table settings
|
|
||||||
* - `columnSizingFeature`: column widths, exposed to CSS as custom properties
|
|
||||||
* - `columnResizingFeature`: the drag handle in the header (requires sizing)
|
|
||||||
*
|
|
||||||
* The `tableMeta` / `columnMeta` slots replace the v8 global module augmentation:
|
|
||||||
* they scope our meta types to this table instead of every table in the app.
|
|
||||||
*/
|
|
||||||
export const cuesheetTableFeatures = tableFeatures({
|
|
||||||
columnOrderingFeature,
|
|
||||||
columnVisibilityFeature,
|
|
||||||
columnSizingFeature,
|
|
||||||
columnResizingFeature,
|
|
||||||
tableMeta: metaHelper<CuesheetTableMeta>(),
|
|
||||||
columnMeta: metaHelper<CuesheetColumnMeta>(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type CuesheetFeatures = typeof cuesheetTableFeatures;
|
|
||||||
|
|
||||||
/** Convenience aliases so consumers do not need to repeat the feature generic */
|
|
||||||
export type CuesheetColumnDef = ColumnDef<CuesheetFeatures, ExtendedEntry>;
|
|
||||||
export type CuesheetTable = Table<CuesheetFeatures, ExtendedEntry>;
|
|
||||||
export type CuesheetCellContext = CellContext<CuesheetFeatures, ExtendedEntry>;
|
|
||||||
export type CuesheetHeaderGroup = HeaderGroup<CuesheetFeatures, ExtendedEntry>;
|
|
||||||
export type CuesheetHeaderCell = Header<CuesheetFeatures, ExtendedEntry, unknown>;
|
|
||||||
export type CuesheetColumn = Column<CuesheetFeatures, ExtendedEntry, unknown>;
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useLocalStorage } from '@mantine/hooks';
|
import { useLocalStorage } from '@mantine/hooks';
|
||||||
import { ColumnSizingState, Updater } from '@tanstack/react-table';
|
import { ColumnDef, ColumnSizingState, Updater } from '@tanstack/react-table';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { debounce } from '../../../common/utils/debounce';
|
import { debounce } from '../../../common/utils/debounce';
|
||||||
import { makeStageKey } from '../../../common/utils/localStorage';
|
import { makeStageKey } from '../../../common/utils/localStorage';
|
||||||
import type { CuesheetColumnDef } from './cuesheetTable.features';
|
import type { ExtendedEntry } from '../../../common/utils/rundownMetadata';
|
||||||
|
|
||||||
type TableRoot = 'editor' | 'cuesheet';
|
type TableRoot = 'editor' | 'cuesheet';
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export function useColumnSizes(tableRoot: TableRoot = 'cuesheet') {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useColumnOrder(columns: CuesheetColumnDef[], tableRoot: TableRoot = 'cuesheet') {
|
export function useColumnOrder(columns: ColumnDef<ExtendedEntry>[], tableRoot: TableRoot = 'cuesheet') {
|
||||||
const tableOrderKey = useMemo(() => makeStageKey(`${tableRoot}-table-order`), [tableRoot]);
|
const tableOrderKey = useMemo(() => makeStageKey(`${tableRoot}-table-order`), [tableRoot]);
|
||||||
|
|
||||||
const [columnOrder, saveColumnOrder] = useLocalStorage<string[]>({
|
const [columnOrder, saveColumnOrder] = useLocalStorage<string[]>({
|
||||||
|
|||||||
@@ -3,14 +3,11 @@
|
|||||||
.error {
|
.error {
|
||||||
padding-inline: 0.5rem;
|
padding-inline: 0.5rem;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
// rows grow when a match is shown from a note or custom field
|
height: 3rem;
|
||||||
min-height: 3rem;
|
|
||||||
padding-block: 0.35rem;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry[data-selected='true'] {
|
.entry[data-selected='true'] {
|
||||||
@@ -21,47 +18,21 @@
|
|||||||
color: $label-gray;
|
color: $label-gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more {
|
|
||||||
padding-inline: 0.5rem;
|
|
||||||
padding-block: 0.75rem;
|
|
||||||
font-size: calc(1rem - 2px);
|
|
||||||
color: $label-gray;
|
|
||||||
border-top: 1px solid $gray-1000;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
color: $error-red;
|
color: $error-red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filters {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.35rem;
|
|
||||||
padding-top: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filterLabel {
|
|
||||||
font-size: calc(1rem - 3px);
|
|
||||||
color: $label-gray;
|
|
||||||
margin-right: 0.15rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.data {
|
.data {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
'index cue'
|
'index cue'
|
||||||
'index title'
|
'index title';
|
||||||
'index match';
|
|
||||||
column-gap: 1rem;
|
column-gap: 1rem;
|
||||||
grid-template-rows: min-content 1fr;
|
grid-template-rows: min-content 1fr;
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
.index {
|
.index {
|
||||||
grid-area: index;
|
grid-area: index;
|
||||||
// background and text colour come from getAccessibleColour, which keeps the
|
background-color: var(--color, $gray-1000);
|
||||||
// number legible whatever colour the user gave the entry
|
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding-block: 0.25rem;
|
padding-block: 0.25rem;
|
||||||
width: 3.5rem;
|
width: 3.5rem;
|
||||||
@@ -71,33 +42,14 @@
|
|||||||
|
|
||||||
.title {
|
.title {
|
||||||
grid-area: title;
|
grid-area: title;
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cue {
|
.cue {
|
||||||
grid-area: cue;
|
grid-area: cue;
|
||||||
font-size: calc(1rem - 2px);
|
font-size: calc(1rem - 2px);
|
||||||
color: $label-gray;
|
color: $label-gray;
|
||||||
|
max-height: 1em;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.match {
|
|
||||||
grid-area: match;
|
|
||||||
font-size: calc(1rem - 3px);
|
|
||||||
color: $label-gray;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.matchLabel {
|
|
||||||
color: $ui-white;
|
|
||||||
margin-right: 0.4rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,14 +63,13 @@
|
|||||||
color: $label-gray;
|
color: $label-gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.count {
|
.filterHint {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.go {
|
.em {
|
||||||
white-space: nowrap;
|
color: $ui-white;
|
||||||
padding-left: 1rem;
|
margin-inline: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hints {
|
.hints {
|
||||||
@@ -147,7 +98,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.count {
|
.filterHint {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { MaybeString } from 'ontime-types';
|
import { useDebouncedCallback } from '@mantine/hooks';
|
||||||
import { KeyboardEvent, useDeferredValue, useEffect, useRef, useState } from 'react';
|
import { SupportedEntry } from 'ontime-types';
|
||||||
|
import { KeyboardEvent, useState } from 'react';
|
||||||
|
|
||||||
import ToggleButton from '../../../common/components/buttons/ToggleButton';
|
|
||||||
import Input from '../../../common/components/input/input/Input';
|
import Input from '../../../common/components/input/input/Input';
|
||||||
import Kbd from '../../../common/components/kbd/Kbd';
|
import Kbd from '../../../common/components/kbd/Kbd';
|
||||||
import Modal from '../../../common/components/modal/Modal';
|
import Modal from '../../../common/components/modal/Modal';
|
||||||
import { getAccessibleColour } from '../../../common/utils/styleUtils';
|
import useFinder from './useFinder';
|
||||||
import useFinder, { FinderResult } from './useFinder';
|
|
||||||
|
|
||||||
import style from './Finder.module.scss';
|
import style from './Finder.module.scss';
|
||||||
|
|
||||||
@@ -16,76 +15,46 @@ interface FinderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Finder({ isOpen, onClose }: FinderProps) {
|
export default function Finder({ isOpen, onClose }: FinderProps) {
|
||||||
const [search, setSearch] = useState('');
|
const { find, select, results, error } = useFinder();
|
||||||
const [filter, setFilter] = useState<MaybeString>(null);
|
const [selected, setSelected] = useState(0);
|
||||||
const [selectedId, setSelectedId] = useState<MaybeString>(null);
|
|
||||||
|
|
||||||
/**
|
const debouncedFind = useDebouncedCallback(find, 100);
|
||||||
* Keeps typing responsive while the list re-renders.
|
|
||||||
* The search itself is cheap, rendering the results is what costs.
|
|
||||||
*/
|
|
||||||
const deferredSearch = useDeferredValue(search);
|
|
||||||
const { select, results, error, total, filters, appliedFilter } = useFinder(deferredSearch, filter);
|
|
||||||
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
const activeRef = useRef<HTMLLIElement>(null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We track the selection by ID so that it survives the result list changing under us:
|
|
||||||
* an entry that no longer exists falls back to the first result instead of dangling past the end
|
|
||||||
*/
|
|
||||||
const activeIndex = Math.max(
|
|
||||||
0,
|
|
||||||
results.findIndex((entry) => entry.id === selectedId),
|
|
||||||
);
|
|
||||||
const activeEntry = results.at(activeIndex);
|
|
||||||
|
|
||||||
/** keep the highlighted entry in view while navigating with the keyboard */
|
|
||||||
useEffect(() => {
|
|
||||||
activeRef.current?.scrollIntoView({ block: 'nearest' });
|
|
||||||
}, [activeEntry?.id]);
|
|
||||||
|
|
||||||
const navigate = (event: KeyboardEvent<HTMLDivElement>) => {
|
const navigate = (event: KeyboardEvent<HTMLDivElement>) => {
|
||||||
// pressing the search shortcut again selects the query, ready to be replaced
|
|
||||||
if ((event.metaKey || event.ctrlKey) && event.key === 'f') {
|
|
||||||
event.preventDefault();
|
|
||||||
inputRef.current?.select();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// all operations need results
|
// all operations need results
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.key === 'ArrowDown') {
|
if (event.key === 'ArrowDown') {
|
||||||
setSelectedId(results[(activeIndex + 1) % results.length].id);
|
setSelected((prev) => (prev + 1) % results.length);
|
||||||
}
|
}
|
||||||
if (event.key === 'ArrowUp') {
|
if (event.key === 'ArrowUp') {
|
||||||
setSelectedId(results[(activeIndex - 1 + results.length) % results.length].id);
|
setSelected((prev) => (prev - 1 + results.length) % results.length);
|
||||||
}
|
}
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
submit(activeEntry);
|
submit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = (entry: FinderResult | undefined) => {
|
const submit = () => {
|
||||||
if (!entry) {
|
const selectedEvent = results[selected];
|
||||||
return;
|
select(selectedEvent);
|
||||||
}
|
|
||||||
select(entry);
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Scopes the search to a single field, or back to all fields when tapped again */
|
const handleMouseMoveEvent = (event: React.MouseEvent<HTMLUListElement>) => {
|
||||||
const handleFilter = (filterKey: string) => {
|
const target = event.target as HTMLElement;
|
||||||
setFilter((previous) => (previous === filterKey ? null : filterKey));
|
const li = target.closest('li');
|
||||||
inputRef.current?.focus();
|
if (li) {
|
||||||
|
const index = Number(li.dataset.index);
|
||||||
|
if (!isNaN(index)) {
|
||||||
|
setSelected(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const hiddenResults = total - results.length;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title=''
|
title=''
|
||||||
@@ -94,68 +63,35 @@ export default function Finder({ isOpen, onClose }: FinderProps) {
|
|||||||
showBackdrop
|
showBackdrop
|
||||||
bodyElements={
|
bodyElements={
|
||||||
<div onKeyDown={navigate}>
|
<div onKeyDown={navigate}>
|
||||||
<Input
|
<Input height='large' fluid onChange={debouncedFind} placeholder='Search...' />
|
||||||
ref={inputRef}
|
<ul className={style.scrollContainer} onMouseMove={handleMouseMoveEvent}>
|
||||||
height='large'
|
|
||||||
fluid
|
|
||||||
autoFocus
|
|
||||||
value={search}
|
|
||||||
onChange={(event) => setSearch(event.target.value)}
|
|
||||||
placeholder='Search...'
|
|
||||||
/>
|
|
||||||
<div className={style.filters} data-testid='finder-filters'>
|
|
||||||
<span className={style.filterLabel}>Filter by</span>
|
|
||||||
{filters.map((option) => (
|
|
||||||
<ToggleButton
|
|
||||||
key={option.key}
|
|
||||||
pressed={appliedFilter === option.key}
|
|
||||||
size='small'
|
|
||||||
onClick={() => handleFilter(option.key)}
|
|
||||||
>
|
|
||||||
{option.label}
|
|
||||||
</ToggleButton>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<ul className={style.scrollContainer}>
|
|
||||||
{error && <li className={style.error}>{error}</li>}
|
{error && <li className={style.error}>{error}</li>}
|
||||||
{!error && results.length === 0 && <li className={style.empty}>No results</li>}
|
{results.length === 0 && <li className={style.empty}>No results</li>}
|
||||||
{results.map((entry) => {
|
{results.length > 0 &&
|
||||||
const isSelected = activeEntry?.id === entry.id;
|
results.map((entry, index) => {
|
||||||
// the title and cue are already on the row, a match anywhere else needs showing
|
const isSelected = selected === index;
|
||||||
const showMatch = entry.match !== null && entry.match.key !== 'title' && entry.match.key !== 'cue';
|
const displayIndex = entry.type === SupportedEntry.Event ? entry.eventIndex : '-';
|
||||||
|
const displayCue = 'cue' in entry ? entry.cue : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={entry.id}
|
key={entry.id}
|
||||||
ref={isSelected ? activeRef : undefined}
|
className={style.entry}
|
||||||
className={style.entry}
|
data-selected={isSelected}
|
||||||
data-testid='finder-result'
|
data-index={index}
|
||||||
data-selected={isSelected}
|
onClick={submit}
|
||||||
onClick={() => submit(entry)}
|
>
|
||||||
onPointerEnter={() => setSelectedId(entry.id)}
|
<div className={style.data}>
|
||||||
>
|
<div className={style.index} style={{ '--color': entry.colour }}>
|
||||||
<div className={style.data}>
|
{displayIndex}
|
||||||
<div className={style.index} style={getAccessibleColour(entry.colour)}>
|
|
||||||
{entry.eventIndex ?? '-'}
|
|
||||||
</div>
|
|
||||||
<div className={style.cue}>{entry.cue}</div>
|
|
||||||
<div className={style.title}>{entry.title}</div>
|
|
||||||
{showMatch && (
|
|
||||||
<div className={style.match} data-testid='finder-result-match'>
|
|
||||||
<span className={style.matchLabel}>{entry.match?.label}</span>
|
|
||||||
{entry.match?.excerpt}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className={style.cue}>{displayCue}</div>
|
||||||
</div>
|
<div className={style.title}>{entry.title}</div>
|
||||||
{isSelected && <span className={style.go}>Go ⏎</span>}
|
</div>
|
||||||
</li>
|
{isSelected && <span>Go ⏎</span>}
|
||||||
);
|
</li>
|
||||||
})}
|
);
|
||||||
{hiddenResults > 0 && (
|
})}
|
||||||
<li className={style.more} data-testid='finder-more'>
|
|
||||||
{hiddenResults} more {hiddenResults === 1 ? 'result' : 'results'} — keep typing to narrow the search
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -176,11 +112,10 @@ export default function Finder({ isOpen, onClose }: FinderProps) {
|
|||||||
Close
|
Close
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{total > 0 && (
|
<div className={style.filterHint}>
|
||||||
<div className={style.count} data-testid='finder-count'>
|
Filter by <span className={style.em}>cue</span>, <span className={style.em}>index</span>, or
|
||||||
{hiddenResults > 0 ? `Showing ${results.length} of ${total}` : `${total} result${total === 1 ? '' : 's'}`}
|
<span className={style.em}>title</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
import { CustomFields, OntimeDelay, OntimeEvent, OntimeGroup, OntimeMilestone, SupportedEntry } from 'ontime-types';
|
|
||||||
|
|
||||||
import { parseQuery, searchByIndex, searchByText } from './useFinder';
|
|
||||||
|
|
||||||
function makeEvent(id: string, overrides: Partial<OntimeEvent> = {}): OntimeEvent {
|
|
||||||
return {
|
|
||||||
type: SupportedEntry.Event,
|
|
||||||
id,
|
|
||||||
cue: '',
|
|
||||||
title: '',
|
|
||||||
note: '',
|
|
||||||
colour: '#000000',
|
|
||||||
custom: {},
|
|
||||||
parent: null,
|
|
||||||
...overrides,
|
|
||||||
} as OntimeEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeGroup(id: string, overrides: Partial<OntimeGroup> = {}): OntimeGroup {
|
|
||||||
return {
|
|
||||||
type: SupportedEntry.Group,
|
|
||||||
id,
|
|
||||||
title: '',
|
|
||||||
note: '',
|
|
||||||
colour: '#000000',
|
|
||||||
custom: {},
|
|
||||||
...overrides,
|
|
||||||
} as OntimeGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeMilestone(id: string, overrides: Partial<OntimeMilestone> = {}): OntimeMilestone {
|
|
||||||
return {
|
|
||||||
type: SupportedEntry.Milestone,
|
|
||||||
id,
|
|
||||||
cue: '',
|
|
||||||
title: '',
|
|
||||||
note: '',
|
|
||||||
colour: '#000000',
|
|
||||||
custom: {},
|
|
||||||
parent: null,
|
|
||||||
...overrides,
|
|
||||||
} as OntimeMilestone;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeDelay(id: string): OntimeDelay {
|
|
||||||
return { type: SupportedEntry.Delay, id, duration: 1000, parent: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('parseQuery()', () => {
|
|
||||||
const filters = [
|
|
||||||
{ key: 'cue', label: 'Cue' },
|
|
||||||
{ key: 'Camera_Notes', label: 'Camera Notes' },
|
|
||||||
];
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['cue 12', { filterKey: 'cue', searchString: '12' }],
|
|
||||||
['cue:12', { filterKey: 'cue', searchString: '12' }],
|
|
||||||
['camera_notes:wide', { filterKey: 'Camera_Notes', searchString: 'wide' }],
|
|
||||||
])('parses the field prefix in %s', (searchValue, expected) => {
|
|
||||||
expect(parseQuery(searchValue, filters)).toStrictEqual(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps an unprefixed query as a search across all fields', () => {
|
|
||||||
expect(parseQuery('zebrafish', filters)).toStrictEqual({ filterKey: null, searchString: 'zebrafish' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('recognises a filter before any search text has been entered', () => {
|
|
||||||
expect(parseQuery('cue', filters)).toStrictEqual({ filterKey: 'cue', searchString: '' });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('searchByText()', () => {
|
|
||||||
const customFields: CustomFields = {
|
|
||||||
Camera_Notes: { type: 'text', label: 'Camera Notes', colour: '#000000' },
|
|
||||||
Slide: { type: 'image', label: 'Slide', colour: '#000000' },
|
|
||||||
};
|
|
||||||
|
|
||||||
it('searches cue, title, note, and text custom fields in rundown order', () => {
|
|
||||||
const data = [
|
|
||||||
makeMilestone('milestone', { cue: 'needle' }),
|
|
||||||
makeGroup('group', { title: 'needle' }),
|
|
||||||
makeEvent('note', { note: 'find the needle here' }),
|
|
||||||
makeEvent('custom', { custom: { Camera_Notes: 'needle' } }),
|
|
||||||
];
|
|
||||||
|
|
||||||
const outcome = searchByText(data, customFields, null, 'needle');
|
|
||||||
|
|
||||||
expect(outcome.results.map(({ id, match }) => ({ id, field: match?.key }))).toStrictEqual([
|
|
||||||
{ id: 'milestone', field: 'cue' },
|
|
||||||
{ id: 'group', field: 'title' },
|
|
||||||
{ id: 'note', field: 'note' },
|
|
||||||
{ id: 'custom', field: 'Camera_Notes' },
|
|
||||||
]);
|
|
||||||
expect(outcome.total).toBe(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('searches only the selected field', () => {
|
|
||||||
const data = [
|
|
||||||
makeEvent('title', { title: 'needle' }),
|
|
||||||
makeEvent('note', { note: 'needle' }),
|
|
||||||
makeEvent('custom', { custom: { Camera_Notes: 'needle' } }),
|
|
||||||
];
|
|
||||||
|
|
||||||
const outcome = searchByText(data, customFields, 'note', 'needle');
|
|
||||||
|
|
||||||
expect(outcome.results.map((result) => result.id)).toStrictEqual(['note']);
|
|
||||||
expect(outcome.total).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reports the first matching field so the result can explain why it matched', () => {
|
|
||||||
const data = [makeEvent('event', { cue: 'NEEDLE', title: 'another needle' })];
|
|
||||||
|
|
||||||
const outcome = searchByText(data, customFields, null, 'needle');
|
|
||||||
|
|
||||||
expect(outcome.results[0].match).toStrictEqual({ key: 'cue', label: 'Cue', excerpt: 'NEEDLE' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not search image custom fields', () => {
|
|
||||||
const data = [makeEvent('image-only', { custom: { Slide: 'needle' } })];
|
|
||||||
|
|
||||||
expect(searchByText(data, customFields, null, 'needle')).toStrictEqual({ results: [], error: null, total: 0 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reports the full match count while limiting rendered results', () => {
|
|
||||||
const data = Array.from({ length: 51 }, (_, index) => makeEvent(String(index), { title: 'needle' }));
|
|
||||||
|
|
||||||
const outcome = searchByText(data, customFields, null, 'needle');
|
|
||||||
|
|
||||||
expect(outcome.results).toHaveLength(50);
|
|
||||||
expect(outcome.total).toBe(51);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('searchByIndex()', () => {
|
|
||||||
it('counts only events while preserving the flat rundown position', () => {
|
|
||||||
const data = [
|
|
||||||
makeGroup('group'),
|
|
||||||
makeDelay('delay'),
|
|
||||||
makeEvent('first'),
|
|
||||||
makeMilestone('milestone'),
|
|
||||||
makeEvent('second'),
|
|
||||||
];
|
|
||||||
|
|
||||||
const outcome = searchByIndex(data, '2');
|
|
||||||
|
|
||||||
expect(outcome.results).toHaveLength(1);
|
|
||||||
expect(outcome.results[0]).toMatchObject({ id: 'second', index: 4, eventIndex: 2 });
|
|
||||||
expect(outcome.total).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each(['0', 'not-a-number'])('rejects invalid index %s', (index) => {
|
|
||||||
expect(searchByIndex([makeEvent('event')], index)).toStrictEqual({
|
|
||||||
results: [],
|
|
||||||
error: 'Invalid index',
|
|
||||||
total: 0,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns no result when the event index is beyond the rundown', () => {
|
|
||||||
expect(searchByIndex([makeEvent('event')], '2')).toStrictEqual({ results: [], error: null, total: 0 });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,259 +1,239 @@
|
|||||||
import {
|
import { EntryId, MaybeString, SupportedEntry, isOntimeEvent, isOntimeGroup, isOntimeMilestone } from 'ontime-types';
|
||||||
CustomFields,
|
import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
EntryId,
|
|
||||||
MaybeNumber,
|
|
||||||
MaybeString,
|
|
||||||
OntimeEntry,
|
|
||||||
OntimeEvent,
|
|
||||||
OntimeGroup,
|
|
||||||
OntimeMilestone,
|
|
||||||
isOntimeDelay,
|
|
||||||
isOntimeEvent,
|
|
||||||
} from 'ontime-types';
|
|
||||||
import { useCallback, useMemo } from 'react';
|
|
||||||
|
|
||||||
import useCustomFields from '../../../common/hooks-query/useCustomFields';
|
|
||||||
import { useFlatRundown } from '../../../common/hooks-query/useRundown';
|
import { useFlatRundown } from '../../../common/hooks-query/useRundown';
|
||||||
import { useSelectAndRevealEntry } from '../../../features/rundown/useSelectAndRevealEntry';
|
import { useSelectAndRevealEntry } from '../../../features/rundown/useSelectAndRevealEntry';
|
||||||
|
|
||||||
/** How many results we render, the total number of matches is reported separately */
|
const maxResults = 12;
|
||||||
const maxResults = 50;
|
|
||||||
/** Notes can hold a whole script, we only show enough to explain the match */
|
|
||||||
const excerptPadding = 40;
|
|
||||||
|
|
||||||
const indexFilter = 'index';
|
type FilterableGroup = {
|
||||||
|
type: SupportedEntry.Group;
|
||||||
/** Everything except delays, which carry no text to search */
|
|
||||||
type SearchableEntry = OntimeEvent | OntimeGroup | OntimeMilestone;
|
|
||||||
|
|
||||||
type FinderFilter = { key: string; label: string };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Offered to the user as filter badges. Index is a positional lookup rather than a
|
|
||||||
* text field, so it is handled separately from the fields a search runs over.
|
|
||||||
*/
|
|
||||||
const staticFilters: FinderFilter[] = [
|
|
||||||
{ key: indexFilter, label: 'Index' },
|
|
||||||
{ key: 'cue', label: 'Cue' },
|
|
||||||
{ key: 'title', label: 'Title' },
|
|
||||||
{ key: 'note', label: 'Note' },
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Why an entry matched, so the UI can show the user */
|
|
||||||
type FinderMatch = { key: string; label: string; excerpt: string };
|
|
||||||
|
|
||||||
export type FinderResult = {
|
|
||||||
id: EntryId;
|
id: EntryId;
|
||||||
/** position in the flat rundown, which is how the rundown reveals an entry */
|
|
||||||
index: number;
|
index: number;
|
||||||
/** 1-based position among events, null for groups and milestones */
|
|
||||||
eventIndex: MaybeNumber;
|
|
||||||
title: string;
|
title: string;
|
||||||
/** groups have no cue */
|
colour: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type FilterableEvent = {
|
||||||
|
type: SupportedEntry.Event;
|
||||||
|
id: EntryId;
|
||||||
|
index: number;
|
||||||
|
eventIndex: number;
|
||||||
|
title: string;
|
||||||
cue: string;
|
cue: string;
|
||||||
colour: string;
|
colour: string;
|
||||||
parent: MaybeString;
|
parent: MaybeString;
|
||||||
/** absent when the entry was found by index rather than by matching text */
|
|
||||||
match: FinderMatch | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type SearchOutcome = { results: FinderResult[]; error: MaybeString; total: number };
|
type FilterableMilestone = {
|
||||||
|
type: SupportedEntry.Milestone;
|
||||||
|
id: EntryId;
|
||||||
|
index: number;
|
||||||
|
title: string;
|
||||||
|
cue: string;
|
||||||
|
colour: string;
|
||||||
|
parent: MaybeString;
|
||||||
|
};
|
||||||
|
|
||||||
const noResults: SearchOutcome = { results: [], error: null, total: 0 };
|
type FilterableEntry = FilterableGroup | FilterableEvent | FilterableMilestone;
|
||||||
|
|
||||||
/** Groups are the only searchable entry with neither a cue nor a parent */
|
export default function useFinder() {
|
||||||
function toResult(entry: SearchableEntry, index: number, eventIndex: MaybeNumber, match: FinderMatch | null) {
|
|
||||||
return {
|
|
||||||
id: entry.id,
|
|
||||||
index,
|
|
||||||
eventIndex,
|
|
||||||
title: entry.title,
|
|
||||||
cue: 'cue' in entry ? entry.cue : '',
|
|
||||||
colour: entry.colour,
|
|
||||||
parent: 'parent' in entry ? entry.parent : null,
|
|
||||||
match,
|
|
||||||
} satisfies FinderResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Shows enough of a long value for the user to see why it matched */
|
|
||||||
function makeExcerpt(value: string, matchIndex: number, searchLength: number): string {
|
|
||||||
const start = Math.max(0, matchIndex - excerptPadding);
|
|
||||||
const end = Math.min(value.length, matchIndex + searchLength + excerptPadding);
|
|
||||||
return `${start > 0 ? '…' : ''}${value.slice(start, end)}${end < value.length ? '…' : ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The first field of an entry to contain the search string, if any.
|
|
||||||
* Fields are tried in the order we prefer to report a match.
|
|
||||||
*/
|
|
||||||
function findMatch(
|
|
||||||
entry: SearchableEntry,
|
|
||||||
customFields: CustomFields,
|
|
||||||
filterKey: MaybeString,
|
|
||||||
searchString: string,
|
|
||||||
): FinderMatch | null {
|
|
||||||
function check(key: string, label: string, value: string): FinderMatch | null {
|
|
||||||
if (!value || (filterKey !== null && key !== filterKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const matchIndex = value.toLowerCase().indexOf(searchString);
|
|
||||||
if (matchIndex === -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return { key, label, excerpt: makeExcerpt(value, matchIndex, searchString.length) };
|
|
||||||
}
|
|
||||||
|
|
||||||
// groups have no cue, the rest is common to every searchable entry
|
|
||||||
const fromCue = 'cue' in entry ? check('cue', 'Cue', entry.cue) : null;
|
|
||||||
const match = fromCue ?? check('title', 'Title', entry.title) ?? check('note', 'Note', entry.note);
|
|
||||||
if (match !== null) {
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom fields are named by the project, so these can only be reached generically
|
|
||||||
for (const [key, value] of Object.entries(entry.custom)) {
|
|
||||||
const definition = customFields[key];
|
|
||||||
if (definition?.type !== 'text') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const custom = check(key, definition.label || key, value);
|
|
||||||
if (custom) return custom;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits the raw search value into an optional field filter and the text to look for.
|
|
||||||
* Both `cue 12` and `cue:12` are accepted so that typing agrees with the filter badges.
|
|
||||||
*/
|
|
||||||
export function parseQuery(searchValue: string, filters: FinderFilter[]) {
|
|
||||||
for (const filter of filters) {
|
|
||||||
// the search value is already lowercased, custom field keys are not
|
|
||||||
const prefix = filter.key.toLowerCase();
|
|
||||||
if (searchValue === prefix) {
|
|
||||||
return { filterKey: filter.key, searchString: '' };
|
|
||||||
}
|
|
||||||
if (searchValue.startsWith(`${prefix} `) || searchValue.startsWith(`${prefix}:`)) {
|
|
||||||
return { filterKey: filter.key, searchString: searchValue.slice(prefix.length + 1).trim() };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { filterKey: null, searchString: searchValue };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Finds the single event at a 1-based position in the rundown */
|
|
||||||
export function searchByIndex(data: OntimeEntry[], indexString: string): SearchOutcome {
|
|
||||||
const target = Number(indexString);
|
|
||||||
if (isNaN(target) || target < 1) {
|
|
||||||
return { ...noResults, error: 'Invalid index' };
|
|
||||||
}
|
|
||||||
|
|
||||||
let eventIndex = 0;
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
const entry = data[i];
|
|
||||||
if (!isOntimeEvent(entry)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
eventIndex++;
|
|
||||||
if (eventIndex === target) {
|
|
||||||
return { results: [toResult(entry, i, eventIndex, null)], error: null, total: 1 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return noResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Matches entries on a single field when one is selected, otherwise on every text field.
|
|
||||||
* Results keep rundown order, which keeps them predictable during a show.
|
|
||||||
*/
|
|
||||||
export function searchByText(
|
|
||||||
data: OntimeEntry[],
|
|
||||||
customFields: CustomFields,
|
|
||||||
filterKey: MaybeString,
|
|
||||||
searchString: string,
|
|
||||||
): SearchOutcome {
|
|
||||||
const results: FinderResult[] = [];
|
|
||||||
let total = 0;
|
|
||||||
// indexes exposed to the UI are 1-based
|
|
||||||
let eventIndex = 0;
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
const entry = data[i];
|
|
||||||
if (isOntimeDelay(entry)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const isEvent = isOntimeEvent(entry);
|
|
||||||
if (isEvent) {
|
|
||||||
eventIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
const match = findMatch(entry, customFields, filterKey, searchString);
|
|
||||||
if (match === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
total++;
|
|
||||||
if (results.length < maxResults) {
|
|
||||||
results.push(toResult(entry, i, isEvent ? eventIndex : null, match));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { results, error: null, total };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param searchValue - the text the user is looking for
|
|
||||||
* @param activeFilter - a field selected from the filter badges, if any
|
|
||||||
*/
|
|
||||||
export default function useFinder(searchValue: string, activeFilter: MaybeString) {
|
|
||||||
const { data, rundownId } = useFlatRundown();
|
const { data, rundownId } = useFlatRundown();
|
||||||
const { data: customFields } = useCustomFields();
|
const [results, setResults] = useState<FilterableEntry[]>([]);
|
||||||
|
const [error, setError] = useState<MaybeString>(null);
|
||||||
|
const lastSearchString = useRef('');
|
||||||
|
|
||||||
const selectAndRevealEntry = useSelectAndRevealEntry(rundownId);
|
const selectAndRevealEntry = useSelectAndRevealEntry(rundownId);
|
||||||
|
|
||||||
/** The filters offered to the user: the fixed fields plus whatever the project defines */
|
/** Filters the rundown to a given evaluation */
|
||||||
const filters = useMemo<FinderFilter[]>(() => {
|
const find = useCallback(
|
||||||
const customFilters = Object.entries(customFields)
|
(event: ChangeEvent<HTMLInputElement>) => {
|
||||||
.filter(([_key, field]) => field.type === 'text')
|
if (!data || data.length === 0) {
|
||||||
.map(([key, field]) => ({ key, label: field.label || key }));
|
setError('No data');
|
||||||
return [...staticFilters, ...customFilters];
|
return;
|
||||||
}, [customFields]);
|
}
|
||||||
|
setError(null);
|
||||||
|
|
||||||
const { results, error, total, appliedFilter } = useMemo(() => {
|
if (event.target.value === '') {
|
||||||
if (data.length === 0) {
|
setResults([]);
|
||||||
return { ...noResults, error: 'No data', appliedFilter: activeFilter };
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalised = searchValue.trim().toLowerCase();
|
const searchValue = event.target.value.toLowerCase();
|
||||||
if (normalised === '') {
|
lastSearchString.current = searchValue;
|
||||||
return { ...noResults, appliedFilter: activeFilter };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (searchValue.startsWith('index ')) {
|
||||||
* If a badge is selected it scopes the search; otherwise, keyword prefixes in the input
|
const searchString = searchValue.slice('index '.length).trim();
|
||||||
* (e.g. "cue:" / "title:") are parsed and the matching badge is highlighted.
|
const { results, error } = searchByIndex(searchString);
|
||||||
*/
|
setResults(results);
|
||||||
const { filterKey, searchString } = activeFilter
|
setError(error);
|
||||||
? { filterKey: activeFilter, searchString: normalised }
|
return;
|
||||||
: parseQuery(normalised, filters);
|
}
|
||||||
|
|
||||||
if (filterKey === indexFilter) {
|
if (searchValue.startsWith('cue ')) {
|
||||||
return { ...searchByIndex(data, searchString), appliedFilter: filterKey };
|
const searchString = searchValue.slice('cue '.length).trim();
|
||||||
}
|
const { results, error } = searchByCue(searchString);
|
||||||
if (searchString === '') {
|
setResults(results);
|
||||||
// a filter is selected, but there is nothing to match on yet
|
setError(error);
|
||||||
return { ...noResults, appliedFilter: filterKey };
|
return;
|
||||||
}
|
}
|
||||||
return { ...searchByText(data, customFields, filterKey, searchString), appliedFilter: filterKey };
|
|
||||||
}, [data, customFields, filters, searchValue, activeFilter]);
|
const searchString = searchValue.startsWith('title ') ? searchValue.slice('title '.length).trim() : searchValue;
|
||||||
|
const { results, error } = searchByTitle(searchString);
|
||||||
|
setResults(results);
|
||||||
|
setError(error);
|
||||||
|
|
||||||
|
/** Returns a single item with a matching index */
|
||||||
|
function searchByIndex(searchString: string) {
|
||||||
|
const searchIndex = Number(searchString);
|
||||||
|
if (isNaN(searchIndex) || searchIndex < 1) {
|
||||||
|
return { results: [], error: 'Invalid index' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchIndex > data.length) {
|
||||||
|
return { results: [], error: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
// indexes exposed to the UI are 1-based
|
||||||
|
let eventIndex = 1;
|
||||||
|
const results: FilterableEvent[] = [];
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
const event = data[i];
|
||||||
|
if (isOntimeEvent(event)) {
|
||||||
|
if (eventIndex === searchIndex) {
|
||||||
|
results.push({
|
||||||
|
type: SupportedEntry.Event,
|
||||||
|
id: event.id,
|
||||||
|
index: i,
|
||||||
|
eventIndex,
|
||||||
|
title: event.title,
|
||||||
|
cue: event.cue,
|
||||||
|
colour: event.colour,
|
||||||
|
parent: event.parent,
|
||||||
|
} satisfies FilterableEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
eventIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { results, error: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns maxResults of OntimeEvents that match the cue field */
|
||||||
|
function searchByCue(searchString: string) {
|
||||||
|
// indexes exposed to the UI are 1-based
|
||||||
|
let eventIndex = 1;
|
||||||
|
// limit amount of results we show
|
||||||
|
let remaining = maxResults;
|
||||||
|
const results: FilterableEvent[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
if (remaining <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const event = data[i];
|
||||||
|
if (isOntimeEvent(event)) {
|
||||||
|
if (event.cue.toLowerCase().includes(searchString)) {
|
||||||
|
remaining--;
|
||||||
|
results.push({
|
||||||
|
type: SupportedEntry.Event,
|
||||||
|
id: event.id,
|
||||||
|
index: i,
|
||||||
|
eventIndex,
|
||||||
|
title: event.title,
|
||||||
|
cue: event.cue,
|
||||||
|
colour: event.colour,
|
||||||
|
parent: event.parent,
|
||||||
|
} satisfies FilterableEvent);
|
||||||
|
}
|
||||||
|
eventIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { results, error: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns maxResults of OntimeEvents that match the title field*/
|
||||||
|
function searchByTitle(searchString: string) {
|
||||||
|
// indexes exposed to the UI are 1-based
|
||||||
|
let eventIndex = 1;
|
||||||
|
// limit amount of results we show
|
||||||
|
let remaining = maxResults;
|
||||||
|
const results: FilterableEntry[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
if (remaining <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const entry = data[i];
|
||||||
|
if (isOntimeEvent(entry)) {
|
||||||
|
if (entry.title.toLowerCase().includes(searchString)) {
|
||||||
|
remaining--;
|
||||||
|
results.push({
|
||||||
|
type: SupportedEntry.Event,
|
||||||
|
id: entry.id,
|
||||||
|
index: i,
|
||||||
|
eventIndex,
|
||||||
|
title: entry.title,
|
||||||
|
cue: entry.cue,
|
||||||
|
colour: entry.colour,
|
||||||
|
parent: entry.parent,
|
||||||
|
} satisfies FilterableEvent);
|
||||||
|
}
|
||||||
|
eventIndex++;
|
||||||
|
} else if (isOntimeGroup(entry)) {
|
||||||
|
if (entry.title.toLowerCase().includes(searchString)) {
|
||||||
|
remaining--;
|
||||||
|
results.push({
|
||||||
|
type: SupportedEntry.Group,
|
||||||
|
id: entry.id,
|
||||||
|
index: i,
|
||||||
|
title: entry.title,
|
||||||
|
colour: entry.colour,
|
||||||
|
} satisfies FilterableGroup);
|
||||||
|
}
|
||||||
|
} else if (isOntimeMilestone(entry)) {
|
||||||
|
if (entry.title.toLowerCase().includes(searchString)) {
|
||||||
|
remaining--;
|
||||||
|
results.push({
|
||||||
|
type: SupportedEntry.Milestone,
|
||||||
|
id: entry.id,
|
||||||
|
index: i,
|
||||||
|
title: entry.title,
|
||||||
|
cue: entry.cue,
|
||||||
|
colour: entry.colour,
|
||||||
|
parent: entry.parent,
|
||||||
|
} satisfies FilterableMilestone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { results, error: null };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[data],
|
||||||
|
);
|
||||||
|
|
||||||
const select = useCallback(
|
const select = useCallback(
|
||||||
(result: FinderResult) => {
|
(selectedEvent: FilterableEntry) => {
|
||||||
selectAndRevealEntry({ id: result.id, index: result.index, parent: result.parent });
|
selectAndRevealEntry({
|
||||||
|
id: selectedEvent.id,
|
||||||
|
index: selectedEvent.index,
|
||||||
|
parent: 'parent' in selectedEvent ? selectedEvent.parent : null,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[selectAndRevealEntry],
|
[selectAndRevealEntry],
|
||||||
);
|
);
|
||||||
|
|
||||||
return { select, results, error, total, filters, appliedFilter };
|
/** clear results when source data changes */
|
||||||
|
useEffect(() => {
|
||||||
|
setResults([]);
|
||||||
|
setError(null);
|
||||||
|
// fake a submit event to re-run the search
|
||||||
|
if (lastSearchString.current) {
|
||||||
|
find({ target: { value: lastSearchString.current } } as ChangeEvent<HTMLInputElement>);
|
||||||
|
}
|
||||||
|
}, [data, find]);
|
||||||
|
|
||||||
|
return { find, select, results, error };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,24 +195,6 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sound-prompt {
|
|
||||||
position: absolute;
|
|
||||||
bottom: $view-block-padding;
|
|
||||||
left: $view-inline-padding;
|
|
||||||
padding: 0.5em 0.75em;
|
|
||||||
border-radius: $element-border-radius;
|
|
||||||
background-color: $viewer-card-bg-color;
|
|
||||||
color: $viewer-secondary-color;
|
|
||||||
font-size: $timer-label-size;
|
|
||||||
text-transform: uppercase;
|
|
||||||
pointer-events: none;
|
|
||||||
transition: opacity $viewer-transition-time;
|
|
||||||
|
|
||||||
&--hidden {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* =================== LOGO ===================*/
|
/* =================== LOGO ===================*/
|
||||||
.logo {
|
.logo {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import TitleCard from '../../common/components/title-card/TitleCard';
|
|||||||
import ViewLogo from '../../common/components/view-logo/ViewLogo';
|
import ViewLogo from '../../common/components/view-logo/ViewLogo';
|
||||||
import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor';
|
import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor';
|
||||||
import { useAutoTickingClock } from '../../common/hooks/useAutoTickingClock';
|
import { useAutoTickingClock } from '../../common/hooks/useAutoTickingClock';
|
||||||
import { useFadeOutOnInactivity } from '../../common/hooks/useFadeOutOnInactivity';
|
|
||||||
import { useTimerSocket } from '../../common/hooks/useSocket';
|
import { useTimerSocket } from '../../common/hooks/useSocket';
|
||||||
import { useWindowTitle } from '../../common/hooks/useWindowTitle';
|
import { useWindowTitle } from '../../common/hooks/useWindowTitle';
|
||||||
import { cx } from '../../common/utils/styleUtils';
|
import { cx } from '../../common/utils/styleUtils';
|
||||||
@@ -31,7 +30,6 @@ import {
|
|||||||
getTotalTime,
|
getTotalTime,
|
||||||
} from './timer.utils';
|
} from './timer.utils';
|
||||||
import { TimerData, useTimerData } from './useTimerData';
|
import { TimerData, useTimerData } from './useTimerData';
|
||||||
import { useTimerSound } from './useTimerSound';
|
|
||||||
|
|
||||||
import './Timer.scss';
|
import './Timer.scss';
|
||||||
|
|
||||||
@@ -68,7 +66,6 @@ function Timer({ customFields, projectData, isMirrored, settings, viewSettings,
|
|||||||
freezeOvertime,
|
freezeOvertime,
|
||||||
freezeMessage,
|
freezeMessage,
|
||||||
hidePhase,
|
hidePhase,
|
||||||
endSound,
|
|
||||||
font,
|
font,
|
||||||
keyColour,
|
keyColour,
|
||||||
timerColour,
|
timerColour,
|
||||||
@@ -78,8 +75,6 @@ function Timer({ customFields, projectData, isMirrored, settings, viewSettings,
|
|||||||
const { getLocalizedString } = useTranslation();
|
const { getLocalizedString } = useTranslation();
|
||||||
const localisedMinutes = getLocalizedString('common.minutes');
|
const localisedMinutes = getLocalizedString('common.minutes');
|
||||||
|
|
||||||
const showSoundPrompt = useTimerSound(time.phase, endSound);
|
|
||||||
|
|
||||||
// gather modifiers
|
// gather modifiers
|
||||||
const viewTimerType = timerType ?? timerTypeNow;
|
const viewTimerType = timerType ?? timerTypeNow;
|
||||||
const showOverlay = getShowMessage(message.timer);
|
const showOverlay = getShowMessage(message.timer);
|
||||||
@@ -161,8 +156,6 @@ function Timer({ customFields, projectData, isMirrored, settings, viewSettings,
|
|||||||
|
|
||||||
<ViewParamsEditor target={OntimeView.Timer} viewOptions={timerOptions} />
|
<ViewParamsEditor target={OntimeView.Timer} viewOptions={timerOptions} />
|
||||||
|
|
||||||
{showSoundPrompt && <SoundPermissionPrompt />}
|
|
||||||
|
|
||||||
<div className={cx(['blackout', message.timer.blackout && 'blackout--active'])} />
|
<div className={cx(['blackout', message.timer.blackout && 'blackout--active'])} />
|
||||||
|
|
||||||
{!hideMessage && (
|
{!hideMessage && (
|
||||||
@@ -234,13 +227,3 @@ function TimerAutoTickingClock({ clockFormat }: { clockFormat: MaybeString }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SoundPermissionPrompt() {
|
|
||||||
const isUserActive = useFadeOutOnInactivity(true);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={cx(['sound-prompt', !isUserActive && 'sound-prompt--hidden'])} aria-live='polite'>
|
|
||||||
Interact with the page (click/tap or press any key) to enable sound
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { TimerPhase } from 'ontime-types';
|
|
||||||
|
|
||||||
import { shouldPlayEndSound } from '../timer.utils';
|
|
||||||
|
|
||||||
describe('shouldPlayEndSound()', () => {
|
|
||||||
test.each([TimerPhase.Default, TimerPhase.Warning, TimerPhase.Danger])(
|
|
||||||
'sounds when a running timer goes into overtime from %s',
|
|
||||||
(previousPhase) => {
|
|
||||||
expect(shouldPlayEndSound(previousPhase, TimerPhase.Overtime)).toBe(true);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
it('stays silent on the first phase we see, a client could be joining mid-overtime', () => {
|
|
||||||
expect(shouldPlayEndSound(null, TimerPhase.Overtime)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('stays silent when the phase was reset, a reload during overtime starts from none', () => {
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.None, TimerPhase.Overtime)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('stays silent for a roll timer waiting to start', () => {
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.Pending, TimerPhase.Overtime)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sounds once, not on every update while in overtime', () => {
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.Overtime, TimerPhase.Overtime)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('stays silent on phases which are not the end of the timer', () => {
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.Default, TimerPhase.Warning)).toBe(false);
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.Warning, TimerPhase.Danger)).toBe(false);
|
|
||||||
expect(shouldPlayEndSound(TimerPhase.Overtime, TimerPhase.None)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -16,7 +16,6 @@ import { ViewOption } from '../../common/components/view-params-editor/viewParam
|
|||||||
import { makeOptionsFromCustomFields } from '../../common/components/view-params-editor/viewParams.utils';
|
import { makeOptionsFromCustomFields } from '../../common/components/view-params-editor/viewParams.utils';
|
||||||
import { PresetContext } from '../../common/context/PresetContext';
|
import { PresetContext } from '../../common/context/PresetContext';
|
||||||
import { isStringBoolean, makeColourString } from '../common/viewUtils';
|
import { isStringBoolean, makeColourString } from '../common/viewUtils';
|
||||||
import { endSoundOptions, isEndSound, type EndSound } from './timer.sound';
|
|
||||||
|
|
||||||
// manually match the properties of TimerType excluding the None
|
// manually match the properties of TimerType excluding the None
|
||||||
const timerDisplayOptions: SelectOption[] = [
|
const timerDisplayOptions: SelectOption[] = [
|
||||||
@@ -77,15 +76,6 @@ export const getTimerOptions = (timeFormat: string, customFields: CustomFields):
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'endSound',
|
|
||||||
title: 'Play sound on timer end',
|
|
||||||
description:
|
|
||||||
'Plays a sound in this screen when the timer reaches zero. The screen must be interacted with once before it can play',
|
|
||||||
type: 'option',
|
|
||||||
values: endSoundOptions,
|
|
||||||
defaultValue: 'none',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -179,7 +169,7 @@ export const getTimerOptions = (timeFormat: string, customFields: CustomFields):
|
|||||||
{
|
{
|
||||||
id: 'timerColour',
|
id: 'timerColour',
|
||||||
title: 'Timer Colour',
|
title: 'Timer Colour',
|
||||||
description: 'Timer colour. Default: #F6F6F6',
|
description: 'Timer colour. Default: #f6f6f6',
|
||||||
type: 'colour',
|
type: 'colour',
|
||||||
defaultValue: 'f6f6f6',
|
defaultValue: 'f6f6f6',
|
||||||
},
|
},
|
||||||
@@ -203,7 +193,6 @@ type TimerOptions = {
|
|||||||
freezeOvertime: boolean;
|
freezeOvertime: boolean;
|
||||||
freezeMessage: string;
|
freezeMessage: string;
|
||||||
hidePhase: boolean;
|
hidePhase: boolean;
|
||||||
endSound: EndSound;
|
|
||||||
font?: string;
|
font?: string;
|
||||||
keyColour?: string;
|
keyColour?: string;
|
||||||
timerColour?: string;
|
timerColour?: string;
|
||||||
@@ -219,7 +208,6 @@ function getOptionsFromParams(searchParams: URLSearchParams, defaultValues?: URL
|
|||||||
|
|
||||||
// Get timerType from either source
|
// Get timerType from either source
|
||||||
const timerType = validateTimerType(getValue('timerType'), TimerType.None);
|
const timerType = validateTimerType(getValue('timerType'), TimerType.None);
|
||||||
const endSoundValue = getValue('endSound');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hideClock: isStringBoolean(getValue('hideClock')),
|
hideClock: isStringBoolean(getValue('hideClock')),
|
||||||
@@ -239,7 +227,6 @@ function getOptionsFromParams(searchParams: URLSearchParams, defaultValues?: URL
|
|||||||
freezeOvertime: isStringBoolean(getValue('freezeOvertime')),
|
freezeOvertime: isStringBoolean(getValue('freezeOvertime')),
|
||||||
freezeMessage: getValue('freezeMessage') ?? '',
|
freezeMessage: getValue('freezeMessage') ?? '',
|
||||||
hidePhase: isStringBoolean(getValue('hidePhase')),
|
hidePhase: isStringBoolean(getValue('hidePhase')),
|
||||||
endSound: isEndSound(endSoundValue) ? endSoundValue : 'none',
|
|
||||||
|
|
||||||
font: getValue('font') ?? undefined,
|
font: getValue('font') ?? undefined,
|
||||||
keyColour: makeColourString(getValue('keyColour')),
|
keyColour: makeColourString(getValue('keyColour')),
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import arpeggio from '../../assets/sounds/arpeggio.wav';
|
|
||||||
import bell from '../../assets/sounds/bell.wav';
|
|
||||||
import chime from '../../assets/sounds/chime.wav';
|
|
||||||
import type { SelectOption } from '../../common/components/select/Select';
|
|
||||||
|
|
||||||
// synthesised tones bundled with the app, no external source or licence to track
|
|
||||||
export const endSoundSources = { chime, bell, arpeggio } as const;
|
|
||||||
|
|
||||||
export type EndSound = 'none' | keyof typeof endSoundSources;
|
|
||||||
|
|
||||||
export const endSoundOptions: SelectOption[] = [
|
|
||||||
{ value: 'none', label: 'None' },
|
|
||||||
{ value: 'chime', label: 'Chime' },
|
|
||||||
{ value: 'bell', label: 'Bell' },
|
|
||||||
{ value: 'arpeggio', label: 'Arpeggio' },
|
|
||||||
];
|
|
||||||
|
|
||||||
export function isEndSound(value: string | null): value is EndSound {
|
|
||||||
return value === 'none' || value === 'chime' || value === 'bell' || value === 'arpeggio';
|
|
||||||
}
|
|
||||||
@@ -189,18 +189,3 @@ export function getCardData(
|
|||||||
nextSecondary,
|
nextSecondary,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the end of timer sound should play for a given phase transition
|
|
||||||
* We only sound the transition into overtime from a phase that was already counting,
|
|
||||||
* which keeps a client that connects or reloads mid-overtime silent
|
|
||||||
*/
|
|
||||||
export function shouldPlayEndSound(previousPhase: TimerPhase | null, phase: TimerPhase): boolean {
|
|
||||||
if (phase !== TimerPhase.Overtime) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
previousPhase === TimerPhase.Default || previousPhase === TimerPhase.Warning || previousPhase === TimerPhase.Danger
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
import { TimerPhase } from 'ontime-types';
|
|
||||||
import { useEffect, useRef, useState } from 'react';
|
|
||||||
|
|
||||||
import { endSoundSources, type EndSound } from './timer.sound';
|
|
||||||
import { shouldPlayEndSound } from './timer.utils';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays a sound when the timer reaches its end
|
|
||||||
*
|
|
||||||
* Browsers reject playback until the document has been interacted with, and that permission
|
|
||||||
* is lost on every page load. Since a timer screen is typically left unattended, we prime the
|
|
||||||
* audio element on the first interaction and let the view prompt for one if it never comes.
|
|
||||||
* Safari grants the permission per element, so priming has to call play() on this element from
|
|
||||||
* inside the event handler, it is not enough to know that an interaction happened.
|
|
||||||
*/
|
|
||||||
export function useTimerSound(phase: TimerPhase, sound: EndSound): boolean {
|
|
||||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
|
||||||
const previousPhaseRef = useRef<TimerPhase | null>(null);
|
|
||||||
const [isArmed, setIsArmed] = useState(false);
|
|
||||||
|
|
||||||
const enabled = sound !== 'none';
|
|
||||||
|
|
||||||
// Create and clean up the audio element; changing sounds requires re-arming it in Safari.
|
|
||||||
useEffect(() => {
|
|
||||||
setIsArmed(false);
|
|
||||||
|
|
||||||
if (sound === 'none') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const audio = new Audio(endSoundSources[sound]);
|
|
||||||
audioRef.current = audio;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
audio.pause();
|
|
||||||
audioRef.current = null;
|
|
||||||
};
|
|
||||||
}, [sound]);
|
|
||||||
|
|
||||||
// Listen for user interaction until muted playback succeeds and arms the selected audio element.
|
|
||||||
useEffect(() => {
|
|
||||||
if (!enabled || isArmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const controller = new AbortController();
|
|
||||||
const prime = () => {
|
|
||||||
const audio = audioRef.current;
|
|
||||||
if (!audio) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wasMuted = audio.muted;
|
|
||||||
audio.muted = true;
|
|
||||||
audio
|
|
||||||
.play()
|
|
||||||
.then(() => {
|
|
||||||
if (audioRef.current !== audio) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
audio.pause();
|
|
||||||
audio.currentTime = 0;
|
|
||||||
setIsArmed(true);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// playback is still blocked, a later interaction will try again
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
audio.muted = wasMuted;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener('pointerdown', prime, { capture: true, signal: controller.signal });
|
|
||||||
document.addEventListener('keydown', prime, { capture: true, signal: controller.signal });
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
controller.abort();
|
|
||||||
};
|
|
||||||
}, [enabled, isArmed]);
|
|
||||||
|
|
||||||
// Track phase transitions and play only when a running timer enters overtime.
|
|
||||||
useEffect(() => {
|
|
||||||
const previousPhase = previousPhaseRef.current;
|
|
||||||
previousPhaseRef.current = phase;
|
|
||||||
|
|
||||||
if (!enabled || !shouldPlayEndSound(previousPhase, phase)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const audio = audioRef.current;
|
|
||||||
if (!audio) return;
|
|
||||||
|
|
||||||
audio.currentTime = 0;
|
|
||||||
audio.play().catch(() => {
|
|
||||||
// the screen has not been interacted with, the view shows a prompt for it
|
|
||||||
});
|
|
||||||
}, [enabled, phase]);
|
|
||||||
|
|
||||||
return enabled && !isArmed;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ontime-electron",
|
"name": "ontime-electron",
|
||||||
"version": "4.13.0",
|
"version": "4.12.0",
|
||||||
"author": "Carlos Valente",
|
"author": "Carlos Valente",
|
||||||
"description": "Time keeping for live events",
|
"description": "Time keeping for live events",
|
||||||
"repository": "https://github.com/cpvalente/ontime",
|
"repository": "https://github.com/cpvalente/ontime",
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "38.2.1",
|
"electron": "38.2.1",
|
||||||
"electron-builder": "26.15.3",
|
"electron-builder": "26.9.1",
|
||||||
"wait-on": "^9.0.0"
|
"wait-on": "^7.2.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:electron": "wait-on http://localhost:3000 && cross-env NODE_ENV=development electron .",
|
"dev:electron": "wait-on http://localhost:3000 && cross-env NODE_ENV=development electron .",
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ function makeFileMenu(askToQuit, serverUrl, redirectWindow, showDialog, download
|
|||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: 'New project...',
|
label: 'New project...',
|
||||||
click: () => redirectWindow('/editor?settings=project__create'),
|
click: () => redirectWindow('/editor?settings=project__manage&new=true'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Load...',
|
label: 'Load...',
|
||||||
@@ -202,18 +202,6 @@ function makeSettingsMenu(redirectWindow) {
|
|||||||
label: 'View settings',
|
label: 'View settings',
|
||||||
click: () => redirectWindow('/editor?settings=settings__view'),
|
click: () => redirectWindow('/editor?settings=settings__view'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Custom views',
|
|
||||||
click: () => redirectWindow('/editor?settings=settings__custom-views'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'MCP Server',
|
|
||||||
click: () => redirectWindow('/editor?settings=settings__mcp'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Server port',
|
|
||||||
click: () => redirectWindow('/editor?settings=settings__port'),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self'; style-src 'unsafe-inline'; script-src 'self'"
|
content="default-src 'self'; style-src 'unsafe-inline'; script-src 'self'"
|
||||||
/>
|
/>
|
||||||
<title>Ontime</title>
|
<title>ontime</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<img src="../assets/logo.png" />
|
<img src="../assets/logo.png" />
|
||||||
<h1>Ontime · event timers</h1>
|
<h1>ontime · event timers</h1>
|
||||||
<div class="lds-ellipsis">
|
<div class="lds-ellipsis">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user