[AAE-10501] Remove config from a CoreModule, a different service is provided in AuthModule to use angular http client instead of super agent

This commit is contained in:
Amedeo Lepore
2023-03-31 12:12:03 +02:00
parent 2c1e768f44
commit 48bbc19bd2
2 changed files with 2 additions and 52 deletions
@@ -1,38 +0,0 @@
/*!
* @license
* Copyright 2019 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 { AlfrescoApiHttpClient } from '@alfresco/adf-core/api';
import { StorageService } from '../common/services/storage.service';
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config';
import { AlfrescoApiService } from '../services/alfresco-api.service';
@Injectable()
export class AlfrescoApiServiceWithAngularBasedHttpClient extends AlfrescoApiService {
constructor(
storage: StorageService,
appConfig: AppConfigService,
private readonly alfrescoApiHttpClient: AlfrescoApiHttpClient
) {
super(appConfig, storage);
}
override createInstance(config: AlfrescoApiConfig) {
return new AlfrescoApi(config, this.alfrescoApiHttpClient);
}
}
+2 -14
View File
@@ -45,7 +45,6 @@ import { BlankPageModule } from './blank-page/blank-page.module';
import { DirectiveModule } from './directives/directive.module'; import { DirectiveModule } from './directives/directive.module';
import { PipeModule } from './pipes/pipe.module'; import { PipeModule } from './pipes/pipe.module';
import { AlfrescoApiService } from './services/alfresco-api.service';
import { TranslationService } from './translation/translation.service'; import { TranslationService } from './translation/translation.service';
import { SortingPickerModule } from './sorting-picker/sorting-picker.module'; import { SortingPickerModule } from './sorting-picker/sorting-picker.module';
import { IconModule } from './icon/icon.module'; import { IconModule } from './icon/icon.module';
@@ -66,13 +65,6 @@ import { loadAppConfig } from './app-config/app-config.loader';
import { AppConfigService } from './app-config/app-config.service'; import { AppConfigService } from './app-config/app-config.service';
import { StorageService } from './common/services/storage.service'; import { StorageService } from './common/services/storage.service';
import { AlfrescoApiLoaderService, createAlfrescoApiInstance } from './api-factories/alfresco-api-v2-loader.service'; import { AlfrescoApiLoaderService, createAlfrescoApiInstance } from './api-factories/alfresco-api-v2-loader.service';
import { AlfrescoApiServiceWithAngularBasedHttpClient } from './api-factories/alfresco-api-service-with-angular-based-http-client';
interface Config {
readonly useAngularBasedHttpClientInAlfrescoJs: boolean;
}
const defaultConfig: Config = { useAngularBasedHttpClientInAlfrescoJs: false };
@NgModule({ @NgModule({
imports: [ imports: [
@@ -150,7 +142,7 @@ const defaultConfig: Config = { useAngularBasedHttpClientInAlfrescoJs: false };
] ]
}) })
export class CoreModule { export class CoreModule {
static forRoot(config: Config = defaultConfig): ModuleWithProviders<CoreModule> { static forRoot(): ModuleWithProviders<CoreModule> {
return { return {
ngModule: CoreModule, ngModule: CoreModule,
providers: [ providers: [
@@ -182,11 +174,7 @@ export class CoreModule {
deps: [ AlfrescoApiLoaderService ], deps: [ AlfrescoApiLoaderService ],
multi: true multi: true
}, },
{ provide: HTTP_INTERCEPTORS, useClass: AuthBearerInterceptor, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: AuthBearerInterceptor, multi: true }
...(config.useAngularBasedHttpClientInAlfrescoJs
? [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceWithAngularBasedHttpClient }]
: []
)
] ]
}; };
} }