| 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'; |
| 28 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; |
| 29 | import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; |
| 30 | import { TranslateHttpLoader } from '@ngx-translate/http-loader'; |
| 31 | import { NotifierModule, NotifierOptions } from 'angular-notifier'; |
| 32 | import { AuthInterceptorService } from 'AuthInterceptorService'; |
| 33 | import { HeaderComponent } from 'HeaderComponent'; |
| 34 | import { LayoutComponent } from 'LayoutComponent'; |
| 35 | import { Ng2SmartTableModule } from 'ng2-smart-table'; |
| 36 | import { RestService } from 'RestService'; |
| 37 | import { SidebarComponent } from 'SidebarComponent'; |
| 38 | import { AppComponent } from './AppComponent'; |
| 39 | |
| 40 | import { appRoutes } from './approutes.module'; |
| 41 | |
| 42 | import { DataService } from 'DataService'; |
| 43 | import { ProjectService } from 'ProjectService'; |
| 44 | import { SharedService } from 'SharedService'; |
| 45 | |
| 46 | import { CodemirrorModule } from '@ctrl/ngx-codemirror'; |
| 47 | import { NgSelectModule } from '@ng-select/ng-select'; |
| 48 | |
| 49 | import { NgIdleKeepaliveModule } from '@ng-idle/keepalive'; |
| 50 | import { AuthenticationService } from 'AuthenticationService'; |
| 51 | import { AuthGuardService } from 'AuthGuardService'; |
| 52 | import { BreadcrumbComponent } from 'BreadCrumb'; |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 53 | import { ChangePasswordComponent } from 'ChangePasswordComponent'; |
| 54 | import { ChangePasswordModule } from 'ChangePasswordModule'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 55 | import { ComposePackages } from 'ComposePackages'; |
| 56 | import { ConfirmationTopologyComponent } from 'ConfirmationTopology'; |
| 57 | import { DeleteComponent } from 'DeleteComponent'; |
| 58 | import { DeviceCheckService } from 'DeviceCheckService'; |
| 59 | import { GoToTopDirective } from 'GoToTopDirective'; |
| 60 | import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate'; |
| 61 | import { InstantiateNsComponent } from 'InstantiateNs'; |
| 62 | import { LoaderModule } from 'LoaderModule'; |
| 63 | import { LoginComponent } from 'LoginComponent'; |
| 64 | import { NetsliceInstancesActionComponent } from 'NetsliceInstancesActionComponent'; |
| 65 | import { NetslicePackagesActionComponent } from 'NetslicePackagesAction'; |
| 66 | import { NSInstancesActionComponent } from 'NSInstancesActionComponent'; |
| 67 | import { NsPackagesActionComponent } from 'NsPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 68 | import { NsUpdateComponent } from 'NsUpdateComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 69 | import { PageNotFoundComponent } from 'PageNotFound'; |
| 70 | import { PDUInstancesActionComponent } from 'PDUInstancesActionComponent'; |
| 71 | import { ProjectLinkComponent } from 'ProjectLinkComponent'; |
| 72 | import { ProjectsActionComponent } from 'ProjectsAction'; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 73 | import { ScalingComponent } from 'ScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 74 | import { SDNControllerActionComponent } from 'SDNControllerActionComponent'; |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 75 | import { SharedModule } from 'SharedModule'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 76 | import { ShowInfoComponent } from 'ShowInfoComponent'; |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 77 | import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 78 | import { SwitchProjectComponent } from 'SwitchProjectComponent'; |
| 79 | import { UsersActionComponent } from 'UsersActionComponent'; |
| 80 | import { UserSettingsComponent } from 'UserSettingsComponent'; |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 81 | import { VerticalScalingComponent } from 'VerticalScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 82 | import { VimAccountsActionComponent } from 'VimAccountsAction'; |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 83 | import { VmMigrationComponent } from 'VmMigrationComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 84 | import { VNFInstancesActionComponent } from 'VNFInstancesActionComponent'; |
| 85 | import { VNFLinkComponent } from 'VNFLinkComponent'; |
| 86 | import { VNFPackagesActionComponent } from 'VNFPackagesAction'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 87 | import { WarningComponent } from 'WarningComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 88 | import { WIMAccountsActionComponent } from 'WIMAccountsAction'; |
| 89 | |
| 90 | /** |
| 91 | * Custom angular notifier options |
| 92 | */ |
| 93 | const 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 R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 133 | GoToTopDirective, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 134 | ScalingComponent, |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 135 | ChangePasswordComponent, |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 136 | VmMigrationComponent, |
| 137 | NsUpdateComponent, |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 138 | WarningComponent, |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 139 | StartStopRebuildComponent, |
| 140 | VerticalScalingComponent |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 141 | ], |
| 142 | imports: [ |
| 143 | NotifierModule.withConfig(customNotifierOptions), |
| 144 | CommonModule, |
| 145 | BrowserModule, |
| 146 | BrowserAnimationsModule, |
| 147 | FormsModule, |
| 148 | ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }), |
| 149 | Ng2SmartTableModule, |
| 150 | CodemirrorModule, |
| 151 | NgSelectModule, |
| 152 | HttpClientModule, |
| 153 | TranslateModule.forRoot({ |
| 154 | loader: { |
| 155 | provide: TranslateLoader, |
| 156 | useFactory: HttpLoaderFactory, |
| 157 | deps: [HttpClient] |
| 158 | } |
| 159 | }), |
| 160 | NgbModule, |
| 161 | NgSelectModule, |
| Barath Kumar R | 5abb274 | 2020-11-22 20:15:10 +0530 | [diff] [blame] | 162 | RouterModule.forRoot(appRoutes, { useHash: false, relativeLinkResolution: 'legacy' }), |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 163 | NgIdleKeepaliveModule.forRoot(), |
| SANDHYA.JS | 4a7a542 | 2021-05-15 15:35:22 +0530 | [diff] [blame] | 164 | LoaderModule, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 165 | SharedModule, |
| 166 | ChangePasswordModule |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 167 | ], |
| 168 | providers: [ |
| 169 | { |
| 170 | provide: APP_INITIALIZER, |
| 171 | useFactory: appInitializerFactory, |
| 172 | deps: [TranslateService, Injector], |
| 173 | multi: true |
| 174 | }, |
| 175 | { |
| 176 | provide: HTTP_INTERCEPTORS, |
| 177 | useClass: AuthInterceptorService, |
| 178 | multi: true |
| 179 | }, |
| 180 | RestService, |
| 181 | AuthenticationService, |
| 182 | AuthGuardService, |
| 183 | DataService, |
| 184 | ProjectService, |
| 185 | SharedService, |
| 186 | DeviceCheckService |
| 187 | ], |
| 188 | bootstrap: [AppComponent], |
| 189 | entryComponents: [ |
| 190 | VNFPackagesActionComponent, |
| 191 | NsPackagesActionComponent, |
| 192 | NSInstancesActionComponent, |
| 193 | VNFInstancesActionComponent, |
| 194 | VNFLinkComponent, |
| 195 | NetsliceInstancesActionComponent, |
| 196 | BreadcrumbComponent, |
| 197 | DeleteComponent, |
| 198 | NetslicePackagesActionComponent, |
| 199 | UsersActionComponent, |
| 200 | VimAccountsActionComponent, |
| 201 | ProjectsActionComponent, |
| 202 | ProjectLinkComponent, |
| 203 | UserSettingsComponent, |
| 204 | ShowInfoComponent, |
| 205 | InstantiateNetSliceTemplateComponent, |
| 206 | InstantiateNsComponent, |
| 207 | ConfirmationTopologyComponent, |
| 208 | ComposePackages, |
| 209 | WIMAccountsActionComponent, |
| 210 | PDUInstancesActionComponent, |
| 211 | SDNControllerActionComponent, |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 212 | SwitchProjectComponent, |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 213 | ScalingComponent, |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 214 | ChangePasswordComponent, |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 215 | VmMigrationComponent, |
| 216 | NsUpdateComponent, |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 217 | WarningComponent, |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 218 | StartStopRebuildComponent, |
| 219 | VerticalScalingComponent |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 220 | ] |
| 221 | }) |
| 222 | |
| 223 | /** Exporting a class @exports AppModule */ |
| 224 | export class AppModule { |
| 225 | /** Variables declared to avoid state-less class */ |
| 226 | private appModule: string; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * HttpLoaderFactory is for translate service of the application. |
| 231 | */ |
| 232 | // tslint:disable:function-name |
| 233 | export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { |
| 234 | const now: number = new Date().getTime(); |
| 235 | return new TranslateHttpLoader(http, './assets/i18n/', '.json?locale=' + now); |
| 236 | } |
| 237 | /** |
| 238 | * HttpLoaderFactory is for translate service of the application. |
| 239 | */ |
| 240 | // tslint:disable:function-name |
| 241 | export function appInitializerFactory(translate: TranslateService, injector: Injector): Object { |
| 242 | // tslint:disable-next-line: no-any |
| 243 | return async (): Promise<any> => { |
| 244 | await injector.get(LOCATION_INITIALIZED, Promise.resolve(null)); |
| 245 | translate.setDefaultLang('en'); |
| SANDHYA.JS | dc7a661 | 2023-05-10 23:01:35 +0530 | [diff] [blame^] | 246 | const languageCode: string = sessionStorage.getItem('languageCode'); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 247 | if (languageCode !== null && languageCode !== undefined && languageCode !== '') { |
| SANDHYA.JS | a981655 | 2022-04-12 09:07:08 +0530 | [diff] [blame] | 248 | await translate.use(languageCode).toPromise().catch((): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 249 | translate.setDefaultLang('en'); |
| 250 | }); |
| 251 | } else { |
| 252 | await translate.use('en').toPromise(); |
| SANDHYA.JS | dc7a661 | 2023-05-10 23:01:35 +0530 | [diff] [blame^] | 253 | sessionStorage.setItem('languageCode', 'en'); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 254 | } |
| 255 | }; |
| 256 | } |