Changed interceptors
This commit is contained in:
parent
1d4d32197c
commit
0f94cb1afd
|
@ -2,8 +2,7 @@ import { Component } from '@angular/core';
|
|||
import { TokenService, TokenProvider } from './services/login/token.service';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
import '../assets/custom.js';
|
||||
declare function sign_out_google(): any;
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
@ -24,31 +23,9 @@ export class AppComponent {
|
|||
showLogin : boolean = false;
|
||||
|
||||
|
||||
authenticateToServer(tokenInfo){
|
||||
|
||||
console.log("Running authenticateToServer");
|
||||
console.log(tokenInfo);
|
||||
|
||||
//backendURL, token
|
||||
//return this.tokenService.authenticate_backend(backendURL, token);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
logout(){
|
||||
//set the log out actions here
|
||||
this.tokenService.setLoggedIn(false);
|
||||
this.tokenService.setEmail(null);
|
||||
this.tokenService.setUsername(null);
|
||||
this.tokenService.setToken(null);
|
||||
|
||||
if(this.tokenService.getProvider() == TokenProvider.google){
|
||||
sign_out_google();
|
||||
}
|
||||
|
||||
|
||||
this.tokenService.setProvider(null);
|
||||
|
||||
this.tokenService.logout();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,9 +24,11 @@ import { OrganisationService } from './services/organisation-service';
|
|||
import { DmpProfileService } from './services/dmpprofile-service';
|
||||
import { RegistryService } from './services/registry-service';
|
||||
import { DatarepoService } from './services/datarepo-service';
|
||||
import { GlobalInterceptor } from './services/interceptor';
|
||||
import { Toolbox } from './services/toolbox';
|
||||
|
||||
import { DataFilterPipe } from './pipes/data-filter.pipe';
|
||||
import { DatasetProfileTableFilterPipe } from './pipes/datasetprofile-table-filter.pipe';
|
||||
import { DmpTableFilterPipe } from './pipes/dmp-table-filter.pipe';
|
||||
import { ServiceTableFilterPipe } from './pipes/service-table-filter.pipe';
|
||||
import { DmpProfileTableFilterPipe } from './pipes/dmp-profile-table-filter.pipe';
|
||||
|
@ -56,6 +58,7 @@ import { RegistryEditorComponent } from './managers/registry-editor/registry-edi
|
|||
import { ServiceEditorComponent } from './managers/service-editor/service-editor.component';
|
||||
import { ResearcherEditorComponent } from './managers/researcher-editor/researcher-editor.component';
|
||||
import { DatareposEditorComponent } from './managers/datarepos-editor/datarepos-editor.component';
|
||||
import { DatasetprofileEditorComponent } from './managers/datasetprofile-editor/datasetprofile-editor.component';
|
||||
|
||||
|
||||
|
||||
|
@ -64,6 +67,7 @@ import { DatareposEditorComponent } from './managers/datarepos-editor/datarepos-
|
|||
DataFilterPipe,
|
||||
DmpTableFilterPipe,
|
||||
DmpProfileTableFilterPipe,
|
||||
DatasetProfileTableFilterPipe,
|
||||
ProjectTableFilterPipe,
|
||||
OrganisationTableFilterPipe,
|
||||
RegistryTableFilterPipe,
|
||||
|
@ -87,7 +91,8 @@ import { DatareposEditorComponent } from './managers/datarepos-editor/datarepos-
|
|||
ServiceEditorComponent,
|
||||
MainSignInComponent,
|
||||
ResearcherEditorComponent,
|
||||
DatareposEditorComponent
|
||||
DatareposEditorComponent,
|
||||
DatasetprofileEditorComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -101,7 +106,12 @@ import { DatareposEditorComponent } from './managers/datarepos-editor/datarepos-
|
|||
NgbModule.forRoot(),
|
||||
AppRouting
|
||||
],
|
||||
providers: [ DatasetsServiceService, TokenService, DmpsServiceService, ResearcherService,
|
||||
providers: [{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: GlobalInterceptor,
|
||||
multi: true,
|
||||
},
|
||||
DatasetsServiceService, TokenService, DmpsServiceService, ResearcherService,
|
||||
DialogService, DatasetProfileService, ProjectService, OrganisationService, DatarepoService,
|
||||
DmpProfileService, RegistryService, ServiceService, NativeLoginService, HttpModule, Toolbox, HttpClient, RestBase],
|
||||
bootstrap: [AppComponent]
|
||||
|
|
|
@ -42,7 +42,6 @@ export class NewDatasetComponent implements OnInit {
|
|||
}
|
||||
this.datasetsService.setDataset(this.newdatasetform.value).subscribe(
|
||||
(data) => {
|
||||
console.log("Created a new dataset with id: "+data.json().objID);
|
||||
jQuery("#newdataset-modal-container").modal("hide");
|
||||
this.idSender.emit(data.json().objID);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export class ProfileEditorComponent implements OnInit {
|
|||
if(fieldName == 'ruleset-label') database_profile.ruleset.label = this.profile.ruleset.label;
|
||||
if(fieldName == 'ruleset-definition') database_profile.ruleset.definition = this.profile.ruleset.definition;
|
||||
//save back
|
||||
this.datasetProfileService.setDatasetProfile(database_profile);
|
||||
this.datasetProfileService.updateDatasetProfile(database_profile);
|
||||
simple_notifier("success",null,"Updated value of field");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -116,16 +116,35 @@ export class DatasetsViewerComponent implements OnInit, AfterViewInit {
|
|||
onFocusOutProfileWin($event, value:string) {
|
||||
this.nullSafeProfile();
|
||||
if(this.haveChanges){
|
||||
|
||||
//delete this.profile.id;
|
||||
//delete this.profile.ruleset.id;
|
||||
//delete this.profile.viewstyle.id;
|
||||
|
||||
delete this.profile.dataset;
|
||||
delete this.profile.ruleset.datasetProfile;
|
||||
delete this.profile.viewstyle.datasetProfile;
|
||||
|
||||
console.log("Saving profile: "+JSON.stringify(this.profile));
|
||||
|
||||
//save back
|
||||
this.datasetProfileService.createDatasetProfile(this.profile).subscribe(
|
||||
response => {
|
||||
simple_notifier("success",null,"Saved Dataset Profile");
|
||||
console.log(response);
|
||||
},
|
||||
err => {
|
||||
simple_notifier("danger",null,"Could not save Dataset Profile");
|
||||
console.log(err);
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
//save back
|
||||
if(this.profile.id == null){ //if profile is new
|
||||
//create profile and a) assign it on data[] and on current profile b) assign it to dataset
|
||||
this.datasetProfileService.setDatasetProfile(this.profile).subscribe((resp) => {
|
||||
this.datasetProfileService.createDatasetProfile(this.profile).subscribe((resp) => {
|
||||
|
||||
|
||||
console.log("SERVICE RESPONSE: ");
|
||||
console.log(resp);
|
||||
console.log(resp.json());
|
||||
this.datasetsService.getDatasetById(this.clickedDatasetID).subscribe( (dataset) => {
|
||||
|
||||
if(dataset.profile != null){
|
||||
|
@ -152,11 +171,10 @@ export class DatasetsViewerComponent implements OnInit, AfterViewInit {
|
|||
console.log("this.profile")
|
||||
console.log(this.profile)
|
||||
|
||||
console.log(this.profile)
|
||||
this.profile.dataset = {"id": this.profile.dataset};
|
||||
//this.profile.dataset = {"id": this.profile.dataset};
|
||||
|
||||
|
||||
this.datasetProfileService.setDatasetProfile(this.profile).subscribe(
|
||||
this.datasetProfileService.updateDatasetProfile(this.profile).subscribe(
|
||||
response => {
|
||||
simple_notifier("success",null,"Saved DMP Profile");
|
||||
console.log(response);
|
||||
|
@ -168,53 +186,13 @@ export class DatasetsViewerComponent implements OnInit, AfterViewInit {
|
|||
);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
onFocusOutProfileWin($event, value:string){
|
||||
if(this.haveChanges){
|
||||
console.log("Saving profile: "+JSON.stringify(this.profile));
|
||||
//save back
|
||||
if(this.profile.id == null){ //if profile is new
|
||||
console.log("================CH 1 =======================");
|
||||
simple_notifier("info",null,"Dataset didn't have a profile. Created and associated a new one");
|
||||
//get the appropriate dataset, and add the new profile
|
||||
this.datasetsService.getDatasetById(this.clickedDatasetID).subscribe( (dataset) => {
|
||||
console.log("================CH 2 =======================");
|
||||
if(dataset.profile != null){
|
||||
this.profile.id = dataset.profile.id;
|
||||
console.log("================CH 3 =======================");
|
||||
}
|
||||
dataset.profile = this.profile;
|
||||
|
||||
console.log("SAVING DATASET: "+JSON.stringify(dataset));
|
||||
|
||||
this.datasetsService.setDataset(dataset).subscribe( (resp) => {
|
||||
console.log("================CH 4 =======================");
|
||||
//console.log(resp);
|
||||
simple_notifier("success",null,"Updated profile element");
|
||||
});
|
||||
});
|
||||
}
|
||||
else{
|
||||
console.log("================CH 5 =======================");
|
||||
this.datasetProfileService.setDatasetProfile(this.profile).subscribe((resp) => {
|
||||
console.log("================CH 6 =======================");
|
||||
console.log(resp.status);
|
||||
simple_notifier("success",null,"Updated profile element");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
nullSafeProfile(){
|
||||
if(this.profile==null){
|
||||
console.log("BEFORE:");
|
||||
|
|
|
@ -4,6 +4,8 @@ import {Router} from '@angular/router';
|
|||
|
||||
declare const gapi: any;
|
||||
|
||||
import '../../../assets/custom.js';
|
||||
declare function simple_notifier(type: string, title: string, message:string): any;
|
||||
|
||||
@Component({
|
||||
selector: 'googgle-sign-in',
|
||||
|
@ -12,7 +14,7 @@ declare const gapi: any;
|
|||
})
|
||||
export class GooggleSignInComponent implements OnInit, AfterViewInit {
|
||||
|
||||
token:any;
|
||||
//token:any;
|
||||
|
||||
constructor(private element: ElementRef, private tokenService : TokenService, private router : Router) {
|
||||
|
||||
|
@ -50,19 +52,11 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit {
|
|||
public attachSignin(element) {
|
||||
this.auth2.attachClickHandler(element, {},
|
||||
(googleUser) => {
|
||||
this.token = googleUser.getAuthResponse().id_token;
|
||||
|
||||
simple_notifier("success",null,"Successful login");
|
||||
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());
|
||||
|
||||
window.location.reload();
|
||||
|
||||
this.tokenService.login(googleUser.getAuthResponse().id_token, TokenProvider.google, profile.getName(), profile.getEmail());
|
||||
}, function (error) {
|
||||
simple_notifier("danger",null,"Failed to login");
|
||||
console.log(JSON.stringify(error, undefined, 2));
|
||||
});
|
||||
|
||||
|
|
|
@ -48,13 +48,7 @@ export class MainSignInComponent implements OnInit {
|
|||
|
||||
simple_notifier("success",null,"Successful login");
|
||||
|
||||
this.tokenService.setLoggedIn(true);
|
||||
this.tokenService.setToken(response['token']);
|
||||
this.tokenService.setProvider(TokenProvider.native);
|
||||
this.tokenService.setUsername(this.creds.username);
|
||||
this.tokenService.setEmail(response['email']);
|
||||
|
||||
window.location.reload();
|
||||
this.tokenService.login(response['token'], TokenProvider.native, this.creds.username, response['email']);
|
||||
|
||||
},
|
||||
err => {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</li>
|
||||
<ul class="sub-menu collapse" id="manage-datasets">
|
||||
<li [ngClass]="{true:'active'}[currentlySelected=='datasets']" (click)="setActive('datasets')" [routerLink]="['/datasets']" ><a style="cursor:pointer">Datasets</a></li>
|
||||
<li [ngClass]="{true:'active'}[currentlySelected=='datasetprofiles']" (click)="setActive('datasetprofiles')" ><a style="cursor:pointer">Dataset Profiles</a></li>
|
||||
<li [ngClass]="{true:'active'}[currentlySelected=='datasetprofiles']" (click)="setActive('datasetprofiles')" [routerLink]="['/datasetprofiles']" ><a style="cursor:pointer">Dataset Profiles</a></li>
|
||||
</ul>
|
||||
|
||||
<li data-toggle="collapse" data-target="#manage-dmps" class="collapsed">
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
|
||||
<div class="editor-container container">
|
||||
|
||||
<div [ngClass]="{true:'visible', false:'invisible'}[tableVisible]">
|
||||
<table class="table table-striped" [mfData]="tableData | datasetProfileTableFilter : filterQuery" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="1">
|
||||
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter'/>
|
||||
</th>
|
||||
<th>
|
||||
<button class="btn btn-default" (click)="refreshTable($event)">
|
||||
<span class="glyphicon glyphicon-refresh"></span>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th [ngClass]="{true:'visible', false:'invisible'}[showIDs]"><mfDefaultSorter by="id">ID</mfDefaultSorter></th>
|
||||
<th><mfDefaultSorter by="label">Label</mfDefaultSorter></th>
|
||||
<th><mfDefaultSorter by="ruleset">Ruleset</mfDefaultSorter></th>
|
||||
<th><mfDefaultSorter by="viewstyle">Viewstyle</mfDefaultSorter></th>
|
||||
<th><mfDefaultSorter by="definition">Definition</mfDefaultSorter></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="grayout-empty-table" *ngIf="!mf.data[0]" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile"> <td colspan="5">No elements</td></tr>
|
||||
<tr *ngFor="let datasetProfile of mf.data" class="hover" [contextMenu]="basicMenu" [contextMenuSubject]="datasetProfile">
|
||||
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{datasetProfile.id}}</td>
|
||||
<td>{{datasetProfile?.label}}</td>
|
||||
<td>{{datasetProfile?.ruleset?.label}}</td>
|
||||
<td>{{datasetProfile?.viewstyle?.label}}</td>
|
||||
<td>{{datasetProfile?.definition}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<mfBootstrapPaginator [rowsOnPageSet]="[10,20,40]"></mfBootstrapPaginator>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- this is the form editor -->
|
||||
<div [ngClass]="{true:'visible', false:'invisible'}[editorVisible]">
|
||||
|
||||
<div> <!-- form container -->
|
||||
<div style="display:block;">
|
||||
<button (click)="switchToTable()" class="btn btn-lg btn-success pull-right" style="max-width:120px;">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Go back
|
||||
</button>
|
||||
</div>
|
||||
<form [formGroup]="datasetProfileEditorForm" novalidate style="display:block;">
|
||||
<div class="form-group" [ngClass]="{null:'invisible'}[editingDatasetProfile?.id]">
|
||||
<label class="center-block">ID: {{datasetProfile?.id}}
|
||||
<input class="form-control invisible" formControlName="id" [ngModel]="editingDatasetProfile?.id">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="center-block">Label:
|
||||
<input class="form-control" formControlName="label" [ngModel]="editingDatasetProfile?.label" (ngModelChange)="editingDatasetProfile.label=$event">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="center-block">Ruleset:
|
||||
<input class="form-control" formControlName="ruleset" [ngModel]="editingDatasetProfile?.ruleset" (ngModelChange)="editingDatasetProfile.ruleset=$event">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="center-block">Viewstyle:
|
||||
<input class="form-control" formControlName="viewstyle" [ngModel]="editingDatasetProfile?.viewstyle" (ngModelChange)="editingDatasetProfile.viewstyle$event">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="center-block">Definition:
|
||||
<input class="form-control" formControlName="definition" [ngModel]="editingDatasetProfile?.definition" (ngModelChange)="editingDatasetProfile.definition$event">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group" style="width:540px;">
|
||||
<button style="float:right;" type="submit" (click)="save($event, $data, $form)"class="btn btn-success">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
<!--
|
||||
<p>Form value: {{ datasetProfileEditorForm.value | json }}</p>
|
||||
-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<context-menu>
|
||||
<ng-template contextMenuItem [subMenu]="manage">
|
||||
<span></span>Manage Dataset Profiles
|
||||
</ng-template>
|
||||
<context-menu #manage>
|
||||
<ng-template contextMenuItem (execute)="new($event?.item)">
|
||||
<span class="glyphicon glyphicon-plus"></span>Create Dataset profile
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="edit($event?.item?.id)">
|
||||
<span class="glyphicon glyphicon-pencil"></span>Edit this Dataset profile
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="delete($event?.item?.id)">
|
||||
<span class="glyphicon glyphicon-trash red"></span> Delete this
|
||||
</ng-template>
|
||||
</context-menu>
|
||||
<ng-template contextMenuItem>
|
||||
<span></span>Show full tree connections
|
||||
</ng-template>
|
||||
</context-menu>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DatasetprofileEditorComponent } from './datasetprofile-editor.component';
|
||||
|
||||
describe('DatasetprofileEditorComponent', () => {
|
||||
let component: DatasetprofileEditorComponent;
|
||||
let fixture: ComponentFixture<DatasetprofileEditorComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ DatasetprofileEditorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DatasetprofileEditorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,135 @@
|
|||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { DatasetProfileService } from '../../services/dataset-profile.service';
|
||||
import { ContextMenuComponent } from 'ngx-contextmenu';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import '../../../assets/custom.js';
|
||||
declare function simple_notifier(type: string, title: string, message:string): any;
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-datasetprofile-editor',
|
||||
templateUrl: './datasetprofile-editor.component.html',
|
||||
styleUrls: ['./datasetprofile-editor.component.css']
|
||||
})
|
||||
export class DatasetprofileEditorComponent implements OnInit {
|
||||
|
||||
|
||||
constructor(private datasetProfileService : DatasetProfileService, private fb: FormBuilder) {
|
||||
|
||||
}
|
||||
|
||||
//whole dmp data model
|
||||
tableData : any[] = new Array();
|
||||
|
||||
//DatasetProfile editor data model
|
||||
editingDatasetProfile: any = {};
|
||||
datasetProfileEditorForm : any;
|
||||
|
||||
//required by the table
|
||||
public filterQuery = "";
|
||||
public rowsOnPage = 10;
|
||||
//public sortBy = "email";
|
||||
public sortOrder = "asc";
|
||||
|
||||
//visibility rules for containers
|
||||
tableVisible: boolean = true;
|
||||
editorVisible: boolean = false;
|
||||
|
||||
|
||||
// for tableIds
|
||||
showIDs : boolean = false;
|
||||
|
||||
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.getAllDatasetProfiles(false);
|
||||
this.createDatasetProfileEditorForm();
|
||||
}
|
||||
|
||||
createDatasetProfileEditorForm(){
|
||||
this.datasetProfileEditorForm = this.fb.group({
|
||||
id: '',
|
||||
label: ['', Validators.required ],
|
||||
ruleset: '',
|
||||
viewstyle: '',
|
||||
definition: ''
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
switchToTable(){
|
||||
this.tableVisible = true;
|
||||
this.editorVisible = false;
|
||||
}
|
||||
|
||||
switchToEditor(datasetProfileID){
|
||||
this.tableVisible = false;
|
||||
this.editorVisible = true;
|
||||
if(datasetProfileID == null){
|
||||
this.editingDatasetProfile = {id: null, label: "", ruleset: "", viewstyle: "", definition: "" };
|
||||
}
|
||||
else{
|
||||
this.editingDatasetProfile = this.tableData.filter((datasetProfile) => datasetProfile.id === datasetProfileID)[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getAllDatasetProfiles(showNotification : boolean){
|
||||
this.datasetProfileService.fetchAllDatasetProfiles().subscribe( (data) => {
|
||||
this.tableData = data;
|
||||
if(showNotification)
|
||||
simple_notifier("info",null,"Refreshed the table");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
edit(data){
|
||||
this.switchToEditor(data);
|
||||
}
|
||||
|
||||
new(){
|
||||
this.switchToEditor(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
save(mouseEvent){
|
||||
this.datasetProfileService.createDatasetProfile(this.datasetProfileEditorForm.value).subscribe(
|
||||
response => {
|
||||
simple_notifier("success",null,"Saved dataset Profile");
|
||||
this.getAllDatasetProfiles(false);
|
||||
this.switchToTable();
|
||||
},
|
||||
err => {
|
||||
simple_notifier("danger",null,"Could not save dataset Profile");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
delete(data){
|
||||
console.log(data);
|
||||
this.datasetProfileService.delete(data).subscribe(
|
||||
(response) => {
|
||||
simple_notifier("success",null,"Deleted dataset profile");
|
||||
this.getAllDatasetProfiles(false);
|
||||
this.switchToTable();
|
||||
},
|
||||
(err) => {
|
||||
simple_notifier("danger",null,"Could not delete dataset profile");
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
refreshTable($event){
|
||||
this.getAllDatasetProfiles(true);
|
||||
}
|
||||
|
||||
|
||||
@ViewChild(ContextMenuComponent) public basicMenu: ContextMenuComponent;
|
||||
|
||||
}
|
|
@ -102,6 +102,7 @@ export class ServiceEditorComponent implements OnInit {
|
|||
response => {
|
||||
simple_notifier("success",null,"Saved service");
|
||||
this.getAllServices(false);
|
||||
this.switchToTable();
|
||||
},
|
||||
err => {
|
||||
simple_notifier("danger",null,"Could not save service");
|
||||
|
@ -113,6 +114,8 @@ export class ServiceEditorComponent implements OnInit {
|
|||
this.serviceService.delete(service).subscribe(
|
||||
(response) => {
|
||||
simple_notifier("success",null,"Deleted service");
|
||||
this.getAllServices(false);
|
||||
this.switchToTable();
|
||||
},
|
||||
(err) => {
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import * as _ from "lodash";
|
||||
import {Pipe, PipeTransform} from "@angular/core";
|
||||
|
||||
@Pipe({
|
||||
name: "datasetProfileTableFilter"
|
||||
})
|
||||
export class DatasetProfileTableFilterPipe implements PipeTransform {
|
||||
|
||||
transform(array: any[], query: string): any {
|
||||
|
||||
if (query) {
|
||||
|
||||
return _.filter(array, row => {
|
||||
if (row.label == null) row.label = "";
|
||||
if (row.id == null) row.id = "";
|
||||
return (
|
||||
row.label.indexOf(query) > -1 ||
|
||||
row.id.indexOf(query) > -1
|
||||
)
|
||||
});
|
||||
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ import { RegistryEditorComponent } from './managers/registry-editor/registry-edi
|
|||
import { OrganisationEditorComponent } from './managers/organisation-editor/organisation-editor.component';
|
||||
import { ResearcherEditorComponent } from './managers/researcher-editor/researcher-editor.component';
|
||||
import { DatareposEditorComponent } from './managers/datarepos-editor/datarepos-editor.component';
|
||||
|
||||
import { DatasetprofileEditorComponent } from './managers/datasetprofile-editor/datasetprofile-editor.component';
|
||||
|
||||
import { MainWindowComponent } from './main-window/main-window.component';
|
||||
|
||||
|
@ -30,6 +30,10 @@ export const routes: Routes = [
|
|||
path: 'datasets',
|
||||
component: DatasetsViewerComponent
|
||||
},
|
||||
{
|
||||
path: 'datasetprofiles',
|
||||
component: DatasetprofileEditorComponent
|
||||
},
|
||||
{
|
||||
path: 'datarepos',
|
||||
component: DatareposEditorComponent
|
||||
|
|
|
@ -16,17 +16,25 @@ export class DatasetProfileService implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
|
||||
fetchAllDatasetProfiles(){
|
||||
return this.restBase.get("datasetprofile/getAll");
|
||||
}
|
||||
|
||||
getDatasetProfileById(datasetProfileID){
|
||||
return this.restBase.get("datasetprofile/"+datasetProfileID);
|
||||
//.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
setDatasetProfile(datasetProfile){
|
||||
return this.restBase.post("datasetprofile/set", datasetProfile);
|
||||
createDatasetProfile(datasetProfile){
|
||||
return this.restBase.post("datasetprofile/create", datasetProfile);
|
||||
}
|
||||
|
||||
updateDatasetProfile(datasetProfile){
|
||||
return this.restBase.post("datasetprofile/update", datasetProfile);
|
||||
}
|
||||
|
||||
delete(datasetProfile){
|
||||
return this.restBase.post("datasetprofile/delete", datasetProfile);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,26 +19,26 @@ export class DatasetsServiceService implements OnInit {
|
|||
|
||||
|
||||
getDatasetById(datasetID){
|
||||
return this.restBase.get("dataset/"+datasetID);
|
||||
return this.restBase.get("datasets/"+datasetID);
|
||||
}
|
||||
|
||||
|
||||
fetchAllDatasets(){
|
||||
return this.restBase.get("getAllDatasets");
|
||||
return this.restBase.get("dataset/getAll");
|
||||
}
|
||||
|
||||
|
||||
setDataset(fullDataset){
|
||||
return this.restBase.post("setDataset", fullDataset);
|
||||
return this.restBase.post("dataset/create", fullDataset);
|
||||
}
|
||||
|
||||
|
||||
deleteDataset(dataset){
|
||||
return this.restBase.post("deleteDataset", dataset);
|
||||
return this.restBase.post("dataset/delete", dataset);
|
||||
}
|
||||
|
||||
assignDMPToDataset(datasetID, dmpID){
|
||||
return this.restBase.get("assignDMPToDataset" +"?datasetID="+datasetID+"&dmpID="+dmpID);
|
||||
return this.restBase.get("dataset/assignDMPToDataset" +"?datasetID="+datasetID+"&dmpID="+dmpID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse, HttpErrorResponse} from '@angular/common/http';
|
||||
import { TokenService } from './login/token.service';
|
||||
|
||||
@Injectable()
|
||||
export class GlobalInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor(public tokenService: TokenService) {}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
|
||||
return next.handle(req).do((event: HttpEvent<any>) => {
|
||||
/*
|
||||
if (event instanceof HttpResponse) {
|
||||
console.log("response ok");
|
||||
}
|
||||
*/
|
||||
}, (err: any) => {
|
||||
if (err instanceof HttpErrorResponse) {
|
||||
if (err.status === 401) {
|
||||
console.log("logging out");
|
||||
this.tokenService.logout();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//return next.handle(req);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,9 @@ import { DOCUMENT } from '@angular/platform-browser';
|
|||
|
||||
declare var jQuery : any;
|
||||
|
||||
import '../../../assets/custom.js';
|
||||
declare function sign_out_google(): any;
|
||||
|
||||
@Injectable()
|
||||
export class TokenService {
|
||||
|
||||
|
@ -66,6 +69,34 @@ export class TokenService {
|
|||
}
|
||||
|
||||
|
||||
login(token: string, provider: TokenProvider, username: string, email: string){
|
||||
|
||||
this.setLoggedIn(true);
|
||||
this.setToken(token);
|
||||
this.setProvider(provider);
|
||||
this.setUsername(username);
|
||||
this.setEmail(email);
|
||||
|
||||
window.location.reload();
|
||||
|
||||
}
|
||||
|
||||
|
||||
logout(){
|
||||
//set the log out actions here
|
||||
this.setLoggedIn(false);
|
||||
this.setEmail(null);
|
||||
this.setUsername(null);
|
||||
this.setToken(null);
|
||||
|
||||
if(this.getProvider() == TokenProvider.google){
|
||||
sign_out_google();
|
||||
}
|
||||
|
||||
this.setProvider(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export enum TokenProvider {
|
||||
|
|
|
@ -15,12 +15,24 @@ export class RestBase {
|
|||
this.xml2jsonOBJ = new X2JS();
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
protocol: string = "http";
|
||||
hostname: string = "dionysus.di.uoa.gr";//"dl010.madgik.di.uoa.gr";//
|
||||
port: number = 7070;//8080;//
|
||||
webappname: string = "dmp-backend";//"dmp-backend-new";//
|
||||
hostname: string = "dionysus.di.uoa.gr";
|
||||
port: number = 7070;
|
||||
webappname: string = "dmp-backend";
|
||||
restpath: string = "rest";
|
||||
|
||||
/*
|
||||
protocol: string = "http";
|
||||
hostname: string = "dl010.madgik.di.uoa.gr";
|
||||
port: number = 8080;
|
||||
webappname: string = "dmp-backend";
|
||||
restpath: string = "rest";
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/login/";
|
||||
restBasePath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/"+this.restpath+"/";
|
||||
|
@ -31,24 +43,32 @@ export class RestBase {
|
|||
return this.http.post<any>(this.loginPath + path, JSON.stringify(data), options);
|
||||
}
|
||||
|
||||
public get(path : string){
|
||||
var options = this.createOptions();
|
||||
public get(path : string, params? : any){
|
||||
var options = this.createOptions(params);
|
||||
return this.http.get<any>(this.restBasePath + path, options);
|
||||
}
|
||||
|
||||
|
||||
public post(path : string, data : any){
|
||||
var options = this.createOptions();
|
||||
public post(path : string, data : any, params? : any){
|
||||
var options = this.createOptions(params);
|
||||
return this.http.post<any>(this.restBasePath + path, JSON.stringify(data), options);
|
||||
}
|
||||
|
||||
|
||||
private createOptions(){
|
||||
|
||||
private createOptions(parameters : any){
|
||||
var token = this.tokenService.getToken();
|
||||
var provider: TokenProvider = this.tokenService.getProvider();
|
||||
var csrfToken : string = this.tokenService.getCSRFToken();
|
||||
|
||||
const params = new HttpParams();
|
||||
var params = new HttpParams();
|
||||
|
||||
if(parameters != null){
|
||||
Object.entries(parameters).forEach( entry => {
|
||||
params = params.set(entry[0], entry[1]);
|
||||
});
|
||||
}
|
||||
|
||||
var headers;
|
||||
if(provider == TokenProvider.google)
|
||||
headers = new HttpHeaders().set('Content-Type', 'application/json').set('X-CSRF-Token', csrfToken).set("google-token", token);
|
||||
|
@ -58,7 +78,7 @@ export class RestBase {
|
|||
return options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -34,7 +34,8 @@ export class ServiceService implements OnInit {
|
|||
create(service){
|
||||
return this.restBase.post("service/create", service);
|
||||
}
|
||||
|
||||
|
||||
|
||||
delete(serviceID){
|
||||
var service = {"id": serviceID};
|
||||
return this.restBase.post("service/delete", service);
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
import { Injectable, } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import {LocalStorageService} from 'ngx-webstorage';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class TokenService {
|
||||
|
||||
|
||||
constructor (private storage : LocalStorageService) {
|
||||
|
||||
}
|
||||
|
||||
getProvider(){
|
||||
return this.storage.retrieve('provider');
|
||||
}
|
||||
|
||||
setProvider(provider : TokenProvider){
|
||||
this.storage.store('provider',provider);
|
||||
}
|
||||
|
||||
getToken(){
|
||||
return this.storage.retrieve('token');
|
||||
}
|
||||
|
||||
setToken(token){
|
||||
this.storage.store('token',token);
|
||||
}
|
||||
|
||||
isLoggedIn(){
|
||||
return this.storage.retrieve('loggedIn');
|
||||
}
|
||||
|
||||
setLoggedIn(boolStatus){
|
||||
this.storage.store('loggedIn',boolStatus);
|
||||
}
|
||||
|
||||
getEmail(){
|
||||
return this.storage.retrieve('email');
|
||||
}
|
||||
|
||||
setEmail(email){
|
||||
this.storage.store('email',email);
|
||||
}
|
||||
|
||||
getUsername(){
|
||||
return this.storage.retrieve('username');
|
||||
}
|
||||
|
||||
setUsername(username){
|
||||
this.storage.store('username',username);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export enum TokenProvider {
|
||||
native,
|
||||
google
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue