Must specify media type in viewer target search.

This commit is contained in:
Dermot Duffy
2022-04-23 16:34:39 -07:00
parent 7bf824d4e9
commit 7273e699a6
4 changed files with 18 additions and 7 deletions
+3 -3
View File
@@ -35,7 +35,7 @@ import type {
Message, Message,
} from './types.js'; } from './types.js';
import { CARD_VERSION, REPO_URL } from './const.js'; import { CAMERA_BIRDSEYE, CARD_VERSION, REPO_URL } from './const.js';
import { FrigateCardElements } from './components/elements.js'; import { FrigateCardElements } from './components/elements.js';
import { FrigateCardImage } from './components/image.js'; import { FrigateCardImage } from './components/image.js';
import { FRIGATE_BUTTON_MENU_ICON, FrigateCardMenu } from './components/menu.js'; import { FRIGATE_BUTTON_MENU_ICON, FrigateCardMenu } from './components/menu.js';
@@ -333,7 +333,7 @@ export class FrigateCard extends LitElement {
if ( if (
this._getConfig().menu.buttons.clips && this._getConfig().menu.buttons.clips &&
cameraConfig?.camera_name && cameraConfig?.camera_name &&
(cameraConfig?.camera_name !== 'birdseye' || (cameraConfig?.camera_name !== CAMERA_BIRDSEYE ||
cameraConfig?.dependent_cameras?.length) cameraConfig?.dependent_cameras?.length)
) { ) {
buttons.push({ buttons.push({
@@ -351,7 +351,7 @@ export class FrigateCard extends LitElement {
if ( if (
this._getConfig().menu.buttons.snapshots && this._getConfig().menu.buttons.snapshots &&
cameraConfig?.camera_name && cameraConfig?.camera_name &&
(cameraConfig?.camera_name !== 'birdseye' || (cameraConfig?.camera_name !== CAMERA_BIRDSEYE ||
cameraConfig?.dependent_cameras?.length) cameraConfig?.dependent_cameras?.length)
) { ) {
buttons.push({ buttons.push({
+3 -2
View File
@@ -32,6 +32,7 @@ import {
FrigateEvent, FrigateEvent,
frigateCardConfigDefaults, frigateCardConfigDefaults,
} from '../types'; } from '../types';
import { CAMERA_BIRDSEYE } from '../const';
import { View, ViewContext } from '../view'; import { View, ViewContext } from '../view';
import { import {
dispatchErrorMessageEvent, dispatchErrorMessageEvent,
@@ -283,7 +284,7 @@ class TimelineEventManager {
if ( if (
this._dateEnd && this._dateEnd &&
this._dateStart && this._dateStart &&
cameraConfig.camera_name !== 'birdseye' cameraConfig.camera_name !== CAMERA_BIRDSEYE
) { ) {
const param = BrowseMediaUtil.getBrowseMediaQueryParameters( const param = BrowseMediaUtil.getBrowseMediaQueryParameters(
hass, hass,
@@ -592,7 +593,7 @@ export class FrigateCardTimelineCore extends LitElement {
protected _getGroups(): DataGroupCollectionType { protected _getGroups(): DataGroupCollectionType {
const groups: FrigateCardGroupData[] = []; const groups: FrigateCardGroupData[] = [];
this.cameras?.forEach((cameraConfig, camera) => { this.cameras?.forEach((cameraConfig, camera) => {
if (cameraConfig.camera_name !== 'birdseye') { if (cameraConfig.camera_name !== CAMERA_BIRDSEYE) {
groups.push({ groups.push({
id: camera, id: camera,
content: getCameraTitle(this.hass, cameraConfig), content: getCameraTitle(this.hass, cameraConfig),
+9 -1
View File
@@ -77,7 +77,12 @@ export class FrigateCardViewer extends LitElement {
); );
if (!this.view.target) { if (!this.view.target) {
if (!browseMediaQueryParameters) { // If the target is not specified, the view must tell us which mediaType
// to search for. When the target *is* specified, the view is not required
// to indicate the media type (e.g. the mixed 'events' view from the
// timeline).
const mediaType = this.view.getMediaType();
if (!browseMediaQueryParameters || !mediaType) {
return; return;
} }
@@ -85,7 +90,10 @@ export class FrigateCardViewer extends LitElement {
this, this,
this.hass, this.hass,
this.view, this.view,
BrowseMediaUtil.overrideMultiBrowseMediaQueryParameters(
browseMediaQueryParameters, browseMediaQueryParameters,
{ mediaType: mediaType },
),
); );
return renderProgressIndicator(); return renderProgressIndicator();
} }
+2
View File
@@ -1,4 +1,6 @@
export const CARD_VERSION = '3.0.0' as const; export const CARD_VERSION = '3.0.0' as const;
export const CAMERA_BIRDSEYE = 'birdseye' as const;
export const REPO_URL = 'https://github.com/dermotduffy/frigate-hass-card' as const; export const REPO_URL = 'https://github.com/dermotduffy/frigate-hass-card' as const;
export const TROUBLESHOOTING_URL = `${REPO_URL}#troubleshooting` as const; export const TROUBLESHOOTING_URL = `${REPO_URL}#troubleshooting` as const;