2017-10-23 15:09:50 +02:00
|
|
|
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
|
|
|
|
import { ServerService } from '../../app/services/server.service';
|
|
|
|
import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown';
|
|
|
|
import { Param } from '../entities/model/param';
|
|
|
|
import { Dataset } from '../entities/model/dataset';
|
2017-10-24 11:49:02 +02:00
|
|
|
import { Project } from '../entities/model/project';
|
2017-10-23 15:09:50 +02:00
|
|
|
import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4';
|
2017-10-24 11:49:02 +02:00
|
|
|
declare var jquery:any;
|
|
|
|
declare var $ :any;
|
2017-10-23 15:09:50 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'modal',
|
|
|
|
templateUrl: './modal.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ModalComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input() datasetDropDown: DropdownField;
|
|
|
|
@Input() dataSetVisibe:boolean;
|
|
|
|
@Input() datasets: Dataset[];
|
2017-10-24 11:49:02 +02:00
|
|
|
@Input() project: Project;
|
2017-10-23 15:09:50 +02:00
|
|
|
datasetResource :DataTableResource<Dataset>;
|
|
|
|
@Input() datasetCount = 0;
|
2017-10-24 11:49:02 +02:00
|
|
|
@Input('show-modal') showModal: boolean;
|
|
|
|
|
2017-10-23 15:09:50 +02:00
|
|
|
@ViewChild('modalDmps') modalDmps;
|
|
|
|
|
|
|
|
constructor(private serverService: ServerService) {
|
|
|
|
this.datasetDropDown = new DropdownField();
|
|
|
|
this.datasetDropDown.options = [];
|
|
|
|
this.dataSetVisibe= false;
|
|
|
|
this.datasets = [];
|
2017-10-24 11:49:02 +02:00
|
|
|
this.project = new Project();
|
2017-10-23 15:09:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
this.serverService.listDmpsLabelID().subscribe(
|
|
|
|
response => {
|
|
|
|
console.log("response");
|
|
|
|
console.log(response);
|
|
|
|
//let params = new Param();
|
|
|
|
response.forEach((dmp) => {
|
|
|
|
let params = new Param();
|
|
|
|
params.key = dmp.id;
|
|
|
|
params.value = dmp.label;
|
|
|
|
this.datasetDropDown.options.push(params);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-24 11:49:02 +02:00
|
|
|
show(gridRow){
|
|
|
|
this.project.label = gridRow.label;
|
|
|
|
this.project.abbreviation = gridRow.abbreviation;
|
|
|
|
this.project.uri = gridRow.uri;
|
|
|
|
$("#exampleModalDmps").modal("show");
|
|
|
|
}
|
|
|
|
|
2017-10-23 15:09:50 +02:00
|
|
|
showDatasets(dmpId, event) {
|
|
|
|
debugger;
|
|
|
|
this.dataSetVisibe = true;
|
|
|
|
this.serverService.getAllDatasets().subscribe(
|
|
|
|
response => {
|
|
|
|
console.log("response");
|
|
|
|
console.log(response);
|
|
|
|
//let params = new Param();
|
|
|
|
response.forEach((dataset) => {
|
|
|
|
let dt = new Dataset();
|
|
|
|
dt.id = dataset.id;
|
|
|
|
dt.name = dataset.label;
|
|
|
|
dt.uriDataset = dataset.uri;
|
|
|
|
this.datasets.push(dt);
|
|
|
|
var params = { limit: 8, offset: 0, sortAsc: false }
|
|
|
|
this.afterLoad();
|
|
|
|
this.datasetResource.query(params).then(datasets => this.datasets = datasets);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
afterLoad(){
|
|
|
|
this.datasetResource = new DataTableResource(this.datasets);
|
|
|
|
this.datasetResource.count().then(count => this.datasetCount = count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|