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

View File

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