mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#543 dedicated AlfrescoApi service
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
'ng2-activiti-form': 'node_modules/ng2-activiti-form/dist',
|
||||
'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist',
|
||||
'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/dist',
|
||||
'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist'
|
||||
'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist',
|
||||
'alfresco-js-api': 'node_modules/alfresco-js-api/dist'
|
||||
};
|
||||
// packages tells the System loader how to load when no filename and/or no extension
|
||||
var packages = {
|
||||
@@ -39,7 +40,8 @@
|
||||
'ng2-alfresco-viewer': { main: 'index.js', defaultExtension: 'js'},
|
||||
'ng2-activiti-form': { main: 'index.js', defaultExtension: 'js'},
|
||||
'ng2-activiti-tasklist': { main: 'index.js', defaultExtension: 'js'},
|
||||
'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'}
|
||||
'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'},
|
||||
'alfresco-js-api': { main: 'alfresco-js-api.js', defaultExtension: 'js'}
|
||||
};
|
||||
var ngPackageNames = [
|
||||
'common',
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoApiService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoTranslationLoader,
|
||||
AlfrescoTranslationService,
|
||||
@@ -31,6 +32,7 @@ export * from './src/components/index';
|
||||
export * from './src/utils/index';
|
||||
|
||||
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSettingsService,
|
||||
|
@@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* @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 { Injectable } from '@angular/core';
|
||||
import { AlfrescoJsApi } from 'alfresco-js-api';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiService {
|
||||
|
||||
private _instance: AlfrescoJsApi;
|
||||
|
||||
public getInstance(): AlfrescoJsApi {
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
public setInstance(value: AlfrescoJsApi) {
|
||||
this._instance = value;
|
||||
}
|
||||
|
||||
}
|
@@ -18,8 +18,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
|
||||
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||
import { AlfrescoJsApi } from 'alfresco-js-api';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
declare var AlfrescoApi: AlfrescoJsApi;
|
||||
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
||||
@@ -27,32 +29,37 @@ declare let AlfrescoApi: any;
|
||||
@Injectable()
|
||||
export class AlfrescoAuthenticationService {
|
||||
|
||||
alfrescoApi: any;
|
||||
alfrescoApi: AlfrescoJsApi;
|
||||
|
||||
/**A
|
||||
/**
|
||||
* Constructor
|
||||
* @param alfrescoSetting
|
||||
* @param settingsService
|
||||
* @param apiService
|
||||
*/
|
||||
constructor(public alfrescoSetting: AlfrescoSettingsService) {
|
||||
constructor(private settingsService: AlfrescoSettingsService,
|
||||
private apiService: AlfrescoApiService) {
|
||||
this.alfrescoApi = new AlfrescoApi({
|
||||
provider: this.alfrescoSetting.getProviders(),
|
||||
provider: this.settingsService.getProviders(),
|
||||
ticketEcm: this.getTicketEcm(),
|
||||
ticketBpm: this.getTicketBpm(),
|
||||
hostEcm: this.alfrescoSetting.ecmHost,
|
||||
hostBpm: this.alfrescoSetting.bpmHost
|
||||
hostEcm: this.settingsService.ecmHost,
|
||||
hostBpm: this.settingsService.bpmHost,
|
||||
contextRoot: 'alfresco'
|
||||
});
|
||||
|
||||
alfrescoSetting.bpmHostSubject.subscribe((bpmHost) => {
|
||||
settingsService.bpmHostSubject.subscribe((bpmHost) => {
|
||||
this.alfrescoApi.changeBpmHost(bpmHost);
|
||||
});
|
||||
|
||||
alfrescoSetting.ecmHostSubject.subscribe((ecmHost) => {
|
||||
settingsService.ecmHostSubject.subscribe((ecmHost) => {
|
||||
this.alfrescoApi.changeEcmHost(ecmHost);
|
||||
});
|
||||
|
||||
alfrescoSetting.providerSubject.subscribe((value) => {
|
||||
settingsService.providerSubject.subscribe((value) => {
|
||||
this.alfrescoApi.config.provider = value;
|
||||
});
|
||||
|
||||
this.apiService.setInstance(this.alfrescoApi);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +80,7 @@ export class AlfrescoAuthenticationService {
|
||||
return Observable.fromPromise(this.callApiLogin(username, password))
|
||||
.map((response: any) => {
|
||||
this.saveTickets();
|
||||
return {type: this.alfrescoSetting.getProviders(), ticket: response};
|
||||
return {type: this.settingsService.getProviders(), ticket: response};
|
||||
})
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './AlfrescoApi.service';
|
||||
export * from './AlfrescoSettings.service';
|
||||
export * from './AlfrescoTranslationLoader.service';
|
||||
export * from './AlfrescoTranslation.service';
|
||||
|
Reference in New Issue
Block a user