show dataset, create, save

This commit is contained in:
annampak 2017-10-27 17:08:10 +03:00
parent d30b6db7b2
commit 7b5f032c1d
7 changed files with 158 additions and 24 deletions

View File

@ -6,6 +6,8 @@ import { Project } from '../entities/model/project';
import { Dataset } from '../entities/model/dataset'; import { Dataset } from '../entities/model/dataset';
import { Dmp } from '../entities/model/dmp'; import { Dmp } from '../entities/model/dmp';
import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4'; import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4';
import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown';
import { Param } from '../entities/model/param';
@Component({ @Component({
selector: 'datasets-table', selector: 'datasets-table',
@ -31,9 +33,12 @@ export class DatasetsComponent implements OnInit{
returnUrl: string; returnUrl: string;
@Input() datasets: Dataset[]; @Input() datasets: Dataset[];
@Input() datasetProfileDropDown: DropdownField;
datasetResource :DataTableResource<Dataset>; datasetResource :DataTableResource<Dataset>;
@Input() datasetCount = 0; @Input() datasetCount = 0;
@Input() dmpIdforDatasets: string;
dataset:any;
@ViewChild(DataTable) projectsTable; @ViewChild(DataTable) projectsTable;
dataSetValue:boolean dataSetValue:boolean
@ -54,13 +59,26 @@ export class DatasetsComponent implements OnInit{
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private ngZone: NgZone){ private ngZone: NgZone){
this.dataset = {
id:null,
label:'',
reference:'',
uri:'',
properties:'',
profile:{"id": ''},
dmp:{"id": ''}
}
this.datasetProfileDropDown = new DropdownField();
this.datasetProfileDropDown.options = [];
} }
ngOnInit() { ngOnInit() {
//this.projects = this.serverService.getDummyProjects(); //this.projects = this.serverService.getDummyProjects();
this.datasets = []; this.datasets = [];
this.serverService.getAllDataSet().subscribe( console.log(this.dmpIdforDatasets);
this.serverService.getDatasetForDmp({"id":this.dmpIdforDatasets}).subscribe(
response => { response => {
console.log("response"); console.log("response");
@ -77,7 +95,22 @@ export class DatasetsComponent implements OnInit{
this.datasetResource.query(params).then(datasets => this.datasets = datasets); this.datasetResource.query(params).then(datasets => this.datasets = datasets);
}); });
} }
); );
this.serverService.getAllDatsetsProfile().subscribe(
response => {
console.log("response");
console.log(response);
//let params = new Param();
response.forEach((datasetprofile) => {
let params = new Param();
params.key = datasetprofile.id;
params.value = datasetprofile.label;
this.datasetProfileDropDown.options.push(params);
});
}
)
} }
reloadDatasets(params) { reloadDatasets(params) {
@ -94,6 +127,16 @@ rowClick(rowEvent){
this.ngZone.run(() => this.router.navigateByUrl('dynamic-form', rowEvent.row.item.id)); this.ngZone.run(() => this.router.navigateByUrl('dynamic-form', rowEvent.row.item.id));
} }
SaveNewDataset(){debugger;
this.dataset.dmp={"id": this.dmpIdforDatasets}
this.dataset.profile = {"id": this.dataset.profile}
this.serverService.createDatasetForDmp(this.dataset).subscribe(
response=>{
console.log(response);
}
)
}
// special params: // special params:
translations = <DataTableTranslations>{ translations = <DataTableTranslations>{
indexColumn: 'Index column', indexColumn: 'Index column',

View File

@ -15,10 +15,65 @@
</data-table-column> --> </data-table-column> -->
</data-table> </data-table>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<button type="button" class="btn btn-info">New Dataset</button> <button type="button" class="btn btn-info" data-toggle="modal" data-target="#newDatasetModal">New Dataset</button>
<!-- <b>Selected:</b> <!-- <b>Selected:</b>
<span *ngIf="projectsTable.selectedRow == null"><i>No item selected</i></span> <span *ngIf="projectsTable.selectedRow == null"><i>No item selected</i></span>
<span [textContent]="projectsTable.selectedRow && projectsTable.selectedRow.item.name"></span> --> <span [textContent]="projectsTable.selectedRow && projectsTable.selectedRow.item.name"></span> -->
</div> </div>
</div>
<div class="modal fade" id="newDatasetModal" tabindex="-1" role="dialog" aria-labelledby="newDatasetModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Create New DMP</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form #newProjectForm="ngForm" (ngSubmit)="SaveNewDmp()">
<div class="form-group">
<label for="recipient-name" class="col-form-label">Dataset Profile:</label>
<select class="form-control" [id]="datasetProfileDropDownKey" [(ngModel)]="dataset.profile" [name]="datasetProfileDropDown" #datasetfield>
<option *ngFor="let opt of datasetProfileDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select>
</div>
<div class="form-group">
<label for="label-name" class="form-control-label">Label:</label>
<input type="text" class="form-control" id="label-name" [(ngModel)]= "dataset.label" name = "label">
</div>
<!-- <div class="form-group">
<label for="abbreviation-text" class="form-control-label">Abbreviation:</label>
<input class="form-control" id="abbreviation-text" [(ngModel)]= "dataset.abbreviation" name = "abbreviation">
</div> -->
<div class="form-group">
<label for="reference-text" class="form-control-label">Reference:</label>
<input class="form-control" id="reference-text" [(ngModel)]= "dataset.reference" name = "reference">
</div>
<div class="form-group">
<label for="uri-text" class="form-control-label">Uri:</label>
<input class="form-control" id="uri-text" [(ngModel)]= "dataset.uri" name = "uri">
</div>
<!-- <div class="form-group">
<label for="start-date" class="form-control-label">Start Date:</label>
<input class="form-control" id="startDate-date" [(ngModel)]= "dataset.startDate" name = "startDate">
</div>
<div class="form-group">
<label for="end-date" class="form-control-label">End Date:</label>
<input class="form-control" id="endDate-date" [(ngModel)]= "dataset.endDate" name = "endDate">
</div> -->
<div class="form-group">
<label for="code-name" class="form-control-label">Code:</label>
<input type="text" class="form-control" id="code-name" disabled>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" (click)="SaveNewDataset();">Save Dmp</button>
</div>
</div>
</div>
</div> </div>

View File

@ -13,6 +13,8 @@ import { HttpErrorResponse } from '@angular/common/http';
import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
declare var $ :any;
@Component({ @Component({
selector: 'dmps', selector: 'dmps',
templateUrl: 'dmps.html', templateUrl: 'dmps.html',
@ -23,9 +25,10 @@ export class DmpComponent implements OnInit{
@Input() dmps: Dmp[]; @Input() dmps: Dmp[];
dmp:any; dmp:any;
dmpResource :DataTableResource<Dmp>; dmpResource :DataTableResource<Dmp>;
dmpIdforDatasets: string;
@Input() dmpCount = 0; @Input() dmpCount = 0;
@Input() projectsDropDown:DropdownField; @Input() projectsDropDown:DropdownField;
//@Input() dataSetVisibe:boolean; @Input() dataSetVisibe:boolean;
@Input() projects: Project[]; @Input() projects: Project[];
@ViewChild(DataTable) dmpsTable; @ViewChild(DataTable) dmpsTable;
@ -36,7 +39,7 @@ export class DmpComponent implements OnInit{
private serverService: ServerService, private serverService: ServerService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router){ private router: Router){
this.projectsDropDown = new DropdownField(); this.projectsDropDown = new DropdownField();
this.projectsDropDown.options = []; this.projectsDropDown.options = [];
this.projects = []; this.projects = [];
this.dmp = { this.dmp = {
@ -56,14 +59,15 @@ export class DmpComponent implements OnInit{
this.dmps = []; this.dmps = [];
this.serverService.getDmpOfUser().subscribe( this.serverService.getDmpOfUser().subscribe(
response => { response => {
debugger; console.log(response);
response.forEach(resp => { response.forEach(resp => {
let pr = new Dmp(); let dmp = new Dmp();
pr.id = resp.id; dmp.id = resp.id;
pr.id = resp.label; dmp.label = resp.label;
pr.name = resp.abbreviation; dmp.version = resp.version;
pr.dataset = resp.definition; dmp.dataset = resp.dataset;
this.dmps.push(pr); dmp.projectLabel = resp.project.label;
this.dmps.push(dmp);
var params = {limit:8,offset:0, sortAsc:false} var params = {limit:8,offset:0, sortAsc:false}
this.afterLoad(); this.afterLoad();
this.dmpResource.query(params).then(dmps => this.dmps = dmps); this.dmpResource.query(params).then(dmps => this.dmps = dmps);
@ -159,5 +163,18 @@ signOut() {
    this.serverService.logOut();     this.serverService.logOut();
} }
selectDmp(rowEvent){
this.dmpIdforDatasets = rowEvent.row.item.id;
this.dataSetVisibe = true;
}
editRow(dmp){
this.dmp.label = this.dmp.label;
this.dmp.abbreviation = this.dmp.abbreviation;
this.dmp.uri = this.dmp.uri;
this.dmp.id = this.dmp.id;
$("#newDmpModal").modal("show");
}
} }

View File

@ -7,10 +7,12 @@
</div> </div>
<data-table id="dmps-grid" headerTitle="My Dmps" [items]="dmps" [itemCount]="dmpCount" (reload)="reloadDmps($event)" <data-table id="dmps-grid" headerTitle="My Dmps" [items]="dmps" [itemCount]="dmpCount" (reload)="reloadDmps($event)"
[limit]="8" [sortBy]="'rating'" [sortAsc]="false" [selectColumn]="true" [multiSelect]="false" [substituteRows]="false" [limit]="8" [sortBy]="'rating'" [sortAsc]="false" [selectColumn]="true" [multiSelect]="false" [substituteRows]="false"
[expandableRows]="true" [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true"> [expandableRows]="true" [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true" (rowClick)="selectDmp($event)">
<data-table-column [property]="'label'" [header]="'Label'" [sortable]="true"> <data-table-column [property]="'label'" [header]="'Label'" [sortable]="true">
</data-table-column> </data-table-column>
<data-table-column [property]="'projectLabel'" [header]="'project'" [sortable]="true">
</data-table-column>
<data-table-column [property]="'abbreviation'" [header]="'Abbreviation'" [sortable]="true"> <data-table-column [property]="'abbreviation'" [header]="'Abbreviation'" [sortable]="true">
</data-table-column> </data-table-column>
<data-table-column [property]="'startDate'" [header]="'Start Date'" [sortable]="true"> <data-table-column [property]="'startDate'" [header]="'Start Date'" [sortable]="true">
@ -42,7 +44,7 @@
<!-- <span *ngIf="dmpsTable.selectedRow == null"><i>No item selected</i></span> <!-- <span *ngIf="dmpsTable.selectedRow == null"><i>No item selected</i></span>
<span [textContent]="dmpsTable.selectedRow && dmpsTable.selectedRow.item.name"></span> --> <span [textContent]="dmpsTable.selectedRow && dmpsTable.selectedRow.item.name"></span> -->
</div> </div>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal">New Dmp</button> <button type="button" class="btn btn-info" data-toggle="modal" data-target="#newDmpModal">New Dmp</button>
<!-- <select class="form-control" [id]="datasetDropDownKey" [(ngModel)]="datasetDropDownKey"> <!-- <select class="form-control" [id]="datasetDropDownKey" [(ngModel)]="datasetDropDownKey">
<option *ngFor="let opt of datasetDropDown.options" [value]="opt.key">{{opt.value}}</option> <option *ngFor="let opt of datasetDropDown.options" [value]="opt.key">{{opt.value}}</option>
@ -51,7 +53,7 @@
</div> </div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="newDmpModal" tabindex="-1" role="dialog" aria-labelledby="newDmpModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -110,7 +112,7 @@
<!-- <modal *ngIf="item && show" [(show)]="show" [item]="item" [(dataSetVisibe)]="dataSetVisibe"></modal> --> <!-- <modal *ngIf="item && show" [(show)]="show" [item]="item" [(dataSetVisibe)]="dataSetVisibe"></modal> -->
<!--DATASET TABLE--> <!--DATASET TABLE-->
<!--<datasets-table *ngIf="dataSetVisibe" [(dataSetVisibe)]="dataSetVisibe"></datasets-table> *ngIf="dataSetVisibe == true"--> <datasets-table *ngIf="dataSetVisibe" [dmpIdforDatasets]= "dmpIdforDatasets"></datasets-table>
<a href="#" (click)="signOut();" #isignOutBtn >Sign out</a> <a href="#" (click)="signOut();" #isignOutBtn >Sign out</a>
<router-outlet></router-outlet> <router-outlet></router-outlet>

View File

@ -3,5 +3,11 @@ import { Injectable } from '@angular/core';
export class Dmp { export class Dmp {
id:string; id:string;
dataset: string; dataset: string;
name: string; label: string;
organisations:string;
previous:string;
profile:string;
profileData:string;
projectLabel:string;
version: number;
} }

View File

@ -15,17 +15,17 @@ export class RestBase {
this.xml2jsonOBJ = new X2JS(); this.xml2jsonOBJ = new X2JS();
} }
/*
protocol: string = "http"; protocol: string = "http";
hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";// hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";//
port: number = 8080;//8080;// port: number = 8080;//8080;//
webappname: string = "dmp-backend";//"dmp-backend-new";// webappname: string = "dmp-backend";//"dmp-backend-new";//
*/
protocol: string = "http"; /* protocol: string = "http";
hostname: string = "dionysus.di.uoa.gr" ; hostname: string = "dionysus.di.uoa.gr" ;
port: number = 7070; port: number = 7070;
webappname: string = "dmp-backend"; webappname: string = "dmp-backend";*/
proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/"; proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/";

View File

@ -106,10 +106,21 @@ export class ServerService {
public createDmpForCurrentUser(data:any){ public createDmpForCurrentUser(data:any){
debugger; return this.restBase.post("dmp/createofuser", data);
return this.restBase.post("dmp/createofuser", data);
} }
public getDatasetForDmp(data:any){
return this.restBase.post("/dmp/getdatasets", data);
}
public createDatasetForDmp(data:any){debugger;
return this.restBase.post("dataset/create", data);
}
public getAllDatsetsProfile(){
return this.restBase.get("datasetprofile/getAll");
}
logOut() { logOut() {