#1387 fix img for systemjs and refactoring apiservice (#1421)

This commit is contained in:
Mario Romano
2017-01-10 16:59:08 +00:00
committed by Denys Vuika
parent c5dca890b7
commit 9fb085eb3a
18 changed files with 222 additions and 134 deletions

View File

@@ -33,15 +33,15 @@ import { LoginModule } from 'ng2-alfresco-login';
<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" checked
(click)="toggleECM(ecm.checked)" #ecm>
<input type="checkbox" id="switch1" class="mdl-switch__input" [checked]="isECM"
(click)="toggleECM()" #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"
(click)="toggleBPM(bpm.checked)" #bpm>
<input type="checkbox" id="switch2" class="mdl-switch__input" [checked]="isBPM"
(click)="toggleBPM()" #bpm>
<span class="mdl-switch__label">BPM</span>
</label>
</p>
@@ -78,12 +78,14 @@ class UserInfoDemo implements OnInit {
userToLogin: string = 'admin';
password: string = 'admin';
loginErrorMessage: string;
providers: string = 'BPM';
providers: string = 'ALL';
private authenticated: boolean;
private token: any;
disableCsrf: boolean = false;
isECM: boolean = true;
isBPM: boolean = false;
constructor(private authService: AuthService,
private settingsService: SettingsService,
@@ -94,6 +96,7 @@ class UserInfoDemo implements OnInit {
ngOnInit() {
this.settingsService.setProviders(this.providers);
this.initProviders();
}
logout() {
@@ -115,33 +118,60 @@ class UserInfoDemo implements OnInit {
});
}
isLoggedIn(): boolean {
return this.authService.isLoggedIn();
initProviders() {
if (this.providers === 'BPM') {
this.isECM = false;
this.isBPM = true;
} else if (this.providers === 'ECM') {
this.isECM = true;
this.isBPM = false;
} else if (this.providers === 'ALL') {
this.isECM = true;
this.isBPM = true;
}
}
toggleECM(checked) {
if (checked && this.providers === 'BPM') {
toggleECM() {
this.isECM = !this.isECM;
this.settingsService.setProviders(this.updateProvider());
}
toggleBPM() {
this.isBPM = !this.isBPM;
this.settingsService.setProviders(this.updateProvider());
}
updateProvider() {
if (this.isBPM && this.isECM) {
this.providers = 'ALL';
} else if (checked) {
return this.providers;
}
if (this.isECM) {
this.providers = 'ECM';
} else {
this.providers = undefined;
return this.providers;
}
}
toggleBPM(checked) {
if (checked && this.providers === 'ECM') {
this.providers = 'ALL';
} else if (checked) {
if (this.isBPM) {
this.providers = 'BPM';
} else {
this.providers = undefined;
return this.providers;
}
}
this.providers = '';
return this.providers;
};
toggleCSRF() {
this.disableCsrf = !this.disableCsrf;
}
updateEcmHost(): void {
this.settingsService.ecmHost = this.ecmHost;
}
updateBpmHost(): void {
this.settingsService.bpmHost = this.bpmHost;
}
}
@NgModule({

View File

@@ -21,7 +21,7 @@
<div class="demo-card-wide mdl-card">
<div class="card-title__option mdl-card__title"
id="ecm-background-image"
[style.background-image]="'url(' + ( ecmBackgroundImage || baseComponentPath + '/../assets/images/ecm-background.png')+')'">
[style.background-image]="'url(' + ( ecmBackgroundImage || baseComponentPath + '/assets/images/ecm-background.png')+')'">
<img class="profile-picture"
id="ecm-user-detail-image"
alt="ecm-profile-image"
@@ -52,7 +52,7 @@
<div class="demo-card-wide mdl-card">
<div class="card-title__option mdl-card__title"
id="bpm-background-image"
[style.background-image]="'url(' + (bpmBackgroundImage || baseComponentPath + '/../assets/images/bpm-background.png')+')'">
[style.background-image]="'url(' + (bpmBackgroundImage || baseComponentPath + '/assets/images/bpm-background.png')+')'">
<img class="profile-picture"
id="bpm-user-detail-image"
alt="bpm-profile-image"

View File

@@ -50,7 +50,7 @@ export class UserInfoComponent implements OnInit {
bpmUser: BpmUserModel;
anonymousImageUrl: string = this.baseComponentPath + '/../assets/images/anonymous.gif';
anonymousImageUrl: string = this.baseComponentPath + '/assets/images/anonymous.gif';
bpmUserImage: any;

View File

@@ -29,7 +29,7 @@ import { BpmUserModel } from '../models/bpm-user.model';
@Injectable()
export class BpmUserService {
constructor(private alfrescoJsApi: AlfrescoApiService,
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
@@ -38,13 +38,13 @@ export class BpmUserService {
* @param userName - the user name
*/
getCurrentUserInfo(): Observable<BpmUserModel> {
return Observable.fromPromise(this.alfrescoJsApi.getInstance().activiti.profileApi.getProfile())
return Observable.fromPromise(this.apiService.getInstance().activiti.profileApi.getProfile())
.map((data) => <BpmUserModel> data)
.catch(err => this.handleError(err));
}
getCurrentUserProfileImage(): string {
return this.alfrescoJsApi.getInstance().activiti.profileApi.getProfilePictureUrl();
return this.apiService.getInstance().activiti.profileApi.getProfilePictureUrl();
}
/**