1 import { Component, EventEmitter, Input, Output } from '@angular/core';
3 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
4 import _ from 'lodash';
6 import { OsdService } from '~/app/shared/api/osd.service';
7 import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
8 import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
9 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
10 import { FinishedTask } from '~/app/shared/models/finished-task';
11 import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
14 selector: 'cd-osd-creation-preview-modal',
15 templateUrl: './osd-creation-preview-modal.component.html',
16 styleUrls: ['./osd-creation-preview-modal.component.scss']
18 export class OsdCreationPreviewModalComponent {
20 driveGroups: Object[] = [];
23 submitAction = new EventEmitter();
26 formGroup: CdFormGroup;
29 public activeModal: NgbActiveModal,
30 public actionLabels: ActionLabelsI18n,
31 private formBuilder: CdFormBuilder,
32 private osdService: OsdService,
33 private taskWrapper: TaskWrapperService
35 this.action = actionLabels.CREATE;
40 this.formGroup = this.formBuilder.group({});
46 task: new FinishedTask('osd/' + URLVerbs.CREATE, {
47 tracking_id: _.join(_.map(this.driveGroups, 'service_id'), ', ')
49 call: this.osdService.create(this.driveGroups)
53 this.formGroup.setErrors({ cdSubmitButton: true });
56 this.submitAction.emit();
57 this.activeModal.close();