| 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'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 48 | import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate'; |
| 49 | import { InstantiateNsComponent } from 'InstantiateNs'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 50 | import { LayoutComponent } from 'LayoutComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 51 | import { LoaderModule } from 'LoaderModule'; |
| 52 | import { LoginComponent } from 'LoginComponent'; |
| 53 | import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent'; |
| 54 | import { NetslicePackagesActionComponent } from 'NetslicePackagesAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 55 | import { Ng2SmartTableModule } from 'ng2-smart-table'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 56 | import { NSInstancesActionComponent } from 'NSInstancesActionComponent'; |
| 57 | import { NsPackagesActionComponent } from 'NsPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 58 | import { NsUpdateComponent } from 'NsUpdateComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 59 | import { PageNotFoundComponent } from 'PageNotFound'; |
| 60 | import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent'; |
| 61 | import { ProjectLinkComponent } from 'ProjectLinkComponent'; |
| 62 | import { ProjectsActionComponent } from 'ProjectsAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 63 | import { ProjectService } from 'ProjectService'; |
| 64 | import { RestService } from 'RestService'; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 65 | import { ScalingComponent } from 'ScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 66 | import { SDNControllerActionComponent } from 'SDNControllerActionComponent'; |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 67 | import { SharedModule } from 'SharedModule'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 68 | import { SharedService } from 'SharedService'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 69 | import { ShowInfoComponent } from 'ShowInfoComponent'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 70 | import { SidebarComponent } from 'SidebarComponent'; |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 71 | import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 72 | import { SwitchProjectComponent } from 'SwitchProjectComponent'; |
| 73 | import { UsersActionComponent } from 'UsersActionComponent'; |
| 74 | import { UserSettingsComponent } from 'UserSettingsComponent'; |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 75 | import { VerticalScalingComponent } from 'VerticalScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 76 | import { VimAccountsActionComponent } from 'VimAccountsAction'; |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 77 | import { VmMigrationComponent } from 'VmMigrationComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 78 | import { VNFInstancesActionComponent } from 'VNFInstancesActionComponent'; |
| 79 | import { VNFLinkComponent } from 'VNFLinkComponent'; |
| 80 | import { VNFPackagesActionComponent } from 'VNFPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 81 | import { WarningComponent } from 'WarningComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 82 | import { WIMAccountsActionComponent } from 'WIMAccountsAction'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 83 | import { AppComponent } from './AppComponent'; |
| 84 | import { appRoutes } from './approutes.module'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * Custom angular notifier options |
| 88 | */ |
| 89 | const 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 R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 129 | GoToTopDirective, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 130 | ScalingComponent, |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 131 | ChangePasswordComponent, |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 132 | VmMigrationComponent, |
| 133 | NsUpdateComponent, |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 134 | WarningComponent, |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 135 | StartStopRebuildComponent, |
| 136 | VerticalScalingComponent |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 137 | ], |
| 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 R | 5abb274 | 2020-11-22 20:15:10 +0530 | [diff] [blame] | 158 | RouterModule.forRoot(appRoutes, { useHash: false, relativeLinkResolution: 'legacy' }), |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 159 | NgIdleKeepaliveModule.forRoot(), |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 160 | LoaderModule, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 161 | SharedModule, |
| 162 | ChangePasswordModule |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 163 | ], |
| 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.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 184 | bootstrap: [AppComponent] |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 185 | }) |
| 186 | |
| 187 | /** Exporting a class @exports AppModule */ |
| 188 | export 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.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 196 | /* eslint-disable */ |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 197 | export 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.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 204 | export function appInitializerFactory(translate: TranslateService, injector: Injector): Object { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame^] | 205 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 206 | 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.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 211 | await translate.use(languageCode).toPromise().catch((): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 212 | translate.setDefaultLang('en'); |
| 213 | }); |
| 214 | } else { |
| 215 | await translate.use('en').toPromise(); |
| 216 | localStorage.setItem('languageCode', 'en'); |
| 217 | } |
| 218 | }; |
| 219 | } |