Commit bf2d3cbffe37c686e06ad7739026f602138d6f6a

Authored by Igor Kulikov
1 parent dddbe34f

Introduce common modules map

  1 +///
  2 +/// Copyright © 2016-2020 The Thingsboard Authors
  3 +///
  4 +/// Licensed under the Apache License, Version 2.0 (the "License");
  5 +/// you may not use this file except in compliance with the License.
  6 +/// You may obtain a copy of the License at
  7 +///
  8 +/// http://www.apache.org/licenses/LICENSE-2.0
  9 +///
  10 +/// Unless required by applicable law or agreed to in writing, software
  11 +/// distributed under the License is distributed on an "AS IS" BASIS,
  12 +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +/// See the License for the specific language governing permissions and
  14 +/// limitations under the License.
  15 +///
  16 +
  17 +import * as AngularCore from '@angular/core';
  18 +import * as AngularCommon from '@angular/common';
  19 +import * as AngularForms from '@angular/forms';
  20 +import * as AngularRouter from '@angular/router';
  21 +import * as AngularCdkKeycodes from '@angular/cdk/keycodes';
  22 +import * as AngularCdkCoercion from '@angular/cdk/coercion';
  23 +import * as AngularMaterialChips from '@angular/material/chips';
  24 +import * as AngularMaterialAutocomplete from '@angular/material/autocomplete';
  25 +import * as AngularMaterialDialog from '@angular/material/dialog';
  26 +import * as NgrxStore from '@ngrx/store';
  27 +import * as RxJs from 'rxjs';
  28 +import * as RxJsOperators from 'rxjs/operators';
  29 +import * as TranslateCore from '@ngx-translate/core';
  30 +import * as TbCore from '@core/public-api';
  31 +import * as TbShared from '@shared/public-api';
  32 +import * as TbHomeComponents from '@home/components/public-api';
  33 +import * as _moment from 'moment';
  34 +
  35 +declare const SystemJS;
  36 +
  37 +export const modulesMap: {[key: string]: any} = {
  38 + '@angular/core': SystemJS.newModule(AngularCore),
  39 + '@angular/common': SystemJS.newModule(AngularCommon),
  40 + '@angular/forms': SystemJS.newModule(AngularForms),
  41 + '@angular/router': SystemJS.newModule(AngularRouter),
  42 + '@angular/cdk/keycodes': SystemJS.newModule(AngularCdkKeycodes),
  43 + '@angular/cdk/coercion': SystemJS.newModule(AngularCdkCoercion),
  44 + '@angular/material/chips': SystemJS.newModule(AngularMaterialChips),
  45 + '@angular/material/autocomplete': SystemJS.newModule(AngularMaterialAutocomplete),
  46 + '@angular/material/dialog': SystemJS.newModule(AngularMaterialDialog),
  47 + '@ngrx/store': SystemJS.newModule(NgrxStore),
  48 + rxjs: SystemJS.newModule(RxJs),
  49 + 'rxjs/operators': SystemJS.newModule(RxJsOperators),
  50 + '@ngx-translate/core': SystemJS.newModule(TranslateCore),
  51 + '@core/public-api': SystemJS.newModule(TbCore),
  52 + '@shared/public-api': SystemJS.newModule(TbShared),
  53 + '@home/components/public-api': SystemJS.newModule(TbHomeComponents),
  54 + moment: SystemJS.newModule(_moment)
  55 +};
@@ -25,6 +25,8 @@ import { DashboardUtilsService } from '@core/services/dashboard-utils.service'; @@ -25,6 +25,8 @@ import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
25 import { DashboardResolver } from '@app/modules/home/pages/dashboard/dashboard-routing.module'; 25 import { DashboardResolver } from '@app/modules/home/pages/dashboard/dashboard-routing.module';
26 import { UtilsService } from '@core/services/utils.service'; 26 import { UtilsService } from '@core/services/utils.service';
27 import { Widget } from '@app/shared/models/widget.models'; 27 import { Widget } from '@app/shared/models/widget.models';
  28 +import { MODULES_MAP } from '../../shared/models/constants';
  29 +import { modulesMap } from '../common/modules-map';
