mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Added new version for component
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
.profile-image {
|
||||
text-align: center;
|
||||
border-radius: 90%;
|
||||
width: 40px;
|
||||
margin-right: 0%;
|
||||
cursor: pointer;
|
||||
border: 1px solid #999999;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.button-profile {
|
||||
display: inline-block;
|
||||
border: 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.detail-user-profile-list-mdl{
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.user-profile-list-mdl{
|
||||
max-height: 450px;
|
||||
min-width: 450px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.header-profile{
|
||||
color: rgb(255,152,0);
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
hr.title-start {
|
||||
border: 0;
|
||||
height: 1px;
|
||||
background: #333;
|
||||
background-image: linear-gradient(to right, #ccc, #333, #ccc);
|
||||
}
|
||||
|
||||
span.role-label-user{
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
letter-spacing: 0;
|
||||
color: rgba(0,0,0,.87);
|
||||
}
|
||||
|
||||
.custom-role-style{
|
||||
font-size: 14px;
|
||||
color: #9e9e9e;
|
||||
}
|
||||
|
||||
.truncate-long-names{
|
||||
text-overflow: ellipsis;
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
<div id="img_container">
|
||||
<span *ngIf="ecmUser">{{ecmUser.firstName || ecmUser.lastName}}</span>
|
||||
<span *ngIf="bpmUser">
|
||||
{{ formatValue(bpmUser.firstName) ||
|
||||
formatValue(bpmUser.lastName) ||
|
||||
formatValue(bpmUser.fullName) }}
|
||||
</span>
|
||||
<div class="button-profile" id="user-profile" data-automation-id="user-profile">
|
||||
<img id="logged-user-img"
|
||||
[src]="getUserAvatar()"
|
||||
class="profile-image"/>
|
||||
</div>
|
||||
<div class="user-profile-list-mdl
|
||||
mdl-menu mdl-menu--bottom-right
|
||||
mdl-js-menu mdl-js-ripple-effect"
|
||||
for="user-profile">
|
||||
<ul class='detail-user-profile-list-mdl mdl-list'>
|
||||
<div *ngIf="ecmUser">
|
||||
<span class="header-profile"><b>ECM</b></span>
|
||||
<hr class="title-start">
|
||||
<li class="mdl-list__item mdl-list__item--two-line">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<i class="mdl-list__item-avatar">
|
||||
<img id="logged-user-img"
|
||||
[src]="getEcmUserDetailAvatarUrl()"
|
||||
class="profile-image"/>
|
||||
</i>
|
||||
<span class="truncate-long-names">{{ecmUser.firstName}} {{ecmUser.lastName}}</span>
|
||||
<span class="mdl-list__item-sub-title">{{ecmUser.email}}</span>
|
||||
</span>
|
||||
<span class="mdl-list__item-secondary-content custom-role-style">
|
||||
<span class="role-label-user">Job Role</span>
|
||||
{{ecmUser.jobTitle}}
|
||||
</span>
|
||||
</li>
|
||||
</div>
|
||||
|
||||
<div *ngIf="bpmUser">
|
||||
<span class="header-profile"><b>BPM</b></span>
|
||||
<hr class="title-start">
|
||||
<li class="mdl-list__item mdl-list__item--two-line">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<i class="mdl-list__item-avatar">
|
||||
<img id="logged-user-img"
|
||||
[src]="getBpmUserDetailAvatarUrl()"
|
||||
class="profile-image"/>
|
||||
</i>
|
||||
<span class="truncate-long-names">
|
||||
{{formatValue(bpmUser.firstName) }} {{ formatValue(bpmUser.lastName) }}
|
||||
</span>
|
||||
<span class="mdl-list__item-sub-title">{{bpmUser.email}}</span>
|
||||
</span>
|
||||
<span class="mdl-list__item-secondary-content custom-role-style">
|
||||
<span class="role-label-user">Tenant</span>
|
||||
{{bpmUser.tenantName}}
|
||||
</span>
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -0,0 +1,25 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
// import { UserInfoComponent } from '../src/userinfo.component';
|
||||
|
||||
describe('Basic Example test ng2-alfresco-userinfo', () => {
|
||||
|
||||
it('Test hello world', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,93 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
import { Component, OnInit } 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 { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@Component({
|
||||
selector: 'ng2-alfresco-userinfo',
|
||||
moduleId: __moduleName,
|
||||
styleUrls: ['./userinfo.component.css'],
|
||||
template: `<h1>HELLO</h1>`
|
||||
})
|
||||
|
||||
export class UserInfoComponent implements OnInit {
|
||||
|
||||
private ecmUser: EcmUserModel;
|
||||
private bpmUser: BpmUserModel;
|
||||
private baseComponentPath = __moduleName.replace('userinfo.component.js', '');
|
||||
private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif';
|
||||
public bpmUserImage: any;
|
||||
public ecmUserImage: any;
|
||||
|
||||
constructor(private ecmUserService: EcmUserService,
|
||||
private bpmUserService: BpmUserService,
|
||||
public authService: AlfrescoAuthenticationService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.authService.getAlfrescoApi().ecmAuth.isLoggedIn()) {
|
||||
this.ecmUserService.getUserInfo('-me-')
|
||||
.subscribe(
|
||||
(res) => {
|
||||
this.ecmUser = <EcmUserModel> res;
|
||||
this.getEcmUserProfileImage();
|
||||
}
|
||||
);
|
||||
}
|
||||
if (this.authService.getAlfrescoApi().bpmAuth.isLoggedIn()) {
|
||||
this.bpmUserService.getCurrentUserInfo()
|
||||
.subscribe(
|
||||
(res) => {
|
||||
this.bpmUser = <BpmUserModel> res;
|
||||
this.getBpmUserProfileImage();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private getBpmUserProfileImage() {
|
||||
this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage();
|
||||
}
|
||||
|
||||
private getEcmUserProfileImage() {
|
||||
this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId);
|
||||
}
|
||||
|
||||
public getUserAvatar() {
|
||||
return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl;
|
||||
}
|
||||
|
||||
public getBpmUserDetailAvatarUrl() {
|
||||
return this.bpmUserImage || this.anonymouseImageUrl;
|
||||
}
|
||||
|
||||
public getEcmUserDetailAvatarUrl() {
|
||||
return this.ecmUserImage || this.anonymouseImageUrl;
|
||||
}
|
||||
|
||||
public formatValue(value: string) {
|
||||
return value === 'null' ? null : value;
|
||||
}
|
||||
|
||||
}
|
24
ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json
Normal file
24
ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"FILE_UPLOAD": {
|
||||
"BUTTON": {
|
||||
"UPLOAD_FILE": "Upload file",
|
||||
"UPLOAD_FOLDER": "Upload folder",
|
||||
"CANCEL": "CANCEL"
|
||||
},
|
||||
"MESSAGES": {
|
||||
"COMPLETED": "uploads complete",
|
||||
"PROGRESS": "Upload in progress...",
|
||||
"FOLDER_ALREADY_EXIST": "The folder {0} already exist",
|
||||
"FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser"
|
||||
},
|
||||
"FILE_INFO": {
|
||||
"NAME": "File name",
|
||||
"PROGRESS": "File progress",
|
||||
"SIZE": "File size",
|
||||
"ACTION": "Actions"
|
||||
},
|
||||
"ACTION": {
|
||||
"UNDO": "Undo"
|
||||
}
|
||||
}
|
||||
}
|
24
ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json
Normal file
24
ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"FILE_UPLOAD": {
|
||||
"BUTTON": {
|
||||
"UPLOAD_FILE": "Carica un file",
|
||||
"UPLOAD_FOLDER": "Carica una cartella",
|
||||
"CANCEL": "CANCELLA"
|
||||
},
|
||||
"MESSAGES": {
|
||||
"COMPLETED": "caricamenti completati",
|
||||
"PROGRESS": "caricamento in corso...",
|
||||
"FOLDER_ALREADY_EXIST": "Cartella {0} già presente",
|
||||
"FOLDER_NOT_SUPPORTED": "L' upload di cartelle non é supportato dal tuo browser"
|
||||
},
|
||||
"FILE_INFO": {
|
||||
"NAME": "Nome file",
|
||||
"PROGRESS": "Percentuale caricamento",
|
||||
"SIZE": "Dimensione file",
|
||||
"ACTION": "Azioni"
|
||||
},
|
||||
"ACTION": {
|
||||
"UNDO": "Annulla"
|
||||
}
|
||||
}
|
||||
}
|
BIN
ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif
Normal file
BIN
ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,39 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
export class BpmUserModel {
|
||||
apps: any;
|
||||
capabilities: string;
|
||||
company: string;
|
||||
created: string;
|
||||
email: string;
|
||||
externalId: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullname: string;
|
||||
groups: any;
|
||||
id: string;
|
||||
lastUpdate: string;
|
||||
latestSyncTimeStamp: string;
|
||||
password: string;
|
||||
pictureId: string;
|
||||
status: string;
|
||||
tenantId: string;
|
||||
tenantName: string;
|
||||
tenantPictureId: string;
|
||||
type: string;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
export class EcmCompanyModel {
|
||||
organization: string;
|
||||
address1: string;
|
||||
address2: string;
|
||||
address3: string;
|
||||
postcode: string;
|
||||
telephone: string;
|
||||
fax: string;
|
||||
email: string;
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { BpmUserModel } from '../models/bpm-user.model';
|
||||
/**
|
||||
*
|
||||
* BPMUserService retrieve all the information of an Ecm user.
|
||||
*
|
||||
* @returns {BPMUserService} .
|
||||
*/
|
||||
@Injectable()
|
||||
export class BpmUserService {
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private settingService: AlfrescoSettingsService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* get User Information via ECM
|
||||
* @param userName - the user name
|
||||
*/
|
||||
getCurrentUserInfo(): Observable<BpmUserModel> {
|
||||
if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) {
|
||||
return Observable.fromPromise(this.callApiGetProfile())
|
||||
.map(
|
||||
(data) => <BpmUserModel> data
|
||||
)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get User Information via ECM
|
||||
* @param userName - the user name
|
||||
*/
|
||||
getCurrentUserProfileImage(): string {
|
||||
if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) {
|
||||
return this.settingService.getBPMApiBaseUrl() + '/api/enterprise/profile-picture';
|
||||
}
|
||||
}
|
||||
|
||||
private callApiGetProfile() {
|
||||
return this.authService.getAlfrescoApi().activiti.profileApi.getProfile();
|
||||
}
|
||||
/**
|
||||
* Throw the error
|
||||
* @param error
|
||||
* @returns {ErrorObservable}
|
||||
*/
|
||||
private handleError(error: Response) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { EcmUserModel } from '../models/ecm-user.model';
|
||||
/**
|
||||
*
|
||||
* ECMUserService retrieve all the information of an Ecm user.
|
||||
*
|
||||
* @returns {ECMUserService} .
|
||||
*/
|
||||
@Injectable()
|
||||
export class EcmUserService {
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private contentService: AlfrescoContentService) {}
|
||||
|
||||
/**
|
||||
* get User Information via ECM
|
||||
* @param userName - the user name
|
||||
*/
|
||||
getUserInfo(userName: string): Observable<EcmUserModel> {
|
||||
if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) {
|
||||
return Observable.fromPromise(this.callApiGetPersonInfo(userName))
|
||||
.map(
|
||||
(data) => <EcmUserModel> data['entry']
|
||||
)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
}
|
||||
|
||||
private callApiGetPersonInfo(userName: string, opts?: any) {
|
||||
return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts);
|
||||
}
|
||||
|
||||
getCurrentUserProfileImageUrl(avatarId: string) {
|
||||
if ( avatarId ) {
|
||||
let nodeObj = {entry: {id: avatarId}};
|
||||
return this.contentService.getContentUrl(nodeObj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the error
|
||||
* @param error
|
||||
* @returns {ErrorObservable}
|
||||
*/
|
||||
private handleError(error: Response) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
console.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user