From ef7b4b0ddf50c1775c039ae353a781c6e45ccfc5 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Tue, 30 Jul 2024 02:23:51 -0700 Subject: [PATCH] Formatting pass. --- docs/configuration/view.md | 26 +++++++++---------- rollup.config.js | 2 +- .../actions/actions/camera-select.ts | 2 +- src/card-controller/triggers-manager.ts | 8 +++--- .../view/modifiers/merge-context.ts | 6 ++--- .../view/modifiers/remove-context.ts | 6 ++--- .../view/modifiers/substream-off.ts | 1 - src/components/gallery.ts | 5 +++- src/view/view.ts | 7 +++-- .../card-controller/triggers-manager.test.ts | 2 +- .../view/modifiers/remove-context.test.ts | 1 - .../view/modifiers/substream-on.test.ts | 6 ++++- 12 files changed, 39 insertions(+), 33 deletions(-) diff --git a/docs/configuration/view.md b/docs/configuration/view.md index c2003f82..a33c5c71 100644 --- a/docs/configuration/view.md +++ b/docs/configuration/view.md @@ -7,19 +7,19 @@ view: # [...] ``` -| Option | Default | Description | -| ------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `actions` | | [Actions](actions/README.md) to use for all views, individual actions may be overriden by view-specific actions. | -| `camera_select` | `current` | The [view](view.md?id=supported-views) to show when a new camera is selected (e.g. in the camera menu). If `current` the view is unchanged when a new camera is selected. | -| `dark_mode` | `off` | Whether or not to turn dark mode `on`, `off` or `auto` to automatically turn on if the card `interaction_seconds` has expired (i.e. card has been left unattended for that period of time) or if dark mode is enabled in the HA profile theme setting. Dark mode dims the brightness by `25%`. | -| `default` | `live` | The view to show in the card by default. The default camera is the first one listed. See [Supported Views](view.md?id=supported-views) below. | -| `default_reset` | | The circumstances and behavior that cause the card to reset to the default view. See below. | -| `interaction_seconds` | `300` | After a mouse/touch interaction with the card, it will be considered "interacted with" until this number of seconds elapses without further interaction. May be used as part of an [interaction condition](conditions.md?id=interaction) or with `reset_after_interaction` to reset the view after the interaction is complete. `0` means no interactions are reported / acted upon. | -| `keyboard_shortcuts` | See [usage](../usage/keyboard-shortcuts.md) for defaults. | Configure keyboard shortcuts. See below. | +| Option | Default | Description | +| ------------------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `actions` | | [Actions](actions/README.md) to use for all views, individual actions may be overriden by view-specific actions. | +| `camera_select` | `current` | The [view](view.md?id=supported-views) to show when a new camera is selected (e.g. in the camera menu). If `current` the view is unchanged when a new camera is selected. | +| `dark_mode` | `off` | Whether or not to turn dark mode `on`, `off` or `auto` to automatically turn on if the card `interaction_seconds` has expired (i.e. card has been left unattended for that period of time) or if dark mode is enabled in the HA profile theme setting. Dark mode dims the brightness by `25%`. | +| `default` | `live` | The view to show in the card by default. The default camera is the first one listed. See [Supported Views](view.md?id=supported-views) below. | +| `default_reset` | | The circumstances and behavior that cause the card to reset to the default view. See below. | +| `interaction_seconds` | `300` | After a mouse/touch interaction with the card, it will be considered "interacted with" until this number of seconds elapses without further interaction. May be used as part of an [interaction condition](conditions.md?id=interaction) or with `reset_after_interaction` to reset the view after the interaction is complete. `0` means no interactions are reported / acted upon. | +| `keyboard_shortcuts` | See [usage](../usage/keyboard-shortcuts.md) for defaults. | Configure keyboard shortcuts. See below. | | `render_entities` | | **YAML only**: A list of entity ids that should cause the card to re-render 'in-place'. The view/camera is not changed. This should **very** rarely be needed, but could be useful if the card is both setting and changing HA state of the same object as could be the case for some complex `card_mod` scenarios ([example](https://github.com/dermotduffy/frigate-hass-card/issues/343)). | -| `reset_after_interaction` | `true` | If `true` the card will reset to the default configured view (i.e. 'screensaver' functionality) after `interaction_seconds` has elapsed after user interaction. | -| `triggers` | | How to react when a camera is [triggered](cameras/README.md?id=triggers). | -| `default_cycle_camera` | `false` | When set to `true` the selected camera is cycled on each default view change. | +| `reset_after_interaction` | `true` | If `true` the card will reset to the default configured view (i.e. 'screensaver' functionality) after `interaction_seconds` has elapsed after user interaction. | +| `triggers` | | How to react when a camera is [triggered](cameras/README.md?id=triggers). | +| `default_cycle_camera` | `false` | When set to `true` the selected camera is cycled on each default view change. | ## `default_reset` @@ -97,7 +97,7 @@ already occupied room will not trigger, but a newly occupied room will). | Option | Default | Description | | ------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `interaction_mode` | `inactive` | Whether actions should be taken when the card is being interacted with. If `all`, actions will always left be taken regardless. If `inactive` actions will only be taken if the card has _not_ had human interaction recently (as defined by `view.interaction_seconds`). If `active` actions will only be taken if the card _has_ had human interaction recently. This does not stop triggering itself (i.e. border will still pulse if `show_trigger_status` is true) but rather just prevents the actions being performed. | -| `trigger` | `update` | If set to `update` the current view is updated in place. If set to `default` the default view of the card will be reloaded. If set to `live` the triggered camera will be selected in `live` view. If set to `media` the appropriate media view (e.g. `clip` or `snapshot`) will be chosen to match a newly available media item (please note that only some [camera engines](cameras/engine.md) support new media detection, e.g. `frigate`). If set to `none` no action is taken. | +| `trigger` | `update` | If set to `update` the current view is updated in place. If set to `default` the default view of the card will be reloaded. If set to `live` the triggered camera will be selected in `live` view. If set to `media` the appropriate media view (e.g. `clip` or `snapshot`) will be chosen to match a newly available media item (please note that only some [camera engines](cameras/engine.md) support new media detection, e.g. `frigate`). If set to `none` no action is taken. | | `untrigger` | `none` | If set to `default` the the default view of the card will be reloaded. If set to `none` no action will be taken. | ## Supported views diff --git a/rollup.config.js b/rollup.config.js index 33ca36e7..be40c43a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -51,7 +51,7 @@ const plugins = [ typescript({ sourceMap: dev, inlineSources: dev, - exclude: ["tests/**/*.test.ts"], + exclude: ['tests/**/*.test.ts'], }), json({ exclude: 'package.json' }), replace({ diff --git a/src/card-controller/actions/actions/camera-select.ts b/src/card-controller/actions/actions/camera-select.ts index 395b47d3..b492bf0d 100644 --- a/src/card-controller/actions/actions/camera-select.ts +++ b/src/card-controller/actions/actions/camera-select.ts @@ -17,7 +17,7 @@ export class CameraSelectAction extends FrigateCardAction { +export const mergeViewContext = ( + a?: ViewContext | null, + b?: ViewContext | null, +): ViewContext => { return merge({}, a, b); -} +}; export class View { public view: FrigateCardView; diff --git a/tests/card-controller/triggers-manager.test.ts b/tests/card-controller/triggers-manager.test.ts index 88b058e6..0ea09bec 100644 --- a/tests/card-controller/triggers-manager.test.ts +++ b/tests/card-controller/triggers-manager.test.ts @@ -465,7 +465,7 @@ describe('TriggersManager', () => { params: { view: 'live' as const, camera: 'camera_1' as const, - } + }, }); await manager.handleCameraEvent({ diff --git a/tests/card-controller/view/modifiers/remove-context.test.ts b/tests/card-controller/view/modifiers/remove-context.test.ts index 28795272..27ad3fde 100644 --- a/tests/card-controller/view/modifiers/remove-context.test.ts +++ b/tests/card-controller/view/modifiers/remove-context.test.ts @@ -23,4 +23,3 @@ it('should remove context property', () => { expect(view.context).toEqual({}); }); - \ No newline at end of file diff --git a/tests/card-controller/view/modifiers/substream-on.test.ts b/tests/card-controller/view/modifiers/substream-on.test.ts index cbba3e27..ea82b18a 100644 --- a/tests/card-controller/view/modifiers/substream-on.test.ts +++ b/tests/card-controller/view/modifiers/substream-on.test.ts @@ -2,7 +2,11 @@ import { describe, expect, it, vi } from 'vitest'; import { CardController } from '../../../../src/card-controller/controller'; import { SubstreamOnViewModifier } from '../../../../src/card-controller/view/modifiers/substream-on'; import { RawFrigateCardConfig } from '../../../../src/config/types'; -import { getStreamCameraID, hasSubstream, setSubstream } from '../../../../src/utils/substream'; +import { + getStreamCameraID, + hasSubstream, + setSubstream, +} from '../../../../src/utils/substream'; import { createCameraConfig, createCameraManager,