[Library | Trunk]: Change login to circle
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58618 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
dad915f543
commit
c3cc637e89
|
@ -8,82 +8,87 @@ import {EnvProperties} from '../utils/properties/env-properties';
|
|||
|
||||
// declare var logoutClicked;
|
||||
@Component({
|
||||
selector: 'user-mini',
|
||||
template: `
|
||||
<ng-container *ngIf="!dashboard">
|
||||
selector: 'user-mini',
|
||||
template: `
|
||||
<ng-container *ngIf="!dashboard">
|
||||
|
||||
<ul *ngIf="!mobileView" class="uk-navbar-nav">
|
||||
<li class="uk-parent">
|
||||
|
||||
<a *ngIf="loggedIn">
|
||||
<span>{{user.fullname + " "}} <span class="uk-margin-small-right uk-icon"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
ratio="1"><circle
|
||||
fill="none" stroke="#000" stroke-width="1.1" cx="9.9" cy="6.4" r="4.4"></circle><path fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"></path></svg></span></span>
|
||||
</a>
|
||||
<a *ngIf="!loggedIn" class="loginLink" (click)="logIn()">Sign in <span
|
||||
class=" uk-margin-small-left uk-margin-small-right uk-icon"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
ratio="1"><circle fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
cx="9.9" cy="6.4"
|
||||
r="4.4"></circle><path
|
||||
fill="none" stroke="#000" stroke-width="1.1"
|
||||
d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"></path></svg> </span>
|
||||
</a>
|
||||
<ul *ngIf="!mobileView" class="uk-navbar-nav">
|
||||
<li class="uk-parent">
|
||||
<a *ngIf="loggedIn" class="login">
|
||||
<svg height="60" width="60">
|
||||
<circle cx="30" cy="30" r="20" stroke-width="2"></circle>
|
||||
<text *ngIf="firstLetters" x="50%" y="50%" text-anchor="middle" dy=".4em"
|
||||
font-size="16">
|
||||
{{firstLetters}}
|
||||
</text>
|
||||
<svg *ngIf="!firstLetters" ratio="1" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
x="20">
|
||||
<circle cx="9.9" cy="6.4" r="4.4" stroke-width="1.1"></circle>
|
||||
<path d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2" stroke-width="1.1"></path>
|
||||
</svg>
|
||||
</svg>
|
||||
</a>
|
||||
<a *ngIf="!loggedIn" class="loginLink" (click)="logIn()">Sign in <span
|
||||
class=" uk-margin-small-left uk-margin-small-right uk-icon"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
ratio="1"><circle fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
cx="9.9" cy="6.4"
|
||||
r="4.4"></circle><path
|
||||
fill="none" stroke="#000" stroke-width="1.1"
|
||||
d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"></path></svg> </span>
|
||||
</a>
|
||||
|
||||
|
||||
<div *ngIf="loggedIn" class="uk-navbar-dropdown uk-navbar-dropdown-bottom-left" id="userMenu"
|
||||
(click)="onClick('userMenu')">
|
||||
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
|
||||
<div class="uk-first-column uk-height-max-medium uk-overflow-auto">
|
||||
<ul class="uk-nav uk-navbar-dropdown-nav">
|
||||
<!--li><a href="" >My profile</a></li>
|
||||
<li><a routerLinkActive="uk-link" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="uk-link" routerLink="/claims">Manage all Claims</a></li-->
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}"
|
||||
[queryParams]=item.params>{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}"
|
||||
target="_blank">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="logout1"></div>
|
||||
<div *ngIf="loggedIn" class="uk-navbar-dropdown uk-navbar-dropdown-bottom-left" id="userMenu"
|
||||
(click)="onClick('userMenu')">
|
||||
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
|
||||
<div class="uk-first-column uk-height-max-medium uk-overflow-auto">
|
||||
<ul class="uk-nav uk-navbar-dropdown-nav">
|
||||
<!--li><a href="" >My profile</a></li>
|
||||
<li><a routerLinkActive="uk-link" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="uk-link" routerLink="/claims">Manage all Claims</a></li-->
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}"
|
||||
[queryParams]=item.params>{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}"
|
||||
target="_blank">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="logout1"></div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ng-container>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="!dashboard">
|
||||
<ng-container *ngIf="!dashboard">
|
||||
|
||||
<li *ngIf="mobileView" class="uk-nav-header uk-parent ">
|
||||
<li *ngIf="mobileView" class="uk-nav-header uk-parent ">
|
||||
|
||||
<span *ngIf="loggedIn">
|
||||
<span>{{user.fullname + " "}}<span class="uk-margin-small-right uk-icon"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
ratio="1"><circle fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
cx="9.9"
|
||||
cy="6.4"
|
||||
r="4.4"></circle><path
|
||||
<span *ngIf="loggedIn" class="uk-flex uk-flex-middle">
|
||||
<span>{{user.fullname + " "}}</span>
|
||||
<span class="uk-margin-small-right uk-icon"><svg width="20" height="20"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
ratio="1"><circle fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
cx="9.9"
|
||||
cy="6.4"
|
||||
r="4.4"></circle><path
|
||||
fill="none" stroke="#000" stroke-width="1.1"
|
||||
d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"></path></svg></span></span>
|
||||
d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2"></path></svg>
|
||||
</span>
|
||||
</span>
|
||||
<span *ngIf="!loggedIn">
|
||||
<span *ngIf="!loggedIn">
|
||||
<a class="loginLink" (click)="logIn()">Sign in <span class="uk-margin-small-right uk-icon"><svg width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
|
@ -96,160 +101,160 @@ import {EnvProperties} from '../utils/properties/env-properties';
|
|||
</a>
|
||||
</span>
|
||||
|
||||
<ul *ngIf="loggedIn" class="uk-nav-sub">
|
||||
<!--li><a href="" >My profile</a></li>
|
||||
<li><a routerLinkActive="uk-link" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="uk-link" routerLink="/claims">Manage all Claims</a></li-->
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}">{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="dashboard">
|
||||
<a *ngIf="!loggedIn" class="login" (click)="logIn()">
|
||||
Sign in <span class="uk-margin-small-left uk-margin-small-right uk-icon">
|
||||
<ul *ngIf="loggedIn" class="uk-nav-sub">
|
||||
<!--li><a href="" >My profile</a></li>
|
||||
<li><a routerLinkActive="uk-link" routerLink="/myclaims">My Claims</a></li>
|
||||
<li *ngIf="isAuthorized"><a routerLinkActive="uk-link" routerLink="/claims">Manage all Claims</a></li-->
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}">{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="dashboard">
|
||||
<a *ngIf="!loggedIn" class="login" (click)="logIn()">
|
||||
Sign in <span class="uk-margin-small-left uk-margin-small-right uk-icon">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1">
|
||||
<circle cx="9.9" cy="6.4" r="4.4" stroke-width="1.1"></circle>
|
||||
<path d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2" stroke-width="1.1"></path>
|
||||
</svg></span>
|
||||
</a>
|
||||
<a *ngIf="loggedIn" class="uk-icon">
|
||||
<svg height="60" width="60">
|
||||
<circle cx="30" cy="30" r="20" stroke-width="2"></circle>
|
||||
<text *ngIf="firstLetters" x="50%" y="50%" text-anchor="middle" dy=".4em"
|
||||
font-size="16">
|
||||
{{firstLetters}}
|
||||
</text>
|
||||
<svg *ngIf="!firstLetters" ratio="1" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
x="20">
|
||||
<circle cx="9.9" cy="6.4" r="4.4" stroke-width="1.1"></circle>
|
||||
<path d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2" stroke-width="1.1"></path>
|
||||
</svg>
|
||||
</a>
|
||||
<a *ngIf="loggedIn" class="uk-icon">
|
||||
<svg height="60" width="60">
|
||||
<circle cx="30" cy="30" r="20" stroke-width="2"></circle>
|
||||
<text *ngIf="firstLetters" x="50%" y="50%" text-anchor="middle" dy=".4em"
|
||||
font-size="16">
|
||||
{{firstLetters}}
|
||||
</text>
|
||||
<svg *ngIf="!firstLetters" ratio="1" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
x="20">
|
||||
<circle cx="9.9" cy="6.4" r="4.4" stroke-width="1.1"></circle>
|
||||
<path d="M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2" stroke-width="1.1"></path>
|
||||
</svg>
|
||||
</a>
|
||||
<div *ngIf="loggedIn" uk-dropdown="mode: click; offset: -2; delay-hide: 0; flip: false; pos: bottom-right"
|
||||
#userMenu
|
||||
class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}"
|
||||
[queryParams]=item.params>{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}"
|
||||
target="_blank">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</ng-container>
|
||||
</svg>
|
||||
</a>
|
||||
<div *ngIf="loggedIn" uk-dropdown="mode: click; offset: -2; delay-hide: 0; flip: false; pos: bottom-right"
|
||||
#userMenu
|
||||
class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<ng-container *ngFor="let item of userMenuItems ">
|
||||
<li *ngIf="item.needsAuthorization && isAuthorized || !item.needsAuthorization">
|
||||
<a *ngIf="item.route.length > 0" routerLink="{{item.route}}"
|
||||
[queryParams]=item.params>{{item.title}}</a>
|
||||
<a *ngIf="item.route.length == 0 && item.url.length > 0" href="{{item.url}}"
|
||||
target="_blank">{{item.title}}</a>
|
||||
</li>
|
||||
</ng-container>
|
||||
<li *ngIf="userMenuItems.length > 0" class="uk-nav-divider"></li>
|
||||
<li><a (click)="logOut()" id="logout">Log out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div id="logout2"></div>
|
||||
`
|
||||
<div id="logout2"></div>
|
||||
`
|
||||
})
|
||||
|
||||
export class UserMiniComponent implements OnInit, OnChanges {
|
||||
@Input() user: User;
|
||||
public loggedIn: boolean = false;
|
||||
public isAuthorized: boolean = false;
|
||||
@Input() public mobileView: boolean = false;
|
||||
public firstLetters: string = "";
|
||||
@Input() public dashboard: boolean = false;
|
||||
public server: boolean = true;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
@Input() userMenuItems;
|
||||
@Input() logInUrl;
|
||||
@Input() logOutUrl;
|
||||
@Input() cookieDomain;
|
||||
@Input() redirectUrl: string;
|
||||
search: string = '';
|
||||
sub: any;
|
||||
|
||||
constructor(private router: Router, private route: ActivatedRoute, private location: Location) {
|
||||
@Input() user: User;
|
||||
public loggedIn: boolean = false;
|
||||
public isAuthorized: boolean = false;
|
||||
@Input() public mobileView: boolean = false;
|
||||
public firstLetters: string = "";
|
||||
@Input() public dashboard: boolean = false;
|
||||
public server: boolean = true;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
@Input() userMenuItems;
|
||||
@Input() logInUrl;
|
||||
@Input() logOutUrl;
|
||||
@Input() cookieDomain;
|
||||
@Input() redirectUrl: string;
|
||||
search: string = '';
|
||||
sub: any;
|
||||
|
||||
constructor(private router: Router, private route: ActivatedRoute, private location: Location) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
this.server = false;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
this.server = false;
|
||||
}
|
||||
this.initialize();
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.initialize();
|
||||
});
|
||||
|
||||
|
||||
this.initialize();
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.initialize();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.user) {
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.user) {
|
||||
this.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
initialize() {
|
||||
if (!this.redirectUrl && typeof location !== 'undefined') {
|
||||
this.redirectUrl = location.pathname;
|
||||
this.search = location.search;
|
||||
}
|
||||
|
||||
initialize() {
|
||||
if (!this.redirectUrl && typeof location !== 'undefined') {
|
||||
this.redirectUrl = location.pathname;
|
||||
this.search = location.search;
|
||||
}
|
||||
if (this.user) {
|
||||
this.loggedIn = true;
|
||||
this.parseName();
|
||||
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
|
||||
|
||||
} else {
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = null;
|
||||
}
|
||||
|
||||
if (this.user) {
|
||||
this.loggedIn = true;
|
||||
this.parseName();
|
||||
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
|
||||
|
||||
} else {
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = null;
|
||||
}
|
||||
|
||||
logOut() {
|
||||
if (this.user) {
|
||||
Session.removeUser();
|
||||
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
|
||||
|
||||
}
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = new User();
|
||||
|
||||
}
|
||||
|
||||
logOut() {
|
||||
if (this.user) {
|
||||
Session.removeUser();
|
||||
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
|
||||
|
||||
}
|
||||
|
||||
logIn() {
|
||||
Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search);
|
||||
window.location.href = this.logInUrl;
|
||||
this.loggedIn = false;
|
||||
this.isAuthorized = false;
|
||||
this.user = new User();
|
||||
}
|
||||
|
||||
logIn() {
|
||||
Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search);
|
||||
window.location.href = this.logInUrl;
|
||||
}
|
||||
|
||||
onClick(id: string) {
|
||||
let el: HTMLElement = document.getElementById(id);
|
||||
el.classList.remove('uk-open');
|
||||
}
|
||||
|
||||
parseName() {
|
||||
this.firstLetters = "";
|
||||
if (this.user && this.user.firstname) {
|
||||
this.firstLetters += this.user.firstname.substr(0, 1);
|
||||
}
|
||||
|
||||
onClick(id: string) {
|
||||
let el: HTMLElement = document.getElementById(id);
|
||||
el.classList.remove('uk-open');
|
||||
if (this.user && this.user.lastname) {
|
||||
this.firstLetters += this.user.lastname.substr(0, 1);
|
||||
}
|
||||
|
||||
parseName() {
|
||||
this.firstLetters = "";
|
||||
if (this.user && this.user.firstname) {
|
||||
this.firstLetters += this.user.firstname.substr(0, 1);
|
||||
}
|
||||
if (this.user && this.user.lastname) {
|
||||
this.firstLetters += this.user.lastname.substr(0, 1);
|
||||
}
|
||||
if (!this.firstLetters && this.user && this.user.fullname) {
|
||||
let matches = this.user.fullname.match(/\b(\w)/g);
|
||||
this.firstLetters += matches.join('');
|
||||
}
|
||||
if (!this.firstLetters && this.user && this.user.fullname) {
|
||||
let matches = this.user.fullname.match(/\b(\w)/g);
|
||||
this.firstLetters += matches.join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue