diff --git a/src/composer/src/app/core/components/dialogs/build-dialog/build-dialog.component.ts b/src/composer/src/app/core/components/dialogs/build-dialog/build-dialog.component.ts index 258080a..9c45b5c 100644 --- a/src/composer/src/app/core/components/dialogs/build-dialog/build-dialog.component.ts +++ b/src/composer/src/app/core/components/dialogs/build-dialog/build-dialog.component.ts @@ -4,6 +4,9 @@ import { FormControl, Validators, FormGroup, FormBuilder, AbstractControl } from import { KeyValueComponent } from '../../common/key-value/key-value/key-value.component' import { Service, Project, Volume, ServicePort, Network } from '../../../store/models' import { CheckCircleComponent } from '../../widgets/check-circle/check-circle.component' +import { Store } from '@ngrx/store' +import * as ProjectActions from './../../../store/project.actions' +import { EventEmitterService } from 'src/app/core/services/event-emitter.service' @Component({ selector: 'app-build-dialog', @@ -20,7 +23,7 @@ export class BuildDialogComponent implements OnInit { currentArgs: [] = [] currentCacheFrom: [] = [] currentLabels: [] = [] - constructor(public dialogRef: MatDialogRef, private formBuilder: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: Service) { } + constructor(public dialogRef: MatDialogRef, private formBuilder: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: Service, private store: Store, private eventEmitterService: EventEmitterService,) { } ngOnInit(): void { this.formGeneral = this.formBuilder.group({ @@ -31,6 +34,19 @@ export class BuildDialogComponent implements OnInit { shm_size: new FormControl(''), target: new FormControl(''), }) + + if (this.data.build) { + this.data.build.labels.forEach(val => this.currentLabels.push(val)) + this.data.build.cache_from.forEach(val => this.currentCacheFrom.push(val)) + this.data.build.args.forEach(val => this.currentArgs.push(val)) + + let fields = Object.keys(this.data.build).reduce((acc, key) => { + if(this.data.build[key]) acc[key] = this.data.build[key] + return acc + }, {}) + + this.formGeneral.patchValue(fields) + } } onSave() { @@ -40,8 +56,9 @@ export class BuildDialogComponent implements OnInit { cache_from: this.cache_from.getKeyValuePaies(), labels: this.labels.getKeyValuePaies() } + this.store.dispatch(ProjectActions.UpdateService({data: {...this.data, build: fields}})) this.checkCircle.showCircle() - console.log(fields) + this.eventEmitterService.broadcast('save:project', {}) } }