diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index e5334bf43..0836fb96d 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -8,7 +8,7 @@ import { Dmp } from '../entities/model/Dmp'; import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4'; @Component({ - selector: 'projects', + selector: 'datasets-table', templateUrl: 'dataset.html', // template: ` //

Projects

@@ -68,6 +68,7 @@ export class DatasetsComponent implements OnInit{ } reloadDatasets(params) { + this.datasetResource = new DataTableResource(this.datasets); this.datasetResource.query(params).then(projects => this.datasets = projects); } diff --git a/dmp-frontend/src/app/datasets/dataset.module.ts b/dmp-frontend/src/app/datasets/dataset.module.ts index 7439526e3..3ac3b0f5f 100644 --- a/dmp-frontend/src/app/datasets/dataset.module.ts +++ b/dmp-frontend/src/app/datasets/dataset.module.ts @@ -19,6 +19,9 @@ import { DatasetRoutingModule } from './dataset-routing.module'; DatasetsComponent //ProjectDetailComponent ], - providers: [ ] + providers: [ ], + exports: [ + DatasetsComponent + ] }) export class DatasetsModule {} \ No newline at end of file diff --git a/dmp-frontend/src/app/login/login-page.html b/dmp-frontend/src/app/login/login-page.html index 748752031..56caf9983 100644 --- a/dmp-frontend/src/app/login/login-page.html +++ b/dmp-frontend/src/app/login/login-page.html @@ -27,7 +27,8 @@
Sign in with
- + +
diff --git a/dmp-frontend/src/app/login/login-page.ts b/dmp-frontend/src/app/login/login-page.ts index 8d0b83416..3300ffafb 100644 --- a/dmp-frontend/src/app/login/login-page.ts +++ b/dmp-frontend/src/app/login/login-page.ts @@ -1,23 +1,24 @@ -import { Component, OnInit, NgZone } from '@angular/core'; -import {GoogleSignInSuccess} from 'angular-google-signin'; +import { Component, OnInit, NgZone, AfterViewInit, ElementRef } from '@angular/core'; +import { GoogleSignInSuccess } from 'angular-google-signin'; import { Router, ActivatedRoute } from '@angular/router'; import { TokenService, TokenProvider } from '../services/token.service'; @Component({ selector: 'login-page', templateUrl: './login-page.html', - providers: [] + providers: [] }) -export class LoginComponent implements OnInit{ +export class LoginComponent implements OnInit, AfterViewInit { returnUrl: string; + token: any; - - constructor( + constructor( private route: ActivatedRoute, private router: Router, private ngZone: NgZone, - private tokenService : TokenService - ){ + private tokenService: TokenService, + private element: ElementRef + ) { } @@ -26,41 +27,61 @@ export class LoginComponent implements OnInit{ //this.authenticationService.logout(); // get return url from route parameters or default to '/' - this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; -} - private myClientId: string = '524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com'; + + //this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; + } + //private myClientId: string = '524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com'; + private myClientId: string = '1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com'; - onGoogleSignInSuccess(event: GoogleSignInSuccess) { - let googleUser: gapi.auth2.GoogleUser = event.googleUser; - let id: string = googleUser.getId(); - let profile: gapi.auth2.BasicProfile = googleUser.getBasicProfile(); - this.tokenService.setToken(googleUser.getAuthResponse().id_token); + public auth2: any; - console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead. - console.log('Name: ' + profile.getName()); - console.log('token: ' + this.tokenService.getToken()); - - this.tokenService.setProvider(TokenProvider.google); - this.tokenService.setLoggedIn(true); - this.tokenService.setEmail(profile.getEmail()); - this.tokenService.setUsername(profile.getName()); + private scope = [ + 'profile', + 'email' + ].join(' '); - localStorage.setItem('currentUser', this.tokenService.getToken()); - /* AYTA FEYGOUN, xanontai me to refresh tis selidas - - localStorage.setItem('currentUser', JSON.stringify(googleUser)); - var currentUser = JSON.parse(localStorage.getItem('currentUser')); - console.log('current user local storage:' +currentUser) - */ + public googleInit() { - // STO LOGOUT, KATHARIZEIS TO tokenService (apo opoudipote... e;inai apo pantou prosvasimo, kai den xanei tis times toy oso exeis to browser anoixto.) + gapi.load('auth2', () => {debugger; + this.auth2 = gapi.auth2.init({ + client_id: this.myClientId, + cookie_policy: 'single_host_origin', + scope: this.scope + }); + var buttonElement = this.element.nativeElement.querySelector('#googleBtn'); + this.attachSignin(buttonElement); + }); + } + + public attachSignin(element) {debugger; + this.auth2.attachClickHandler(element, {}, + (googleUser) => { + this.token = googleUser.getAuthResponse().id_token; + + let profile = googleUser.getBasicProfile(); + + this.tokenService.setLoggedIn(true); + this.tokenService.setToken(this.token); + this.tokenService.setProvider(TokenProvider.google); + this.tokenService.setUsername(profile.getName()); + this.tokenService.setEmail(profile.getEmail()); + + this.ngZone.run(() => this.router.navigateByUrl('projects')); + + window.location.reload(); + + }, function (error) { + console.log(JSON.stringify(error, undefined, 2)); + }); + + + + } + + ngAfterViewInit() { + this.googleInit(); + } - - //this.router.navigateByUrl('dynamic-form'); - this.ngZone.run(() => this.router.navigateByUrl('projects')); - //this.router.navigate(['/projects']); - } - } diff --git a/dmp-frontend/src/app/modal/modal.component.ts b/dmp-frontend/src/app/modal/modal.component.ts new file mode 100644 index 000000000..05fffc372 --- /dev/null +++ b/dmp-frontend/src/app/modal/modal.component.ts @@ -0,0 +1,76 @@ +import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core'; +import { ServerService } from '../../app/services/server.service'; +import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; +import { Param } from '../entities/model/param'; +import { Dataset } from '../entities/model/dataset'; +import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4'; + +@Component({ + selector: 'modal', + templateUrl: './modal.html' +}) + +export class ModalComponent implements OnInit { + + @Input() datasetDropDown: DropdownField; + @Input() dataSetVisibe:boolean; + @Input() datasets: Dataset[]; + datasetResource :DataTableResource; + @Input() datasetCount = 0; + + @ViewChild('modalDmps') modalDmps; + + constructor(private serverService: ServerService) { + this.datasetDropDown = new DropdownField(); + this.datasetDropDown.options = []; + this.dataSetVisibe= false; + this.datasets = []; + } + + ngOnInit() { + + this.serverService.listDmpsLabelID().subscribe( + response => { + console.log("response"); + console.log(response); + //let params = new Param(); + response.forEach((dmp) => { + let params = new Param(); + params.key = dmp.id; + params.value = dmp.label; + this.datasetDropDown.options.push(params); + }); + + } + ) + + } + + showDatasets(dmpId, event) { + debugger; + this.dataSetVisibe = true; + this.serverService.getAllDatasets().subscribe( + response => { + console.log("response"); + console.log(response); + //let params = new Param(); + response.forEach((dataset) => { + let dt = new Dataset(); + dt.id = dataset.id; + dt.name = dataset.label; + dt.uriDataset = dataset.uri; + this.datasets.push(dt); + var params = { limit: 8, offset: 0, sortAsc: false } + this.afterLoad(); + this.datasetResource.query(params).then(datasets => this.datasets = datasets); + }); + }); + + } + + afterLoad(){ + this.datasetResource = new DataTableResource(this.datasets); + this.datasetResource.count().then(count => this.datasetCount = count); + } +} + diff --git a/dmp-frontend/src/app/modal/modal.html b/dmp-frontend/src/app/modal/modal.html new file mode 100644 index 000000000..987447324 --- /dev/null +++ b/dmp-frontend/src/app/modal/modal.html @@ -0,0 +1,58 @@ + + + + diff --git a/dmp-frontend/src/app/projects/project.css b/dmp-frontend/src/app/projects/project.css index 320901ed8..526299dad 100644 --- a/dmp-frontend/src/app/projects/project.css +++ b/dmp-frontend/src/app/projects/project.css @@ -7,10 +7,6 @@ background-color: #E4EDF9; } -.fa { - display: inline-block; - font: normal normal normal 14px/1 FontAwesome; - font-size: inherit; - text-rendering: auto; - -webkit-font-smoothing: antialiased; +a.editGridColumn{ + color: #333; } \ No newline at end of file diff --git a/dmp-frontend/src/app/projects/project.html b/dmp-frontend/src/app/projects/project.html index 5d533459d..83205f50a 100644 --- a/dmp-frontend/src/app/projects/project.html +++ b/dmp-frontend/src/app/projects/project.html @@ -1,42 +1,38 @@ -
- + Filter: + +
+ - + - + - + - + + + + + + +
@@ -44,7 +40,69 @@ No item selected
- - - + + + + + + + + + + + + + + +Sign out + \ No newline at end of file diff --git a/dmp-frontend/src/app/projects/project.module.ts b/dmp-frontend/src/app/projects/project.module.ts index 205c44a52..7be3d4a85 100644 --- a/dmp-frontend/src/app/projects/project.module.ts +++ b/dmp-frontend/src/app/projects/project.module.ts @@ -7,17 +7,21 @@ import { ProjectsComponent } from './projects.component'; import { ProjectRoutingModule } from './project-routing.module'; import { ProjectDetailComponent } from './project.detail'; +import { DatasetsModule } from '../datasets/dataset.module'; +import { ModalComponent } from '../modal/modal.component'; @NgModule({ imports: [ CommonModule, FormsModule, ProjectRoutingModule, - DataTableModule + DataTableModule, + DatasetsModule ], declarations: [ ProjectsComponent, - ProjectDetailComponent + ProjectDetailComponent, + ModalComponent ], providers: [ ] }) diff --git a/dmp-frontend/src/app/projects/projects.component.ts b/dmp-frontend/src/app/projects/projects.component.ts index 6781bc5c1..4d52a0263 100644 --- a/dmp-frontend/src/app/projects/projects.component.ts +++ b/dmp-frontend/src/app/projects/projects.component.ts @@ -6,6 +6,10 @@ import { Project } from '../entities/model/project'; import { Dmp } from '../entities/model/Dmp'; import { Dataset } from '../entities/model/dataset'; 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'; +import { ModalComponent } from '../modal/modal.component'; +import { HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'projects', @@ -31,15 +35,24 @@ export class ProjectsComponent implements OnInit{ returnUrl: string; @Input() projects: Project[]; projectResource :DataTableResource; + datasetResource :DataTableResource; @Input() projectCount = 0; + @Input() datasetDropDown:DropdownField; + @Input() dataSetVisibe:boolean; + @Input() datasets: Dataset[]; @ViewChild(DataTable) projectsTable; + @ViewChild(DataTable) datasetsTable; + @ViewChild('isignOutBtn') isignOutBtn; constructor( private serverService: ServerService, private route: ActivatedRoute, private router: Router){ - + this.datasetDropDown = new DropdownField(); + this.datasetDropDown.options = []; + this.dataSetVisibe= false; + this.datasets = []; } ngOnInit() { @@ -48,8 +61,7 @@ export class ProjectsComponent implements OnInit{ this.serverService.getAllProjects().subscribe( //getProjects() response => { - console.log("response"); - console.log(response); + response.forEach(resp => { let pr = new Project(); pr.id = resp.id; @@ -59,19 +71,34 @@ export class ProjectsComponent implements OnInit{ 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.id = resp.dmp =! null ? resp.dmp.id : null; pr.dataset = new Dataset(); - pr.dmp.dataset = resp.dmp.dataset != null ? resp.dmp.dataset.id: null; + pr.dmp.dataset = resp.dmp !=null && resp.dmp.dataset != null ? resp.dmp.dataset.id: null; this.projects.push(pr); var params = {limit:8,offset:0, sortAsc:false} this.afterLoad(); this.projectResource.query(params).then(projects => this.projects = projects); - }); + } + ); + }, + (err: HttpErrorResponse) => {debugger; + if (err.error instanceof Error) { + // A client-side or network error occurred. Handle it accordingly. + 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}`); + } } - ); + ); } - reloadProjects(params) { +reloadProjects(params) { + this.projectResource = new DataTableResource(this.projects); this.projectResource.query(params).then(projects => this.projects = projects); } @@ -80,6 +107,73 @@ afterLoad(){ this.projectResource.count().then(count => this.projectCount = count); } +getDMPs(){ + this.serverService.listDmpsLabelID().subscribe( + response =>{ + console.log("response"); + console.log(response); + //let params = new Param(); + response.forEach((dmp) => { + let params = new Param(); + params.key = dmp.id; + params.value = dmp.label; + this.datasetDropDown.options.push(params); + }); + + } + ) +} + +showDatasets(dmpId, event){debugger; + this.dataSetVisibe = true; + this.serverService.getAllDatasets().subscribe( + response =>{ + console.log("response"); + console.log(response); + //let params = new Param(); + response.forEach((dataset) => { + let dt = new Dataset(); + dt.id = dataset.id; + dt.name = dataset.label; + dt.uriDataset = dataset.uri; + this.datasets.push(dt); + var params = {limit:8,offset:0, sortAsc:false} + this.afterLoad(); + this.datasetResource.query(params).then(datasets => this.datasets = datasets); + }, + (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); + } else { + // The backend returned an unsuccessful response code. + // The response body may contain clues as to what went wrong, + console.log(`Backend returned code ${err.status}, body was: ${err.error}`); + } + } + ); + }); + +} + +myFunction() { + var input, filter, table, tr, td, i; + input = document.getElementById("myInput"); + filter = input.value.toUpperCase(); + table = document.getElementById("projects-grid"); + tr = table.getElementsByTagName("tr"); + for (i = 0; i < tr.length; i++) { + td = tr[i].getElementsByTagName("td")[3]; + if (td) { + if (td.innerText.toUpperCase().indexOf(filter) > -1) { + tr[i].style.display = ""; + } else { + tr[i].style.display = "none"; + } + } + } +} + // special params: translations = { indexColumn: 'Index column', diff --git a/dmp-frontend/src/app/services/dataModelBuilder.service.ts b/dmp-frontend/src/app/services/dataModelBuilder.service.ts index 4e5eccff8..db1ef6ab8 100644 --- a/dmp-frontend/src/app/services/dataModelBuilder.service.ts +++ b/dmp-frontend/src/app/services/dataModelBuilder.service.ts @@ -78,7 +78,7 @@ export class dataModelBuilder { newfield = new CheckBoxField({ label: element.title.__cdata, key: element._id, - value: element.value, + value: false, order: element._ordinal, rules: element.visible.rule != undefined ? element.visible.rule : rule, visible: element._defaultVisibility, @@ -230,21 +230,16 @@ export class dataModelBuilder { fields.find(x => x.key == newAttribute.id).url.url = attr.sources.source.url._value; - + this.restBase.proxy_get(attr.sources.source.url._value).subscribe((data) => { - - - - console.log(data); - newAttribute.sources.forEach(src => { - src.params = new Array(); - data.data.forEach(data => { + console.log(data); + newAttribute.sources.forEach(src => { + src.params = new Array(); + data.data.forEach(data => { let prm = new Param(); - prm.key = data.id; - prm.value = data.attributes.name; - src.params.push(prm); - - + prm.key = data.id; + prm.value = data.attributes.name; + src.params.push(prm); }); }); @@ -307,7 +302,7 @@ export class dataModelBuilder { attribute.push(newAttribute); //if (fields.find(x => x.key == newAttribute.id).url.url == null) - fields.find(x => x.key == newAttribute.id).attributes.sources = newAttribute.sources; + fields.find(x => x.key == newAttribute.id).attributes.sources = newAttribute.sources; fields.find(x => x.key == newAttribute.id).attributes.validation = newAttribute.validation; }); diff --git a/dmp-frontend/src/app/services/rest-base.ts b/dmp-frontend/src/app/services/rest-base.ts index 9d8e3ae84..f9dea8d72 100644 --- a/dmp-frontend/src/app/services/rest-base.ts +++ b/dmp-frontend/src/app/services/rest-base.ts @@ -18,7 +18,12 @@ export class RestBase { protocol: string = "http"; hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";// port: number = 8080;//8080;// - webappname: string = "dmp-backend";//"dmp-backend-new";// + webappname: string = "dmp-backend-1";//"dmp-backend-new";// + + /*protocol: string = "http"; + hostname: string ="dionysus.di.uoa.gr" ; + port: number = 7070; + webappname: string = "dmp-backend-1";//"dmp-backend-new";//*/ proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/"; diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 2725aea5f..b5ae5e15e 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -17,7 +17,6 @@ declare var X2JS: any; @Injectable() export class ServerService { - xml2jsonOBJ: any; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a868dbbb-ee37-4ce6-81c8-27048e0599a9'; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';//include rules! @@ -85,9 +84,18 @@ export class ServerService { public listProjectsLabelID(){ return this.restBase.get("project/listAllLabelIDs"); } - + signOut2() { + +     var auth2 = gapi.auth2.getAuthInstance(); +     auth2.signOut().then(function () { +       console.log('User signed out.'); + localStorage.removeItem('currentUser'); +     }); + this.tokenService.setToken(null); //kanonika prepei na mpei mesa sthn function..... +   } + getData() { diff --git a/dmp-frontend/src/index.html b/dmp-frontend/src/index.html index 00b6f0c31..0f41afc37 100644 --- a/dmp-frontend/src/index.html +++ b/dmp-frontend/src/index.html @@ -9,7 +9,7 @@ - Digital Management Plans - Manager + Data Management Plans - Manager @@ -32,7 +32,7 @@
-

Digital Management Plan

+

Data Management Plan