blob: 8a4ebaf31c4a00246b120747de8cf3c79870a8b7 [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';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053028import { CodemirrorModule } from '@ctrl/ngx-codemirror';
kumaran.m3b4814a2020-05-01 19:48:54 +053029import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053030import { NgIdleKeepaliveModule } from '@ng-idle/keepalive';
31import { NgSelectModule } from '@ng-select/ng-select';
kumaran.m3b4814a2020-05-01 19:48:54 +053032import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
33import { TranslateHttpLoader } from '@ngx-translate/http-loader';
34import { NotifierModule, NotifierOptions } from 'angular-notifier';
kumaran.m3b4814a2020-05-01 19:48:54 +053035import { AuthenticationService } from 'AuthenticationService';
36import { AuthGuardService } from 'AuthGuardService';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053037import { AuthInterceptorService } from 'AuthInterceptorService';
kumaran.m3b4814a2020-05-01 19:48:54 +053038import { BreadcrumbComponent } from 'BreadCrumb';
SANDHYA.JSa9816552022-04-12 09:07:08 +053039import { ChangePasswordComponent } from 'ChangePasswordComponent';
40import { ChangePasswordModule } from 'ChangePasswordModule';
kumaran.m3b4814a2020-05-01 19:48:54 +053041import { ComposePackages } from 'ComposePackages';
42import { ConfirmationTopologyComponent } from 'ConfirmationTopology';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053043import { DataService } from 'DataService';
kumaran.m3b4814a2020-05-01 19:48:54 +053044import { DeleteComponent } from 'DeleteComponent';
45import { DeviceCheckService } from 'DeviceCheckService';
46import { GoToTopDirective } from 'GoToTopDirective';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053047import { HeaderComponent } from 'HeaderComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053048import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate';
49import { InstantiateNsComponent } from 'InstantiateNs';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053050import { LayoutComponent } from 'LayoutComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053051import { LoaderModule } from 'LoaderModule';
52import { LoginComponent } from 'LoginComponent';
53import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent';
54import { NetslicePackagesActionComponent } from 'NetslicePackagesAction';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053055import { Ng2SmartTableModule } from 'ng2-smart-table';
kumaran.m3b4814a2020-05-01 19:48:54 +053056import { NSInstancesActionComponent } from 'NSInstancesActionComponent';
57import { NsPackagesActionComponent } from 'NsPackagesAction';
SANDHYA.JS99144582022-04-27 17:22:35 +053058import { NsUpdateComponent } from 'NsUpdateComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053059import { PageNotFoundComponent } from 'PageNotFound';
60import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent';
61import { ProjectLinkComponent } from 'ProjectLinkComponent';
62import { ProjectsActionComponent } from 'ProjectsAction';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053063import { ProjectService } from 'ProjectService';
64import { RestService } from 'RestService';
Barath Kumar R07698ab2021-03-30 11:50:42 +053065import { ScalingComponent } from 'ScalingComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053066import { SDNControllerActionComponent } from 'SDNControllerActionComponent';
SANDHYA.JS4a7a5422021-05-15 15:35:22 +053067import { SharedModule } from 'SharedModule';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053068import { SharedService } from 'SharedService';
kumaran.m3b4814a2020-05-01 19:48:54 +053069import { ShowInfoComponent } from 'ShowInfoComponent';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053070import { SidebarComponent } from 'SidebarComponent';
SANDHYA.JS3d81a282022-05-02 08:25:39 +053071import { StartStopRebuildComponent } from 'StartStopRebuildComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053072import { SwitchProjectComponent } from 'SwitchProjectComponent';
73import { UsersActionComponent } from 'UsersActionComponent';
74import { UserSettingsComponent } from 'UserSettingsComponent';
SANDHYA.JS017df362022-05-02 06:57:11 +053075import { VerticalScalingComponent } from 'VerticalScalingComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053076import { VimAccountsActionComponent } from 'VimAccountsAction';
SANDHYA.JSfced3d42022-04-28 20:28:17 +053077import { VmMigrationComponent } from 'VmMigrationComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053078import { VNFInstancesActionComponent } from 'VNFInstancesActionComponent';
79import { VNFLinkComponent } from 'VNFLinkComponent';
80import { VNFPackagesActionComponent } from 'VNFPackagesAction';
SANDHYA.JS99144582022-04-27 17:22:35 +053081import { WarningComponent } from 'WarningComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053082import { WIMAccountsActionComponent } from 'WIMAccountsAction';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053083import { AppComponent } from './AppComponent';
84import { appRoutes } from './approutes.module';
kumaran.m3b4814a2020-05-01 19:48:54 +053085
86/**
87 * Custom angular notifier options
88 */
89const customNotifierOptions: NotifierOptions = {
90 position: { horizontal: { position: 'right' }, vertical: { position: 'top' } },
91 behaviour: { autoHide: 3000, onClick: 'hide', onMouseover: 'pauseAutoHide' }
92};
93
94/**
95 * An NgModule is a class adorned with the @NgModule decorator function.
96 * @NgModule takes a metadata object that tells Angular how to compile and run module code.
97 */
98@NgModule({
99 declarations: [
100 AppComponent,
101 LayoutComponent,
102 HeaderComponent,
103 SidebarComponent,
104 LoginComponent,
105 PageNotFoundComponent,
106 VNFPackagesActionComponent,
107 NsPackagesActionComponent,
108 NSInstancesActionComponent,
109 VNFInstancesActionComponent,
110 VNFLinkComponent,
111 NetsliceInstancesActionComponent,
112 BreadcrumbComponent,
113 DeleteComponent,
114 NetslicePackagesActionComponent,
115 UsersActionComponent,
116 VimAccountsActionComponent,
117 ProjectsActionComponent,
118 ProjectLinkComponent,
119 UserSettingsComponent,
120 ShowInfoComponent,
121 InstantiateNetSliceTemplateComponent,
122 InstantiateNsComponent,
123 ConfirmationTopologyComponent,
124 ComposePackages,
125 WIMAccountsActionComponent,
126 PDUInstancesActionComponent,
127 SDNControllerActionComponent,
128 SwitchProjectComponent,
Barath Kumar R07698ab2021-03-30 11:50:42 +0530129 GoToTopDirective,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530130 ScalingComponent,
SANDHYA.JSfced3d42022-04-28 20:28:17 +0530131 ChangePasswordComponent,
SANDHYA.JS99144582022-04-27 17:22:35 +0530132 VmMigrationComponent,
133 NsUpdateComponent,
SANDHYA.JS3d81a282022-05-02 08:25:39 +0530134 WarningComponent,
SANDHYA.JS017df362022-05-02 06:57:11 +0530135 StartStopRebuildComponent,
136 VerticalScalingComponent
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 ],
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530184 bootstrap: [AppComponent]
kumaran.m3b4814a2020-05-01 19:48:54 +0530185})
186
187/** Exporting a class @exports AppModule */
188export class AppModule {
189 /** Variables declared to avoid state-less class */
190 private appModule: string;
191}
192
193/**
194 * HttpLoaderFactory is for translate service of the application.
195 */
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530196/* eslint-disable */
kumaran.m3b4814a2020-05-01 19:48:54 +0530197export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
198 const now: number = new Date().getTime();
199 return new TranslateHttpLoader(http, './assets/i18n/', '.json?locale=' + now);
200}
201/**
202 * HttpLoaderFactory is for translate service of the application.
203 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530204export function appInitializerFactory(translate: TranslateService, injector: Injector): Object {
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530205 // eslint-disable-next-line @typescript-eslint/no-explicit-any
kumaran.m3b4814a2020-05-01 19:48:54 +0530206 return async (): Promise<any> => {
207 await injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
208 translate.setDefaultLang('en');
209 const languageCode: string = localStorage.getItem('languageCode');
210 if (languageCode !== null && languageCode !== undefined && languageCode !== '') {
SANDHYA.JSa9816552022-04-12 09:07:08 +0530211 await translate.use(languageCode).toPromise().catch((): void => {
kumaran.m3b4814a2020-05-01 19:48:54 +0530212 translate.setDefaultLang('en');
213 });
214 } else {
215 await translate.use('en').toPromise();
216 localStorage.setItem('languageCode', 'en');
217 }
218 };
219}