mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#ADF-452-userinfo show full name on the banner (#1814)
* #ADF-452-userinfo show full name on the banner * #ADF-452 - added improvement from PR
This commit is contained in:
@@ -19,11 +19,8 @@
|
||||
export { BpmUserModel } from '../models/bpm-user.model';
|
||||
export { BpmUserService } from '../services/bpm-user.service';
|
||||
|
||||
import { BpmUserModel } from '../models/bpm-user.model';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
export var fakeBpmUserNoImage: BpmUserModel = {
|
||||
apps: {},
|
||||
export var fakeBpmUserNoImage = {
|
||||
apps: [],
|
||||
capabilities: 'fake-capability',
|
||||
company: 'fake-company',
|
||||
created: 'fake-create-date',
|
||||
@@ -32,7 +29,7 @@ export var fakeBpmUserNoImage: BpmUserModel = {
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
fullname: 'fake-full-name',
|
||||
groups: {},
|
||||
groups: [],
|
||||
id: 'fake-id',
|
||||
lastUpdate: 'fake-update-date',
|
||||
latestSyncTimeStamp: 'fake-timestamp',
|
||||
@@ -45,17 +42,17 @@ export var fakeBpmUserNoImage: BpmUserModel = {
|
||||
type: 'fake-type'
|
||||
};
|
||||
|
||||
export var fakeBpmUser: BpmUserModel = {
|
||||
apps: {},
|
||||
capabilities: 'fake-capability',
|
||||
export var fakeBpmUser = {
|
||||
apps: [],
|
||||
capabilities: null,
|
||||
company: 'fake-company',
|
||||
created: 'fake-create-date',
|
||||
email: 'fakeBpm@fake.com',
|
||||
externalId: 'fake-external-id',
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
fullname: 'fake-full-name',
|
||||
groups: {},
|
||||
firstName: 'fake-bpm-first-name',
|
||||
lastName: 'fake-bpm-last-name',
|
||||
fullname: 'fake-bpm-full-name',
|
||||
groups: [],
|
||||
id: 'fake-id',
|
||||
lastUpdate: 'fake-update-date',
|
||||
latestSyncTimeStamp: 'fake-timestamp',
|
||||
@@ -68,8 +65,8 @@ export var fakeBpmUser: BpmUserModel = {
|
||||
type: 'fake-type'
|
||||
};
|
||||
|
||||
export var fakeBpmEditedUser: BpmUserModel = {
|
||||
apps: {},
|
||||
export var fakeBpmEditedUser = {
|
||||
apps: [],
|
||||
capabilities: 'fake-capability',
|
||||
company: 'fake-company',
|
||||
created: 'fake-create-date',
|
||||
@@ -78,7 +75,7 @@ export var fakeBpmEditedUser: BpmUserModel = {
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
fullname: 'fake-full-name',
|
||||
groups: {},
|
||||
groups: [],
|
||||
id: 'fake-id',
|
||||
lastUpdate: 'fake-update-date',
|
||||
latestSyncTimeStamp: 'fake-timestamp',
|
||||
@@ -90,34 +87,3 @@ export var fakeBpmEditedUser: BpmUserModel = {
|
||||
tenantPictureId: 'fake-tenant-picture-id',
|
||||
type: 'fake-type'
|
||||
};
|
||||
|
||||
export class FakeBpmUserService {
|
||||
|
||||
lastPromise: Observable<BpmUserModel>;
|
||||
public userNeeded = 0;
|
||||
usersList = [fakeBpmUser, fakeBpmUserNoImage, fakeBpmEditedUser];
|
||||
|
||||
getUserInfo(userName: string) {
|
||||
return this.lastPromise = Observable.of(this.usersList[this.userNeeded]);
|
||||
};
|
||||
|
||||
getCurrentUserInfo() {
|
||||
return this.getUserInfo('fake-id');
|
||||
};
|
||||
|
||||
getCurrentUserProfileImage() {
|
||||
return Observable.of(this.usersList[this.userNeeded].pictureId);
|
||||
};
|
||||
|
||||
respondWithTheUserWithoutImage() {
|
||||
this.userNeeded = 1;
|
||||
}
|
||||
|
||||
respondWithTheUserWithImage() {
|
||||
this.userNeeded = 0;
|
||||
}
|
||||
|
||||
respondWithEditedUser() {
|
||||
this.userNeeded = 2;
|
||||
}
|
||||
}
|
||||
|
@@ -19,11 +19,9 @@
|
||||
export { EcmUserModel } from '../models/ecm-user.model';
|
||||
export { EcmUserService } from '../services/ecm-user.service';
|
||||
|
||||
import { EcmUserModel } from '../models/ecm-user.model';
|
||||
import { EcmCompanyModel } from '../models/ecm-company.model';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
export var fakeEcmCompany: EcmCompanyModel = {
|
||||
export let fakeEcmCompany: EcmCompanyModel = {
|
||||
organization: 'company-fake-name',
|
||||
address1: 'fake-address-1',
|
||||
address2: 'fake-address-2',
|
||||
@@ -34,7 +32,28 @@ export var fakeEcmCompany: EcmCompanyModel = {
|
||||
email: 'fakeCompany@fake.com'
|
||||
};
|
||||
|
||||
export var fakeEcmUserNoImage: EcmUserModel = {
|
||||
export let fakeEcmUser = {
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
description: 'i am a fake user for test',
|
||||
avatarId: 'fake-avatar-id',
|
||||
email: 'fakeEcm@ecmUser.com',
|
||||
skypeId: 'fake-skype-id',
|
||||
googleId: 'fake-googleId-id',
|
||||
instantMessageId: 'fake-instantMessageId-id',
|
||||
company: fakeEcmCompany,
|
||||
jobTitle: 'test job',
|
||||
location: 'fake location',
|
||||
mobile: '000000000',
|
||||
telephone: '11111111',
|
||||
statusUpdatedAt: 'fake-date',
|
||||
userStatus: 'active',
|
||||
enabled: true,
|
||||
emailNotificationsEnabled: true
|
||||
};
|
||||
|
||||
export let fakeEcmUserNoImage = {
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
@@ -55,7 +74,7 @@ export var fakeEcmUserNoImage: EcmUserModel = {
|
||||
emailNotificationsEnabled: true
|
||||
};
|
||||
|
||||
export var fakeEcmUser: EcmUserModel = {
|
||||
export let fakeEcmEditedUser = {
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
@@ -75,58 +94,3 @@ export var fakeEcmUser: EcmUserModel = {
|
||||
enabled: true,
|
||||
emailNotificationsEnabled: true
|
||||
};
|
||||
|
||||
export var fakeEcmEditedUser: EcmUserModel = {
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'fake-last-name',
|
||||
description: 'i am a fake user for test',
|
||||
avatarId: 'fake-avatar-id',
|
||||
email: 'fakeEcm@ecmUser.com',
|
||||
skypeId: 'fake-skype-id',
|
||||
googleId: 'fake-googleId-id',
|
||||
instantMessageId: 'fake-instantMessageId-id',
|
||||
company: fakeEcmCompany,
|
||||
jobTitle: 'test job',
|
||||
location: 'fake location',
|
||||
mobile: '000000000',
|
||||
telephone: '11111111',
|
||||
statusUpdatedAt: 'fake-date',
|
||||
userStatus: 'active',
|
||||
enabled: true,
|
||||
emailNotificationsEnabled: true
|
||||
};
|
||||
|
||||
export class FakeEcmUserService {
|
||||
|
||||
lastPromise: Observable<EcmUserModel>;
|
||||
public userNeeded = 0;
|
||||
usersList = [fakeEcmUser, fakeEcmUserNoImage, fakeEcmEditedUser];
|
||||
|
||||
getUserInfo(userName: string) {
|
||||
return this.lastPromise = Observable.of(this.usersList[this.userNeeded]);
|
||||
};
|
||||
|
||||
getCurrentUserInfo() {
|
||||
return this.getUserInfo('fake-id');
|
||||
};
|
||||
|
||||
getUserProfileImage(avatarId: string) {
|
||||
if (avatarId) {
|
||||
return 'src/assets/images/ecmImg.gif';
|
||||
}
|
||||
};
|
||||
|
||||
respondWithTheUserWithoutImage() {
|
||||
this.userNeeded = 1;
|
||||
};
|
||||
|
||||
respondWithTheUserWithImage() {
|
||||
this.userNeeded = 0;
|
||||
};
|
||||
|
||||
respondWithEditedUser() {
|
||||
this.userNeeded = 2;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@
|
||||
alt="ecm-profile-image"
|
||||
(error)="onImageLoadingError($event)"
|
||||
[src]="getEcmUserAvatar()"/>
|
||||
<h2 class="mdl-card__title-text" id="ecm-username">{{getUserNameHeaderFor('ECM')}}</h2>
|
||||
<h2 class="mdl-card__title-text" id="ecm-username">{{ecmUser.fullNameDisplay}}</h2>
|
||||
</div>
|
||||
<div class="mdl-card__supporting-text">
|
||||
<li class="mdl-list__item mdl-list__item--two-line">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<span id="ecm-full-name" class="truncate-long-names">{{getEcmFullName()}}</span>
|
||||
<span id="ecm-full-name" class="truncate-long-names">{{ecmUser.fullNameDisplay}}</span>
|
||||
<span id="ecm-email" class="mdl-list__item-sub-title">{{ecmUser.email}}</span>
|
||||
</span>
|
||||
<span id="ecm-job-title" class="mdl-list__item-secondary-content user-info__job-title">
|
||||
@@ -55,12 +55,12 @@
|
||||
alt="bpm-profile-image"
|
||||
(error)="onImageLoadingError($event)"
|
||||
[src]="getBpmUserAvatar()"/>
|
||||
<h2 class="mdl-card__title-text" id="bpm-username">{{getUserNameHeaderFor('BPM')}}</h2>
|
||||
<h2 class="mdl-card__title-text" id="bpm-username">{{bpmUser.fullNameDisplay}}</h2>
|
||||
</div>
|
||||
<div class="mdl-card__supporting-text">
|
||||
<li class="mdl-list__item mdl-list__item--two-line">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<span id="bpm-full-name" class="truncate-long-names">{{ getBpmFullName() }}</span>
|
||||
<span id="bpm-full-name" class="truncate-long-names">{{ bpmUser.fullNameDisplay }}</span>
|
||||
<span id="bpm-email" class="mdl-list__item-sub-title">{{bpmUser.email}}</span>
|
||||
</span>
|
||||
<span id="bpm-tenant" class="mdl-list__item-secondary-content user-info__job-title">
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { UserInfoComponent } from './user-info.component';
|
||||
import { EcmUserService } from '../services/ecm-user.service';
|
||||
import { BpmUserService } from '../services/bpm-user.service';
|
||||
import { BpmUserModel } from '../models/bpm-user.model';
|
||||
import { fakeBpmUser } from '../assets/fake-bpm-user.service.mock';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import {
|
||||
CoreModule,
|
||||
@@ -27,47 +27,10 @@ import {
|
||||
AlfrescoTranslationService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { BpmUserModel } from './../models/bpm-user.model';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
const fakeBpmUser: BpmUserModel = <BpmUserModel>{
|
||||
'id': 'fake-id',
|
||||
'firstName': 'fake-bpm-first-name',
|
||||
'lastName': 'fake-bpm-last-name',
|
||||
'created': null,
|
||||
'lastUpdate': null,
|
||||
'latestSyncTimeStamp': null,
|
||||
'email': 'fake-bpm-email',
|
||||
'externalId': null,
|
||||
'company': null,
|
||||
'pictureId': null,
|
||||
'fullname': 'fake-full-name',
|
||||
'password': null,
|
||||
'type': 'enterprise',
|
||||
'status': 'active',
|
||||
'tenantId': '1',
|
||||
'groups': [{
|
||||
'id': 1,
|
||||
'name': 'analytics-users',
|
||||
'externalId': null,
|
||||
'status': 'active',
|
||||
'tenantId': 1,
|
||||
'type': 0,
|
||||
'parentGroupId': null,
|
||||
'lastSyncTimeStamp': null,
|
||||
'userCount': null,
|
||||
'users': null,
|
||||
'capabilities': null,
|
||||
'groups': null,
|
||||
'manager': null
|
||||
}],
|
||||
'capabilities': null,
|
||||
'apps': [],
|
||||
'primaryGroup': null,
|
||||
'tenantPictureId': null,
|
||||
'tenantName': 'fake-tenant-name'
|
||||
};
|
||||
|
||||
describe('User info component', () => {
|
||||
|
||||
let userInfoComp: UserInfoComponent;
|
||||
@@ -90,7 +53,7 @@ describe('User info component', () => {
|
||||
providers: [
|
||||
EcmUserService,
|
||||
BpmUserService,
|
||||
{provide: AlfrescoTranslationService, useClass: TranslationMock}
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(UserInfoComponent);
|
||||
@@ -119,18 +82,6 @@ describe('User info component', () => {
|
||||
expect(element.querySelector('#user-profile-lists')).toBeNull();
|
||||
});
|
||||
|
||||
it('should format null string values in empty value', () => {
|
||||
let res = userInfoComp.formatValue('null');
|
||||
expect(res).toBe('');
|
||||
});
|
||||
|
||||
it('should return the value when it is not null string', () => {
|
||||
let res = userInfoComp.formatValue('fake-value');
|
||||
expect(res).toBeDefined();
|
||||
expect(res).not.toBeNull();
|
||||
expect(res).toEqual('fake-value');
|
||||
});
|
||||
|
||||
it('should return the anonymous avatar when users do not have images', () => {
|
||||
let event = <any> {
|
||||
target: {
|
||||
@@ -156,6 +107,32 @@ describe('User info component', () => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should show ecm only last name when user first name is null ', async(() => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
'entry': {
|
||||
'id': 'fake-id',
|
||||
'firstName': null,
|
||||
'lastName': 'fake-ecm-last-name',
|
||||
'description': 'i am a fake user for test',
|
||||
'avatarId': 'fake-avatar-id',
|
||||
'email': 'fakeEcm@ecmUser.com'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#ecm-username')).toBeDefined();
|
||||
expect(element.querySelector('#ecm-username').textContent).not.toContain('fake-ecm-first-name');
|
||||
expect(element.querySelector('#ecm-username').textContent).not.toContain('null');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('and has image', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
@@ -180,21 +157,13 @@ describe('User info component', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show ecm only last name when user first name is null ', async(() => {
|
||||
userInfoComp.ecmUser.firstName = null;
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#ecm-username')).toBeDefined();
|
||||
expect(element.querySelector('#ecm-username').textContent).not.toContain('fake-ecm-first-name');
|
||||
}));
|
||||
|
||||
xit('should get the ecm current user image from the service', async(() => {
|
||||
it('should get the ecm current user image from the service', async(() => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img').getAttribute('src')).toContain('assets/images/ecmImg.gif');
|
||||
}));
|
||||
|
||||
xit('should get the ecm user informations from the service', async(() => {
|
||||
it('should get the ecm user informations from the service', async(() => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#ecm_username')).toBeDefined();
|
||||
expect(element.querySelector('#ecm_title')).toBeDefined();
|
||||
@@ -243,13 +212,10 @@ describe('User info component', () => {
|
||||
|
||||
describe('when user is logged on bpm', () => {
|
||||
|
||||
let fakeBpmUserForTest;
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(stubAuthService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
||||
jasmine.Ajax.install();
|
||||
fakeBpmUserForTest = fakeBpmUser;
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
@@ -257,8 +223,8 @@ describe('User info component', () => {
|
||||
fixture.detectChanges();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: fakeBpmUserForTest
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeBpmUser)
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -270,6 +236,13 @@ describe('User info component', () => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should show full name next the user image', async(() => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username').innerHTML).toContain('fake-bpm-first-name fake-bpm-last-name');
|
||||
|
||||
}));
|
||||
|
||||
it('should get the bpm current user image from the service', async(() => {
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
||||
@@ -279,27 +252,25 @@ describe('User info component', () => {
|
||||
}));
|
||||
|
||||
it('should show last name if first name is null', async(() => {
|
||||
userInfoComp.bpmUser.firstName = null;
|
||||
let wrongBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: null,
|
||||
lastName: 'fake-last-name'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongBpmUser;
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username')).not.toBeNull();
|
||||
expect(element.querySelector('#bpm-username').textContent).toContain('fake-bpm-last-name');
|
||||
|
||||
}));
|
||||
|
||||
it('should show full name if first and last name are null', async(() => {
|
||||
userInfoComp.bpmUser.firstName = null;
|
||||
userInfoComp.bpmUser.lastName = null;
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-username').innerHTML).toContain('fake-full-name');
|
||||
expect(element.querySelector('#bpm-username').textContent).toContain('fake-last-name');
|
||||
expect(element.querySelector('#bpm-username').textContent).not.toContain('fake-bpm-first-name');
|
||||
|
||||
}));
|
||||
|
||||
it('should not show first name if it is null string', async(() => {
|
||||
userInfoComp.bpmUser.firstName = 'null';
|
||||
userInfoComp.bpmUser.lastName = 'fake-last-name';
|
||||
let wrongFirstNameBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: 'null',
|
||||
lastName: 'fake-last-name'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongFirstNameBpmUser;
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name')).toBeDefined();
|
||||
@@ -308,8 +279,11 @@ describe('User info component', () => {
|
||||
}));
|
||||
|
||||
it('should not show last name if it is null string', async(() => {
|
||||
userInfoComp.bpmUser.firstName = 'fake-first-name';
|
||||
userInfoComp.bpmUser.lastName = 'null';
|
||||
let wrongLastNameBpmUser: BpmUserModel = new BpmUserModel({
|
||||
firstName: 'fake-first-name',
|
||||
lastName: 'null'
|
||||
});
|
||||
userInfoComp.bpmUser = wrongLastNameBpmUser;
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||
expect(element.querySelector('#bpm-full-name')).toBeDefined();
|
||||
|
@@ -81,7 +81,7 @@ export class UserInfoComponent implements OnInit {
|
||||
if (this.authService.isEcmLoggedIn()) {
|
||||
this.ecmUserService.getCurrentUserInfo()
|
||||
.subscribe((res) => {
|
||||
this.ecmUser = <EcmUserModel> res;
|
||||
this.ecmUser = new EcmUserModel(res);
|
||||
this.getEcmAvatar();
|
||||
}
|
||||
);
|
||||
@@ -95,7 +95,7 @@ export class UserInfoComponent implements OnInit {
|
||||
if (this.authService.isBpmLoggedIn()) {
|
||||
this.bpmUserService.getCurrentUserInfo()
|
||||
.subscribe((res) => {
|
||||
this.bpmUser = <BpmUserModel> res;
|
||||
this.bpmUser = new BpmUserModel(res);
|
||||
});
|
||||
this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage();
|
||||
} else {
|
||||
@@ -115,32 +115,6 @@ export class UserInfoComponent implements OnInit {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
getEcmFullName(): string {
|
||||
if (this.ecmUser) {
|
||||
return `${this.formatValue(this.ecmUser.firstName)} ${this.formatValue(this.ecmUser.lastName)}`.trim();
|
||||
}
|
||||
return 'N/A';
|
||||
}
|
||||
|
||||
getBpmFullName(): string {
|
||||
if (this.bpmUser) {
|
||||
return `${this.formatValue(this.bpmUser.firstName)} ${this.formatValue(this.bpmUser.lastName)}`.trim();
|
||||
}
|
||||
return 'N/A';
|
||||
}
|
||||
|
||||
getUserNameHeaderFor(env: string): string {
|
||||
if (this.ecmUser && env === 'ECM') {
|
||||
return this.ecmUser.firstName || this.ecmUser.lastName;
|
||||
}
|
||||
|
||||
if (this.bpmUser && env === 'BPM') {
|
||||
return this.formatValue(this.bpmUser.firstName) ||
|
||||
this.formatValue(this.bpmUser.lastName) ||
|
||||
this.formatValue(this.bpmUser.fullname);
|
||||
}
|
||||
}
|
||||
|
||||
private getEcmAvatar() {
|
||||
this.ecmUserImage = this.ecmUserService.getUserProfileImage(this.ecmUser.avatarId);
|
||||
}
|
||||
@@ -156,8 +130,4 @@ export class UserInfoComponent implements OnInit {
|
||||
getEcmUserAvatar() {
|
||||
return this.ecmUserImage;
|
||||
}
|
||||
|
||||
formatValue(value: string) {
|
||||
return value && value !== 'null' ? value : '';
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ export class BpmUserModel {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullname: string;
|
||||
fullNameDisplay: string;
|
||||
groups: any;
|
||||
id: string;
|
||||
lastUpdate: string;
|
||||
@@ -36,4 +37,32 @@ export class BpmUserModel {
|
||||
tenantName: string;
|
||||
tenantPictureId: string;
|
||||
type: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.apps = obj && obj.apps || null;
|
||||
this.capabilities = obj && obj.capabilities || false;
|
||||
this.company = obj && obj.company || null;
|
||||
this.created = obj && obj.created || null;
|
||||
this.email = obj && obj.email || null;
|
||||
this.externalId = obj && obj.externalId || null;
|
||||
this.firstName = obj && obj.firstName;
|
||||
this.lastName = obj && obj.lastName;
|
||||
this.fullname = obj && obj.fullname;
|
||||
this.fullNameDisplay = obj ? this.formatValue(obj.firstName).trim() + ' ' + this.formatValue(obj.lastName).trim() : null;
|
||||
this.groups = obj && obj.groups || null;
|
||||
this.id = obj && obj.id || null;
|
||||
this.lastUpdate = obj && obj.lastUpdate;
|
||||
this.latestSyncTimeStamp = obj && obj.latestSyncTimeStamp;
|
||||
this.password = obj && obj.password;
|
||||
this.pictureId = obj && obj.pictureId;
|
||||
this.status = obj && obj.status;
|
||||
this.tenantId = obj && obj.tenantId;
|
||||
this.tenantName = obj && obj.tenantName;
|
||||
this.tenantPictureId = obj && obj.tenantPictureId;
|
||||
this.type = obj && obj.type;
|
||||
}
|
||||
|
||||
private formatValue(value: string): string {
|
||||
return value && value !== 'null' ? value : 'N/A';
|
||||
}
|
||||
}
|
||||
|
@@ -18,22 +18,49 @@
|
||||
import { EcmCompanyModel } from './ecm-company.model';
|
||||
|
||||
export class EcmUserModel {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
description: string;
|
||||
avatarId: string;
|
||||
email: string;
|
||||
skypeId: string;
|
||||
googleId: string;
|
||||
instantMessageId: string;
|
||||
jobTitle: string;
|
||||
location: string;
|
||||
company: EcmCompanyModel;
|
||||
mobile: string;
|
||||
telephone: string;
|
||||
statusUpdatedAt: string;
|
||||
userStatus: string;
|
||||
enabled: boolean;
|
||||
emailNotificationsEnabled: boolean;
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullNameDisplay: string;
|
||||
description: string;
|
||||
avatarId: string;
|
||||
email: string;
|
||||
skypeId: string;
|
||||
googleId: string;
|
||||
instantMessageId: string;
|
||||
jobTitle: string;
|
||||
location: string;
|
||||
company: EcmCompanyModel;
|
||||
mobile: string;
|
||||
telephone: string;
|
||||
statusUpdatedAt: string;
|
||||
userStatus: string;
|
||||
enabled: boolean;
|
||||
emailNotificationsEnabled: boolean;
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.id = obj && obj.id || null;
|
||||
this.firstName = obj && obj.firstName;
|
||||
this.lastName = obj && obj.lastName;
|
||||
this.fullNameDisplay = obj ? this.formatValue(obj.firstName).trim() + ' ' + this.formatValue(obj.lastName).trim() : null;
|
||||
this.description = obj && obj.description || null;
|
||||
this.avatarId = obj && obj.avatarId || null;
|
||||
this.email = obj && obj.email || null;
|
||||
this.skypeId = obj && obj.skypeId;
|
||||
this.googleId = obj && obj.googleId;
|
||||
this.instantMessageId = obj && obj.instantMessageId;
|
||||
this.jobTitle = obj && obj.jobTitle || null;
|
||||
this.location = obj && obj.location || null;
|
||||
this.company = obj && obj.company;
|
||||
this.mobile = obj && obj.mobile;
|
||||
this.telephone = obj && obj.telephone;
|
||||
this.statusUpdatedAt = obj && obj.statusUpdatedAt;
|
||||
this.userStatus = obj && obj.userStatus;
|
||||
this.enabled = obj && obj.enabled;
|
||||
this.emailNotificationsEnabled = obj && obj.emailNotificationsEnabled;
|
||||
}
|
||||
|
||||
private formatValue(value: string) {
|
||||
return value && value !== 'null' ? value : 'N/A';
|
||||
}
|
||||
}
|
||||
|
@@ -15,31 +15,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { CoreModule, AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { BpmUserService } from '../services/bpm-user.service';
|
||||
// import { fakeBpmUser } from '../assets/fake-bpm-user.service.mock';
|
||||
|
||||
import { BpmUserModel } from '../models/bpm-user.model';
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('BpmUserService', () => {
|
||||
describe('Bpm user service', () => {
|
||||
|
||||
let service: BpmUserService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let apiService: AlfrescoApiService;
|
||||
let service, injector;
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
BpmUserService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(BpmUserService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
BpmUserService
|
||||
]
|
||||
});
|
||||
service = TestBed.get(BpmUserService);
|
||||
authService = TestBed.get(AlfrescoAuthenticationService);
|
||||
apiService = TestBed.get(AlfrescoApiService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
@@ -47,36 +54,36 @@ describe('BpmUserService', () => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
// TODO: these tests do not make sense
|
||||
|
||||
describe('when user is logged in', () => {
|
||||
|
||||
/*
|
||||
it('should be able to retrieve current user info', (done) => {
|
||||
service.getCurrentUserInfo().subscribe(
|
||||
(user) => {
|
||||
expect(user.fakeBpmUser).toBeDefined();
|
||||
expect(user.fakeBpmUser.firstName).toEqual('fake-first-name');
|
||||
expect(user.fakeBpmUser.lastName).toEqual('fake-last-name');
|
||||
expect(user.fakeBpmUser.email).toEqual('fakeBpm@fake.com');
|
||||
done();
|
||||
});
|
||||
it('should be able to retrieve the user information', (done) => {
|
||||
service.getCurrentUserInfo().subscribe((user: BpmUserModel) => {
|
||||
expect(user).toBeDefined();
|
||||
expect(user.id).toBe(1);
|
||||
expect(user.lastName).toBe('fake-last-name');
|
||||
expect(user.fullname).toBe('fake-full-name');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {fakeBpmUser}
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
lastName: 'fake-last-name',
|
||||
fullname: 'fake-full-name',
|
||||
groups: [],
|
||||
id: 1
|
||||
})
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
xit('should retrieve avatar url for current user', () => {
|
||||
it('should retrieve avatar url for current user', () => {
|
||||
let path = service.getCurrentUserProfileImage();
|
||||
expect(path).toBeDefined();
|
||||
expect(path).toContain('/app/rest/admin/profile-picture');
|
||||
});
|
||||
|
||||
xit('should catch errors on call for profile', (done) => {
|
||||
it('should catch errors on call for profile', (done) => {
|
||||
service.getCurrentUserInfo().subscribe(() => {
|
||||
}, () => {
|
||||
done();
|
||||
|
@@ -15,11 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { CoreModule, AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
import { EcmUserService } from '../services/ecm-user.service';
|
||||
import { fakeEcmUser } from '../assets/fake-ecm-user.service.mock';
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('EcmUserService', () => {
|
||||
@@ -27,30 +33,38 @@ describe('EcmUserService', () => {
|
||||
let service: EcmUserService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let contentService: AlfrescoContentService;
|
||||
let injector;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
EcmUserService
|
||||
]
|
||||
});
|
||||
service = TestBed.get(EcmUserService);
|
||||
authService = TestBed.get(AlfrescoAuthenticationService);
|
||||
contentService = TestBed.get(AlfrescoContentService);
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
EcmUserService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(EcmUserService);
|
||||
authService = injector.get(AlfrescoAuthenticationService);
|
||||
contentService = injector.get(AlfrescoContentService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
describe('when user is logged in', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should be able to retrieve current user info', (done) => {
|
||||
@@ -64,8 +78,8 @@ describe('EcmUserService', () => {
|
||||
});
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {entry: fakeEcmUser}
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({entry: fakeEcmUser})
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user