feat: Add easy access to card from JS console for user debugging (#2502)
This commit is contained in:
committed by
dermotduffy
parent
326c8d4e71
commit
88fde79721
+21
@@ -81,6 +81,11 @@ console.info(
|
|||||||
documentationURL: REPO_URL,
|
documentationURL: REPO_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Expose currently-connected card instances on `window.advancedCameraCards` for
|
||||||
|
// console-based debugging and user support. `??=` so a double-loaded card
|
||||||
|
// shares one array (same pattern as `customCards` above).
|
||||||
|
const advancedCameraCards: AdvancedCameraCard[] = (window.advancedCameraCards ??= []);
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Main AdvancedCameraCard WebComponent
|
// Main AdvancedCameraCard WebComponent
|
||||||
//
|
//
|
||||||
@@ -157,6 +162,19 @@ class AdvancedCameraCard extends LitElement {
|
|||||||
this._controller.getConfigManager().setConfig(config);
|
this._controller.getConfigManager().setConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public connectedCallback(): void {
|
||||||
|
super.connectedCallback();
|
||||||
|
advancedCameraCards.push(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback(): void {
|
||||||
|
const i = advancedCameraCards.indexOf(this);
|
||||||
|
if (i >= 0) {
|
||||||
|
advancedCameraCards.splice(i, 1);
|
||||||
|
}
|
||||||
|
super.disconnectedCallback();
|
||||||
|
}
|
||||||
|
|
||||||
protected shouldUpdate(): boolean {
|
protected shouldUpdate(): boolean {
|
||||||
// Do not allow a disconnected element to update, as it may cause cameras to
|
// Do not allow a disconnected element to update, as it may cause cameras to
|
||||||
// reinitialize/subscribe for an element that is no longer part of the
|
// reinitialize/subscribe for an element that is no longer part of the
|
||||||
@@ -525,4 +543,7 @@ declare global {
|
|||||||
'advanced-camera-card': AdvancedCameraCard;
|
'advanced-camera-card': AdvancedCameraCard;
|
||||||
'frigate-card': FrigateCard;
|
'frigate-card': FrigateCard;
|
||||||
}
|
}
|
||||||
|
interface Window {
|
||||||
|
advancedCameraCards?: AdvancedCameraCard[];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user