53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
|
import { JsonSerializer } from '../../../utilities/JsonSerializer';
|
||
|
import { RequestItem } from '../../../models/criteria/RequestItem';
|
||
|
import { Component, OnInit, Inject } from "@angular/core";
|
||
|
import { FormGroup } from '@angular/forms';
|
||
|
import { Params, ActivatedRoute, Router } from '@angular/router';
|
||
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||
|
import { DatasetService } from '../../../services/dataset/dataset.service';
|
||
|
import { DatasetProfileModel } from '../../../models/datasetprofile/DatasetProfileModel';
|
||
|
import { DatasetProfileModule } from '../../../dataset-profile-form/dataset-profile.module';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'available-profiles-component',
|
||
|
templateUrl: 'available-profiles.component.html',
|
||
|
|
||
|
})
|
||
|
export class AvailableProfilesComponent implements OnInit {
|
||
|
|
||
|
private formGroup: FormGroup;
|
||
|
private profiles: DatasetProfileModel[] = [];
|
||
|
private selectedProfiles: DatasetProfileModel[] = [];
|
||
|
|
||
|
constructor(
|
||
|
private datasetService: DatasetService,
|
||
|
private route: ActivatedRoute,
|
||
|
public router: Router,
|
||
|
public dialogRef: MatDialogRef<AvailableProfilesComponent>,
|
||
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||
|
) { }
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
|
||
|
this.datasetService.getDatasetProfiles().subscribe(data => {
|
||
|
this.profiles = JsonSerializer.fromJSONArray(data, DatasetProfileModel)
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
|
||
|
addProfiles(profiles) {
|
||
|
// profiles.selectedOptions.forEach(element => {
|
||
|
// selectedProfiles.push(element.value)
|
||
|
// });
|
||
|
|
||
|
profiles.selectedOptions.selected.forEach(element => {
|
||
|
let selectedElement = new DatasetProfileModel();
|
||
|
selectedElement.id = element.value.id;
|
||
|
selectedElement.label = element.value.label;
|
||
|
this.selectedProfiles.push(selectedElement)
|
||
|
})
|
||
|
|
||
|
this.dialogRef.close(this.selectedProfiles);
|
||
|
}
|
||
|
}
|