diff --git a/ng2-components/ng2-alfresco-userinfo/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js index 8f3adc54b4..2b805693c3 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma.conf.js +++ b/ng2-components/ng2-alfresco-userinfo/karma.conf.js @@ -45,6 +45,10 @@ module.exports = function (config) { // ng2-components { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, + // Fake files + { pattern: 'src/assets/ecmImg.gif', included: false, watched: true, served: true }, + { pattern: 'src/assets/bpmImg.gif', included: false, watched: true, served: true }, + { pattern: 'src/img/anonymous.gif', included: false, watched: true, served: true }, // paths to support debugging with source maps in dev tools {pattern: 'src/**/*.ts', included: false, watched: false}, diff --git a/ng2-components/ng2-alfresco-userinfo/src/assets/anonymous.gif b/ng2-components/ng2-alfresco-userinfo/src/assets/anonymous.gif new file mode 100644 index 0000000000..e1b58fa57d Binary files /dev/null and b/ng2-components/ng2-alfresco-userinfo/src/assets/anonymous.gif differ diff --git a/ng2-components/ng2-alfresco-userinfo/src/assets/bpmImg.gif b/ng2-components/ng2-alfresco-userinfo/src/assets/bpmImg.gif new file mode 100644 index 0000000000..e1b58fa57d Binary files /dev/null and b/ng2-components/ng2-alfresco-userinfo/src/assets/bpmImg.gif differ diff --git a/ng2-components/ng2-alfresco-userinfo/src/assets/ecmImg.gif b/ng2-components/ng2-alfresco-userinfo/src/assets/ecmImg.gif new file mode 100644 index 0000000000..e1b58fa57d Binary files /dev/null and b/ng2-components/ng2-alfresco-userinfo/src/assets/ecmImg.gif differ diff --git a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/assets/fake-bpm-user.service.mock.ts similarity index 61% rename from ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts rename to ng2-components/ng2-alfresco-userinfo/src/assets/fake-bpm-user.service.mock.ts index c8eaeb2ab1..eae63e6272 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/assets/fake-bpm-user.service.mock.ts @@ -60,7 +60,30 @@ export var fakeBpmUser: BpmUserModel = { lastUpdate: 'fake-update-date', latestSyncTimeStamp: 'fake-timestamp', password: 'fake-password', - pictureId: 'fake-picture-id', + pictureId: 'src/assets/bpmImg.gif', + status: 'fake-status', + tenantId: 'fake-tenant-id', + tenantName: 'fake-tenant-name', + tenantPictureId: 'fake-tenant-picture-id', + type: 'fake-type' +}; + +export var fakeBpmEditedUser: BpmUserModel = { + apps: {}, + capabilities: 'fake-capability', + 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: {}, + id: 'fake-id', + lastUpdate: 'fake-update-date', + latestSyncTimeStamp: 'fake-timestamp', + password: 'fake-password', + pictureId: 'src/assets/bpmImg.gif', status: 'fake-status', tenantId: 'fake-tenant-id', tenantName: 'fake-tenant-name', @@ -70,27 +93,31 @@ export var fakeBpmUser: BpmUserModel = { export class FakeBpmUserService { - lastPromise: Observable; - public userNeeded = 0; - usersList = [fakeBpmUser, fakeBpmUserNoImage]; + lastPromise: Observable; + public userNeeded = 0; + usersList = [fakeBpmUser, fakeBpmUserNoImage, fakeBpmEditedUser]; - getUserInfo(userName: string) { - return this.lastPromise = Observable.of(this.usersList[this.userNeeded]); - }; + getUserInfo(userName: string) { + return this.lastPromise = Observable.of(this.usersList[this.userNeeded]); + }; - getCurrentUserInfo() { - return this.getUserInfo('fake-id'); - }; + getCurrentUserInfo() { + return this.getUserInfo('fake-id'); + }; - getCurrentUserProfileImage() { - return this.usersList[this.userNeeded].pictureId; - }; + getCurrentUserProfileImage() { + return Observable.of(this.usersList[this.userNeeded].pictureId); + }; - respondWithTheUserWithoutImage() { - this.userNeeded = 1; - } + respondWithTheUserWithoutImage() { + this.userNeeded = 1; + } - respondWithTheUserWithImage() { - this.userNeeded = 0; - } + respondWithTheUserWithImage() { + this.userNeeded = 0; + } + + respondWithEditedUser() { + this.userNeeded = 2; + } } diff --git a/ng2-components/ng2-alfresco-userinfo/src/assets/fake-ecm-user.service.mock.ts b/ng2-components/ng2-alfresco-userinfo/src/assets/fake-ecm-user.service.mock.ts new file mode 100644 index 0000000000..c2d7a9d040 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/assets/fake-ecm-user.service.mock.ts @@ -0,0 +1,132 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// re-export for tester convenience +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 = { + organization: 'company-fake-name', + address1: 'fake-address-1', + address2: 'fake-address-2', + address3: 'fake-address-3', + postcode: 'fAk1', + telephone: '00000000', + fax: '11111111', + email: 'fakeCompany@fake.com' +}; + +export var fakeEcmUserNoImage: EcmUserModel = { + id: 'fake-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + description: 'i am a fake user for test', + avatarId: undefined, + 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 var fakeEcmUser: 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 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; + 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/ecmImg.gif'; + } + }; + + respondWithTheUserWithoutImage() { + this.userNeeded = 1; + }; + + respondWithTheUserWithImage() { + this.userNeeded = 0; + }; + + respondWithEditedUser() { + this.userNeeded = 2; + }; + +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css index 93254d00fa..ddda950182 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css @@ -2,6 +2,7 @@ text-align: center; border-radius: 90%; width: 40px; + height: 40px; margin-right: 0%; cursor: pointer; border: 1px solid #999999; @@ -16,6 +17,7 @@ .detail-user-profile-list-mdl{ margin-right: 10px; + padding: 0px 0; } .user-profile-list-mdl{ diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html index 5a8b50db9c..a5cccc1539 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html @@ -1,56 +1,58 @@ -
- {{ecmUser.firstName || ecmUser.lastName}} - +
+ {{ecmUser.firstName || ecmUser.lastName}} + {{ formatValue(bpmUser.firstName) || formatValue(bpmUser.lastName) || - formatValue(bpmUser.fullName) }} + formatValue(bpmUser.fullname) }} -
+
-