Merge pull request #4236 from vvlladd28/improvement/validate/entityId
UI: Added validate EntityId before update dashboard state
This commit is contained in:
commit
d61890a96a
@ -18,6 +18,8 @@ import _ from 'lodash';
|
|||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { finalize, share } from 'rxjs/operators';
|
import { finalize, share } from 'rxjs/operators';
|
||||||
import { Datasource } from '@app/shared/models/widget.models';
|
import { Datasource } from '@app/shared/models/widget.models';
|
||||||
|
import { EntityId } from '@shared/models/id/entity-id';
|
||||||
|
import { NULL_UUID } from '@shared/models/id/has-uuid';
|
||||||
|
|
||||||
const varsRegex = /\${([^}]*)}/g;
|
const varsRegex = /\${([^}]*)}/g;
|
||||||
|
|
||||||
@ -431,3 +433,7 @@ export function generateSecret(length?: number): string {
|
|||||||
}
|
}
|
||||||
return str.concat(generateSecret(length - str.length));
|
return str.concat(generateSecret(length - str.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function validateEntityId(entityId: EntityId): boolean {
|
||||||
|
return isDefinedAndNotNull(entityId.id) && entityId.id !== NULL_UUID && isDefinedAndNotNull(entityId.entityType);
|
||||||
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ import { AppState } from '@core/core.state';
|
|||||||
import { WidgetService } from '@core/http/widget.service';
|
import { WidgetService } from '@core/http/widget.service';
|
||||||
import { UtilsService } from '@core/services/utils.service';
|
import { UtilsService } from '@core/services/utils.service';
|
||||||
import { forkJoin, Observable, of, ReplaySubject, Subscription, throwError } from 'rxjs';
|
import { forkJoin, Observable, of, ReplaySubject, Subscription, throwError } from 'rxjs';
|
||||||
import { deepClone, insertVariable, isDefined, objToBase64, objToBase64URI } from '@core/utils';
|
import { deepClone, insertVariable, isDefined, objToBase64, objToBase64URI, validateEntityId } from '@core/utils';
|
||||||
import {
|
import {
|
||||||
IDynamicWidgetComponent,
|
IDynamicWidgetComponent,
|
||||||
WidgetContext,
|
WidgetContext,
|
||||||
@ -1004,7 +1004,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
const type = descriptor.type;
|
const type = descriptor.type;
|
||||||
const targetEntityParamName = descriptor.stateEntityParamName;
|
const targetEntityParamName = descriptor.stateEntityParamName;
|
||||||
let targetEntityId: EntityId;
|
let targetEntityId: EntityId;
|
||||||
if (descriptor.setEntityId) {
|
if (descriptor.setEntityId && validateEntityId(entityId)) {
|
||||||
targetEntityId = entityId;
|
targetEntityId = entityId;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user