mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Add BPM user logged in
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `<h4>START</h4><ng2-alfresco-userinfo></ng2-alfresco-userinfo>`,
|
||||
template: `<h4>START</h4><ng2-alfresco-userinfo [userEmail]="'test'"></ng2-alfresco-userinfo>`,
|
||||
directives: [ UserInfoComponent ],
|
||||
providers: [AlfrescoAuthenticationService, AlfrescoSettingsService]
|
||||
})
|
||||
@@ -20,36 +20,31 @@ import {
|
||||
class UserInfoDemo implements OnInit {
|
||||
|
||||
private authenticated: boolean;
|
||||
private ticket: string;
|
||||
// private ecmHost: string;
|
||||
private token: any;
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private settingsService: AlfrescoSettingsService) {
|
||||
this.settingsService.setProviders('ECM');
|
||||
this.settingsService.setProviders('ALL');
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.login();
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login('test', 'test').subscribe(
|
||||
ticket => {
|
||||
console.log(ticket);
|
||||
this.ticket = this.authService.getTicketEcm();
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.authenticated = false;
|
||||
});
|
||||
}
|
||||
login() {
|
||||
this.authService.login('test', 'test').subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.authenticated = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bootstrap(UserInfoDemo, [
|
||||
UserInfoComponent,
|
||||
HTTP_PROVIDERS,
|
||||
|
@@ -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,65 @@
|
||||
/*!
|
||||
* @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 } from 'ng2-alfresco-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { BpmUserModel } from '../models/bpmUser.model';
|
||||
/**
|
||||
*
|
||||
* BPMUserService retrieve all the information of an Ecm user.
|
||||
*
|
||||
* @returns {BPMUserService} .
|
||||
*/
|
||||
@Injectable()
|
||||
export class BPMUserService {
|
||||
|
||||
constructor(public authService: AlfrescoAuthenticationService) {}
|
||||
|
||||
/**
|
||||
* get User Information via ECM
|
||||
* @param userName - the user name
|
||||
*/
|
||||
getCurrentUserInfo(): Observable<BpmUserModel> {
|
||||
return Observable.fromPromise(this.callApiGetProfile())
|
||||
.map(
|
||||
data => <BpmUserModel> data
|
||||
)
|
||||
.do(
|
||||
data => console.log('Node data', data)
|
||||
) // eyeball results in the console
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
@@ -37,9 +37,9 @@ export class ECMUserService {
|
||||
*/
|
||||
getUserInfo(userName: string): Observable<EcmUserModel> {
|
||||
return Observable.fromPromise(this.callApiGetPersonInfo(userName))
|
||||
.map( data => <EcmUserModel> data )
|
||||
.map( data => <EcmUserModel> data['entry'])
|
||||
.do(
|
||||
data => console.log('Node data', data)
|
||||
data => console.log('Node data', data['entry'])
|
||||
) // eyeball results in the console
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
@@ -1 +1,139 @@
|
||||
<div [innerHtml]="ecmUser">TEST</div>
|
||||
<main class="mdl-layout__content">
|
||||
<div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
|
||||
<!-- Tab Bars -->
|
||||
<div class="mdl-tabs__tab-bar">
|
||||
<a *ngIf="ecmUser" href="#ecm-panel" class="mdl-tabs__tab is-active">ECM</a>
|
||||
<a *ngIf="bpmUser" href="#bpm-panel" class="mdl-tabs__tab">BPM</a>
|
||||
</div>
|
||||
|
||||
<!-- MDL tab panels, is-active to denote currently active -->
|
||||
<div *ngIf="ecmUser" class="mdl-tabs__panel" id="ecm-panel">
|
||||
<ul class="demo-list-control mdl-list">
|
||||
<li class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<i class="material-icons mdl-list__item-avatar">person</i>
|
||||
{{ecmUser.firstName}} {{ecmUser.lastName}}
|
||||
</span>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.id" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Id: </span>
|
||||
<label title="Id">
|
||||
{{ecmUser.id}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.description" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Description: </span>
|
||||
<label title="description">
|
||||
{{ecmUser.description}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.email" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Email: </span>
|
||||
<label title="email">
|
||||
{{ecmUser.email}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.skypeId" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Skype Id: </span>
|
||||
<label title="skypeId">
|
||||
{{ecmUser.skypeId}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.googleId" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Google Id: </span>
|
||||
<label title="googleId">
|
||||
{{ecmUser.googleId}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.instantMessageId" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Instant Message Id: </span>
|
||||
<label title="instantMessageId">
|
||||
{{ecmUser.instantMessageId}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.jobTitle" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Job Title: </span>
|
||||
<label title="jobTitle">
|
||||
{{ecmUser.jobTitle}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.location" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Location: </span>
|
||||
<label title="location">
|
||||
{{ecmUser.location}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.mobile" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Mobile: </span>
|
||||
<label title="mobile">
|
||||
{{ecmUser.mobile}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.telephone" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Telephone: </span>
|
||||
<label title="telephone">
|
||||
{{ecmUser.telephone}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.userStatus" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">User Status: </span>
|
||||
<label title="userStatus">
|
||||
{{ ecmUser.userStatus? 'Active':'Inactive' }}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.enabled" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Enabled: </span>
|
||||
<label title="enabled">
|
||||
{{ecmUser.enabled}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="ecmUser.emailNotificationsEnabled" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Email Notifications: </span>
|
||||
<label title="emailNotificationsEnabled">
|
||||
{{ecmUser.emailNotificationsEnabled? 'Enabled': 'Disabled'}}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf="bpmUser" class="mdl-tabs__panel" id="bpm-panel">
|
||||
<ul class="demo-list-control mdl-list">
|
||||
<li class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">
|
||||
<i class="material-icons mdl-list__item-avatar">person</i>
|
||||
{{bpmUser.fullname}}
|
||||
</span>
|
||||
</li>
|
||||
<li *ngIf="bpmUser.id" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Id: </span>
|
||||
<label title="Id">
|
||||
{{bpmUser.id}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="bpmUser.email" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Email: </span>
|
||||
<label title="email">
|
||||
{{bpmUser.email}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="bpmUser.status" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Status: </span>
|
||||
<label title="jobTitle">
|
||||
{{bpmUser.status}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="bpmUser.tenantName" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Tenant Name: </span>
|
||||
<label title="tenantName">
|
||||
{{bpmUser.tenantName}}
|
||||
</label>
|
||||
</li>
|
||||
<li *ngIf="bpmUser.company" class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content">Company: </span>
|
||||
<label title="company">
|
||||
{{bpmUser.company}}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
@@ -1,31 +1,46 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { ECMUserService } from './services/ecmUser.service';
|
||||
import { BPMUserService } from './services/bpmUser.service';
|
||||
import { EcmUserModel } from './models/ecmUser.model';
|
||||
import { BpmUserModel } from './models/bpmUser.model';
|
||||
import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@Component({
|
||||
selector: 'ng2-alfresco-userinfo',
|
||||
moduleId: __moduleName,
|
||||
styles: [`:host h1 { font-size:22px }`],
|
||||
template: `<h1>Hello World Angular 2 ng2-alfresco-userinfo</h1> <button (click)='doQueryUser()'>Do Query</button>`,
|
||||
providers: [ ECMUserService ]
|
||||
templateUrl: './userinfo.component.html',
|
||||
providers: [ ECMUserService, BPMUserService, AlfrescoContentService ]
|
||||
})
|
||||
|
||||
export class UserInfoComponent implements OnInit {
|
||||
|
||||
export class UserInfoComponent {
|
||||
@Input()
|
||||
userEmail: string;
|
||||
|
||||
private ecmUser: EcmUserModel;
|
||||
private bpmUser: BpmUserModel;
|
||||
|
||||
constructor(private ecmUserService: ECMUserService) {
|
||||
console.log('User info component constr');
|
||||
constructor(private ecmUserService: ECMUserService,
|
||||
private bpmUserService: BPMUserService,
|
||||
private contentService: AlfrescoContentService) {
|
||||
}
|
||||
|
||||
doQueryUser() {
|
||||
this.ecmUserService.getUserInfo('admin')
|
||||
.subscribe(
|
||||
res => this.ecmUser = <EcmUserModel> res.entry
|
||||
);
|
||||
ngOnInit() {
|
||||
this.ecmUserService.getUserInfo(this.userEmail)
|
||||
.subscribe(
|
||||
res => this.ecmUser = <EcmUserModel> res
|
||||
);
|
||||
this.bpmUserService.getCurrentUserInfo()
|
||||
.subscribe(
|
||||
res => this.bpmUser = <BpmUserModel> res
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public getDocumentThumbnailUrl(avatarId: string): string {
|
||||
return this.contentService.getDocumentThumbnailUrl(document);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user