dataset page , getDataset rest-base urls

This commit is contained in:
annampak 2017-10-18 21:30:55 +03:00
parent 1d4878ae4d
commit ab5d169e77
8 changed files with 59 additions and 74 deletions

View File

@ -1,8 +1,9 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Component, OnInit, Input, ViewChild, NgZone } from '@angular/core';
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';
import { Dataset } from '../entities/model/dataset';
import { Dmp } from '../entities/model/Dmp';
import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4';
@ -29,54 +30,54 @@ import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-d
export class DatasetsComponent implements OnInit{
returnUrl: string;
@Input() projects: Project[];
projectResource :DataTableResource<Project>;
@Input() projectCount = 0;
@Input() datasets: Dataset[];
datasetResource :DataTableResource<Dataset>;
@Input() datasetCount = 0;
@ViewChild(DataTable) projectsTable;
constructor(
private serverService: ServerService,
private route: ActivatedRoute,
private router: Router){
private router: Router,
private ngZone: NgZone){
}
ngOnInit() {
//this.projects = this.serverService.getDummyProjects();
this.projects = [];
this.serverService.getProjects().subscribe(
this.datasets = [];
this.serverService.getAllDatasets().subscribe(
response => {
console.log("response");
console.log(response);
response.forEach(resp => {
let pr = new Project();
pr.id = resp.id;
pr.name = resp.label;
pr.abbreviation = resp.abbreviation;
pr.definition = resp.definition;
pr.uri = resp.uri;
pr.dmp = new Dmp();
// pr.dmp.id = resp.dmp;
pr.dmp.id = resp.dmp =! null || resp.dmp ==! undefined ? resp.dmp.id : null;
// pr.dmp.dataset = resp.dmp.dataset != null ? resp.dmp.dataset.id: null;
this.projects.push(pr);
let dt = new Dataset();
dt.id = resp.id;
dt.name = resp.label;
dt.uriDataset = resp.uri;
this.datasets.push(dt);
var params = {limit:8,offset:0, sortAsc:false}
this.afterLoad();
this.projectResource.query(params).then(projects => this.projects = projects);
this.datasetResource.query(params).then(datasets => this.datasets = datasets);
});
}
);
}
reloadProjects(params) {
this.projectResource.query(params).then(projects => this.projects = projects);
reloadDatasets(params) {
this.datasetResource.query(params).then(projects => this.datasets = projects);
}
afterLoad(){
this.projectResource = new DataTableResource(this.projects);
this.projectResource.count().then(count => this.projectCount = count);
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));
}
// special params:

View File

@ -1,42 +1,23 @@
<div style="margin: auto; max-width: 1000px; margin-top:50px">
<data-table id="films-grid" headerTitle="My Projects" [items]="projects" [itemCount]="projectCount" (reload)="reloadProjects($event)"
[limit]="8" [sortBy]="'rating'" [sortAsc]="false" [selectColumn]="true" [multiSelect]="false" [substituteRows]="false"
[expandableRows]="true" [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true">
<data-table id="films-grid" headerTitle="Datasets" [items]="datasets" [itemCount]="datasetCount" (reload)="reloadDatasets($event)"
[limit]="8" [sortBy]="'rating'" [sortAsc]="false" [substituteRows]="false"
[expandableRows]="true" [translations]="translations" [selectOnRowClick]="true" (rowClick)="rowClick($event)">
<template #dataTableExpand let-item="item">
<div>
<!-- <a [routerLink]="['/dynamic-form', item.id]"> {{ item.dmp.id }}</a> -->
<table class="table">
<thead class="thead-inverse">
<tr>
<th>Dmp</th>
<th>Id</th>
</tr>
</thead>
<tbody>
<tr>
<!-- <td> <a [routerLink]="['/dynamic-form', item.id]"> {{ item.dmp.id }}</a></td>-->
<td> <a [routerLink]="['/dataset']"> {{ item.dmp.id }}</a></td>
<td>{{item.dmp.id}}</td>
</tr>
</tbody>
</table>
<a [routerLink]="['/dynamic-form', item.id]"> dataset</a>
</div>
</template>
<data-table-column [property]="'name'" [header]="'Label'" [sortable]="true">
</data-table-column>
<data-table-column [property]="'abbreviation'" [header]="'Abbreviation'" [sortable]="true">
</data-table-column>
<!-- <data-table-column [property]="'abbreviation'" [header]="'Abbreviation'" [sortable]="true">
</data-table-column> -->
<data-table-column [property]="'id'" [header]="'Id'" [sortable]="true">
</data-table-column>
<data-table-column [property]="'uri'" [header]="'Uri'" [sortable]="true">
</data-table-column>
<data-table-column [property]="'definition'" [header]="'Definition'" [sortable]="true">
<data-table-column [property]="'uriDataset'" [header]="'Uri'" [sortable]="true">
</data-table-column>
<!-- <data-table-column [property]="'definition'" [header]="'Definition'" [sortable]="true">
</data-table-column> -->
</data-table>
<div style="margin-top: 10px">
<b>Selected:</b>

View File

@ -3,4 +3,5 @@ import { Injectable } from '@angular/core';
export class Dataset {
id:string;
name: string;
uriDataset: string;
}

View File

@ -1,3 +1,4 @@
<div> <a [routerLink]="['/dynamic-form',123]"> dataset</a></div>
<div style="margin: auto; max-width: 1000px; margin-top:50px">
<data-table id="films-grid" headerTitle="My Projects" [items]="projects" [itemCount]="projectCount" (reload)="reloadProjects($event)"
[limit]="8" [sortBy]="'rating'" [sortAsc]="false" [selectColumn]="true" [multiSelect]="false" [substituteRows]="false"

View File

@ -45,7 +45,7 @@ export class ProjectsComponent implements OnInit{
ngOnInit() {
//this.projects = this.serverService.getDummyProjects();
this.projects = [];
this.serverService.getProjects().subscribe(
this.serverService.getAllProjects().subscribe( //getProjects()
response => {
console.log("response");

View File

@ -16,8 +16,8 @@ export class RestBase {
}
protocol: string = "http";
hostname: string = "localhost";//"dl010.madgik.di.uoa.gr";//
port: number = 7070;//8080;//
hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";//
port: number = 8080;//8080;//
webappname: string = "dmp-backend";//"dmp-backend-new";//
@ -48,7 +48,7 @@ export class RestBase {
}
private createOptions(){
private createOptions(){debugger;
var token = this.tokenService.getToken();
var provider: TokenProvider = this.tokenService.getProvider();
//var csrfToken : string = this.tokenService.getCSRFToken();

View File

@ -40,49 +40,49 @@ export class ServerService {
listDatasetIDs(){
public listDatasetIDs(){
return this.restBase.get("dataset");
}
getAllDatasets(){
public getAllDatasets(){
return this.restBase.get("getAllDatasets");
}
getAllDatasetIDs(datasetId: string){
public getAllDatasetIDs(datasetId: string){
return this.restBase.get("dataset/"+datasetId);
}
getAllDmps(){
public getAllDmps(){
return this.restBase.get("dmp/getAll");
}
listDmpsLabelID(){
public listDmpsLabelID(){
return this.restBase.get("dmp/listDMPLabelID");
}
getDmp(dmpid : string){
public getDmp(dmpid : string){
return this.restBase.get("dmps/"+dmpid);
}
listDmpIDs(){
public listDmpIDs(){
return this.restBase.get("dmps");
}
listProjectIDs(){
public listProjectIDs(){
return this.restBase.get("projects");
}
getAllProjects(){
public getAllProjects(){
return this.restBase.get("project/getAll");
}
getProject(projectID : string){
public getProject(projectID : string){
return this.restBase.get("projects/"+projectID);
}
listProjectsLabelID(){
public listProjectsLabelID(){
return this.restBase.get("project/listAllLabelIDs");
}
@ -92,12 +92,13 @@ export class ServerService {
getData() {
//let headers = new HttpHeaders();
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
console.log("google-token: "+ this.tokenService.getToken());
// let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
return this.httpClient.get<any>(this.fetchURL);
// console.log("google-token: "+ this.tokenService.getToken());
// return this.httpClient.get<any>(this.fetchURL);
return this.restBase.get("dmps/9a4a4a57-4d01-465e-9887-254534f31600");
/*
return this.http.get(this.fetchURL)

View File

@ -31,7 +31,7 @@
<div class="panel panel-default" style="margin-top: 30px; margin-bottom: 30px; margin-right: 30px; margin-left: 30px;">
<div class="panel-heading">
<h3 class="panel-title" style="text-align: center;">Digital Management Plans Editor</h3>
<h3 class="panel-title" style="text-align: center;">Digital Management Plan</h3>
</div>
<div class="panel-body">