From 25152a15d35013ba53c558b3c0b6e24211c04e7d Mon Sep 17 00:00:00 2001 From: skier233 Date: Fri, 7 Feb 2025 18:37:58 -0500 Subject: [PATCH] Add interface option to show range markers --- graphql/schema/types/config.graphql | 6 ++++++ internal/api/resolver_mutation_configure.go | 1 + internal/api/resolver_query_configuration.go | 2 ++ internal/manager/config/config.go | 7 +++++++ ui/v2.5/graphql/data/config.graphql | 1 + .../src/components/ScenePlayer/ScenePlayer.tsx | 16 ++++++++++++---- ui/v2.5/src/components/ScenePlayer/markers.ts | 4 +--- .../SettingsInterfacePanel.tsx | 6 ++++++ ui/v2.5/src/locales/en-GB.json | 1 + 9 files changed, 37 insertions(+), 7 deletions(-) diff --git a/graphql/schema/types/config.graphql b/graphql/schema/types/config.graphql index 4d6d2080b59..5677082eb62 100644 --- a/graphql/schema/types/config.graphql +++ b/graphql/schema/types/config.graphql @@ -355,6 +355,9 @@ input ConfigInterfaceInput { "Show scene scrubber by default" showScrubber: Boolean + "Show scene range markers by default" + showRangeMarkers: Boolean + "Maximum duration (in seconds) in which a scene video will loop in the scene player" maximumLoopDuration: Int "If true, video will autostart on load in the scene player" @@ -421,6 +424,9 @@ type ConfigInterfaceResult { "Show scene scrubber by default" showScrubber: Boolean + "Show scene range markers by default" + showRangeMarkers: Boolean + "Maximum duration (in seconds) in which a scene video will loop in the scene player" maximumLoopDuration: Int "True if we should not auto-open a browser window on startup" diff --git a/internal/api/resolver_mutation_configure.go b/internal/api/resolver_mutation_configure.go index d9c71b09fca..21741c4ff10 100644 --- a/internal/api/resolver_mutation_configure.go +++ b/internal/api/resolver_mutation_configure.go @@ -457,6 +457,7 @@ func (r *mutationResolver) ConfigureInterface(ctx context.Context, input ConfigI r.setConfigBool(config.NotificationsEnabled, input.NotificationsEnabled) r.setConfigBool(config.ShowScrubber, input.ShowScrubber) + r.setConfigBool(config.ShowRangeMarkers, input.ShowRangeMarkers) r.setConfigString(config.WallPlayback, input.WallPlayback) r.setConfigInt(config.MaximumLoopDuration, input.MaximumLoopDuration) diff --git a/internal/api/resolver_query_configuration.go b/internal/api/resolver_query_configuration.go index 3328e4a356b..4f223eff824 100644 --- a/internal/api/resolver_query_configuration.go +++ b/internal/api/resolver_query_configuration.go @@ -141,6 +141,7 @@ func makeConfigInterfaceResult() *ConfigInterfaceResult { soundOnPreview := config.GetSoundOnPreview() wallShowTitle := config.GetWallShowTitle() showScrubber := config.GetShowScrubber() + showRangeMarkers := config.GetShowRangeMarkers() wallPlayback := config.GetWallPlayback() noBrowser := config.GetNoBrowser() notificationsEnabled := config.GetNotificationsEnabled() @@ -168,6 +169,7 @@ func makeConfigInterfaceResult() *ConfigInterfaceResult { WallShowTitle: &wallShowTitle, WallPlayback: &wallPlayback, ShowScrubber: &showScrubber, + ShowRangeMarkers: &showRangeMarkers, MaximumLoopDuration: &maximumLoopDuration, NoBrowser: &noBrowser, NotificationsEnabled: ¬ificationsEnabled, diff --git a/internal/manager/config/config.go b/internal/manager/config/config.go index aa7999c5386..66ccdf746d6 100644 --- a/internal/manager/config/config.go +++ b/internal/manager/config/config.go @@ -195,6 +195,9 @@ const ( ShowScrubber = "show_scrubber" showScrubberDefault = true + ShowRangeMarkers = "show_rangemarkers" + showRangeMarkersDef = true + WallPlayback = "wall_playback" defaultWallPlayback = "video" @@ -1212,6 +1215,10 @@ func (i *Config) GetShowScrubber() bool { return i.getBoolDefault(ShowScrubber, showScrubberDefault) } +func (i *Config) GetShowRangeMarkers() bool { + return i.getBoolDefault(ShowRangeMarkers, showRangeMarkersDef) +} + func (i *Config) GetMaximumLoopDuration() int { return i.getInt(MaximumLoopDuration) } diff --git a/ui/v2.5/graphql/data/config.graphql b/ui/v2.5/graphql/data/config.graphql index ae15aa939c4..65ecd0ef622 100644 --- a/ui/v2.5/graphql/data/config.graphql +++ b/ui/v2.5/graphql/data/config.graphql @@ -75,6 +75,7 @@ fragment ConfigInterfaceData on ConfigInterfaceResult { wallShowTitle wallPlayback showScrubber + showRangeMarkers maximumLoopDuration noBrowser notificationsEnabled diff --git a/ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx b/ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx index f40e03bab51..b57d5a7e7a1 100644 --- a/ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx +++ b/ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx @@ -718,13 +718,21 @@ export const ScenePlayer: React.FC = ({ // Wait for colors await markers.findColors(uniqueTagNames); + const showRangeTags = interfaceConfig?.showRangeMarkers ?? true; const timestampMarkers: IMarker[] = []; const rangeMarkers: IMarker[] = []; - for (const marker of markerData) { - if (marker.end_seconds === null) { + + if (!showRangeTags) { + for (const marker of markerData) { timestampMarkers.push(marker); - } else { - rangeMarkers.push(marker); + } + } else { + for (const marker of markerData) { + if (marker.end_seconds === null) { + timestampMarkers.push(marker); + } else { + rangeMarkers.push(marker); + } } } diff --git a/ui/v2.5/src/components/ScenePlayer/markers.ts b/ui/v2.5/src/components/ScenePlayer/markers.ts index ea8e1e80c12..cda350144dd 100644 --- a/ui/v2.5/src/components/ScenePlayer/markers.ts +++ b/ui/v2.5/src/components/ScenePlayer/markers.ts @@ -68,9 +68,7 @@ class MarkersPlugin extends videojs.getPlugin("plugin") { range?: HTMLDivElement; } = {}; const seekBar = this.player.el().querySelector(".vjs-progress-control"); - if (marker.end_seconds) { - throw new Error("Cannot add range marker with addDotMarker"); - } + markerSet.dot = videojs.dom.createEl("div") as HTMLDivElement; markerSet.dot.className = "vjs-marker-dot"; if (duration) { diff --git a/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx b/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx index c174847c982..96b3fa620d8 100644 --- a/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx +++ b/ui/v2.5/src/components/Settings/SettingsInterfacePanel/SettingsInterfacePanel.tsx @@ -351,6 +351,12 @@ export const SettingsInterfacePanel: React.FC = PatchComponent( checked={iface.showScrubber ?? undefined} onChange={(v) => saveInterface({ showScrubber: v })} /> + saveInterface({ showRangeMarkers: v })} + />