blob: cc9af15cfe2606e1221fdedd49d283ac33aaee1b [file] [log] [blame]
kumaran.m3b4814a2020-05-01 19:48:54 +05301/*
2 Copyright 2020 TATA ELXSI
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 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
17*/
18/**
19 * @file Instance Module file
20 */
21import { CommonModule, LOCATION_INITIALIZED } from '@angular/common';
Barath Kumar R5abb2742020-11-22 20:15:10 +053022import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
kumaran.m3b4814a2020-05-01 19:48:54 +053023import { APP_INITIALIZER, Injector, NgModule } from '@angular/core';
24import { FormsModule, ReactiveFormsModule } from '@angular/forms';
25import { BrowserModule } from '@angular/platform-browser';
26import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
27import { RouterModule } from '@angular/router';
28import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
29import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
30import { TranslateHttpLoader } from '@ngx-translate/http-loader';
31import { NotifierModule, NotifierOptions } from 'angular-notifier';
32import { AuthInterceptorService } from 'AuthInterceptorService';
33import { HeaderComponent } from 'HeaderComponent';
34import { LayoutComponent } from 'LayoutComponent';
35import { Ng2SmartTableModule } from 'ng2-smart-table';
36import { RestService } from 'RestService';
37import { SidebarComponent } from 'SidebarComponent';
38import { AppComponent } from './AppComponent';
39
40import { appRoutes } from './approutes.module';
41
42import { DataService } from 'DataService';
43import { ProjectService } from 'ProjectService';
44import { SharedService } from 'SharedService';
45
46import { CodemirrorModule } from '@ctrl/ngx-codemirror';
47import { NgSelectModule } from '@ng-select/ng-select';
48
49import { NgIdleKeepaliveModule } from '@ng-idle/keepalive';
50import { AuthenticationService } from 'AuthenticationService';
51import { AuthGuardService } from 'AuthGuardService';
52import { BreadcrumbComponent } from 'BreadCrumb';
SANDHYA.JSa9816552022-04-12 09:07:08 +053053import { ChangePasswordComponent } from 'ChangePasswordComponent';
54import { ChangePasswordModule } from 'ChangePasswordModule';
kumaran.m3b4814a2020-05-01 19:48:54 +053055import { ComposePackages } from 'ComposePackages';
56import { ConfirmationTopologyComponent } from 'ConfirmationTopology';
57import { DeleteComponent } from 'DeleteComponent';
58import { DeviceCheckService } from 'DeviceCheckService';
59import { GoToTopDirective } from 'GoToTopDirective';
60import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate';
61import { InstantiateNsComponent } from 'InstantiateNs';
62import { LoaderModule } from 'LoaderModule';
63import { LoginComponent } from 'LoginComponent';
64import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent';
65import { NetslicePackagesActionComponent } from 'NetslicePackagesAction';
66import { NSInstancesActionComponent } from 'NSInstancesActionComponent';
67import { NsPackagesActionComponent } from 'NsPackagesAction';
SANDHYA.JS99144582022-04-27 17:22:35 +053068import { NsUpdateComponent } from 'NsUpdateComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053069import { PageNotFoundComponent } from 'PageNotFound';
70import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent';
71import { ProjectLinkComponent } from 'ProjectLinkComponent';
72import { ProjectsActionComponent } from 'ProjectsAction';
Barath Kumar R07698ab2021-03-30 11:50:42 +053073import { ScalingComponent } from 'ScalingComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053074import { SDNControllerActionComponent } from 'SDNControllerActionComponent';
SANDHYA.JS4a7a5422021-05-15 15:35:22 +053075import { SharedModule } from 'SharedModule';
kumaran.m3b4814a2020-05-01 19:48:54 +053076import { ShowInfoComponent } from 'ShowInfoComponent';
77import { SwitchProjectComponent } from 'SwitchProjectComponent';
78import { UsersActionComponent } from 'UsersActionComponent';
79import { UserSettingsComponent } from 'UserSettingsComponent';
80import { VimAccountsActionComponent } from 'VimAccountsAction';
SANDHYA.JSfced3d42022-04-28 20:28:17 +053081import { VmMigrationComponent } from 'VmMigrationComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053082import { VNFInstancesActionComponent } from 'VNFInstancesActionComponent';
83import { VNFLinkComponent } from 'VNFLinkComponent';
84import { VNFPackagesActionComponent } from 'VNFPackagesAction';
SANDHYA.JS99144582022-04-27 17:22:35 +053085import { WarningComponent } from 'WarningComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053086import { WIMAccountsActionComponent } from 'WIMAccountsAction';
87
88/**
89 * Custom angular notifier options
90 */
91const customNotifierOptions: NotifierOptions = {
92 position: { horizontal: { position: 'right' }, vertical: { position: 'top' } },
93 behaviour: { autoHide: 3000, onClick: 'hide', onMouseover: 'pauseAutoHide' }
94};
95
96/**
97 * An NgModule is a class adorned with the @NgModule decorator function.
98 * @NgModule takes a metadata object that tells Angular how to compile and run module code.
99 */
100@NgModule({
101 declarations: [
102 AppComponent,
103 LayoutComponent,
104 HeaderComponent,
105 SidebarComponent,
106 LoginComponent,
107 PageNotFoundComponent,
108 VNFPackagesActionComponent,
109 NsPackagesActionComponent,
110 NSInstancesActionComponent,
111 VNFInstancesActionComponent,
112 VNFLinkComponent,
113 NetsliceInstancesActionComponent,
114 BreadcrumbComponent,
115 DeleteComponent,
116 NetslicePackagesActionComponent,
117 UsersActionComponent,
118 VimAccountsActionComponent,
119 ProjectsActionComponent,
120 ProjectLinkComponent,
121 UserSettingsComponent,
122 ShowInfoComponent,
123 InstantiateNetSliceTemplateComponent,
124 InstantiateNsComponent,
125 ConfirmationTopologyComponent,
126 ComposePackages,
127 WIMAccountsActionComponent,
128 PDUInstancesActionComponent,
129 SDNControllerActionComponent,
130 SwitchProjectComponent,
Barath Kumar R07698ab2021-03-30 11:50:42 +0530131 GoToTopDirective,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530132 ScalingComponent,
SANDHYA.JSfced3d42022-04-28 20:28:17 +0530133 ChangePasswordComponent,
SANDHYA.JS99144582022-04-27 17:22:35 +0530134 VmMigrationComponent,
135 NsUpdateComponent,
136 WarningComponent
kumaran.m3b4814a2020-05-01 19:48:54 +0530137 ],
138 imports: [
139 NotifierModule.withConfig(customNotifierOptions),
140 CommonModule,
141 BrowserModule,
142 BrowserAnimationsModule,
143 FormsModule,
144 ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }),
145 Ng2SmartTableModule,
146 CodemirrorModule,
147 NgSelectModule,
148 HttpClientModule,
149 TranslateModule.forRoot({
150 loader: {
151 provide: TranslateLoader,
152 useFactory: HttpLoaderFactory,
153 deps: [HttpClient]
154 }
155 }),
156 NgbModule,
157 NgSelectModule,
Barath Kumar R5abb2742020-11-22 20:15:10 +0530158 RouterModule.forRoot(appRoutes, { useHash: false, relativeLinkResolution: 'legacy' }),
kumaran.m3b4814a2020-05-01 19:48:54 +0530159 NgIdleKeepaliveModule.forRoot(),
SANDHYA.JS4a7a5422021-05-15 15:35:22 +0530160 LoaderModule,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530161 SharedModule,
162 ChangePasswordModule
kumaran.m3b4814a2020-05-01 19:48:54 +0530163 ],
164 providers: [
165 {
166 provide: APP_INITIALIZER,
167 useFactory: appInitializerFactory,
168 deps: [TranslateService, Injector],
169 multi: true
170 },
171 {
172 provide: HTTP_INTERCEPTORS,
173 useClass: AuthInterceptorService,
174 multi: true
175 },
176 RestService,
177 AuthenticationService,
178 AuthGuardService,
179 DataService,
180 ProjectService,
181 SharedService,
182 DeviceCheckService
183 ],
184 bootstrap: [AppComponent],
185 entryComponents: [
186 VNFPackagesActionComponent,
187 NsPackagesActionComponent,
188 NSInstancesActionComponent,
189 VNFInstancesActionComponent,
190 VNFLinkComponent,
191 NetsliceInstancesActionComponent,
192 BreadcrumbComponent,
193 DeleteComponent,
194 NetslicePackagesActionComponent,
195 UsersActionComponent,
196 VimAccountsActionComponent,
197 ProjectsActionComponent,
198 ProjectLinkComponent,
199 UserSettingsComponent,
200 ShowInfoComponent,
201 InstantiateNetSliceTemplateComponent,
202 InstantiateNsComponent,
203 ConfirmationTopologyComponent,
204 ComposePackages,
205 WIMAccountsActionComponent,
206 PDUInstancesActionComponent,
207 SDNControllerActionComponent,
Barath Kumar R07698ab2021-03-30 11:50:42 +0530208 SwitchProjectComponent,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530209 ScalingComponent,
SANDHYA.JSfced3d42022-04-28 20:28:17 +0530210 ChangePasswordComponent,
SANDHYA.JS99144582022-04-27 17:22:35 +0530211 VmMigrationComponent,
212 NsUpdateComponent,
213 WarningComponent
kumaran.m3b4814a2020-05-01 19:48:54 +0530214 ]
215})
216
217/** Exporting a class @exports AppModule */
218export class AppModule {
219 /** Variables declared to avoid state-less class */
220 private appModule: string;
221}
222
223/**
224 * HttpLoaderFactory is for translate service of the application.
225 */
226// tslint:disable:function-name
227export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
228 const now: number = new Date().getTime();
229 return new TranslateHttpLoader(http, './assets/i18n/', '.json?locale=' + now);
230}
231/**
232 * HttpLoaderFactory is for translate service of the application.
233 */
234// tslint:disable:function-name
235export function appInitializerFactory(translate: TranslateService, injector: Injector): Object {
236 // tslint:disable-next-line: no-any
237 return async (): Promise<any> => {
238 await injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
239 translate.setDefaultLang('en');
240 const languageCode: string = localStorage.getItem('languageCode');
241 if (languageCode !== null && languageCode !== undefined && languageCode !== '') {
SANDHYA.JSa9816552022-04-12 09:07:08 +0530242 await translate.use(languageCode).toPromise().catch((): void => {
kumaran.m3b4814a2020-05-01 19:48:54 +0530243 translate.setDefaultLang('en');
244 });
245 } else {
246 await translate.use('en').toPromise();
247 localStorage.setItem('languageCode', 'en');
248 }
249 };
250}