2017-10-25 15:17:16 +02:00
|
|
|
import { Component, OnInit, Input, ViewChild, NgZone ,Output ,EventEmitter} from '@angular/core';
|
2017-10-18 18:30:39 +02:00
|
|
|
import {GoogleSignInSuccess} from 'angular-google-signin';
|
|
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
|
|
import { ServerService } from '../../app/services/server.service';
|
|
|
|
import { Project } from '../entities/model/project';
|
2017-10-18 20:30:55 +02:00
|
|
|
import { Dataset } from '../entities/model/dataset';
|
2017-10-27 10:34:05 +02:00
|
|
|
import { Dmp } from '../entities/model/dmp';
|
2017-10-18 18:30:39 +02:00
|
|
|
import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4';
|
|
|
|
|
|
|
|
@Component({
|
2017-10-23 15:09:50 +02:00
|
|
|
selector: 'datasets-table',
|
2017-10-18 18:30:39 +02:00
|
|
|
templateUrl: 'dataset.html',
|
|
|
|
// template: `
|
|
|
|
// <h1 class="title">Projects</h1>
|
|
|
|
|
|
|
|
// <ul class="list-group col-md-4">
|
|
|
|
// <li *ngFor="let project of projects"
|
|
|
|
// class="list-group-item">
|
|
|
|
// <a [routerLink]="['/dynamic-form', project.id]" >
|
|
|
|
// {{ project.name }}
|
|
|
|
// </a>
|
|
|
|
// </li>
|
|
|
|
// </ul>
|
|
|
|
|
|
|
|
// <router-outlet></router-outlet>
|
|
|
|
// `,
|
|
|
|
providers: [ServerService]
|
|
|
|
})
|
|
|
|
|
|
|
|
export class DatasetsComponent implements OnInit{
|
2017-10-18 20:30:55 +02:00
|
|
|
|
2017-10-18 18:30:39 +02:00
|
|
|
returnUrl: string;
|
2017-10-18 20:30:55 +02:00
|
|
|
@Input() datasets: Dataset[];
|
|
|
|
datasetResource :DataTableResource<Dataset>;
|
|
|
|
@Input() datasetCount = 0;
|
2017-10-18 18:30:39 +02:00
|
|
|
|
|
|
|
@ViewChild(DataTable) projectsTable;
|
|
|
|
|
2017-10-25 15:17:16 +02:00
|
|
|
dataSetValue:boolean
|
|
|
|
@Input()
|
|
|
|
get dataSetVisibe(){
|
|
|
|
return this.dataSetValue;
|
|
|
|
}
|
|
|
|
@Output()
|
|
|
|
public dataSetValueChange = new EventEmitter();
|
|
|
|
|
|
|
|
set dataSetVisibe(value:any){
|
|
|
|
this.dataSetValue = value
|
|
|
|
this.dataSetValueChange.emit(this.dataSetValue)
|
|
|
|
}
|
|
|
|
|
2017-10-18 18:30:39 +02:00
|
|
|
constructor(
|
|
|
|
private serverService: ServerService,
|
|
|
|
private route: ActivatedRoute,
|
2017-10-18 20:30:55 +02:00
|
|
|
private router: Router,
|
|
|
|
private ngZone: NgZone){
|
2017-10-18 18:30:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
//this.projects = this.serverService.getDummyProjects();
|
2017-10-18 20:30:55 +02:00
|
|
|
this.datasets = [];
|
2017-10-25 15:17:16 +02:00
|
|
|
this.serverService.getAllDataSet().subscribe(
|
2017-10-18 18:30:39 +02:00
|
|
|
response => {
|
|
|
|
|
|
|
|
console.log("response");
|
|
|
|
console.log(response);
|
|
|
|
response.forEach(resp => {
|
2017-10-18 20:30:55 +02:00
|
|
|
|
|
|
|
let dt = new Dataset();
|
|
|
|
dt.id = resp.id;
|
|
|
|
dt.name = resp.label;
|
|
|
|
dt.uriDataset = resp.uri;
|
|
|
|
this.datasets.push(dt);
|
2017-10-18 18:30:39 +02:00
|
|
|
var params = {limit:8,offset:0, sortAsc:false}
|
|
|
|
this.afterLoad();
|
2017-10-18 20:30:55 +02:00
|
|
|
this.datasetResource.query(params).then(datasets => this.datasets = datasets);
|
2017-10-18 18:30:39 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-10-18 20:30:55 +02:00
|
|
|
reloadDatasets(params) {
|
2017-10-23 15:09:50 +02:00
|
|
|
this.datasetResource = new DataTableResource(this.datasets);
|
2017-10-18 20:30:55 +02:00
|
|
|
this.datasetResource.query(params).then(projects => this.datasets = projects);
|
2017-10-18 18:30:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
afterLoad(){
|
2017-10-18 20:30:55 +02:00
|
|
|
this.datasetResource = new DataTableResource(this.datasets);
|
|
|
|
this.datasetResource.count().then(count => this.datasetCount = count);
|
|
|
|
}
|
|
|
|
|
|
|
|
rowClick(rowEvent){
|
|
|
|
this.ngZone.run(() => this.router.navigateByUrl('dynamic-form', rowEvent.row.item.id));
|
2017-10-18 18:30:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// special params:
|
|
|
|
translations = <DataTableTranslations>{
|
|
|
|
indexColumn: 'Index column',
|
|
|
|
expandColumn: 'Expand column',
|
|
|
|
selectColumn: 'Select column',
|
|
|
|
paginationLimit: 'Max results',
|
|
|
|
paginationRange: 'Result range'
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|