workflow project-dmp-dataset/sign out status 401

This commit is contained in:
annampak 2017-10-23 16:09:50 +03:00
parent d342ebb247
commit f04c984dbc
11 changed files with 301 additions and 61 deletions

View File

@ -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: `
// <h1 class="title">Projects</h1>
@ -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);
}

View File

@ -19,6 +19,9 @@ import { DatasetRoutingModule } from './dataset-routing.module';
DatasetsComponent
//ProjectDetailComponent
],
providers: [ ]
providers: [ ],
exports: [
DatasetsComponent
]
})
export class DatasetsModule {}

View File

@ -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<Dataset>;
@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);
}
}

View File

@ -0,0 +1,58 @@
<div class="modal fade" id="exampleModalDmps" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" #exampleModalDmps>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Project</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>
<div class="form-group">
<label for="recipient-name" class="col-form-label">DMP:</label>
<select class="form-control" [id]="datasetDropDownKey" [(ngModel)]="datasetDropDownKey" [name]="datasetDropDown" #datasetfield>
<option *ngFor="let opt of datasetDropDown.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">
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">Abbreviation:</label>
<input class="form-control" id="abbreviation-text">
</div>
<div class="form-group">
<label for="reference-text" class="form-control-label">Reference:</label>
<input class="form-control" id="reference-text">
</div>
<div class="form-group">
<label for="uri-text" class="form-control-label">Uri:</label>
<input class="form-control" id="uri-text">
</div>
<div class="form-group">
<label for="start-date" class="form-control-label">Start Date:</label>
<input class="form-control" id="startDate-date">
</div>
<div class="form-group">
<label for="end-date" class="form-control-label">End Date:</label>
<input class="form-control" id="endDate-date">
</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="button" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-primary" (click)= "showDatasets(datasetfield.value, exampleModalDmps)" >Show Datasets</button>
</div>
</div>
</div>
</div>
<!--DATASET TABLE-->
<datasets-table *ngIf="dataSetVisibe == true"></datasets-table>

View File

@ -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;
}

View File

@ -1,32 +1,12 @@
<div style="margin: auto; max-width: 1000px; margin-top:50px">
<data-table id="films-grid" headerTitle="My Projects" [items]="projects" [itemCount]="projectCount" (reload)="reloadProjects($event)"
<div>
<span>Filter: </span>
<input type="text" id="myInput" (keyup)="myFunction()" placeholder="Search for labels.." title="Type in a name">
</div>
<data-table id="projects-grid" headerTitle="My Projects" [items]="projects" [itemCount]="projectCount" (reload)="reloadProjects($event)"
[limit]="8" [sortBy]="'rating'" [sortAsc]="false" [selectColumn]="true" [multiSelect]="false" [substituteRows]="false"
[expandableRows]="true" [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true">
<template #dataTableExpand let-item="item">
<div>
<!-- <a [routerLink]="['/dynamic-form', item.id]"> {{ item.dmp.id }}</a> -->
<table class="table">
<thead class="thead-inverse">
<tr>
<th>Dmp</th>
<th>Id</th>
</tr>
</thead>
<tbody>
<tr>
<!-- <td> <a [routerLink]="['/dynamic-form', item.id]"> {{ item.dmp.id }}</a></td>-->
<td> <a [routerLink]="['/dataset']"> {{ item.dmp.id }}</a></td>
<td>{{item.dmp.id}}</td>
</tr>
</tbody>
</table>
</div>
</template>
<data-table-column [property]="'name'" [header]="'Label'" [sortable]="true">
</data-table-column>
<data-table-column [property]="'abbreviation'" [header]="'Abbreviation'" [sortable]="true">
@ -46,6 +26,14 @@
</span>
</template>
</data-table-column>
<data-table-column header="Actions">
<template #dataTableHeader let-item="item">
<i>Actions</i>
</template>
<template #dataTableCell let-item="item">
<a class="editGridColumn" data-toggle="modal" data-target="#exampleModalDmps"><i class="fa fa-pencil fa-fw"></i></a>
</template>
</data-table-column>
</data-table>
<div style="margin-top: 10px">
<b>Selected:</b>
@ -53,8 +41,14 @@
<span [textContent]="projectsTable.selectedRow && projectsTable.selectedRow.item.name"></span>
</div>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal">New Project</button>
<!-- <select class="form-control" [id]="datasetDropDownKey" [(ngModel)]="datasetDropDownKey">
<option *ngFor="let opt of datasetDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select> -->
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -104,5 +98,11 @@
</div>
</div>
<a href="#" (click)="signOut2();">Sign out</a>
<!--Modal for DMPs-->
<modal></modal>
<!--DATASET TABLE-->
<datasets-table *ngIf="dataSetVisibe == true"></datasets-table>
<a href="#" (click)="signOut2();" #isignOutBtn >Sign out</a>
<router-outlet></router-outlet>

View File

@ -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: [ ]
})

View File

@ -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<Project>;
datasetResource :DataTableResource<Dataset>;
@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 = <DataTableTranslations>{
indexColumn: 'Index column',

View File

@ -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;
});

View File

@ -20,6 +20,11 @@ export class RestBase {
port: number = 8080;//8080;//
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/";
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/login/";

View File

@ -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() {