fixed SDC UI loading issues
[sdc.git] / catalog-ui / src / app / ng2 / app.module.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import {BrowserModule} from '@angular/platform-browser';
22 import {NgModule, APP_INITIALIZER} from '@angular/core';
23 import {FormsModule} from '@angular/forms';
24 import {forwardRef} from '@angular/core';
25 import {AppComponent} from './app.component';
26 import {UpgradeAdapter} from '@angular/upgrade';
27 import {UpgradeModule} from '@angular/upgrade/static';
28 import {PropertiesAssignmentModule} from './pages/properties-assignment/properties-assignment.module';
29 import {
30     DataTypesServiceProvider, SharingServiceProvider, CookieServiceProvider, StateServiceFactory,
31     StateParamsServiceFactory, CacheServiceProvider, EventListenerServiceProvider, ScopeServiceFactory,
32     NotificationServiceProvider
33 } from "./utils/ng1-upgraded-provider";
34 import {ConfigService} from "./services/config.service";
35 import {HttpModule} from '@angular/http';
36 import {HttpService} from './services/http.service';
37 import {AuthenticationService} from './services/authentication.service';
38 import {Cookie2Service} from "./services/cookie.service";
39 import {ComponentServiceNg2} from "./services/component-services/component.service";
40 import {ComponentServiceFactoryNg2} from "./services/component-services/component.service.factory";
41 import {ServiceServiceNg2} from "./services/component-services/service.service";
42 import {ComponentInstanceServiceNg2} from "./services/component-instance-services/component-instance.service";
43 import {ModalService} from "./services/modal.service";
44 import {UiElementsModule} from "./components/ui/ui-elements.module";
45 import {ConnectionWizardModule} from "./pages/connection-wizard/connection-wizard.module";
46 import {InterfaceOperationModule} from "./pages/interface-operation/interface-operation.module";
47 import {OperationCreatorModule} from "./pages/interface-operation/operation-creator/operation-creator.module";
48 import {LayoutModule} from "./components/layout/layout.module";
49 import {UserService} from "./services/user.service";
50 import {PoliciesService} from "./services/policies.service";
51 import {DynamicComponentService} from "./services/dynamic-component.service";
52 import {SdcConfig} from "./config/sdc-config.config";
53 import { TranslateModule } from "./shared/translator/translate.module";
54 import { TranslationServiceConfig } from "./config/translation.service.config";
55 import {ServicePathCreatorModule} from './pages/service-path-creator/service-path-creator.module';
56 import {ServicePathsListModule} from './pages/service-paths-list/service-paths-list.module';
57 import {PluginFrameModule} from "./components/ui/plugin/plugin-frame.module";
58 import {PluginsService} from "./services/plugins.service";
59 import {EventBusService} from "./services/event-bus.service";
60 import {ServicePathModule} from 'app/ng2/components/logic/service-path/service-path.module';
61 import {ServicePathSelectorModule} from 'app/ng2/components/logic/service-path-selector/service-path-selector.module';
62
63 export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule));
64
65 export function configServiceFactory(config:ConfigService) {
66     return () => {
67         return Promise.all([
68             config.loadValidationConfiguration(),
69             config.loadPluginsConfiguration()
70         ]);
71     }
72 }
73
74
75 @NgModule({
76     declarations: [
77         AppComponent
78     ],
79     imports: [
80         BrowserModule,
81         UpgradeModule,
82         FormsModule,
83         HttpModule,
84         LayoutModule,
85         TranslateModule,
86         UiElementsModule,
87
88         //We need to import them here since we use them in angular1
89         ConnectionWizardModule,
90         PropertiesAssignmentModule,
91         PluginFrameModule,
92         InterfaceOperationModule,
93         OperationCreatorModule,
94         ServicePathCreatorModule,
95         ServicePathsListModule,
96         ServicePathModule,
97         ServicePathSelectorModule
98     ],
99     exports: [],
100     entryComponents: [],
101     providers: [
102         DataTypesServiceProvider,
103         SharingServiceProvider,
104         CookieServiceProvider,
105         StateServiceFactory,
106         StateParamsServiceFactory,
107         ScopeServiceFactory,
108         CacheServiceProvider,
109         EventListenerServiceProvider,
110         NotificationServiceProvider,
111         AuthenticationService,
112         Cookie2Service,
113         ConfigService,
114         ComponentServiceNg2,
115         ComponentServiceFactoryNg2,
116         ModalService,
117         ServiceServiceNg2,
118         HttpService,
119         UserService,
120         PoliciesService,
121         DynamicComponentService,
122         SdcConfig,
123         ComponentInstanceServiceNg2,
124         TranslationServiceConfig,
125         PluginsService,
126         EventBusService,
127         {
128             provide: APP_INITIALIZER,
129             useFactory: configServiceFactory,
130             deps: [ConfigService],
131             multi: true
132         },
133      ],
134     bootstrap: [AppComponent]
135 })
136
137
138 export class AppModule {
139
140     constructor(public upgrade:UpgradeModule, eventBusService:EventBusService) {
141     }
142 }