diff --git a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts index 6d3c7e1453..d961efbb2e 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts @@ -17,13 +17,14 @@ import { BaseData, HasId } from '@shared/models/base-data'; import { FormBuilder, FormGroup } from '@angular/forms'; import { PageComponent } from '@shared/components/page.component'; -import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Directive, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { EntityAction } from '@home/models/entity/entity-component.models'; import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { PageLink } from '@shared/models/page/page-link'; import { isObject, isString } from '@core/utils'; +import { WINDOW } from "@core/services/window.service"; // @dynamic @Directive() @@ -80,7 +81,8 @@ export abstract class EntityComponent, protected constructor(protected store: Store, protected fb: FormBuilder, protected entityValue: T, - protected entitiesTableConfigValue: C) { + protected entitiesTableConfigValue: C, + @Inject(WINDOW) protected window: Window) { super(store); this.entityForm = this.buildForm(this.entityValue); } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge.component.ts b/ui-ngx/src/app/modules/home/pages/edge/edge.component.ts index a1a3f27372..009d5ee27c 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge.component.ts +++ b/ui-ngx/src/app/modules/home/pages/edge/edge.component.ts @@ -18,7 +18,7 @@ import { Component, Inject } from '@angular/core'; import { Store } from '@ngrx/store'; import { AppState } from "@core/core.state"; import { EntityComponent } from "@home/components/entity/entity.component"; -import {FormBuilder, FormControl, FormGroup, NgModel, Validators} from "@angular/forms"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { EntityType } from "@shared/models/entity-type.models"; import { EdgeInfo } from "@shared/models/edge.models"; import { TranslateService } from "@ngx-translate/core"; @@ -26,6 +26,7 @@ import { NULL_UUID } from "@shared/models/id/has-uuid"; import { ActionNotificationShow } from "@core/notification/notification.actions"; import { guid, isUndefined } from "@core/utils"; import { EntityTableConfig } from "@home/models/entity/entities-table-config.models"; +import { WINDOW } from "@core/services/window.service"; @Component({ selector: 'tb-edge', @@ -42,8 +43,9 @@ export class EdgeComponent extends EntityComponent { protected translate: TranslateService, @Inject('entity') protected entityValue: EdgeInfo, @Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig, - public fb: FormBuilder) { - super(store, fb, entityValue, entitiesTableConfigValue); + public fb: FormBuilder, + @Inject(WINDOW) protected window: Window) { + super(store, fb, entityValue, entitiesTableConfigValue, window); } ngOnInit() { @@ -69,8 +71,8 @@ export class EdgeComponent extends EntityComponent { name: [entity ? entity.name : '', [Validators.required]], type: [entity ? entity.type : null, [Validators.required]], label: [entity ? entity.label : ''], - cloudEndpoint: '', - edgeLicenseKey: '', + cloudEndpoint: [this.window.location.origin, [Validators.required]], + edgeLicenseKey: ['', [Validators.required]], routingKey: guid(), secret: this.generateSecret(20), additionalInfo: this.fb.group(