mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
committed by
Denys Vuika
parent
c5dca890b7
commit
9fb085eb3a
@@ -16,32 +16,94 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as alfrescoApi from 'alfresco-js-api';
|
||||
import { AlfrescoApi } from 'alfresco-js-api';
|
||||
import * as alfrescoApi from 'alfresco-js-api';
|
||||
import { SettingsService } from './settings.service';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiService {
|
||||
|
||||
private _instance: AlfrescoApi;
|
||||
private alfrescoApi: AlfrescoApi;
|
||||
|
||||
private provider: string;
|
||||
|
||||
private ticketEcm: string;
|
||||
|
||||
private ticketBpm: string;
|
||||
|
||||
private hostEcm: string;
|
||||
|
||||
private hostBpm: string;
|
||||
|
||||
private contextRoot: string;
|
||||
|
||||
private disableCsrf: boolean;
|
||||
|
||||
public getInstance(): AlfrescoApi {
|
||||
return this._instance;
|
||||
return this.alfrescoApi;
|
||||
}
|
||||
|
||||
public setInstance(value: AlfrescoApi) {
|
||||
this._instance = value;
|
||||
}
|
||||
constructor(private settingsService: SettingsService,
|
||||
private storage: StorageService) {
|
||||
|
||||
constructor() {
|
||||
this._instance = <AlfrescoApi>new alfrescoApi({
|
||||
provider: 'ALL',
|
||||
ticketEcm: null,
|
||||
ticketBpm: null,
|
||||
hostEcm: 'http://localhost:8080',
|
||||
hostBpm: 'http://localhost:9999',
|
||||
contextRoot: 'alfresco',
|
||||
disableCsrf: true
|
||||
this.provider = this.settingsService.getProviders();
|
||||
this.ticketEcm = this.getTicketEcm();
|
||||
this.ticketBpm = this.getTicketBpm();
|
||||
this.hostEcm = this.settingsService.ecmHost;
|
||||
this.hostBpm = this.settingsService.bpmHost;
|
||||
this.contextRoot = 'alfresco';
|
||||
this.disableCsrf = false;
|
||||
|
||||
this.init();
|
||||
|
||||
settingsService.bpmHostSubject.subscribe((hostBpm) => {
|
||||
this.hostBpm = hostBpm;
|
||||
this.init();
|
||||
});
|
||||
|
||||
settingsService.ecmHostSubject.subscribe((hostEcm) => {
|
||||
this.hostEcm = hostEcm;
|
||||
this.init();
|
||||
});
|
||||
|
||||
settingsService.csrfSubject.subscribe((disableCsrf) => {
|
||||
this.disableCsrf = disableCsrf;
|
||||
this.init();
|
||||
});
|
||||
|
||||
settingsService.providerSubject.subscribe((provider) => {
|
||||
this.provider = provider;
|
||||
this.init();
|
||||
});
|
||||
}
|
||||
|
||||
private init() {
|
||||
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
|
||||
provider: this.provider,
|
||||
ticketEcm: this.ticketEcm,
|
||||
ticketBpm: this.ticketBpm,
|
||||
hostEcm: this.hostEcm,
|
||||
hostBpm: this.hostBpm,
|
||||
contextRoot: this.contextRoot,
|
||||
disableCsrf: this.disableCsrf
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return the ECM ticket stored in the Storage
|
||||
* @returns ticket
|
||||
*/
|
||||
private getTicketEcm(): string {
|
||||
return this.storage.getItem('ticket-ECM');
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return the BPM ticket stored in the Storage
|
||||
* @returns ticket
|
||||
*/
|
||||
private getTicketBpm(): string {
|
||||
return this.storage.getItem('ticket-BPM');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user