Rename TimelineDataManager to DataManager .
This commit is contained in:
+7
-10
@@ -100,7 +100,7 @@ import { isValidMediaLoadedInfo } from './utils/media-info.js';
|
||||
import { View } from './view.js';
|
||||
import pkg from '../package.json';
|
||||
import { ViewContext } from 'view';
|
||||
import { TimelineDataManager } from './utils/timeline-data-manager.js';
|
||||
import { DataManager } from './utils/data-manager.js';
|
||||
|
||||
/** A note on media callbacks:
|
||||
*
|
||||
@@ -203,7 +203,7 @@ export class FrigateCard extends LitElement {
|
||||
protected _resolvedMediaCache = new ResolvedMediaCache();
|
||||
|
||||
// Shared timeline data manager (for main timeline view and mini-timelines).
|
||||
protected _timelineDataManager?: TimelineDataManager;
|
||||
protected _dataManager?: DataManager;
|
||||
|
||||
// The mouse handler may be called continually, throttle it to at most once
|
||||
// per second for performance reasons.
|
||||
@@ -1052,10 +1052,7 @@ export class FrigateCard extends LitElement {
|
||||
}
|
||||
|
||||
if (this._cameras && (changedProps.has('_config') || changedProps.has('_cameras'))) {
|
||||
this._timelineDataManager = new TimelineDataManager(
|
||||
this._cameras,
|
||||
this._config.timeline.media,
|
||||
);
|
||||
this._dataManager = new DataManager(this._cameras, this._config.timeline.media);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1956,7 +1953,7 @@ export class FrigateCard extends LitElement {
|
||||
.view=${this._view}
|
||||
.cameras=${this._cameras}
|
||||
.galleryConfig=${this._getConfig().event_gallery}
|
||||
.dataManager=${this._timelineDataManager}
|
||||
.dataManager=${this._dataManager}
|
||||
>
|
||||
</frigate-card-gallery>`
|
||||
: ``}
|
||||
@@ -1967,7 +1964,7 @@ export class FrigateCard extends LitElement {
|
||||
.cameras=${this._cameras}
|
||||
.viewerConfig=${this._getConfig().media_viewer}
|
||||
.resolvedMediaCache=${this._resolvedMediaCache}
|
||||
.timelineDataManager=${this._timelineDataManager}
|
||||
.dataManager=${this._dataManager}
|
||||
>
|
||||
</frigate-card-viewer>`
|
||||
: ``}
|
||||
@@ -1977,7 +1974,7 @@ export class FrigateCard extends LitElement {
|
||||
.view=${this._view}
|
||||
.cameras=${this._cameras}
|
||||
.timelineConfig=${this._getConfig().timeline}
|
||||
.timelineDataManager=${this._timelineDataManager}
|
||||
.dataManager=${this._dataManager}
|
||||
>
|
||||
</frigate-card-timeline>`
|
||||
: ``}
|
||||
@@ -1998,7 +1995,7 @@ export class FrigateCard extends LitElement {
|
||||
.conditionState=${this._conditionState}
|
||||
.liveOverrides=${getOverridesByKey(this._getConfig().overrides, 'live')}
|
||||
.cameras=${this._cameras}
|
||||
.timelineDataManager=${this._timelineDataManager}
|
||||
.dataManager=${this._dataManager}
|
||||
class="${classMap(liveClasses)}"
|
||||
>
|
||||
</frigate-card-live>
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
getFullDependentBrowseMediaQueryParametersOrDispatchError,
|
||||
} from '../utils/ha/browse-media';
|
||||
import { changeViewToRecentRecordingForCameraAndDependents } from '../utils/media-to-view.js';
|
||||
import { TimelineDataManager } from '../utils/timeline-data-manager';
|
||||
import { DataManager } from '../utils/data-manager';
|
||||
import { View } from '../view.js';
|
||||
import { renderProgressIndicator } from './message.js';
|
||||
import './thumbnail.js';
|
||||
@@ -44,7 +44,7 @@ export class FrigateCardGallery extends LitElement {
|
||||
public cameras?: Map<string, CameraConfig>;
|
||||
|
||||
@property({ attribute: false })
|
||||
public dataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
/**
|
||||
* Master render method.
|
||||
|
||||
@@ -68,7 +68,7 @@ import { renderTask } from '../utils/task.js';
|
||||
import { classMap } from 'lit/directives/class-map.js';
|
||||
import './image';
|
||||
import { updateElementStyleFromMediaLayoutConfig } from '../utils/media-layout.js';
|
||||
import { TimelineDataManager } from '../utils/timeline-data-manager.js';
|
||||
import { DataManager } from '../utils/data-manager.js';
|
||||
|
||||
// Number of seconds a signed URL is valid for.
|
||||
const URL_SIGN_EXPIRY_SECONDS = 24 * 60 * 60;
|
||||
@@ -97,7 +97,7 @@ export class FrigateCardLive extends LitElement {
|
||||
public liveOverrides?: LiveOverrides;
|
||||
|
||||
@property({ attribute: false })
|
||||
public timelineDataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
// Whether or not the live view is currently in the background (i.e. preloaded
|
||||
// but not visible)
|
||||
@@ -221,7 +221,7 @@ export class FrigateCardLive extends LitElement {
|
||||
.timelineConfig=${config.controls.timeline}
|
||||
.browseMediaParams=${browseMediaParams ?? undefined}
|
||||
.cameras=${this.cameras}
|
||||
.timelineDataManager=${this.timelineDataManager}
|
||||
.dataManager=${this.dataManager}
|
||||
.inBackground=${this._inBackground}
|
||||
@frigate-card:message=${(ev: CustomEvent<Message>) => {
|
||||
this._renderKey++;
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
getFirstTrueMediaChildIndex,
|
||||
multipleBrowseMediaQueryMerged,
|
||||
} from '../utils/ha/browse-media';
|
||||
import { TimelineDataManager } from '../utils/timeline-data-manager';
|
||||
import { DataManager } from '../utils/data-manager';
|
||||
import { View } from '../view.js';
|
||||
import { dispatchFrigateCardErrorEvent } from './message.js';
|
||||
import { ThumbnailCarouselTap } from './thumbnail-carousel.js';
|
||||
@@ -70,7 +70,7 @@ export class FrigateCardSurround extends LitElement {
|
||||
public cameras?: Map<string, CameraConfig>;
|
||||
|
||||
@property({ attribute: false })
|
||||
public timelineDataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
/**
|
||||
* Fetch thumbnail media when a target is not specified in the view (e.g. for
|
||||
@@ -210,7 +210,7 @@ export class FrigateCardSurround extends LitElement {
|
||||
.timelineConfig=${this.timelineConfig}
|
||||
.thumbnailDetails=${this.thumbnailConfig?.show_details}
|
||||
.thumbnailSize=${this.thumbnailConfig?.size}
|
||||
.timelineDataManager=${this.timelineDataManager}
|
||||
.dataManager=${this.dataManager}
|
||||
>
|
||||
</frigate-card-timeline-core>`
|
||||
: ''}
|
||||
|
||||
@@ -63,8 +63,8 @@ import {
|
||||
import {
|
||||
FrigateCardTimelineItem,
|
||||
sortYoungestToOldest,
|
||||
TimelineDataManager,
|
||||
} from '../utils/timeline-data-manager';
|
||||
DataManager,
|
||||
} from '../utils/data-manager';
|
||||
import { View } from '../view';
|
||||
import { dispatchMessageEvent } from './message.js';
|
||||
import './thumbnail.js';
|
||||
@@ -186,7 +186,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
public mini = false;
|
||||
|
||||
@property({ attribute: false })
|
||||
public timelineDataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
@state()
|
||||
protected _locked = false;
|
||||
@@ -385,7 +385,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
!this._timeline ||
|
||||
!this.view ||
|
||||
!this.view.target?.children?.length ||
|
||||
!this.timelineDataManager
|
||||
!this.dataManager
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
const canSeek = !!this.view?.isViewerView();
|
||||
const context = canSeek
|
||||
? generateMediaViewerContextForChildren(
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
this.view.target.children,
|
||||
targetTime,
|
||||
)
|
||||
@@ -439,7 +439,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
!this._ignoreClick &&
|
||||
properties.what &&
|
||||
this.hass &&
|
||||
this.timelineDataManager &&
|
||||
this.dataManager &&
|
||||
this.cameras &&
|
||||
this.view
|
||||
) {
|
||||
@@ -456,7 +456,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
changeViewToRecording(
|
||||
this,
|
||||
this.hass,
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
this.cameras,
|
||||
this.view, {
|
||||
cameraIDs: new Set([String(properties.group)]),
|
||||
@@ -469,7 +469,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
changeViewToRecording(
|
||||
this,
|
||||
this.hass,
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
this.cameras,
|
||||
this.view, {
|
||||
targetTime: window.end,
|
||||
@@ -481,7 +481,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
changeViewToRecording(
|
||||
this,
|
||||
this.hass,
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
this.cameras,
|
||||
this.view, {
|
||||
cameraIDs: this._getAllCameraIDs(),
|
||||
@@ -496,7 +496,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
properties.item &&
|
||||
this.view &&
|
||||
this.view.target?.children &&
|
||||
this.timelineDataManager
|
||||
this.dataManager
|
||||
) {
|
||||
let childIndex: number | null = null;
|
||||
let target: FrigateBrowseMediaSource | null = null;
|
||||
@@ -510,7 +510,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
childIndex = thumbnails.childIndex;
|
||||
if (thumbnails.target?.children?.length) {
|
||||
context = generateMediaViewerContextForChildren(
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
thumbnails.target.children,
|
||||
properties.time,
|
||||
);
|
||||
@@ -573,7 +573,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
properties.start,
|
||||
properties.end,
|
||||
);
|
||||
this.timelineDataManager
|
||||
this.dataManager
|
||||
?.fetchIfNecessary(this, this.hass, prefetchStart, prefetchEnd)
|
||||
.then(() => {
|
||||
// Don't show event thumbnails if the user is looking at recordings,
|
||||
@@ -879,7 +879,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
windowStart,
|
||||
windowEnd,
|
||||
);
|
||||
fetched = !!(await this.timelineDataManager?.fetchIfNecessary(
|
||||
fetched = !!(await this.dataManager?.fetchIfNecessary(
|
||||
this,
|
||||
this.hass,
|
||||
prefetchStart,
|
||||
@@ -900,7 +900,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
// update the dataset to ensure the newly selected item cannot be included
|
||||
// in a cluster. Only do this when the pointer is not held to avoid
|
||||
// interrupting the user and to make the timeline smoother.
|
||||
this.timelineDataManager?.rewriteItem(event.id);
|
||||
this.dataManager?.rewriteItem(event.id);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -1027,7 +1027,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
let createdTimeline = false;
|
||||
|
||||
if (
|
||||
this.timelineDataManager &&
|
||||
this.dataManager &&
|
||||
this._refTimeline.value &&
|
||||
options &&
|
||||
this.timelineConfig &&
|
||||
@@ -1051,7 +1051,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
return;
|
||||
}
|
||||
|
||||
this._dataview = this.timelineDataManager.createDataView(
|
||||
this._dataview = this.dataManager.createDataView(
|
||||
this._getTimelineCameraIDs(),
|
||||
!!this.timelineConfig.show_recordings,
|
||||
this.timelineConfig.media,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import timelineStyle from '../scss/timeline.scss';
|
||||
import { CameraConfig, ExtendedHomeAssistant, TimelineConfig } from '../types';
|
||||
import { TimelineDataManager } from '../utils/timeline-data-manager';
|
||||
import { DataManager } from '../utils/data-manager';
|
||||
import { View } from '../view';
|
||||
import './surround.js';
|
||||
import './timeline-core.js';
|
||||
@@ -27,7 +27,7 @@ export class FrigateCardTimeline extends LitElement {
|
||||
public timelineConfig?: TimelineConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
public timelineDataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
/**
|
||||
* Master render method.
|
||||
@@ -52,7 +52,7 @@ export class FrigateCardTimeline extends LitElement {
|
||||
.timelineConfig=${this.timelineConfig}
|
||||
.thumbnailDetails=${this.timelineConfig.controls.thumbnails.show_details}
|
||||
.thumbnailSize=${this.timelineConfig.controls.thumbnails.size}
|
||||
.timelineDataManager=${this.timelineDataManager}
|
||||
.dataManager=${this.dataManager}
|
||||
>
|
||||
</frigate-card-timeline-core>
|
||||
</frigate-card-surround>`;
|
||||
|
||||
@@ -55,7 +55,7 @@ import './surround.js';
|
||||
import { EmblaCarouselPlugins } from './carousel.js';
|
||||
import { renderTask } from '../utils/task.js';
|
||||
import { updateElementStyleFromMediaLayoutConfig } from '../utils/media-layout.js';
|
||||
import { TimelineDataManager } from '../utils/timeline-data-manager.js';
|
||||
import { DataManager } from '../utils/data-manager.js';
|
||||
import { changeViewToRecentRecordingForCameraAndDependents } from '../utils/media-to-view.js';
|
||||
|
||||
export interface MediaSeek {
|
||||
@@ -95,7 +95,7 @@ export class FrigateCardViewer extends LitElement {
|
||||
public resolvedMediaCache?: ResolvedMediaCache;
|
||||
|
||||
@property({ attribute: false })
|
||||
public timelineDataManager?: TimelineDataManager;
|
||||
public dataManager?: DataManager;
|
||||
|
||||
/**
|
||||
* Master render method.
|
||||
@@ -107,7 +107,7 @@ export class FrigateCardViewer extends LitElement {
|
||||
!this.view ||
|
||||
!this.cameras ||
|
||||
!this.viewerConfig ||
|
||||
!this.timelineDataManager
|
||||
!this.dataManager
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ export class FrigateCardViewer extends LitElement {
|
||||
changeViewToRecentRecordingForCameraAndDependents(
|
||||
this,
|
||||
this.hass,
|
||||
this.timelineDataManager,
|
||||
this.dataManager,
|
||||
this.cameras,
|
||||
this.view,
|
||||
{
|
||||
@@ -160,7 +160,7 @@ export class FrigateCardViewer extends LitElement {
|
||||
.fetch=${false}
|
||||
.thumbnailConfig=${this.viewerConfig.controls.thumbnails}
|
||||
.timelineConfig=${this.viewerConfig.controls.timeline}
|
||||
.timelineDataManager=${this.timelineDataManager}
|
||||
.dataManager=${this.dataManager}
|
||||
.cameras=${this.cameras}
|
||||
>
|
||||
<frigate-card-viewer-carousel
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
FrigateEvent,
|
||||
FrigateEvents,
|
||||
} from '../types.js';
|
||||
import { errorToConsole, runWhenIdleIfSupported } from '../utils/basic.js';
|
||||
import { errorToConsole, runWhenIdleIfSupported } from './basic.js';
|
||||
import {
|
||||
FrigateGetEventsParameters,
|
||||
getEventsMultiple,
|
||||
@@ -23,8 +23,8 @@ import fromUnixTime from 'date-fns/fromUnixTime';
|
||||
import { throttle } from 'lodash-es';
|
||||
|
||||
const RECORDING_SEGMENT_TOLERANCE = 60;
|
||||
const TIMELINE_DATA_MANAGER_MAX_AGE_SECONDS = 10;
|
||||
const TIMELINE_DATA_MANAGER_MAX_FETCH_COUNT = 10000;
|
||||
const DATA_MANAGER_MAX_AGE_SECONDS = 10;
|
||||
const DATA_MANAGER_MAX_FETCH_COUNT = 10000;
|
||||
|
||||
export interface FrigateCardTimelineItem extends TimelineItem {
|
||||
// DataView has issues using datasets with Date objects, so avoid them and use
|
||||
@@ -84,7 +84,7 @@ export const sortOldestToYoungest = (
|
||||
/**
|
||||
* A manager to maintain/fetch timeline events.
|
||||
*/
|
||||
export class TimelineDataManager {
|
||||
export class DataManager {
|
||||
protected _recordingSummary: Map<string, RecordingSummary | null> = new Map();
|
||||
protected _recordingSegments = new DataSet<RecordingSegmentsItem>();
|
||||
|
||||
@@ -101,7 +101,7 @@ export class TimelineDataManager {
|
||||
|
||||
// The maximum allowable age of fetch data (will not fetch more frequently
|
||||
// than this).
|
||||
protected _maxAgeSeconds: number = TIMELINE_DATA_MANAGER_MAX_AGE_SECONDS;
|
||||
protected _maxAgeSeconds: number = DATA_MANAGER_MAX_AGE_SECONDS;
|
||||
|
||||
protected _cameras: Map<string, CameraConfig>;
|
||||
protected _mediaType: TimelineMediaType;
|
||||
@@ -526,7 +526,7 @@ export class TimelineDataManager {
|
||||
...(cameraConfig.frigate.zone && { label: cameraConfig.frigate.zone }),
|
||||
before: Math.floor(end.getTime() / 1000),
|
||||
after: Math.floor(start.getTime() / 1000),
|
||||
limit: TIMELINE_DATA_MANAGER_MAX_FETCH_COUNT,
|
||||
limit: DATA_MANAGER_MAX_FETCH_COUNT,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -10,8 +10,8 @@ import { createChild, createEventParentForChildren, sortYoungestToOldest } from
|
||||
import {
|
||||
RecordingSegmentsItem,
|
||||
sortOldestToYoungest,
|
||||
TimelineDataManager,
|
||||
} from './timeline-data-manager';
|
||||
DataManager,
|
||||
} from './data-manager';
|
||||
import { getAllDependentCameras, getTrueCameras } from './camera.js';
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ import { getAllDependentCameras, getTrueCameras } from './camera.js';
|
||||
export const changeViewToRecentRecordingForCameraAndDependents = async (
|
||||
element: HTMLElement,
|
||||
hass: ExtendedHomeAssistant,
|
||||
dataManager: TimelineDataManager,
|
||||
dataManager: DataManager,
|
||||
cameras: Map<string, CameraConfig>,
|
||||
view: View,
|
||||
options?: {
|
||||
@@ -66,7 +66,7 @@ import { getAllDependentCameras, getTrueCameras } from './camera.js';
|
||||
export const changeViewToRecording = async (
|
||||
element: HTMLElement,
|
||||
hass: ExtendedHomeAssistant,
|
||||
dataManager: TimelineDataManager,
|
||||
dataManager: DataManager,
|
||||
cameras: Map<string, CameraConfig>,
|
||||
view: View,
|
||||
options?: {
|
||||
@@ -122,7 +122,7 @@ export const changeViewToRecording = async (
|
||||
* @returns
|
||||
*/
|
||||
const createRecordingChildren = (
|
||||
dataManager: TimelineDataManager,
|
||||
dataManager: DataManager,
|
||||
cameras: Map<string, CameraConfig>,
|
||||
cameraIDs: Set<string>,
|
||||
options?: {
|
||||
@@ -191,7 +191,7 @@ const createRecordingChildren = (
|
||||
* @returns The ViewContext.
|
||||
*/
|
||||
export const generateMediaViewerContextForChildren = (
|
||||
dataManager: TimelineDataManager,
|
||||
dataManager: DataManager,
|
||||
children: FrigateBrowseMediaSource[],
|
||||
targetTime: Date,
|
||||
): ViewContext => {
|
||||
|
||||
Reference in New Issue
Block a user