Remove dset/dlv. Use lodash instead.
This commit is contained in:
@@ -22,8 +22,6 @@
|
|||||||
"@material/rtl": "^13.0.0",
|
"@material/rtl": "^13.0.0",
|
||||||
"custom-card-helpers": "^1.8.0",
|
"custom-card-helpers": "^1.8.0",
|
||||||
"dayjs": "^1.10.7",
|
"dayjs": "^1.10.7",
|
||||||
"dlv": "github:developit/dlv",
|
|
||||||
"dset": "^3.1.1",
|
|
||||||
"embla-carousel": "^5.0.1",
|
"embla-carousel": "^5.0.1",
|
||||||
"home-assistant-js-websocket": "^5.11.1",
|
"home-assistant-js-websocket": "^5.11.1",
|
||||||
"lit": "^2.0.2",
|
"lit": "^2.0.2",
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// TODO different live configs per camera
|
// TODO different live configs per camera
|
||||||
// TODO replace dset/dlv with lodash
|
|
||||||
// TODO evaluate single override section instead of per-subcomponent
|
// TODO evaluate single override section instead of per-subcomponent
|
||||||
// TODO fix adaptive height in fullscreen
|
|
||||||
// TODO Remove id as a concept for cameras and use an array instead?
|
// TODO Remove id as a concept for cameras and use an array instead?
|
||||||
// TODO Convert menu condition to use overrides
|
// TODO Convert menu condition to use overrides
|
||||||
// TODO Remove media load event console message
|
// TODO Remove media load event console message
|
||||||
|
|||||||
+4
-9
@@ -1,5 +1,4 @@
|
|||||||
import delve from 'dlv';
|
import { get, set } from 'lodash-es';
|
||||||
import { dset } from 'dset';
|
|
||||||
import {
|
import {
|
||||||
CONF_CAMERAS,
|
CONF_CAMERAS,
|
||||||
CONF_CAMERAS_ARRAY_CAMERA_ENTITY,
|
CONF_CAMERAS_ARRAY_CAMERA_ENTITY,
|
||||||
@@ -36,7 +35,7 @@ export const setConfigValue = (
|
|||||||
keys: string | (string | number)[],
|
keys: string | (string | number)[],
|
||||||
value: unknown,
|
value: unknown,
|
||||||
): void => {
|
): void => {
|
||||||
dset(obj, keys, value);
|
set(obj, keys, value)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,11 +49,7 @@ export const getConfigValue = (
|
|||||||
keys: string | (string | number)[],
|
keys: string | (string | number)[],
|
||||||
def?: unknown,
|
def?: unknown,
|
||||||
): unknown => {
|
): unknown => {
|
||||||
// Need to manually split the key apart to use delve array accesses by number.
|
return get(obj, keys, def);
|
||||||
if (typeof keys === 'string') {
|
|
||||||
keys = keys.split('.');
|
|
||||||
}
|
|
||||||
return delve(obj, keys, def);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,7 +167,7 @@ export const moveConfigValue = (
|
|||||||
* @returns The true config path.
|
* @returns The true config path.
|
||||||
*/
|
*/
|
||||||
export const getArrayConfigPath = (path: string, index: number): string => {
|
export const getArrayConfigPath = (path: string, index: number): string => {
|
||||||
return path.replace('#', index.toString());
|
return path.replace('#', `[${index.toString()}]`);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -211,10 +211,10 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
|||||||
* @returns A localized label.
|
* @returns A localized label.
|
||||||
*/
|
*/
|
||||||
protected _getLabel(configPath: string): string {
|
protected _getLabel(configPath: string): string {
|
||||||
// Strip out single number path components as they are array indicies.
|
// Strip out array indices from the path.
|
||||||
const path = configPath
|
const path = configPath
|
||||||
.split('.')
|
.split('.')
|
||||||
.filter((e) => isNaN(Number(e)))
|
.filter((e) => !e.match(/^\[[0-9]+\]$/))
|
||||||
.join('.');
|
.join('.');
|
||||||
return localize(`config.${path}`);
|
return localize(`config.${path}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user