#878 doc,demo and code improvements userinfo component

This commit is contained in:
Mario Romano
2016-11-09 12:27:44 +00:00
parent 3aa64626de
commit 177c9694af
21 changed files with 269 additions and 108 deletions

View File

@@ -15,12 +15,14 @@
* limitations under the License.
*/
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input, AfterViewChecked } from '@angular/core';
import { EcmUserModel } from './../models/ecm-user.model';
import { BpmUserModel } from './../models/bpm-user.model';
import { EcmUserService } from './../services/ecm-user.service';
import { BpmUserService } from './../services/bpm-user.service';
import { AlfrescoSettingsService, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
declare let componentHandler: any;
@Component({
selector: 'ng2-alfresco-userinfo',
@@ -28,8 +30,7 @@ import { AlfrescoSettingsService, AlfrescoTranslationService } from 'ng2-alfresc
styleUrls: ['./user-info.component.css'],
templateUrl: './user-info.component.html'
})
export class UserInfoComponent implements OnInit {
export class UserInfoComponent implements AfterViewChecked, OnInit {
@Input()
ecmBackgroundImage: string;
@@ -53,16 +54,27 @@ export class UserInfoComponent implements OnInit {
constructor(private ecmUserService: EcmUserService,
private bpmUserService: BpmUserService,
public setting: AlfrescoSettingsService,
private authService: AlfrescoAuthenticationService,
private translate: AlfrescoTranslationService) {
if (translate) {
translate.addTranslationFolder('node_modules/ng2-alfresco-userinfo/src');
}
}
ngAfterViewChecked() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
ngOnInit() {
if (this.setting.getProviders() === 'ECM' ||
this.setting.getProviders() === 'ALL') {
this.getEcmUserInfo();
this.getBpmUserInfo();
}
getEcmUserInfo(): void {
if (this.authService.isEcmLoggedIn()) {
this.ecmUserService.getCurrentUserInfo()
.subscribe((res) => {
this.ecmUser = <EcmUserModel> res;
@@ -70,9 +82,10 @@ export class UserInfoComponent implements OnInit {
}
);
}
}
if (this.setting.getProviders() === 'BPM' ||
this.setting.getProviders() === 'ALL') {
getBpmUserInfo(): void {
if (this.authService.isBpmLoggedIn()) {
this.bpmUserService.getCurrentUserInfo()
.subscribe((res) => {
this.bpmUser = <BpmUserModel> res;