From 0d93c65fd7fb91b1f2048d5fadb2639a870b0750 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 31 Jan 2018 17:39:26 +0000 Subject: [PATCH] [ADF-2064] Lazy loading support (#2811) * remove BrowserAnimationsModule dependency * improve test shim * update test shim * test shim updates * example of lazy-loaded datatable * local and global i18n demo for lazy modules * lazy loading support for CoreModule providers * test shim updates * update test shim * support global i18n for lazy modules * cleanup lazy loading example * update card view after rebase * backwards compatibility * cleanup files * fix code after rebase --- demo-shell/.angular-cli.json | 10 + demo-shell/resources/i18n/en.json | 1 + demo-shell/src/app/app.module.ts | 14 +- demo-shell/src/app/app.routes.ts | 4 + .../app-layout/app-layout.component.ts | 1 + .../app/components/lazy-loading/i18n/en.json | 5 + .../lazy-loading/lazy-loading.component.ts | 54 ++++++ .../lazy-loading/lazy-loading.module.ts | 19 ++ .../lazy-loading/lazy-loading.routes.ts | 21 +++ lib/config/karma-test-shim.js | 10 +- lib/content-services/content.module.ts | 2 - lib/content-services/karma-test-shim.js | 9 +- .../search-control.component.spec.ts | 4 +- lib/core/card-view/card-view.module.ts | 7 - lib/core/core.module.ts | 172 ++++++++++++++---- lib/core/index.ts | 1 - lib/core/karma-test-shim.js | 4 +- .../services/notification.service.spec.ts | 4 +- lib/core/services/service.module.ts | 92 ---------- lib/insights/insights.module.ts | 4 +- lib/insights/karma-test-shim.js | 9 +- lib/process-services/karma-test-shim.js | 13 +- lib/process-services/process.module.ts | 3 - 23 files changed, 298 insertions(+), 165 deletions(-) create mode 100644 demo-shell/src/app/components/lazy-loading/i18n/en.json create mode 100644 demo-shell/src/app/components/lazy-loading/lazy-loading.component.ts create mode 100644 demo-shell/src/app/components/lazy-loading/lazy-loading.module.ts create mode 100644 demo-shell/src/app/components/lazy-loading/lazy-loading.routes.ts delete mode 100644 lib/core/services/service.module.ts diff --git a/demo-shell/.angular-cli.json b/demo-shell/.angular-cli.json index 7d156ca548..8103d163c5 100644 --- a/demo-shell/.angular-cli.json +++ b/demo-shell/.angular-cli.json @@ -18,6 +18,11 @@ "input": "../resources", "output": "./resources" }, + { + "glob": "**/*", + "input": "./app/components/lazy-loading/i18n", + "output": "./resources/lazy-loading/i18n" + }, { "glob": "**/*", "input": "../node_modules/@alfresco/adf-core/prebuilt-themes", @@ -90,6 +95,11 @@ "input": "../resources", "output": "./resources" }, + { + "glob": "**/*", + "input": "./app/components/lazy-loading/i18n", + "output": "./resources/lazy-loading/i18n" + }, { "glob": "**/*", "input": "../../lib/core/prebuilt-themes", diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json index e232a358c6..ad9c6c5143 100644 --- a/demo-shell/resources/i18n/en.json +++ b/demo-shell/resources/i18n/en.json @@ -17,6 +17,7 @@ "LOGIN": "Login", "CUSTOM_SOURCES": "Custom Sources", "DATATABLE": "Datatable", + "DATATABLE_LAZY": "Datatable (Lazy)", "FORM": "Form", "FORM_LIST": "Form List", "UPLOADER": "Uploader", diff --git a/demo-shell/src/app/app.module.ts b/demo-shell/src/app/app.module.ts index 3649774921..75b2230b14 100644 --- a/demo-shell/src/app/app.module.ts +++ b/demo-shell/src/app/app.module.ts @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms'; import { FlexLayoutModule } from '@angular/flex-layout'; import { ChartsModule } from 'ng2-charts'; import { HttpClientModule } from '@angular/common/http'; -import { TranslateService } from '@ngx-translate/core'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppConfigService, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; import { AppComponent } from './app.component'; @@ -40,7 +40,6 @@ import { ThemePickerModule } from './components/theme-picker/theme-picker'; import { DebugAppConfigService } from './services/debug-app-config.service'; import { routing } from './app.routes'; -import { TranslateModule } from '@ngx-translate/core'; import { ReactiveFormsModule } from '@angular/forms'; import { TaskAttachmentsComponent } from './components/process-service/task-attachments.component'; import { ProcessAttachmentsComponent } from './components/process-service/process-attachments.component'; @@ -49,8 +48,8 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li @NgModule({ imports: [ + BrowserAnimationsModule, ReactiveFormsModule, - TranslateModule, BrowserModule, routing, FormsModule, @@ -92,7 +91,6 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li SharedLinkViewComponent ], providers: [ - TranslateService, { provide: AppConfigService, useClass: DebugAppConfigService }, { provide: TRANSLATION_PROVIDER, @@ -101,6 +99,14 @@ import { SharedLinkViewComponent } from './components/shared-link-view/shared-li name: 'app', source: 'resources' } + }, + { + provide: TRANSLATION_PROVIDER, + multi: true, + useValue: { + name: 'lazy-loading', + source: 'resources/lazy-loading' + } } ], entryComponents: [ diff --git a/demo-shell/src/app/app.routes.ts b/demo-shell/src/app/app.routes.ts index 5869b81417..6911f17814 100644 --- a/demo-shell/src/app/app.routes.ts +++ b/demo-shell/src/app/app.routes.ts @@ -166,6 +166,10 @@ export const appRoutes: Routes = [ path: 'overlay-viewer', component: OverlayViewerComponent, canActivate: [AuthGuardEcm] + }, + { + path: 'datatable-lazy', + loadChildren: 'app/components/lazy-loading/lazy-loading.module#LazyLoadingModule' } ] } diff --git a/demo-shell/src/app/components/app-layout/app-layout.component.ts b/demo-shell/src/app/components/app-layout/app-layout.component.ts index 1fef973b98..7791e05ab3 100644 --- a/demo-shell/src/app/components/app-layout/app-layout.component.ts +++ b/demo-shell/src/app/components/app-layout/app-layout.component.ts @@ -34,6 +34,7 @@ export class AppLayoutComponent { { href: '/login', icon: 'vpn_key', title: 'APP_LAYOUT.LOGIN' }, { href: '/dl-custom-sources', icon: 'extension', title: 'APP_LAYOUT.CUSTOM_SOURCES' }, { href: '/datatable', icon: 'view_module', title: 'APP_LAYOUT.DATATABLE' }, + { href: '/datatable-lazy', icon: 'view_module', title: 'APP_LAYOUT.DATATABLE_LAZY' }, { href: '/form', icon: 'poll', title: 'APP_LAYOUT.FORM' }, { href: '/form-list', icon: 'library_books', title: 'APP_LAYOUT.FORM_LIST' }, { href: '/uploader', icon: 'file_upload', title: 'APP_LAYOUT.UPLOADER' }, diff --git a/demo-shell/src/app/components/lazy-loading/i18n/en.json b/demo-shell/src/app/components/lazy-loading/i18n/en.json new file mode 100644 index 0000000000..d0594e603a --- /dev/null +++ b/demo-shell/src/app/components/lazy-loading/i18n/en.json @@ -0,0 +1,5 @@ +{ + "LAZY": { + "TEXT": "Text from lazy component resources" + } +} diff --git a/demo-shell/src/app/components/lazy-loading/lazy-loading.component.ts b/demo-shell/src/app/components/lazy-loading/lazy-loading.component.ts new file mode 100644 index 0000000000..a045b12ae5 --- /dev/null +++ b/demo-shell/src/app/components/lazy-loading/lazy-loading.component.ts @@ -0,0 +1,54 @@ +import { Component } from '@angular/core'; +import { ObjectDataTableAdapter, AuthenticationService } from '@alfresco/adf-core'; + +@Component({ + selector: 'app-lazy-component', + template: ` + + + + ` +}) +export class LazyLoadingComponent { + + data: ObjectDataTableAdapter; + + get isLoggedIn(): boolean { + return this.auth.isLoggedIn(); + } + + get username(): string { + return this.auth.getEcmUsername(); + } + + constructor(private auth: AuthenticationService) { + this.data = new ObjectDataTableAdapter( + // data + [ + {id: 1, name: 'Name 1'}, + {id: 2, name: 'Name 2'} + ], + // schema + [ + { + type: 'text', + key: 'id', + title: 'Id', + sortable: true + }, + { + type: 'text', + key: 'name', + title: 'Name', + cssClass: 'full-width', + sortable: true + } + ] + ); + } +} diff --git a/demo-shell/src/app/components/lazy-loading/lazy-loading.module.ts b/demo-shell/src/app/components/lazy-loading/lazy-loading.module.ts new file mode 100644 index 0000000000..f35c0f5f3e --- /dev/null +++ b/demo-shell/src/app/components/lazy-loading/lazy-loading.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { CoreModule, TranslationService } from '@alfresco/adf-core'; + +import { LazyLoadingRoutes } from './lazy-loading.routes'; +import { LazyLoadingComponent } from './lazy-loading.component'; + +@NgModule({ + imports: [ + CoreModule.forChild(), + LazyLoadingRoutes + ], + declarations: [ + LazyLoadingComponent + ] +}) +export class LazyLoadingModule { + constructor(translation: TranslationService) { + } +} diff --git a/demo-shell/src/app/components/lazy-loading/lazy-loading.routes.ts b/demo-shell/src/app/components/lazy-loading/lazy-loading.routes.ts new file mode 100644 index 0000000000..824a649b71 --- /dev/null +++ b/demo-shell/src/app/components/lazy-loading/lazy-loading.routes.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { LazyLoadingComponent } from './lazy-loading.component'; + +export const routes: Routes = [ + { + path: '', + component: LazyLoadingComponent + } +]; + +@NgModule({ + imports: [ + RouterModule.forChild(routes) + ], + exports: [ + RouterModule + ] +}) +export class LazyLoadingRoutes { +} diff --git a/lib/config/karma-test-shim.js b/lib/config/karma-test-shim.js index c9ed23e1e0..7b95d363a5 100644 --- a/lib/config/karma-test-shim.js +++ b/lib/config/karma-test-shim.js @@ -17,6 +17,7 @@ var appContext = require.context(".", true, /.spec.ts/);appContext.keys().forEac const TestBed = require('@angular/core/testing').TestBed; const browser = require('@angular/platform-browser-dynamic/testing'); +const NoopAnimationsModule = require('@angular/platform-browser/animations').NoopAnimationsModule; const CoreModule = require('@alfresco/adf-core').CoreModule; const AppConfigService = require('@alfresco/adf-core').AppConfigService; const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock; @@ -31,7 +32,14 @@ TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platfor beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreModule, TranslateModule, CommonModule, FormsModule, ReactiveFormsModule], + imports: [ + NoopAnimationsModule, + CoreModule, + TranslateModule, + CommonModule, + FormsModule, + ReactiveFormsModule + ], providers: [ {provide: AppConfigService, useClass: AppConfigServiceMock}, {provide: TranslationService, useClass: TranslationMock} diff --git a/lib/content-services/content.module.ts b/lib/content-services/content.module.ts index a52cdb2f1f..0281ab8c9b 100644 --- a/lib/content-services/content.module.ts +++ b/lib/content-services/content.module.ts @@ -18,7 +18,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CoreModule, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; import { MaterialModule } from './material.module'; @@ -47,7 +46,6 @@ import { ContentMetadataModule } from './content-metadata/content-metadata.modul FormsModule, ReactiveFormsModule, SearchModule, - BrowserAnimationsModule, DocumentListModule, UploadModule, MaterialModule, diff --git a/lib/content-services/karma-test-shim.js b/lib/content-services/karma-test-shim.js index 66b295c42a..a94f5669ff 100644 --- a/lib/content-services/karma-test-shim.js +++ b/lib/content-services/karma-test-shim.js @@ -13,10 +13,12 @@ require('zone.js/dist/fake-async-test'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; -var appContext = require.context(".", true, /.spec.ts/);appContext.keys().forEach(appContext); +var appContext = require.context(".", true, /.spec.ts/); +appContext.keys().forEach(appContext); const TestBed = require('@angular/core/testing').TestBed; const browser = require('@angular/platform-browser-dynamic/testing'); +const NoopAnimationsModule = require('@angular/platform-browser/animations').NoopAnimationsModule; const CoreModule = require('@alfresco/adf-core').CoreModule; const AppConfigService = require('@alfresco/adf-core').AppConfigService; const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock; @@ -29,7 +31,10 @@ patchTestBedToDestroyFixturesAfterEveryTest(TestBed); beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreModule], + imports: [ + NoopAnimationsModule, + CoreModule.forRoot() + ], providers: [ {provide: AppConfigService, useClass: AppConfigServiceMock}, {provide: TranslationService, useClass: TranslationMock} diff --git a/lib/content-services/search/components/search-control.component.spec.ts b/lib/content-services/search/components/search-control.component.spec.ts index da4a1f954e..560977f54c 100644 --- a/lib/content-services/search/components/search-control.component.spec.ts +++ b/lib/content-services/search/components/search-control.component.spec.ts @@ -17,7 +17,6 @@ import { DebugElement } from '@angular/core'; import { async, discardPeriodicTasks, fakeAsync, ComponentFixture, TestBed, tick } from '@angular/core/testing'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MaterialModule } from '../../material.module'; import { By } from '@angular/platform-browser'; import { AuthenticationService, SearchService } from '@alfresco/adf-core'; @@ -40,8 +39,7 @@ describe('SearchControlComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MaterialModule, - NoopAnimationsModule + MaterialModule ], declarations: [ SearchControlComponent, diff --git a/lib/core/card-view/card-view.module.ts b/lib/core/card-view/card-view.module.ts index 416aff18c9..ae5f2e068f 100644 --- a/lib/core/card-view/card-view.module.ts +++ b/lib/core/card-view/card-view.module.ts @@ -38,9 +38,6 @@ import { CardViewItemDispatcherComponent } from './components/card-view-item-dis import { CardViewMapItemComponent } from './components/card-view-mapitem/card-view-mapitem.component'; import { CardViewTextItemComponent } from './components/card-view-textitem/card-view-textitem.component'; -import { CardItemTypeService } from './services/card-item-types.service'; -import { CardViewUpdateService } from './services/card-view-update.service'; - @NgModule({ imports: [ CommonModule, @@ -77,10 +74,6 @@ import { CardViewUpdateService } from './services/card-view-update.service'; CardViewDateItemComponent, CardViewMapItemComponent, CardViewTextItemComponent - ], - providers: [ - CardItemTypeService, - CardViewUpdateService ] }) export class CardViewModule {} diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts index 012c43d73c..b5d28a5de9 100644 --- a/lib/core/core.module.ts +++ b/lib/core/core.module.ts @@ -17,15 +17,12 @@ import { CommonModule } from '@angular/common'; import { HttpClient, HttpClientModule } from '@angular/common/http'; -import { NgModule } from '@angular/core'; +import { NgModule, ModuleWithProviders } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; - -import { TRANSLATION_PROVIDER, TranslationService } from './services/translation.service'; +import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; +import { TranslateStore } from '@ngx-translate/core/src/translate.store'; import { MaterialModule } from './material.module'; - import { AppConfigModule } from './app-config/app-config.module'; import { CardViewModule } from './card-view/card-view.module'; import { CollapsableModule } from './collapsable/collapsable.module'; @@ -45,16 +42,47 @@ import { SideBarActionModule } from './sidebar/sidebar-action.module'; import { DirectiveModule } from './directives/directive.module'; import { PipeModule } from './pipes/pipe.module'; -import { ServiceModule } from './services/service.module'; + +import { AlfrescoApiService } from './services/alfresco-api.service'; +import { AppsProcessService } from './services/apps-process.service'; +import { AuthGuardBpm } from './services/auth-guard-bpm.service'; +import { AuthGuardEcm } from './services/auth-guard-ecm.service'; +import { AuthGuard } from './services/auth-guard.service'; +import { AuthenticationService } from './services/authentication.service'; +import { CardItemTypeService } from './card-view/services/card-item-types.service'; +import { CardViewUpdateService } from './card-view/services/card-view-update.service'; +import { CommentProcessService } from './services/comment-process.service'; +import { ContentService } from './services/content.service'; +import { CookieService } from './services/cookie.service'; +import { DeletedNodesApiService } from './services/deleted-nodes-api.service'; +import { DiscoveryApiService } from './services/discovery-api.service'; +import { FavoritesApiService } from './services/favorites-api.service'; +import { HighlightTransformService } from './services/highlight-transform.service'; import { LogService } from './services/log.service'; +import { NodesApiService } from './services/nodes-api.service'; +import { NotificationService } from './services/notification.service'; +import { PageTitleService } from './services/page-title.service'; +import { PeopleContentService } from './services/people-content.service'; +import { PeopleProcessService } from './services/people-process.service'; +import { RenditionsService } from './services/renditions.service'; +import { SearchService } from './services/search.service'; +import { SettingsService } from './services/settings.service'; +import { SharedLinksApiService } from './services/shared-links-api.service'; +import { SitesService } from './services/sites.service'; +import { StorageService } from './services/storage.service'; +import { ThumbnailService } from './services/thumbnail.service'; import { TranslateLoaderService } from './services/translate-loader.service'; +import { TRANSLATION_PROVIDER, TranslationService } from './services/translation.service'; +import { UploadService } from './services/upload.service'; +import { UserPreferencesService } from './services/user-preferences.service'; +import { SearchConfigurationService } from './services/search-configuration.service'; export function createTranslateLoader(http: HttpClient, logService: LogService) { return new TranslateLoaderService(http, logService); } -@NgModule({ - imports: [ +export function modules() { + return [ ViewerModule, SideBarActionModule, PipeModule, @@ -63,7 +91,6 @@ export function createTranslateLoader(http: HttpClient, logService: LogService) FormsModule, ReactiveFormsModule, HttpClientModule, - BrowserAnimationsModule, HostSettingsModule, UserInfoModule, MaterialModule, @@ -73,8 +100,75 @@ export function createTranslateLoader(http: HttpClient, logService: LogService) ContextMenuModule, CardViewModule, CollapsableModule, - ServiceModule, FormModule, + LoginModule, + LanguageMenuModule, + InfoDrawerModule, + DataColumnModule, + DataTableModule + ]; +} + +export function providers() { + return [ + AuthenticationService, + AlfrescoApiService, + SettingsService, + ContentService, + AuthGuard, + AuthGuardEcm, + AuthGuardBpm, + AppsProcessService, + PageTitleService, + StorageService, + CookieService, + RenditionsService, + NotificationService, + LogService, + TranslationService, + TranslateLoaderService, + ThumbnailService, + UploadService, + CardItemTypeService, + CardViewUpdateService, + UserPreferencesService, + HighlightTransformService, + DeletedNodesApiService, + FavoritesApiService, + NodesApiService, + PeopleContentService, + PeopleProcessService, + SearchService, + SharedLinksApiService, + SitesService, + DiscoveryApiService, + CommentProcessService, + SearchConfigurationService + ]; +} + +@NgModule({ + imports: [ + ...modules(), + TranslateModule.forChild({ + loader: { + provide: TranslateLoader, + useFactory: (createTranslateLoader), + deps: [HttpClient, LogService] + } + }) + ], + exports: [ + ...modules(), + TranslateModule + ] +}) +export class CoreModuleLazy { +} + +@NgModule({ + imports: [ + ...modules(), TranslateModule.forRoot({ loader: { provide: TranslateLoader, @@ -83,6 +177,10 @@ export function createTranslateLoader(http: HttpClient, logService: LogService) } }) ], + exports: [ + ...modules(), + TranslateModule + ], providers: [ { provide: TRANSLATION_PROVIDER, @@ -92,35 +190,31 @@ export function createTranslateLoader(http: HttpClient, logService: LogService) source: 'assets/adf-core' } }, - TranslationService - ], - exports: [ - AppConfigModule, - BrowserAnimationsModule, - CommonModule, - FormsModule, - ReactiveFormsModule, - TranslateModule, - ContextMenuModule, - CardViewModule, - CollapsableModule, - PaginationModule, - ToolbarModule, - LoginModule, - UserInfoModule, - LanguageMenuModule, - InfoDrawerModule, - DataColumnModule, - DataTableModule, - HostSettingsModule, - ServiceModule, - ViewerModule, - SideBarActionModule, - PipeModule, - DirectiveModule, - FormModule, - MaterialModule + ...providers() ] }) export class CoreModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: CoreModule, + providers: [ + { + provide: TRANSLATION_PROVIDER, + multi: true, + useValue: { + name: 'adf-core', + source: 'assets/adf-core' + } + }, + TranslateStore, + ...providers() + ] + }; + } + + static forChild(): ModuleWithProviders { + return { + ngModule: CoreModuleLazy + }; + } } diff --git a/lib/core/index.ts b/lib/core/index.ts index 6347462be1..e99e8621ad 100644 --- a/lib/core/index.ts +++ b/lib/core/index.ts @@ -34,7 +34,6 @@ export * from './app-config/app-config.module'; export * from './form/form.module'; export * from './pipes/pipe.module'; -export * from './services/service.module'; export * from './directives/directive.module'; export * from './viewer'; diff --git a/lib/core/karma-test-shim.js b/lib/core/karma-test-shim.js index 5ba7d00a9b..c04c02f21d 100644 --- a/lib/core/karma-test-shim.js +++ b/lib/core/karma-test-shim.js @@ -25,7 +25,6 @@ const HttpClientModule = require('@angular/common/http').HttpClientModule; const TranslateModule = require('@ngx-translate/core').TranslateModule; const TranslateLoader = require('@ngx-translate/core').TranslateLoader; -const ServicesModule = require('./services/service.module').ServiceModule; const DirectiveModule = require('./directives/directive.module').DirectiveModule; const ContextMenuModule = require('./context-menu/context-menu.module').ContextMenuModule; const PipeModule = require('./pipes/pipe.module').PipeModule; @@ -34,6 +33,7 @@ const LogService = require('./services/log.service').LogService; const TranslateLoaderService = require('./services/translate-loader.service').TranslateLoaderService; const AppConfigService = require('@alfresco/adf-core').AppConfigService; const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock; +const providers = require('./core.module').providers; TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting()); @@ -44,7 +44,6 @@ export function createTranslateLoader(http, logService) { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - ServicesModule, TranslateModule.forRoot({ loader: { provide: TranslateLoader, @@ -62,6 +61,7 @@ beforeEach(() => { HttpClientModule ], providers: [ + ...providers(), {provide: AppConfigService, useClass: AppConfigServiceMock} ]}); }); diff --git a/lib/core/services/notification.service.spec.ts b/lib/core/services/notification.service.spec.ts index 38d86f48ab..62058f7c51 100644 --- a/lib/core/services/notification.service.spec.ts +++ b/lib/core/services/notification.service.spec.ts @@ -21,7 +21,7 @@ import { Component } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MatSnackBar, MatSnackBarModule } from '@angular/material'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NotificationService } from './notification.service'; describe('NotificationService', () => { @@ -30,7 +30,7 @@ describe('NotificationService', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - BrowserAnimationsModule, + NoopAnimationsModule, OverlayModule, MatSnackBarModule ], diff --git a/lib/core/services/service.module.ts b/lib/core/services/service.module.ts deleted file mode 100644 index 4a905442b7..0000000000 --- a/lib/core/services/service.module.ts +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * @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 { NgModule } from '@angular/core'; - -import { AlfrescoApiService } from './alfresco-api.service'; -import { AppsProcessService } from './apps-process.service'; -import { AuthGuardBpm } from './auth-guard-bpm.service'; -import { AuthGuardEcm } from './auth-guard-ecm.service'; -import { AuthGuard } from './auth-guard.service'; -import { AuthenticationService } from './authentication.service'; -import { CommentProcessService } from './comment-process.service'; -import { ContentService } from './content.service'; -import { CookieService } from './cookie.service'; -import { DeletedNodesApiService } from './deleted-nodes-api.service'; -import { DiscoveryApiService } from './discovery-api.service'; -import { FavoritesApiService } from './favorites-api.service'; -import { HighlightTransformService } from './highlight-transform.service'; -import { LogService } from './log.service'; -import { NodesApiService } from './nodes-api.service'; -import { NotificationService } from './notification.service'; -import { PageTitleService } from './page-title.service'; -import { PeopleContentService } from './people-content.service'; -import { PeopleProcessService } from './people-process.service'; -import { RenditionsService } from './renditions.service'; -import { SearchService } from './search.service'; -import { SettingsService } from './settings.service'; -import { SharedLinksApiService } from './shared-links-api.service'; -import { SitesService } from './sites.service'; -import { StorageService } from './storage.service'; -import { ThumbnailService } from './thumbnail.service'; -import { TranslateLoaderService } from './translate-loader.service'; -import { TranslationService } from './translation.service'; -import { UploadService } from './upload.service'; -import { UserPreferencesService } from './user-preferences.service'; -import { SearchConfigurationService } from './search-configuration.service'; - -@NgModule({ - imports: [], - declarations: [], - providers: [ - AuthenticationService, - AlfrescoApiService, - SettingsService, - ContentService, - AuthGuard, - AuthGuardEcm, - AuthGuardBpm, - AppsProcessService, - PageTitleService, - StorageService, - CookieService, - RenditionsService, - NotificationService, - LogService, - TranslationService, - TranslateLoaderService, - ThumbnailService, - UploadService, - UserPreferencesService, - HighlightTransformService, - DeletedNodesApiService, - FavoritesApiService, - NodesApiService, - PeopleContentService, - PeopleProcessService, - SearchService, - SharedLinksApiService, - SitesService, - DiscoveryApiService, - CommentProcessService, - SearchConfigurationService - ], - exports: [ - ] -}) -export class ServiceModule { -} diff --git a/lib/insights/insights.module.ts b/lib/insights/insights.module.ts index b144c046c9..41db783dd1 100644 --- a/lib/insights/insights.module.ts +++ b/lib/insights/insights.module.ts @@ -18,7 +18,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CoreModule, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; import { DiagramsModule } from './diagram/diagram.module'; @@ -32,7 +31,6 @@ import { MaterialModule } from './material.module'; CommonModule, FormsModule, ReactiveFormsModule, - BrowserAnimationsModule, MaterialModule, DiagramsModule, AnalyticsProcessModule @@ -52,7 +50,7 @@ import { MaterialModule } from './material.module'; CommonModule, FormsModule, ReactiveFormsModule, - BrowserAnimationsModule, + MaterialModule, DiagramsModule, AnalyticsProcessModule ] diff --git a/lib/insights/karma-test-shim.js b/lib/insights/karma-test-shim.js index 12b444cdb7..8fc9754037 100644 --- a/lib/insights/karma-test-shim.js +++ b/lib/insights/karma-test-shim.js @@ -13,10 +13,12 @@ require('zone.js/dist/fake-async-test'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; -var appContext = require.context(".", true, /.spec.ts/);appContext.keys().forEach(appContext); +var appContext = require.context(".", true, /.spec.ts/); +appContext.keys().forEach(appContext); const TestBed = require('@angular/core/testing').TestBed; const browser = require('@angular/platform-browser-dynamic/testing'); +const NoopAnimationsModule = require('@angular/platform-browser/animations').NoopAnimationsModule; const CoreModule = require('@alfresco/adf-core').CoreModule; const AppConfigService = require('@alfresco/adf-core').AppConfigService; const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock; @@ -29,7 +31,10 @@ patchTestBedToDestroyFixturesAfterEveryTest(TestBed); beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreModule], + imports: [ + NoopAnimationsModule, + CoreModule.forRoot() + ], providers: [ {provide: AppConfigService, useClass: AppConfigServiceMock}, {provide: TranslationService, useClass: TranslationMock} diff --git a/lib/process-services/karma-test-shim.js b/lib/process-services/karma-test-shim.js index c9ed23e1e0..7030edea6e 100644 --- a/lib/process-services/karma-test-shim.js +++ b/lib/process-services/karma-test-shim.js @@ -13,10 +13,12 @@ require('zone.js/dist/fake-async-test'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; -var appContext = require.context(".", true, /.spec.ts/);appContext.keys().forEach(appContext); +var appContext = require.context(".", true, /.spec.ts/); +appContext.keys().forEach(appContext); const TestBed = require('@angular/core/testing').TestBed; const browser = require('@angular/platform-browser-dynamic/testing'); +const NoopAnimationsModule = require('@angular/platform-browser/animations').NoopAnimationsModule; const CoreModule = require('@alfresco/adf-core').CoreModule; const AppConfigService = require('@alfresco/adf-core').AppConfigService; const AppConfigServiceMock = require('@alfresco/adf-core').AppConfigServiceMock; @@ -31,7 +33,14 @@ TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platfor beforeEach(() => { TestBed.configureTestingModule({ - imports: [CoreModule, TranslateModule, CommonModule, FormsModule, ReactiveFormsModule], + imports: [ + NoopAnimationsModule, + CoreModule.forRoot(), + TranslateModule, + CommonModule, + FormsModule, + ReactiveFormsModule + ], providers: [ {provide: AppConfigService, useClass: AppConfigServiceMock}, {provide: TranslationService, useClass: TranslationMock} diff --git a/lib/process-services/process.module.ts b/lib/process-services/process.module.ts index 0299b5b1fa..cd373a5d73 100644 --- a/lib/process-services/process.module.ts +++ b/lib/process-services/process.module.ts @@ -18,7 +18,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CoreModule, TRANSLATION_PROVIDER } from '@alfresco/adf-core'; import { MaterialModule } from './material.module'; @@ -37,7 +36,6 @@ import { PeopleModule } from './people/people.module'; CommentsModule, FormsModule, ReactiveFormsModule, - BrowserAnimationsModule, MaterialModule, ProcessListModule, TaskListModule, @@ -60,7 +58,6 @@ import { PeopleModule } from './people/people.module'; CommentsModule, FormsModule, ReactiveFormsModule, - BrowserAnimationsModule, ProcessListModule, TaskListModule, AppsListModule,