28 30
29 @Injectable() 31 @Injectable()
30 export class WidgetEditorDashboardResolver implements Resolve<Dashboard> { 32 export class WidgetEditorDashboardResolver implements Resolve<Dashboard> {
@@ -92,7 +94,11 @@ const routes: Routes = [ @@ -92,7 +94,11 @@ const routes: Routes = [
92 imports: [RouterModule.forChild(routes)], 94 imports: [RouterModule.forChild(routes)],
93 exports: [RouterModule], 95 exports: [RouterModule],
94 providers: [ 96 providers: [
95 - WidgetEditorDashboardResolver 97 + WidgetEditorDashboardResolver,
  98 + {
  99 + provide: MODULES_MAP,
  100 + useValue: modulesMap
  101 + }
96 ] 102 ]
97 }) 103 })
98 export class DashboardPagesRoutingModule { } 104 export class DashboardPagesRoutingModule { }
@@ -29,46 +29,8 @@ import { EntityViewModule } from '@modules/home/pages/entity-view/entity-view.mo @@ -29,46 +29,8 @@ import { EntityViewModule } from '@modules/home/pages/entity-view/entity-view.mo
29 import { RuleChainModule } from '@modules/home/pages/rulechain/rulechain.module'; 29 import { RuleChainModule } from '@modules/home/pages/rulechain/rulechain.module';
30 import { WidgetLibraryModule } from '@modules/home/pages/widget/widget-library.module'; 30 import { WidgetLibraryModule } from '@modules/home/pages/widget/widget-library.module';
31 import { DashboardModule } from '@modules/home/pages/dashboard/dashboard.module'; 31 import { DashboardModule } from '@modules/home/pages/dashboard/dashboard.module';
32 -import * as AngularCore from '@angular/core';  
33 -import * as AngularCommon from '@angular/common';  
34 -import * as AngularForms from '@angular/forms';  
35 -import * as AngularRouter from '@angular/router';  
36 -import * as AngularCdkKeycodes from '@angular/cdk/keycodes';  
37 -import * as AngularCdkCoercion from '@angular/cdk/coercion';  
38 -import * as AngularMaterialChips from '@angular/material/chips';  
39 -import * as AngularMaterialAutocomplete from '@angular/material/autocomplete';  
40 -import * as AngularMaterialDialog from '@angular/material/dialog';  
41 -import * as NgrxStore from '@ngrx/store';  
42 -import * as RxJs from 'rxjs';  
43 -import * as RxJsOperators from 'rxjs/operators';  
44 -import * as TranslateCore from '@ngx-translate/core';  
45 -import * as TbCore from '@core/public-api';  
46 -import * as TbShared from '@shared/public-api';  
47 -import * as TbHomeComponents from '@home/components/public-api';  
48 -import * as _moment from 'moment';  
49 import { MODULES_MAP } from '@shared/public-api'; 32 import { MODULES_MAP } from '@shared/public-api';
50 -  
51 -declare const SystemJS;  
52 -  
53 -const modulesMap: {[key: string]: any} = {  
54 - '@angular/core': SystemJS.newModule(AngularCore),  
55 - '@angular/common': SystemJS.newModule(AngularCommon),  
56 - '@angular/forms': SystemJS.newModule(AngularForms),  
57 - '@angular/router': SystemJS.newModule(AngularRouter),  
58 - '@angular/cdk/keycodes': SystemJS.newModule(AngularCdkKeycodes),  
59 - '@angular/cdk/coercion': SystemJS.newModule(AngularCdkCoercion),  
60 - '@angular/material/chips': SystemJS.newModule(AngularMaterialChips),  
61 - '@angular/material/autocomplete': SystemJS.newModule(AngularMaterialAutocomplete),  
62 - '@angular/material/dialog': SystemJS.newModule(AngularMaterialDialog),  
63 - '@ngrx/store': SystemJS.newModule(NgrxStore),  
64 - rxjs: SystemJS.newModule(RxJs),  
65 - 'rxjs/operators': SystemJS.newModule(RxJsOperators),  
66 - '@ngx-translate/core': SystemJS.newModule(TranslateCore),  
67 - '@core/public-api': SystemJS.newModule(TbCore),  
68 - '@shared/public-api': SystemJS.newModule(TbShared),  
69 - '@home/components/public-api': SystemJS.newModule(TbHomeComponents),  
70 - moment: SystemJS.newModule(_moment)  
71 -}; 33 +import { modulesMap } from '../../common/modules-map';
72 34
73 @NgModule({ 35 @NgModule({
74 exports: [ 36 exports: [