mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
Added the change for user image
This commit is contained in:
@@ -11,7 +11,43 @@ import {
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `<h4>START</h4><ng2-alfresco-userinfo [userEmail]="'test'"></ng2-alfresco-userinfo>`,
|
||||
styles: [`:host h1 { font-size:22px }`],
|
||||
template: `
|
||||
<h4> START DEMO USERINFO </h4>
|
||||
<div style="border-radius: 8px; position: absolute; background-color:papayawhip; color: cadetblue; left: 320px; top: 30px; z-index: 1;">
|
||||
<p style="width:120px;margin: 20px;">
|
||||
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input type="checkbox" id="switch1" class="mdl-switch__input"
|
||||
(click)="toggleECM(ecm.checked)" #ecm>
|
||||
<span class="mdl-switch__label">ECM</span>
|
||||
</label>
|
||||
</p>
|
||||
<p style="width:120px;margin: 20px;">
|
||||
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input type="checkbox" id="switch2" class="mdl-switch__input" checked
|
||||
(click)="toggleBPM(bpm.checked)" #bpm>
|
||||
<span class="mdl-switch__label">BPM</span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
<div *ngIf="isLoggedIn()">
|
||||
<ng2-alfresco-userinfo [userEmail]=userToLogin></ng2-alfresco-userinfo>
|
||||
</div>
|
||||
<p></p>
|
||||
<div>
|
||||
<p>
|
||||
<span>Username</span>
|
||||
<input id="user" type="text" [(ngModel)]="userToLogin" value="admin"/>
|
||||
</p>
|
||||
<p>
|
||||
<span>Password</span>
|
||||
<input id="passw" type="password" [(ngModel)]="password" value="admin"/>
|
||||
</p>
|
||||
<button type="submit" (click)="attemptLogin()"> Login !</button>
|
||||
</div>
|
||||
<span>{{loginErrorMessage}}</span>
|
||||
|
||||
<button (click)="logout()">Logout</button>`,
|
||||
directives: [ UserInfoComponent ],
|
||||
providers: [AlfrescoAuthenticationService, AlfrescoSettingsService]
|
||||
})
|
||||
@@ -19,30 +55,68 @@ import {
|
||||
|
||||
class UserInfoDemo implements OnInit {
|
||||
|
||||
public userToLogin: string = 'admin';
|
||||
public password: string = 'admin';
|
||||
public loginErrorMessage: string;
|
||||
public providers: string = 'BPM';
|
||||
private authenticated: boolean;
|
||||
private token: any;
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private settingsService: AlfrescoSettingsService) {
|
||||
this.settingsService.setProviders('ALL');
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.login();
|
||||
ngOnInit() {
|
||||
this.settingsService.setProviders(this.providers);
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login('test', 'test').subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.authenticated = false;
|
||||
});
|
||||
}
|
||||
attemptLogin() {
|
||||
this.loginErrorMessage = '';
|
||||
this.login(this.userToLogin, this.password);
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.authService.logout();
|
||||
}
|
||||
|
||||
login(user, password) {
|
||||
this.settingsService.setProviders(this.providers);
|
||||
this.authService.login(user, password).subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.authenticated = false;
|
||||
this.loginErrorMessage = error;
|
||||
});
|
||||
}
|
||||
|
||||
isLoggedIn(): boolean {
|
||||
return this.authService.isLoggedIn();
|
||||
}
|
||||
|
||||
toggleECM(checked) {
|
||||
if (checked && this.providers === 'BPM') {
|
||||
this.providers = 'ALL';
|
||||
} else if (checked) {
|
||||
this.providers = 'ECM';
|
||||
} else {
|
||||
this.providers = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
toggleBPM(checked) {
|
||||
if (checked && this.providers === 'ECM') {
|
||||
this.providers = 'ALL';
|
||||
} else if (checked) {
|
||||
this.providers = 'BPM';
|
||||
} else {
|
||||
this.providers = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(UserInfoDemo, [
|
||||
|
Reference in New Issue
Block a user