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

This commit is contained in:
annampak 2017-10-17 12:15:10 +03:00
commit 2f7d0a2e73
6 changed files with 48 additions and 21 deletions

View File

@ -17,7 +17,9 @@
<a href="#" class="pull-right need-help">Need help? </a><span class="clearfix"></span>
</form>
<!--
<p>Form value: {{ nativeLoginForm.value | json }}</p>
-->
<a href="#" class="text-center new-account">Create an account </a>
</div>

View File

@ -18,7 +18,7 @@ export class NativeLoginService implements OnInit {
login(username, password){
var credentials = {"username": username, "password":password};
return this.restBase.post("nativeLogin", credentials);
return this.restBase.login("nativeLogin", credentials);
}

View File

@ -22,9 +22,13 @@ export class RestBase {
restpath: string = "rest";
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/";
restBasePath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/"+this.restpath+"/";
public login(path : string, data : any){
return this.http.post<any>(this.loginPath + path, JSON.stringify(data));
}
public get(path : string){
var options = this.createOptions();
@ -32,7 +36,7 @@ export class RestBase {
}
public post (path : string, data : any){
public post(path : string, data : any){
var options = this.createOptions();
return this.http.post<any>(this.restBasePath + path, JSON.stringify(data), options);
}

View File

@ -12,6 +12,9 @@ import { DataModel } from '../entities/DataModel';
import { GroupBase } from './dynamic-form-group/group-base';
import { PaginationService } from '../../app/services/pagination.service';
import './../../assets/xml2json.min.js';
declare var X2JS: any;
@Component({
selector: 'dynamic-form',
templateUrl: './dynamic-form.component.html',
@ -27,10 +30,12 @@ export class DynamicFormComponent implements OnInit {
@Input() pagination: any = {};
private fragment: string;
xml2jsonOBJ: any;
constructor(private qcs: FieldControlService, private serverService: ServerService, private dataModelService: dataModelBuilder, private router: Router,
private route: ActivatedRoute, private pagerService: PaginationService) {
this.form = this.qcs.toFormGroup(new Array(), new Array());
this.xml2jsonOBJ = new X2JS();
}
getSubForm(subformName) {
@ -45,12 +50,23 @@ export class DynamicFormComponent implements OnInit {
console.log("DynamicFormComponent.ngOnInit() -- RUNNIGN");
let id = this.route.snapshot.paramMap.get('id'); //get the project id
this.serverService.getData()
.subscribe(
(data: any[]) => {
this.serverService.getData().subscribe(
response => {
console.log("response");
console.log(response);
const data = response;
//replace the xmls {model,view,rule} definitions with json -- https://github.com/abdmob/x2js library
data.dataset.profile.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.definition);
data.dataset.profile.ruleset.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.ruleset.definition);
data.dataset.profile.viewstyle.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.viewstyle.definition);
//can be converted back to xml (which shouldn't be needed) with this.xml2jsonOBJ.json2xml_str
console.log("this.serverService.getFields");
this.dataModel = new DataModel();
this.dataModel = this.dataModelService.getDataModel(data);
@ -92,9 +108,13 @@ export class DynamicFormComponent implements OnInit {
// initialize to page 1
this.setPage(1);
},
(error) => console.log(error)
);
err => {
console.log("There was an error fetching the data from server");
console.log(err);
}
);
}

View File

@ -57,7 +57,7 @@ export class LoginComponent implements OnInit{
//this.router.navigateByUrl('dynamic-form');
this.ngZone.run(() => this.router.navigateByUrl('projects'));
//this.router.navigate(['/projects']);

View File

@ -1,7 +1,5 @@
import {Injectable, ReflectiveInjector, Injector} from '@angular/core';
import {Headers, Http, Response} from '@angular/http';
import { HttpClient , HttpHeaders, HttpParams} from '@angular/common/http';
import 'rxjs/Rx';
import {FieldBase} from '../../app/form/fields/field-base';
import {JsonObjest} from '../../app/entities/JsonObject.class';
import {dataModelBuilder} from '../../app/services/dataModelBuilder.service';
@ -10,9 +8,9 @@ import {DataModel} from '../entities/DataModel';
import {Project} from '../entities/model/project';
import {LoginComponent} from '../../app/login/login-page';
import { TokenService, TokenProvider } from './token.service';
import 'rxjs/Rx';
import './../../assets/xml2json.min.js';
declare var X2JS: any;
@Injectable()
@ -32,27 +30,30 @@ export class ServerService {
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364';
*/
data: any;
//data: any;
constructor(private http: Http, private tokenService: TokenService) { //private http: Http
constructor(private httpClient: HttpClient, private tokenService: TokenService) { //private http: Http
this.xml2jsonOBJ = new X2JS();
}
getData() {
if(this.data != null)
return this.data; //use the already loaded one
//let headers = new HttpHeaders();
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
console.log("google-token: "+ this.tokenService.getToken());
console.log("google-token: "+ this.tokenService.getToken());
return this.httpClient.get<any>(this.fetchURL);
/*
return this.http.get(this.fetchURL)
.map(
(response: Response) => {
const data = response.json();
console.log("response");
console.log(response);
const data = response.json();
//replace the xmls {model,view,rule} definitions with json -- https://github.com/abdmob/x2js library
data.dataset.profile.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.definition);
@ -64,7 +65,7 @@ console.log("google-token: "+ this.tokenService.getToken());
return data;
}
);
*/
}