blob: d8689afbf68b2d2c91f6526c46be801ae9366362 [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';
SANDHYA.JS219fe612024-01-23 15:52:43 +053048import { HealingComponent } from 'HealingComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053049import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate';
50import { InstantiateNsComponent } from 'InstantiateNs';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053051import { LayoutComponent } from 'LayoutComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053052import { LoaderModule } from 'LoaderModule';
53import { LoginComponent } from 'LoginComponent';
54import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent';
55import { NetslicePackagesActionComponent } from 'NetslicePackagesAction';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053056import { Ng2SmartTableModule } from 'ng2-smart-table';
SANDHYA.JS1b17c432023-04-26 17:54:57 +053057import { ToastrModule } from 'ngx-toastr';
SANDHYA.JS07decc02024-07-01 21:50:48 +053058import { NSConfigTemplateActionComponent } from 'NSCONFIGTEMPLATEACTION';
kumaran.m3b4814a2020-05-01 19:48:54 +053059import { NSInstancesActionComponent } from 'NSInstancesActionComponent';
60import { NsPackagesActionComponent } from 'NsPackagesAction';
SANDHYA.JS99144582022-04-27 17:22:35 +053061import { NsUpdateComponent } from 'NsUpdateComponent';
SANDHYA.JS26570112024-07-05 21:35:46 +053062import { OkaPackagesActionComponent } from 'OkaPackagesActionComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053063import { PageNotFoundComponent } from 'PageNotFound';
64import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent';
65import { ProjectLinkComponent } from 'ProjectLinkComponent';
66import { ProjectsActionComponent } from 'ProjectsAction';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053067import { ProjectService } from 'ProjectService';
68import { RestService } from 'RestService';
Barath Kumar R07698ab2021-03-30 11:50:42 +053069import { ScalingComponent } from 'ScalingComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053070import { SDNControllerActionComponent } from 'SDNControllerActionComponent';
SANDHYA.JS4a7a5422021-05-15 15:35:22 +053071import { SharedModule } from 'SharedModule';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053072import { SharedService } from 'SharedService';
kumaran.m3b4814a2020-05-01 19:48:54 +053073import { ShowInfoComponent } from 'ShowInfoComponent';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053074import { SidebarComponent } from 'SidebarComponent';
SANDHYA.JS3d81a282022-05-02 08:25:39 +053075import { StartStopRebuildComponent } from 'StartStopRebuildComponent';
Isabel Lloret523d6752025-04-29 08:06:54 +000076import { ShowVduConsoleComponent } from 'ShowVduConsoleComponent';
kumaran.m3b4814a2020-05-01 19:48:54 +053077import { 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';
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +053087import { AppComponent } from './AppComponent';
88import { appRoutes } from './approutes.module';
kumaran.m3b4814a2020-05-01 19:48:54 +053089
90/**
91 * Custom angular notifier options
92 */
93const customNotifierOptions: NotifierOptions = {
94 position: { horizontal: { position: 'right' }, vertical: { position: 'top' } },
95 behaviour: { autoHide: 3000, onClick: 'hide', onMouseover: 'pauseAutoHide' }
96};
97
98/**
99 * An NgModule is a class adorned with the @NgModule decorator function.
100 * @NgModule takes a metadata object that tells Angular how to compile and run module code.
101 */
102@NgModule({
103 declarations: [
104 AppComponent,
105 LayoutComponent,
106 HeaderComponent,
107 SidebarComponent,
108 LoginComponent,
109 PageNotFoundComponent,
110 VNFPackagesActionComponent,
111 NsPackagesActionComponent,
112 NSInstancesActionComponent,
113 VNFInstancesActionComponent,
114 VNFLinkComponent,
115 NetsliceInstancesActionComponent,
116 BreadcrumbComponent,
117 DeleteComponent,
118 NetslicePackagesActionComponent,
119 UsersActionComponent,
120 VimAccountsActionComponent,
121 ProjectsActionComponent,
122 ProjectLinkComponent,
123 UserSettingsComponent,
124 ShowInfoComponent,
125 InstantiateNetSliceTemplateComponent,
126 InstantiateNsComponent,
127 ConfirmationTopologyComponent,
128 ComposePackages,
129 WIMAccountsActionComponent,
130 PDUInstancesActionComponent,
131 SDNControllerActionComponent,
132 SwitchProjectComponent,
Barath Kumar R07698ab2021-03-30 11:50:42 +0530133 GoToTopDirective,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530134 ScalingComponent,
SANDHYA.JSfced3d42022-04-28 20:28:17 +0530135 ChangePasswordComponent,
SANDHYA.JS99144582022-04-27 17:22:35 +0530136 VmMigrationComponent,
137 NsUpdateComponent,
SANDHYA.JS3d81a282022-05-02 08:25:39 +0530138 WarningComponent,
SANDHYA.JS017df362022-05-02 06:57:11 +0530139 StartStopRebuildComponent,
Isabel Lloret523d6752025-04-29 08:06:54 +0000140 ShowVduConsoleComponent,
SANDHYA.JS07decc02024-07-01 21:50:48 +0530141 HealingComponent,
SANDHYA.JS26570112024-07-05 21:35:46 +0530142 NSConfigTemplateActionComponent,
143 OkaPackagesActionComponent
kumaran.m3b4814a2020-05-01 19:48:54 +0530144 ],
145 imports: [
146 NotifierModule.withConfig(customNotifierOptions),
147 CommonModule,
148 BrowserModule,
149 BrowserAnimationsModule,
150 FormsModule,
151 ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }),
152 Ng2SmartTableModule,
153 CodemirrorModule,
154 NgSelectModule,
155 HttpClientModule,
156 TranslateModule.forRoot({
157 loader: {
158 provide: TranslateLoader,
159 useFactory: HttpLoaderFactory,
160 deps: [HttpClient]
161 }
162 }),
163 NgbModule,
164 NgSelectModule,
SANDHYA.JSc84f1122024-06-04 21:50:03 +0530165 RouterModule.forRoot(appRoutes, { useHash: false }),
kumaran.m3b4814a2020-05-01 19:48:54 +0530166 NgIdleKeepaliveModule.forRoot(),
SANDHYA.JS4a7a5422021-05-15 15:35:22 +0530167 LoaderModule,
SANDHYA.JSa9816552022-04-12 09:07:08 +0530168 SharedModule,
SANDHYA.JS1b17c432023-04-26 17:54:57 +0530169 ChangePasswordModule,
170 ToastrModule.forRoot({
171 timeOut: 500,
172 positionClass: 'toast-bottom-right'
173 })
kumaran.m3b4814a2020-05-01 19:48:54 +0530174 ],
175 providers: [
176 {
177 provide: APP_INITIALIZER,
178 useFactory: appInitializerFactory,
179 deps: [TranslateService, Injector],
180 multi: true
181 },
182 {
183 provide: HTTP_INTERCEPTORS,
184 useClass: AuthInterceptorService,
185 multi: true
186 },
187 RestService,
188 AuthenticationService,
189 AuthGuardService,
190 DataService,
191 ProjectService,
192 SharedService,
193 DeviceCheckService
194 ],
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530195 bootstrap: [AppComponent]
kumaran.m3b4814a2020-05-01 19:48:54 +0530196})
197
198/** Exporting a class @exports AppModule */
199export class AppModule {
200 /** Variables declared to avoid state-less class */
201 private appModule: string;
202}
203
204/**
205 * HttpLoaderFactory is for translate service of the application.
206 */
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530207/* eslint-disable */
kumaran.m3b4814a2020-05-01 19:48:54 +0530208export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
209 const now: number = new Date().getTime();
210 return new TranslateHttpLoader(http, './assets/i18n/', '.json?locale=' + now);
211}
212/**
213 * HttpLoaderFactory is for translate service of the application.
214 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530215export function appInitializerFactory(translate: TranslateService, injector: Injector): Object {
SANDHYA.JS0a34dfa2023-04-25 23:59:41 +0530216 // eslint-disable-next-line @typescript-eslint/no-explicit-any
kumaran.m3b4814a2020-05-01 19:48:54 +0530217 return async (): Promise<any> => {
218 await injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
219 translate.setDefaultLang('en');
SANDHYA.JS5b35bcd2023-04-27 15:11:06 +0530220 const languageCode: string = sessionStorage.getItem('languageCode');
kumaran.m3b4814a2020-05-01 19:48:54 +0530221 if (languageCode !== null && languageCode !== undefined && languageCode !== '') {
SANDHYA.JSa9816552022-04-12 09:07:08 +0530222 await translate.use(languageCode).toPromise().catch((): void => {
kumaran.m3b4814a2020-05-01 19:48:54 +0530223 translate.setDefaultLang('en');
224 });
225 } else {
226 await translate.use('en').toPromise();
SANDHYA.JS5b35bcd2023-04-27 15:11:06 +0530227 sessionStorage.setItem('languageCode', 'en');
kumaran.m3b4814a2020-05-01 19:48:54 +0530228 }
229 };
230}