Duplicated code blocks has been cleaned in library
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54903 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
7205f2e34c
commit
9627d08570
|
@ -1,8 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
import { ResultInfo } from '../results/resultInfo';
|
||||
import { Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { CommunityInfo } from './communityInfo';
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
|
@ -32,10 +29,12 @@ export class CommunityService {
|
|||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||
.map(res => <any> res.json()).map(res => this.parseCommunity(res)).map(community => community.managers.indexOf(manager)!=-1);
|
||||
}
|
||||
|
||||
iscommunityRI(properties:EnvProperties, url: string){
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||
.map(res => <any> res.json()).map(res => this.parseCommunity(res)).map(community => (community && community.type && community.type !="community"));
|
||||
}
|
||||
|
||||
isSubscribedToCommunity(pid:string, email:string, url:string){
|
||||
return this.http.get(url+"/community/"+pid+"/subscribers")
|
||||
.map(res => ((<any>res =="")?{}:<any> res.json()))
|
||||
|
@ -53,118 +52,60 @@ export class CommunityService {
|
|||
|
||||
});
|
||||
}
|
||||
parseCommunity(data:any): CommunityInfo {
|
||||
|
||||
let length = Array.isArray(data) ? data.length :1;
|
||||
private parseCommunity(data:any): CommunityInfo {
|
||||
|
||||
for (let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[0] : data;
|
||||
|
||||
let resData = Array.isArray(data) ? data[i] : data;
|
||||
|
||||
var community: CommunityInfo = new CommunityInfo();
|
||||
|
||||
if(Array.isArray(resData)) {
|
||||
|
||||
community['title'] = resData[0].name;
|
||||
community['shortTitle'] = resData[0].shortName;
|
||||
community['communityId'] = resData[0].id;
|
||||
community['queryId'] = resData[0].queryId;
|
||||
community['logoUrl'] = resData[0].logoUrl;
|
||||
community['description'] = resData[0].description;
|
||||
community['date'] = resData[0].creationDate;
|
||||
community['zenodoCommunity'] = resData[0].zenodoCommunity;
|
||||
community['status'] = "all";
|
||||
if(resData[0].hasOwnProperty('status')){
|
||||
community['status'] = resData[0].status;
|
||||
var status = ["all","hidden","manager"];
|
||||
if(status.indexOf(community['status']) ==-1){
|
||||
community['status'] = "hidden";
|
||||
}
|
||||
}
|
||||
if (resData[0].type != null) {
|
||||
community['type'] = resData[0].type;
|
||||
}
|
||||
|
||||
if(resData[0].managers != null) {
|
||||
if(community['managers'] == undefined) {
|
||||
community['managers'] = new Array<string>();
|
||||
}
|
||||
|
||||
let managers = resData[0].managers;
|
||||
let length = Array.isArray(managers) ? managers.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let manager = Array.isArray(managers) ? managers[i] : managers;
|
||||
community.managers[i] = manager;
|
||||
}
|
||||
}
|
||||
|
||||
if(resData[0].subjects != null) {
|
||||
if(community['subjects'] == undefined) {
|
||||
community['subjects'] = new Array<string>();
|
||||
}
|
||||
|
||||
let subjects = resData[0].subjects;
|
||||
let length = Array.isArray(subjects) ? subjects.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let subject = Array.isArray(subjects) ? subjects[i] : subjects;
|
||||
community.subjects[i] = subject;
|
||||
}
|
||||
}
|
||||
|
||||
} else if(!Array.isArray(resData)) {
|
||||
|
||||
community['title'] = resData.name;
|
||||
community['shortTitle'] = resData.shortName;
|
||||
community['communityId'] = resData.id;
|
||||
community['queryId'] = resData.queryId;
|
||||
community['logoUrl'] = resData.logoUrl;
|
||||
community['description'] = resData.description;
|
||||
community['date'] = resData.creationDate;
|
||||
community['zenodoCommunity'] = resData.zenodoCommunity;
|
||||
community['status'] = "all";
|
||||
if(resData.hasOwnProperty('status')){
|
||||
community['status'] = resData.status;
|
||||
var status = ["all","hidden","manager"];
|
||||
if(status.indexOf(community['status']) ==-1){
|
||||
community['status'] = "hidden";
|
||||
}
|
||||
}
|
||||
if (resData.type != null) {
|
||||
community['type'] = resData.type;
|
||||
}
|
||||
|
||||
if(resData.managers != null) {
|
||||
if(community['managers'] == undefined) {
|
||||
community['managers'] = new Array<string>();
|
||||
}
|
||||
|
||||
let managers = resData.managers;
|
||||
let length = Array.isArray(managers) ? managers.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let manager = Array.isArray(managers) ? managers[i] : managers;
|
||||
community.managers[i] = manager;
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.subjects != null) {
|
||||
if(community['subjects'] == undefined) {
|
||||
community['subjects'] = new Array<string>();
|
||||
}
|
||||
|
||||
let subjects = resData.subjects;
|
||||
let length = Array.isArray(subjects) ? subjects.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let subject = Array.isArray(subjects) ? subjects[i] : subjects;
|
||||
community.subjects[i] = subject;
|
||||
}
|
||||
}
|
||||
let community: CommunityInfo = new CommunityInfo();
|
||||
community['title'] = resData.name;
|
||||
community['shortTitle'] = resData.shortName;
|
||||
community['communityId'] = resData.id;
|
||||
community['queryId'] = resData.queryId;
|
||||
community['logoUrl'] = resData.logoUrl;
|
||||
community['description'] = resData.description;
|
||||
community['date'] = resData.creationDate;
|
||||
community['zenodoCommunity'] = resData.zenodoCommunity;
|
||||
community['status'] = "all";
|
||||
if(resData.hasOwnProperty('status')){
|
||||
community['status'] = resData.status;
|
||||
let status = ["all","hidden","manager"];
|
||||
if(status.indexOf(community['status']) ==-1){
|
||||
community['status'] = "hidden";
|
||||
}
|
||||
}
|
||||
return community;
|
||||
}
|
||||
if (resData.type != null) {
|
||||
community['type'] = resData.type;
|
||||
}
|
||||
|
||||
if(resData.managers != null) {
|
||||
if(community['managers'] == undefined) {
|
||||
community['managers'] = new Array<string>();
|
||||
}
|
||||
|
||||
let managers = resData.managers;
|
||||
let length = Array.isArray(managers) ? managers.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let manager = Array.isArray(managers) ? managers[i] : managers;
|
||||
community.managers[i] = manager;
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.subjects != null) {
|
||||
if(community['subjects'] == undefined) {
|
||||
community['subjects'] = new Array<string>();
|
||||
}
|
||||
|
||||
let subjects = resData.subjects;
|
||||
let length = Array.isArray(subjects) ? subjects.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let subject = Array.isArray(subjects) ? subjects[i] : subjects;
|
||||
community.subjects[i] = subject;
|
||||
}
|
||||
}
|
||||
return community;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,33 +12,19 @@ export class ConnectAdminLoginGuard implements CanActivate {
|
|||
constructor(private router: Router, private communityService: CommunityService, private propertiesService:EnvironmentSpecificService ) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
//console.log(state.url);
|
||||
var user;
|
||||
var loggedIn = false;
|
||||
var isAdmin = false;
|
||||
var errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
let community = (route.queryParams["communityId"]);
|
||||
if(Session.isLoggedIn()){
|
||||
loggedIn = true;
|
||||
if(!Session.isLoggedIn()){
|
||||
loggedIn = false;
|
||||
errorCode = LoginErrorCodes.NOT_VALID;
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
|
||||
return false;
|
||||
}else if(Session.isPortalAdministrator() || Session.isCommunityCurator()) {
|
||||
//console.log("is Admin");
|
||||
isAdmin = true;
|
||||
if(Session.isPortalAdministrator() || Session.isCommunityCurator()) {
|
||||
return true;
|
||||
}else {
|
||||
} else {
|
||||
let obs = this.propertiesService.subscribeEnvironment().map(res=>res).mergeMap(properties => {
|
||||
return this.communityService.iscommunityManager(properties, properties["communityAPI"]+community,Session.getUserEmail())});
|
||||
obs.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }));
|
||||
return obs;
|
||||
}
|
||||
}else{
|
||||
} else{
|
||||
errorCode =LoginErrorCodes.NOT_LOGIN;
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
|
||||
|
@ -47,26 +33,4 @@ export class ConnectAdminLoginGuard implements CanActivate {
|
|||
|
||||
|
||||
}
|
||||
/*
|
||||
constructor(private route: ActivatedRoute,private router: Router, private config: ConfigurationService) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
|
||||
let customRedirect = route.data['redirect'];
|
||||
let api = route.data['api'];
|
||||
let community = route.data['community']
|
||||
if(!community){
|
||||
community = (route.queryParams["communityId"])?route.queryParams["communityId"]:route.queryParams["community"];
|
||||
}
|
||||
if(community){
|
||||
let isEnabled = this.config.isPageEnabled(api, community,"/"+state.url.split("?")[0].substring(1));
|
||||
let redirect = !!customRedirect ? customRedirect : '/error';
|
||||
|
||||
isEnabled.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate([redirect], { queryParams: { "page": state.url } }));
|
||||
return isEnabled;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -12,34 +12,20 @@ export class ConnectRIGuard implements CanActivate {
|
|||
constructor(private router: Router, private communityService: CommunityService, private propertiesService:EnvironmentSpecificService ) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
//console.log(state.url);
|
||||
var user;
|
||||
var loggedIn = false;
|
||||
var isAdmin = false;
|
||||
var errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
let community = (route.queryParams["communityId"]);
|
||||
if(Session.isLoggedIn()){
|
||||
loggedIn = true;
|
||||
if(!Session.isLoggedIn()){
|
||||
loggedIn = false;
|
||||
errorCode = LoginErrorCodes.NOT_VALID;
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
|
||||
return false;
|
||||
}else if(Session.isPortalAdministrator()) {
|
||||
isAdmin = true;
|
||||
if(Session.isPortalAdministrator()) {
|
||||
return true;
|
||||
}else {
|
||||
|
||||
} else {
|
||||
let obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => {
|
||||
return this.communityService.iscommunityRI(properties, properties["communityAPI"]+community)});
|
||||
obs.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }));
|
||||
return obs;
|
||||
}
|
||||
}else{
|
||||
errorCode =LoginErrorCodes.NOT_LOGIN;
|
||||
} else{
|
||||
errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
|
||||
|
||||
return false;
|
||||
|
@ -47,26 +33,4 @@ export class ConnectRIGuard implements CanActivate {
|
|||
|
||||
|
||||
}
|
||||
/*
|
||||
constructor(private route: ActivatedRoute,private router: Router, private config: ConfigurationService) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
|
||||
let customRedirect = route.data['redirect'];
|
||||
let api = route.data['api'];
|
||||
let community = route.data['community']
|
||||
if(!community){
|
||||
community = (route.queryParams["communityId"])?route.queryParams["communityId"]:route.queryParams["community"];
|
||||
}
|
||||
if(community){
|
||||
let isEnabled = this.config.isPageEnabled(api, community,"/"+state.url.split("?")[0].substring(1));
|
||||
let redirect = !!customRedirect ? customRedirect : '/error';
|
||||
|
||||
isEnabled.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate([redirect], { queryParams: { "page": state.url } }));
|
||||
return isEnabled;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// import { NgModule } from '@angular/core';
|
||||
// import { RouterModule } from '@angular/router';
|
||||
//
|
||||
// import { DataProviderComponent } from './dataProvider.component';
|
||||
// import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
// import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard';
|
||||
// import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
//
|
||||
// @NgModule({
|
||||
// imports: [
|
||||
// RouterModule.forChild([
|
||||
// { path: '', component: DataProviderComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
|
||||
// redirect: '/error'
|
||||
// },canDeactivate: [PreviousRouteRecorder] }
|
||||
// ])
|
||||
// ]
|
||||
// })
|
||||
// export class DataProviderRoutingModule { }
|
|
@ -164,14 +164,8 @@ export class DataProviderService {
|
|||
}
|
||||
|
||||
if(data[4] != null) {
|
||||
let oaiPmhURL: string;
|
||||
if(Array.isArray(data[4])) {
|
||||
oaiPmhURL = data[4][0];
|
||||
}
|
||||
else {
|
||||
oaiPmhURL = data[4];
|
||||
}
|
||||
|
||||
let oaiPmhURL:string;
|
||||
oaiPmhURL = Array.isArray(data[4]) ? data[4][0]:data[4];
|
||||
if(oaiPmhURL != '' && oaiPmhURL != 'unknown') {
|
||||
this.dataProviderInfo.oaiPmhURL = oaiPmhURL;
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// import { NgModule } from '@angular/core';
|
||||
// import { RouterModule } from '@angular/router';
|
||||
//
|
||||
// import { ProjectComponent } from './project.component';
|
||||
// import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
// import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard';
|
||||
// import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
//
|
||||
// @NgModule({
|
||||
// imports: [
|
||||
// RouterModule.forChild([
|
||||
// { path: '', component: ProjectComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
|
||||
// redirect: '/error'
|
||||
// },canDeactivate: [PreviousRouteRecorder] }
|
||||
// ])
|
||||
// ]
|
||||
// })
|
||||
// export class ProjectRoutingModule { }
|
|
@ -33,6 +33,7 @@ export class ProjectService {
|
|||
.map(res => this.parseProjectInfo(res, properties));
|
||||
|
||||
}
|
||||
|
||||
getProjectInfoByGrantId (grant: string, funder:string, properties:EnvProperties):any {
|
||||
|
||||
let url =properties.searchAPIURLLAst+ 'resources?query=(oaftype exact project)'+
|
||||
|
@ -80,8 +81,6 @@ export class ProjectService {
|
|||
}
|
||||
|
||||
private handleError (error: Response) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.log(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
@ -98,15 +97,11 @@ export class ProjectService {
|
|||
parseProjectInfo (data: any, properties:EnvProperties):any {
|
||||
this.projectInfo = new ProjectInfo();
|
||||
if(data[3] != null) {
|
||||
this.projectInfo.id =data[3];
|
||||
this.projectInfo.id = data[3];
|
||||
}
|
||||
if(data[0] != null) {
|
||||
this.projectInfo.acronym = data[0].acronym;
|
||||
if(Array.isArray(data[0]['title'])) {
|
||||
this.projectInfo.title = data[0].title[0];
|
||||
} else {
|
||||
this.projectInfo.title = data[0].title;
|
||||
}
|
||||
this.projectInfo.title = Array.isArray(data[0]['title']) ? data[0].title[0] : data[0].title;
|
||||
this.projectInfo.callIdentifier = data[0].callidentifier;
|
||||
this.projectInfo.contractNum = data[0].code;
|
||||
this.projectInfo.startDate = data[0].startdate;
|
||||
|
@ -116,39 +111,8 @@ export class ProjectService {
|
|||
this.projectInfo.openAccessMandateDatasets = data[0].ecarticle29_3;
|
||||
}
|
||||
if(data[1] != null) {
|
||||
/*
|
||||
if(data[1]['funder'] != null) {
|
||||
this.projectInfo.funder = data[1]['funder'].shortname;
|
||||
}
|
||||
|
||||
let funding;
|
||||
this.projectInfo.funding = "";
|
||||
|
||||
if(data[1]['funding_level_2'] != null) {
|
||||
funding = data[1]['funding_level_2'].id;
|
||||
} else if(data[1]['funding_level_1'] != null) {
|
||||
funding = data[1]['funding_level_1'].id;
|
||||
} else if(data[1]['funding_level_0'] != null) {
|
||||
funding = data[1]['funding_level_0'].id;
|
||||
}
|
||||
|
||||
if(funding != undefined) {
|
||||
funding = funding.split("::");
|
||||
for(let i=1; i<funding.length; i++) {
|
||||
if(this.projectInfo.funding != "") {
|
||||
this.projectInfo.funding += " | ";
|
||||
}
|
||||
this.projectInfo.funding += funding[i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
let funding: {"funderName": string, "funderShortname": string, "stream": string};
|
||||
funding = this.parsingFunctions.parseFundingTrees(data[1]);
|
||||
|
||||
// if(funding.funderName) {
|
||||
// this.publicationInfo.fundedByProjects[counter]['funderName'] = funding.funderName;
|
||||
// }
|
||||
if(funding.funderShortname) {
|
||||
this.projectInfo.funder = funding.funderShortname;
|
||||
}
|
||||
|
@ -214,7 +178,7 @@ export class ProjectService {
|
|||
}
|
||||
|
||||
parseProjectDates (id: string, data: any):any {
|
||||
var project = { id: id, startDate: "", endDate: ""};
|
||||
let project = { id: id, startDate: "", endDate: ""};
|
||||
if(data[0] != null) {
|
||||
project.startDate = data[0].startdate;
|
||||
project.endDate = data[0].enddate;
|
||||
|
|
|
@ -10,8 +10,6 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
|
|||
constructor(private router: Router) {}
|
||||
|
||||
check(path: string) : boolean{
|
||||
//var user;
|
||||
//var role = route.data['role']
|
||||
let loggedIn = false;
|
||||
let isAuthorized = false;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
CanLoad
|
||||
} from '@angular/router';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Session} from './utils/helper.class';
|
||||
import {LoginErrorCodes} from './utils/guardHelper.class';
|
||||
|
||||
@Injectable()
|
||||
|
@ -17,7 +16,6 @@ export class FreeGuard implements CanActivate, CanLoad{
|
|||
constructor(private router: Router) {}
|
||||
|
||||
check(path: string) :boolean {
|
||||
//var user;
|
||||
let valid = true;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
if(!valid){
|
||||
|
|
|
@ -10,7 +10,6 @@ export class LoginGuard implements CanActivate, CanLoad {
|
|||
constructor(private router: Router) {}
|
||||
|
||||
check(path: string): boolean{
|
||||
//var user;
|
||||
let loggedIn = false;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
||||
|
|
|
@ -2,9 +2,6 @@ import {Component, ElementRef} from '@angular/core';
|
|||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Title, Meta} from '@angular/platform-browser';
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
// import {LoginService} from './login.service';
|
||||
import {User,Session} from './utils/helper.class';
|
||||
import {RouterHelper} from '../utils/routerHelper.class';
|
||||
|
||||
|
@ -20,9 +17,9 @@ export class UserComponent {
|
|||
public loggedIn: boolean = false;
|
||||
public server: boolean = true;
|
||||
public errorMessage: string = "";
|
||||
public username: string = "";
|
||||
public password: string = "";
|
||||
private sub:any;private sublogin:any;
|
||||
private sub:any;
|
||||
private sublogin:any;
|
||||
public errorCode: string = "";
|
||||
public redirectUrl: string = "";
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
|
@ -68,17 +65,7 @@ export class UserComponent {
|
|||
this.sublogin.unsubscribe();
|
||||
}
|
||||
}
|
||||
// logout(){
|
||||
// if(Session.isLoggedIn()){
|
||||
// Session.removeUser();
|
||||
// }
|
||||
// this.loggedIn = false;
|
||||
// this.user = new User();
|
||||
// this.username = "";
|
||||
// this.password = "";
|
||||
// this.redirect();
|
||||
//
|
||||
// }
|
||||
|
||||
redirect(){
|
||||
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
|
||||
this.redirectUrl = decodeURIComponent(this.redirectUrl);
|
||||
|
@ -104,13 +91,12 @@ export class UserComponent {
|
|||
this.router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
|
||||
logIn(){
|
||||
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
|
||||
this.redirectUrl = decodeURIComponent(this.redirectUrl);
|
||||
var baseUrl = this.redirectUrl;
|
||||
var queryParams = "";
|
||||
var paramsArray =[];
|
||||
var valuesArray =[];
|
||||
if(this.redirectUrl.indexOf('?') != -1){
|
||||
var splits =this.redirectUrl.split('?');
|
||||
if(splits.length>0){
|
||||
|
|
|
@ -10,7 +10,6 @@ import {UserComponent} from './user.component';
|
|||
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
|
||||
import {FreeGuard} from './freeGuard.guard';
|
||||
import {LoginGuard} from './loginGuard.guard';
|
||||
// import {LoginService} from './login.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import {Component, ElementRef, Input} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
// import {LoginService} from './login.service';
|
||||
import {User,Session} from './utils/helper.class';
|
||||
import {RouterHelper} from '../utils/routerHelper.class';
|
||||
import {StringUtils} from '../utils/string-utils.class';
|
||||
|
@ -82,9 +80,7 @@ export class UserMiniComponent {
|
|||
@Input() logOutUrl;
|
||||
@Input() cookieDomain;
|
||||
public redirectUrl: string = "";
|
||||
private baseUrl = "user-info";
|
||||
sub:any;
|
||||
// public properties:EnvProperties;
|
||||
|
||||
constructor( private router: Router, private route: ActivatedRoute, private location: Location) {}
|
||||
|
||||
|
@ -103,53 +99,44 @@ export class UserMiniComponent {
|
|||
ngOnDestroy(){
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
initialize(){
|
||||
this.redirectUrl = this.location.path();
|
||||
if(Session.isLoggedIn()){
|
||||
this.loggedIn = Session.isLoggedIn();
|
||||
this.loggedIn = true;
|
||||
this.user = Session.getUser();
|
||||
if(Session.isClaimsCurator() || Session.isPortalAdministrator()){
|
||||
this.isAuthorized = true;
|
||||
}else {
|
||||
this.isAuthorized = false;
|
||||
this.isAuthorized = true;
|
||||
} else {
|
||||
this.isAuthorized = false;
|
||||
}
|
||||
|
||||
}else {
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = null;
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = null;
|
||||
}
|
||||
|
||||
}
|
||||
// gotoUserPage(){
|
||||
// this.redirectUrl = this.location.path();
|
||||
// if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != "" && this.redirectUrl !="user-info"){
|
||||
// this.router.navigate([this.baseUrl], { queryParams: this.routerHelper.createQueryParam("redirectUrl",this.redirectUrl )});
|
||||
// }else{
|
||||
// this.router.navigate([this.baseUrl]);
|
||||
// }
|
||||
// }
|
||||
|
||||
logOut(){
|
||||
if(Session.isLoggedIn()){
|
||||
Session.removeUser();
|
||||
//console.log("Try to Logout!");
|
||||
// console.log("Redirect to "+location.href);
|
||||
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
|
||||
|
||||
}
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = new User();
|
||||
}
|
||||
|
||||
logIn(){
|
||||
// console.log("LOgin is clicked " + this.logInUrl);
|
||||
Session.setReloadUrl(location.protocol +"//"+location.host, location.pathname, location.search);
|
||||
window.location.href = this.logInUrl
|
||||
}
|
||||
|
||||
onClick(id: string) {
|
||||
var el: HTMLElement = document.getElementById(id);
|
||||
let el: HTMLElement = document.getElementById(id);
|
||||
el.classList.remove('uk-open');
|
||||
}
|
||||
|
||||
|
|
|
@ -251,11 +251,7 @@ export class SearchSoftwareService {
|
|||
|
||||
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
|
||||
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = resData.description;
|
||||
} else {
|
||||
result.description = resData.description[0];
|
||||
}
|
||||
result.description = Array.isArray(resData.description) ? resData.description[0] : resData.description;
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue