Formatting pass.

This commit is contained in:
Dermot Duffy
2024-07-30 02:23:51 -07:00
parent 8823e769a2
commit ef7b4b0ddf
12 changed files with 39 additions and 33 deletions
+13 -13
View File
@@ -7,19 +7,19 @@ view:
# [...] # [...]
``` ```
| Option | Default | Description | | Option | Default | Description |
| ------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions` | | [Actions](actions/README.md) to use for all views, individual actions may be overriden by view-specific actions. | | `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. | | `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%`. | | `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` | `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. | | `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. | | `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. | | `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)). | | `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. | | `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). | | `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_cycle_camera` | `false` | When set to `true` the selected camera is cycled on each default view change. |
## `default_reset` ## `default_reset`
@@ -97,7 +97,7 @@ already occupied room will not trigger, but a newly occupied room will).
| Option | Default | Description | | 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. | | `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. | | `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 ## Supported views
+1 -1
View File
@@ -51,7 +51,7 @@ const plugins = [
typescript({ typescript({
sourceMap: dev, sourceMap: dev,
inlineSources: dev, inlineSources: dev,
exclude: ["tests/**/*.test.ts"], exclude: ['tests/**/*.test.ts'],
}), }),
json({ exclude: 'package.json' }), json({ exclude: 'package.json' }),
replace({ replace({
@@ -17,7 +17,7 @@ export class CameraSelectAction extends FrigateCardAction<CameraSelectActionConf
const targetViewName = const targetViewName =
viewOnCameraSelect === 'current' ? view.view : viewOnCameraSelect; viewOnCameraSelect === 'current' ? view.view : viewOnCameraSelect;
await api.getViewManager().setViewByParametersWithNewQuery({ await api.getViewManager().setViewByParametersWithNewQuery({
params:{ params: {
view: targetViewName, view: targetViewName,
camera: selectCameraID, camera: selectCameraID,
}, },
+3 -5
View File
@@ -98,11 +98,9 @@ export class TriggersManager {
if (this._hasAllowableInteractionStateForAction()) { if (this._hasAllowableInteractionStateForAction()) {
if (triggerAction === 'update') { if (triggerAction === 'update') {
await this._api await this._api.getViewManager().setViewByParametersWithNewQuery({
.getViewManager() queryExecutorOptions: { useCache: false },
.setViewByParametersWithNewQuery({ });
queryExecutorOptions: { useCache: false },
});
} else if (triggerAction === 'live') { } else if (triggerAction === 'live') {
await this._api.getViewManager().setViewByParametersWithNewQuery({ await this._api.getViewManager().setViewByParametersWithNewQuery({
params: { params: {
@@ -1,6 +1,6 @@
import { ViewContext } from "view"; import { ViewContext } from 'view';
import { View } from "../../../view/view"; import { View } from '../../../view/view';
import { ViewModifier } from "../types"; import { ViewModifier } from '../types';
export class MergeContextViewModifier implements ViewModifier { export class MergeContextViewModifier implements ViewModifier {
protected _context?: ViewContext | null; protected _context?: ViewContext | null;
@@ -1,6 +1,6 @@
import { ViewContext } from "view"; import { ViewContext } from 'view';
import { View } from "../../../view/view"; import { View } from '../../../view/view';
import { ViewModifier } from "../types"; import { ViewModifier } from '../types';
export class RemoveContextViewModifier implements ViewModifier { export class RemoveContextViewModifier implements ViewModifier {
protected _keys: (keyof ViewContext)[]; protected _keys: (keyof ViewContext)[];
@@ -7,4 +7,3 @@ export class SubstreamOffViewModifier implements ViewModifier {
removeSubstream(view); removeSubstream(view);
} }
} }
+4 -1
View File
@@ -374,7 +374,10 @@ export class FrigateCardGalleryCore extends LitElement {
const view = this.viewManagerEpoch?.manager.getView(); const view = this.viewManagerEpoch?.manager.getView();
const oldView = this.viewManagerEpoch?.oldView; const oldView = this.viewManagerEpoch?.oldView;
if (!this._media || oldView?.queryResults?.getResults() !== view?.queryResults?.getResults()) { if (
!this._media ||
oldView?.queryResults?.getResults() !== view?.queryResults?.getResults()
) {
// Gallery places the most recent media at the top (the query results place // Gallery places the most recent media at the top (the query results place
// the most recent media at the end for use in the viewer). This is copied // the most recent media at the end for use in the viewer). This is copied
// to a new array to avoid reversing the query results in place. // to a new array to avoid reversing the query results in place.
+5 -2
View File
@@ -18,9 +18,12 @@ export interface ViewParameters extends ViewEvolveParameters {
camera: string; camera: string;
} }
export const mergeViewContext = (a?: ViewContext | null, b?: ViewContext | null): ViewContext => { export const mergeViewContext = (
a?: ViewContext | null,
b?: ViewContext | null,
): ViewContext => {
return merge({}, a, b); return merge({}, a, b);
} };
export class View { export class View {
public view: FrigateCardView; public view: FrigateCardView;
@@ -465,7 +465,7 @@ describe('TriggersManager', () => {
params: { params: {
view: 'live' as const, view: 'live' as const,
camera: 'camera_1' as const, camera: 'camera_1' as const,
} },
}); });
await manager.handleCameraEvent({ await manager.handleCameraEvent({
@@ -23,4 +23,3 @@ it('should remove context property', () => {
expect(view.context).toEqual({}); expect(view.context).toEqual({});
}); });
@@ -2,7 +2,11 @@ import { describe, expect, it, vi } from 'vitest';
import { CardController } from '../../../../src/card-controller/controller'; import { CardController } from '../../../../src/card-controller/controller';
import { SubstreamOnViewModifier } from '../../../../src/card-controller/view/modifiers/substream-on'; import { SubstreamOnViewModifier } from '../../../../src/card-controller/view/modifiers/substream-on';
import { RawFrigateCardConfig } from '../../../../src/config/types'; import { RawFrigateCardConfig } from '../../../../src/config/types';
import { getStreamCameraID, hasSubstream, setSubstream } from '../../../../src/utils/substream'; import {
getStreamCameraID,
hasSubstream,
setSubstream,
} from '../../../../src/utils/substream';
import { import {
createCameraConfig, createCameraConfig,
createCameraManager, createCameraManager,