Browse Source
Merge pull request #4236 from vvlladd28/improvement/validate/entityId
UI: Added validate EntityId before update dashboard state
pull/4240/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
2 deletions
-
ui-ngx/src/app/core/utils.ts
-
ui-ngx/src/app/modules/home/components/widget/widget.component.ts
|
|
|
@ -18,6 +18,8 @@ import _ from 'lodash'; |
|
|
|
import { Observable, Subject } from 'rxjs'; |
|
|
|
import { finalize, share } from 'rxjs/operators'; |
|
|
|
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; |
|
|
|
|
|
|
|
@ -431,3 +433,7 @@ export function generateSecret(length?: number): string { |
|
|
|
} |
|
|
|
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 { UtilsService } from '@core/services/utils.service'; |
|
|
|
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 { |
|
|
|
IDynamicWidgetComponent, |
|
|
|
WidgetContext, |
|
|
|
@ -1004,7 +1004,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI |
|
|
|
const type = descriptor.type; |
|
|
|
const targetEntityParamName = descriptor.stateEntityParamName; |
|
|
|
let targetEntityId: EntityId; |
|
|
|
if (descriptor.setEntityId) { |
|
|
|
if (descriptor.setEntityId && validateEntityId(entityId)) { |
|
|
|
targetEntityId = entityId; |
|
|
|
} |
|
|
|
switch (type) { |
|
|
|
|