| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 21 | import { CommonModule, LOCATION_INITIALIZED } from '@angular/common'; |
| Barath Kumar R | 5abb274 | 2020-11-22 20:15:10 +0530 | [diff] [blame] | 22 | import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 23 | import { APP_INITIALIZER, Injector, NgModule } from '@angular/core'; |
| 24 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
| 25 | import { BrowserModule } from '@angular/platform-browser'; |
| 26 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 27 | import { RouterModule } from '@angular/router'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 28 | import { CodemirrorModule } from '@ctrl/ngx-codemirror'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 29 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 30 | import { NgIdleKeepaliveModule } from '@ng-idle/keepalive'; |
| 31 | import { NgSelectModule } from '@ng-select/ng-select'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 32 | import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; |
| 33 | import { TranslateHttpLoader } from '@ngx-translate/http-loader'; |
| 34 | import { NotifierModule, NotifierOptions } from 'angular-notifier'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 35 | import { AuthenticationService } from 'AuthenticationService'; |
| 36 | import { AuthGuardService } from 'AuthGuardService'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 37 | import { AuthInterceptorService } from 'AuthInterceptorService'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 38 | import { BreadcrumbComponent } from 'BreadCrumb'; |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 39 | import { ChangePasswordComponent } from 'ChangePasswordComponent'; |
| 40 | import { ChangePasswordModule } from 'ChangePasswordModule'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 41 | import { ComposePackages } from 'ComposePackages'; |
| 42 | import { ConfirmationTopologyComponent } from 'ConfirmationTopology'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 43 | import { DataService } from 'DataService'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 44 | import { DeleteComponent } from 'DeleteComponent'; |
| 45 | import { DeviceCheckService } from 'DeviceCheckService'; |
| 46 | import { GoToTopDirective } from 'GoToTopDirective'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 47 | import { HeaderComponent } from 'HeaderComponent'; |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame] | 48 | import { HealingComponent } from 'HealingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 49 | import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate'; |
| 50 | import { InstantiateNsComponent } from 'InstantiateNs'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 51 | import { LayoutComponent } from 'LayoutComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 52 | import { LoaderModule } from 'LoaderModule'; |
| 53 | import { LoginComponent } from 'LoginComponent'; |
| 54 | import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent'; |
| 55 | import { NetslicePackagesActionComponent } from 'NetslicePackagesAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 56 | import { Ng2SmartTableModule } from 'ng2-smart-table'; |
| SANDHYA.JS | 1b17c43 | 2023-04-26 17:54:57 +0530 | [diff] [blame] | 57 | import { ToastrModule } from 'ngx-toastr'; |
| SANDHYA.JS | 07decc0 | 2024-07-01 21:50:48 +0530 | [diff] [blame] | 58 | import { NSConfigTemplateActionComponent } from 'NSCONFIGTEMPLATEACTION'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 59 | import { NSInstancesActionComponent } from 'NSInstancesActionComponent'; |
| 60 | import { NsPackagesActionComponent } from 'NsPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 61 | import { NsUpdateComponent } from 'NsUpdateComponent'; |
| SANDHYA.JS | 2657011 | 2024-07-05 21:35:46 +0530 | [diff] [blame] | 62 | import { OkaPackagesActionComponent } from 'OkaPackagesActionComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 63 | import { PageNotFoundComponent } from 'PageNotFound'; |
| 64 | import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent'; |
| 65 | import { ProjectLinkComponent } from 'ProjectLinkComponent'; |
| 66 | import { ProjectsActionComponent } from 'ProjectsAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 67 | import { ProjectService } from 'ProjectService'; |
| 68 | import { RestService } from 'RestService'; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 69 | import { ScalingComponent } from 'ScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 70 | import { SDNControllerActionComponent } from 'SDNControllerActionComponent'; |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 71 | import { SharedModule } from 'SharedModule'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 72 | import { SharedService } from 'SharedService'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 73 | import { ShowInfoComponent } from 'ShowInfoComponent'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 74 | import { SidebarComponent } from 'SidebarComponent'; |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 75 | import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 76 | import { SwitchProjectComponent } from 'SwitchProjectComponent'; |
| 77 | import { UsersActionComponent } from 'UsersActionComponent'; |
| 78 | import { UserSettingsComponent } from 'UserSettingsComponent'; |
| 79 | import { VimAccountsActionComponent } from 'VimAccountsAction'; |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 80 | import { VmMigrationComponent } from 'VmMigrationComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 81 | import { VNFInstancesActionComponent } from 'VNFInstancesActionComponent'; |
| 82 | import { VNFLinkComponent } from 'VNFLinkComponent'; |
| 83 | import { VNFPackagesActionComponent } from 'VNFPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 84 | import { WarningComponent } from 'WarningComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 85 | import { WIMAccountsActionComponent } from 'WIMAccountsAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 86 | import { AppComponent } from './AppComponent'; |
| 87 | import { appRoutes } from './approutes.module'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Custom angular notifier options |
| 91 | */ |
| 92 | const customNotifierOptions: NotifierOptions = { |
| 93 | position: { horizontal: { position: 'right' }, vertical: { position: 'top' } }, |
| 94 | behaviour: { autoHide: 3000, onClick: 'hide', onMouseover: 'pauseAutoHide' } |
| 95 | }; |
| 96 | |
| 97 | /** |
| 98 | * An NgModule is a class adorned with the @NgModule decorator function. |
| 99 | * @NgModule takes a metadata object that tells Angular how to compile and run module code. |
| 100 | */ |
| 101 | @NgModule({ |
| 102 | declarations: [ |
| 103 | AppComponent, |
| 104 | LayoutComponent, |
| 105 | HeaderComponent, |
| 106 | SidebarComponent, |
| 107 | LoginComponent, |
| 108 | PageNotFoundComponent, |
| 109 | VNFPackagesActionComponent, |
| 110 | NsPackagesActionComponent, |
| 111 | NSInstancesActionComponent, |
| 112 | VNFInstancesActionComponent, |
| 113 | VNFLinkComponent, |
| 114 | NetsliceInstancesActionComponent, |
| 115 | BreadcrumbComponent, |
| 116 | DeleteComponent, |
| 117 | NetslicePackagesActionComponent, |
| 118 | UsersActionComponent, |
| 119 | VimAccountsActionComponent, |
| 120 | ProjectsActionComponent, |
| 121 | ProjectLinkComponent, |
| 122 | UserSettingsComponent, |
| 123 | ShowInfoComponent, |
| 124 | InstantiateNetSliceTemplateComponent, |
| 125 | InstantiateNsComponent, |
| 126 | ConfirmationTopologyComponent, |
| 127 | ComposePackages, |
| 128 | WIMAccountsActionComponent, |
| 129 | PDUInstancesActionComponent, |
| 130 | SDNControllerActionComponent, |
| 131 | SwitchProjectComponent, |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 132 | GoToTopDirective, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 133 | ScalingComponent, |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 134 | ChangePasswordComponent, |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 135 | VmMigrationComponent, |
| 136 | NsUpdateComponent, |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 137 | WarningComponent, |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 138 | StartStopRebuildComponent, |
| SANDHYA.JS | 07decc0 | 2024-07-01 21:50:48 +0530 | [diff] [blame] | 139 | HealingComponent, |
| SANDHYA.JS | 2657011 | 2024-07-05 21:35:46 +0530 | [diff] [blame] | 140 | NSConfigTemplateActionComponent, |
| 141 | OkaPackagesActionComponent |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 142 | ], |
| 143 | imports: [ |
| 144 | NotifierModule.withConfig(customNotifierOptions), |
| 145 | CommonModule, |
| 146 | BrowserModule, |
| 147 | BrowserAnimationsModule, |
| 148 | FormsModule, |
| 149 | ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }), |
| 150 | Ng2SmartTableModule, |
| 151 | CodemirrorModule, |
| 152 | NgSelectModule, |
| 153 | HttpClientModule, |
| 154 | TranslateModule.forRoot({ |
| 155 | loader: { |
| 156 | provide: TranslateLoader, |
| 157 | useFactory: HttpLoaderFactory, |
| 158 | deps: [HttpClient] |
| 159 | } |
| 160 | }), |
| 161 | NgbModule, |
| 162 | NgSelectModule, |
| SANDHYA.JS | c84f112 | 2024-06-04 21:50:03 +0530 | [diff] [blame] | 163 | RouterModule.forRoot(appRoutes, { useHash: false }), |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 164 | NgIdleKeepaliveModule.forRoot(), |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 165 | LoaderModule, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 166 | SharedModule, |
| SANDHYA.JS | 1b17c43 | 2023-04-26 17:54:57 +0530 | [diff] [blame] | 167 | ChangePasswordModule, |
| 168 | ToastrModule.forRoot({ |
| 169 | timeOut: 500, |
| 170 | positionClass: 'toast-bottom-right' |
| 171 | }) |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 172 | ], |
| 173 | providers: [ |
| 174 | { |
| 175 | provide: APP_INITIALIZER, |
| 176 | useFactory: appInitializerFactory, |
| 177 | deps: [TranslateService, Injector], |
| 178 | multi: true |
| 179 | }, |
| 180 | { |
| 181 | provide: HTTP_INTERCEPTORS, |
| 182 | useClass: AuthInterceptorService, |
| 183 | multi: true |
| 184 | }, |
| 185 | RestService, |
| 186 | AuthenticationService, |
| 187 | AuthGuardService, |
| 188 | DataService, |
| 189 | ProjectService, |
| 190 | SharedService, |
| 191 | DeviceCheckService |
| 192 | ], |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 193 | bootstrap: [AppComponent] |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 194 | }) |
| 195 | |
| 196 | /** Exporting a class @exports AppModule */ |
| 197 | export class AppModule { |
| 198 | /** Variables declared to avoid state-less class */ |
| 199 | private appModule: string; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * HttpLoaderFactory is for translate service of the application. |
| 204 | */ |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 205 | /* eslint-disable */ |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 206 | export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { |
| 207 | const now: number = new Date().getTime(); |
| 208 | return new TranslateHttpLoader(http, './assets/i18n/', '.json?locale=' + now); |
| 209 | } |
| 210 | /** |
| 211 | * HttpLoaderFactory is for translate service of the application. |
| 212 | */ |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 213 | export function appInitializerFactory(translate: TranslateService, injector: Injector): Object { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 214 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 215 | return async (): Promise<any> => { |
| 216 | await injector.get(LOCATION_INITIALIZED, Promise.resolve(null)); |
| 217 | translate.setDefaultLang('en'); |
| SANDHYA.JS | 5b35bcd | 2023-04-27 15:11:06 +0530 | [diff] [blame] | 218 | const languageCode: string = sessionStorage.getItem('languageCode'); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 219 | if (languageCode !== null && languageCode !== undefined && languageCode !== '') { |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 220 | await translate.use(languageCode).toPromise().catch((): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 221 | translate.setDefaultLang('en'); |
| 222 | }); |
| 223 | } else { |
| 224 | await translate.use('en').toPromise(); |
| SANDHYA.JS | 5b35bcd | 2023-04-27 15:11:06 +0530 | [diff] [blame] | 225 | sessionStorage.setItem('languageCode', 'en'); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 226 | } |
| 227 | }; |
| 228 | } |