|
|
|
@ -19,7 +19,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; |
|
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|
|
|
import { Store } from '@ngrx/store'; |
|
|
|
import { AppState } from '@core/core.state'; |
|
|
|
import { FormGroupDirective, NgForm, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; |
|
|
|
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, Validators } from '@angular/forms'; |
|
|
|
import { EntityId } from '@shared/models/id/entity-id'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { DialogComponent } from '@app/shared/components/dialog.component'; |
|
|
|
@ -41,7 +41,7 @@ export interface AddAttributeDialogData { |
|
|
|
export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDialogComponent, boolean> |
|
|
|
implements OnInit, ErrorStateMatcher { |
|
|
|
|
|
|
|
attributeFormGroup: UntypedFormGroup; |
|
|
|
attributeFormGroup: FormGroup; |
|
|
|
|
|
|
|
submitted = false; |
|
|
|
|
|
|
|
@ -53,7 +53,7 @@ export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDia |
|
|
|
private attributeService: AttributeService, |
|
|
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, |
|
|
|
public dialogRef: MatDialogRef<AddAttributeDialogComponent, boolean>, |
|
|
|
public fb: UntypedFormBuilder) { |
|
|
|
public fb: FormBuilder) { |
|
|
|
super(store, router, dialogRef); |
|
|
|
} |
|
|
|
|
|
|
|
@ -66,7 +66,7 @@ export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDia |
|
|
|
'attribute.add-telemetry' : 'attribute.add' |
|
|
|
} |
|
|
|
|
|
|
|
isErrorState(control: UntypedFormControl | null, form: FormGroupDirective | NgForm | null): boolean { |
|
|
|
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { |
|
|
|
const originalErrorState = this.errorStateMatcher.isErrorState(control, form); |
|
|
|
const customErrorState = !!(control && control.invalid && this.submitted); |
|
|
|
return originalErrorState || customErrorState; |
|
|
|
@ -87,8 +87,7 @@ export class AddAttributeDialogComponent extends DialogComponent<AddAttributeDia |
|
|
|
if (this.data.attributeScope === LatestTelemetry.LATEST_TELEMETRY) { |
|
|
|
task = this.attributeService.saveEntityTimeseries(this.data.entityId, |
|
|
|
this.data.attributeScope, [attribute]); |
|
|
|
} |
|
|
|
if (this.data.attributeScope in AttributeScope) { |
|
|
|
} else { |
|
|
|
task = this.attributeService.saveEntityAttributes(this.data.entityId, |
|
|
|
this.data.attributeScope as AttributeScope, [attribute]); |
|
|
|
} |
|
|
|
|