Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot

This commit is contained in:
annampak 2017-11-01 14:01:24 +02:00
commit c09cd7305c
2 changed files with 45 additions and 75 deletions

View File

@ -26,7 +26,7 @@ declare var $ :any;
export class DmpComponent implements OnInit{ export class DmpComponent implements OnInit{
// Start ALTERNATIVE // Start ALTERNATIVE
//whole dmp data model //whole dmp data model
tableData : any[] = new Array(); tableData : any[] = new Array();
@ -52,12 +52,12 @@ export class DmpComponent implements OnInit{
@Input() dmps: Dmp[]; //@Input() dmps: Dmp[];
dmp:any; dmp:any;
@Input() dmpCount = 0; @Input() dmpCount = 0;
@Input() projectsDropDown:DropdownField; @Input() projectsDropDown:DropdownField;
@Input() dataSetVisibe:boolean; @Input() dataSetVisibe:boolean;
@Input() projects: Project[]; //@Input() projects: Project[];
dmpIdforDatasets: string; dmpIdforDatasets: string;
dmpLabelforDatasets:string; dmpLabelforDatasets:string;
@ViewChild(DatasetsComponent) datasetsComponent:DatasetsComponent; @ViewChild(DatasetsComponent) datasetsComponent:DatasetsComponent;
@ -82,8 +82,9 @@ export class DmpComponent implements OnInit{
label: '', label: '',
previous:'', previous:'',
version:'', version:'',
profileData:'', profileData:''
profile:'' //,
//profile:{}
} }
} }
@ -92,46 +93,21 @@ export class DmpComponent implements OnInit{
gapi.load('auth2', function() { gapi.load('auth2', function() {
gapi.auth2.init({}); gapi.auth2.init({});
}); });
this.dmps = [];
this.serverService.getDmpOfUser().subscribe( this.serverService.getDmpOfUser().subscribe(
response => { response => {
this.tableData = response; this.tableData = response;
console.log(response); },
response.forEach(resp => { (err: HttpErrorResponse) => {
// let dmp = new Dmp();
// dmp.id = resp.id;
// dmp.label = resp.label;
// dmp.version = resp.version;
// dmp.dataset = resp.dataset;
// dmp.projectLabel = resp.project.label;
// dmp.projectid = resp.project.id;
// dmp.previous = resp.previous;
// dmp.profile = resp.profile;
// dmp.profileData = resp.profileData;
// this.dmps.push(dmp);
// var params = {limit:8,offset:0, sortAsc:false}
//this.afterLoad();
//this.dmpResource.query(params).then(dmps => this.dmps = dmps);
}
);
(err: HttpErrorResponse) => {debugger;
if (err.error instanceof Error) { if (err.error instanceof Error) {
// A client-side or network error occurred. Handle it accordingly. console.log("An error occurred:", err.error.message);
console.log('An error occurred:', err.error.message);
} else { } else {
// The backend returned an unsuccessful response code. console.log("Backend returned code ${err.status}, body was: ${err.error}");
// The response body may contain clues as to what went wrong,
if(err.status == 401){
this.isignOutBtn.nativeElement.click();
}
console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
} }
} }
}); );
this.serverService.getAllProjects().subscribe( this.serverService.getAllProjects().subscribe(
response => { response => {
console.log("response");
console.log(response); console.log(response);
//let params = new Param(); //let params = new Param();
response.forEach((dmp) => { response.forEach((dmp) => {
@ -141,63 +117,57 @@ export class DmpComponent implements OnInit{
this.projectsDropDown.options.push(params); this.projectsDropDown.options.push(params);
}); });
},
(err: HttpErrorResponse) => {
} }
) )
} }
CallDmps(){
getDmps(){
this.serverService.getDmpOfUser().subscribe( this.serverService.getDmpOfUser().subscribe(
response => { response => {
response.forEach(resp => { this.tableData = response;
let dmp = new Dmp(); },
dmp.id = resp.id; (err: HttpErrorResponse) => {
dmp.label = resp.label; if (err.error instanceof Error) {
dmp.version = resp.version; console.log("An error occurred:", err.error.message);
dmp.dataset = resp.dataset; } else {
dmp.projectLabel = resp.project.label; console.log("Backend returned code ${err.status}, body was: ${err.error}");
this.dmps.push(dmp); }
var params = {limit:8,offset:0, sortAsc:false} }
//this.afterLoad(); );
//this.dmpResource.query(params).then(dmps => this.dmps = dmps);
}
);
});
} }
SaveNewDmp(){ newDMP(){
console.log(this.dmp, this.dmp.projectsDropDownKey); console.log(this.dmp, this.dmp.projectsDropDownKey);
//this.http.post('http://someurl', JSON.stringify(this.project))
this.dmp.project = {"id":this.dmp.project}; this.dmp.project = {"id" : this.dmp.project};
this.dmp["version"] = 1; this.dmp["version"] = 1;
//this.dmp.profile = {};
this.serverService.createDmpForCurrentUser(this.dmp) this.serverService.createDmpForCurrentUser(this.dmp)
.subscribe( .subscribe(
response =>{ response =>{
console.log("response"); this.getDmps();
console.log(response);
this.dmps = [];
this.CallDmps();
} }
); );
$("#newDmpModal").modal("hide"); $("#newDmpModal").modal("hide");
} }
SaveUpdatesDmp(){ updateDMP(){
console.log(this.dmp, this.dmp.projectsDropDownKey); console.log(this.dmp, this.dmp.projectsDropDownKey);
//this.http.post('http://someurl', JSON.stringify(this.project))
this.dmp.project = {"id":this.dmp.project}; this.dmp.project = {"id":this.dmp.project};
this.dmp["version"] = 1;
this.serverService.updateDmpForCurrentUser(this.dmp)
this.serverService.updateDmp(this.dmp)
.subscribe( .subscribe(
response =>{ response =>{
console.log("response"); console.log("response");
console.log(response); console.log(response);
this.dmps = [];
this.CallDmps();
} }
); );
$("#newDmpModal").modal("hide"); $("#newDmpModal").modal("hide");
@ -205,16 +175,14 @@ SaveUpdatesDmp(){
} }
SaveDmp(){ debugger; SaveDmp(){
debugger;
if (this.dmp.id == null) if (this.dmp.id == null)
this.SaveNewDmp(); this.newDMP();
else else
this.SaveUpdatesDmp(); this.updateDMP();
} }
signOut() {
    this.serverService.logOut();
}
selectDmp(item){ selectDmp(item){
this.dmpIdforDatasets = item.id; this.dmpIdforDatasets = item.id;
@ -265,7 +233,8 @@ newDmp(item){
} }
refreshTable(){ refreshTable(){
this.CallDmps(); this.getDmps();
} }
} }

View File

@ -103,9 +103,10 @@ export class ServerService {
return this.restBase.post("dmp/createofuser", data); return this.restBase.post("dmp/createofuser", data);
} }
public updateDmpForCurrentUser(data:any){ public updateDmp(data:any){
return this.restBase.post("dmp/update", data); return this.restBase.post("dmp/update", data);
} }
public getDatasetForDmp(data:any){ public getDatasetForDmp(data:any){
return this.restBase.post("dmp/getdatasets", data); return this.restBase.post("dmp/getdatasets", data);