mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#878 fix user info demo
This commit is contained in:
@@ -21,6 +21,8 @@ import { AlfrescoSettingsService } from './AlfrescoSettings.service';
|
|||||||
import { AlfrescoApiService } from './AlfrescoApi.service';
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
import * as alfrescoApi from 'alfresco-js-api';
|
import * as alfrescoApi from 'alfresco-js-api';
|
||||||
import { AlfrescoApi } from 'alfresco-js-api';
|
import { AlfrescoApi } from 'alfresco-js-api';
|
||||||
|
import { Subject } from 'rxjs/Subject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +31,10 @@ export class AlfrescoAuthenticationService {
|
|||||||
|
|
||||||
alfrescoApi: AlfrescoApi;
|
alfrescoApi: AlfrescoApi;
|
||||||
|
|
||||||
|
public loginSubject: Subject<any> = new Subject<any>();
|
||||||
|
|
||||||
|
public logoutSubject: Subject<any> = new Subject<any>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param settingsService
|
* @param settingsService
|
||||||
@@ -84,6 +90,7 @@ export class AlfrescoAuthenticationService {
|
|||||||
return Observable.fromPromise(this.callApiLogin(username, password))
|
return Observable.fromPromise(this.callApiLogin(username, password))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
this.saveTickets();
|
this.saveTickets();
|
||||||
|
this.loginSubject.next(response);
|
||||||
return {type: this.settingsService.getProviders(), ticket: response};
|
return {type: this.settingsService.getProviders(), ticket: response};
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
@@ -109,6 +116,7 @@ export class AlfrescoAuthenticationService {
|
|||||||
return Observable.fromPromise(this.callApiLogout())
|
return Observable.fromPromise(this.callApiLogout())
|
||||||
.map(res => <any> res)
|
.map(res => <any> res)
|
||||||
.do(response => {
|
.do(response => {
|
||||||
|
this.logoutSubject.next(response);
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
|
@@ -64,7 +64,6 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfr
|
|||||||
<ng2-alfresco-userinfo [menuOpenType]="left"></ng2-alfresco-userinfo>
|
<ng2-alfresco-userinfo [menuOpenType]="left"></ng2-alfresco-userinfo>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- LOGIN COMPONENT -->
|
<!-- LOGIN COMPONENT -->
|
||||||
<alfresco-login [providers]="providers"
|
<alfresco-login [providers]="providers"
|
||||||
[disableCsrf]="disableCsrf"></alfresco-login>`,
|
[disableCsrf]="disableCsrf"></alfresco-login>`,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<div id="userinfo_container">
|
<div id="userinfo_container" *ngIf="isLoggedIn()">
|
||||||
<div *ngIf="ecmUser || bpmUser" class="button-profile" id="user-profile" data-automation-id="user-profile">
|
<div *ngIf="ecmUser || bpmUser" class="button-profile" id="user-profile" data-automation-id="user-profile">
|
||||||
<img id="logged-user-img"
|
<img id="logged-user-img"
|
||||||
[src]="getUserAvatar()"
|
[src]="getUserAvatar()"
|
||||||
|
@@ -47,9 +47,13 @@ export class UserInfoComponent implements AfterViewChecked, OnInit {
|
|||||||
private baseComponentPath = module.id.replace('components/user-info.component.js', '');
|
private baseComponentPath = module.id.replace('components/user-info.component.js', '');
|
||||||
|
|
||||||
ecmUser: EcmUserModel;
|
ecmUser: EcmUserModel;
|
||||||
|
|
||||||
bpmUser: BpmUserModel;
|
bpmUser: BpmUserModel;
|
||||||
|
|
||||||
anonymousImageUrl: string = this.baseComponentPath + 'img/anonymous.gif';
|
anonymousImageUrl: string = this.baseComponentPath + 'img/anonymous.gif';
|
||||||
|
|
||||||
bpmUserImage: any;
|
bpmUserImage: any;
|
||||||
|
|
||||||
ecmUserImage: any;
|
ecmUserImage: any;
|
||||||
|
|
||||||
constructor(private ecmUserService: EcmUserService,
|
constructor(private ecmUserService: EcmUserService,
|
||||||
@@ -59,6 +63,10 @@ export class UserInfoComponent implements AfterViewChecked, OnInit {
|
|||||||
if (translate) {
|
if (translate) {
|
||||||
translate.addTranslationFolder('node_modules/ng2-alfresco-userinfo/src');
|
translate.addTranslationFolder('node_modules/ng2-alfresco-userinfo/src');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authService.loginSubject.subscribe((response) => {
|
||||||
|
this.getUserInfo();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked() {
|
ngAfterViewChecked() {
|
||||||
@@ -69,10 +77,18 @@ export class UserInfoComponent implements AfterViewChecked, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.getUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserInfo() {
|
||||||
this.getEcmUserInfo();
|
this.getEcmUserInfo();
|
||||||
this.getBpmUserInfo();
|
this.getBpmUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoggedIn() {
|
||||||
|
return this.authService.isLoggedIn();
|
||||||
|
}
|
||||||
|
|
||||||
getEcmUserInfo(): void {
|
getEcmUserInfo(): void {
|
||||||
if (this.authService.isEcmLoggedIn()) {
|
if (this.authService.isEcmLoggedIn()) {
|
||||||
this.ecmUserService.getCurrentUserInfo()
|
this.ecmUserService.getCurrentUserInfo()
|
||||||
|
Reference in New Issue
Block a user