generator-jhipster 7.4.1 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/generators/app/index.js +11 -1
  2. package/generators/cleanup.js +27 -171
  3. package/generators/client/files-angular.js +6 -1
  4. package/generators/client/files-vue.js +5 -1
  5. package/generators/client/index.js +2 -1
  6. package/generators/client/templates/angular/angular.json.ejs +5 -0
  7. package/generators/client/templates/angular/jest.conf.js.ejs +2 -0
  8. package/generators/client/templates/angular/package.json +24 -24
  9. package/generators/client/templates/angular/package.json.ejs +3 -1
  10. package/generators/client/templates/angular/src/main/webapp/app/account/activate/activate.component.ts.ejs +4 -4
  11. package/generators/client/templates/angular/src/main/webapp/app/account/password/password-strength-bar/password-strength-bar.component.ts.ejs +1 -1
  12. package/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs +4 -4
  13. package/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs +4 -4
  14. package/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.spec.ts.ejs +10 -9
  15. package/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs +1 -1
  16. package/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.spec.ts.ejs +8 -6
  17. package/generators/client/templates/angular/src/main/webapp/app/admin/health/health.component.ts.ejs +4 -4
  18. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.spec.ts.ejs +4 -4
  19. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs +4 -4
  20. package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/update/user-management-update.component.ts.ejs +8 -8
  21. package/generators/client/templates/angular/src/main/webapp/app/app-routing.module.ts.ejs +14 -3
  22. package/generators/client/templates/angular/src/main/webapp/app/app.module.ts.ejs +8 -29
  23. package/generators/client/templates/angular/src/main/webapp/app/config/datepicker-adapter.ts.ejs +1 -1
  24. package/generators/client/templates/angular/src/main/webapp/app/config/dayjs.ts.ejs +4 -4
  25. package/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.spec.ts.ejs +14 -9
  26. package/generators/client/templates/angular/src/main/webapp/app/core/tracker/tracker.service.ts.ejs +6 -6
  27. package/generators/client/templates/angular/src/main/webapp/app/core/util/parse-links.service.ts.ejs +1 -1
  28. package/generators/client/templates/angular/src/main/webapp/app/entities/entity-navbar-items.ts.ejs +29 -0
  29. package/generators/client/templates/angular/src/main/webapp/app/home/home.component.spec.ts.ejs +14 -4
  30. package/generators/client/templates/angular/src/main/webapp/app/layouts/main/main.component.ts.ejs +1 -1
  31. package/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.html.ejs +20 -0
  32. package/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.spec.ts.ejs +10 -4
  33. package/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.ts.ejs +41 -2
  34. package/generators/client/templates/angular/src/main/webapp/app/login/login.component.spec.ts.ejs +3 -2
  35. package/generators/client/templates/angular/src/main/webapp/app/login/login.component.ts.ejs +4 -4
  36. package/generators/client/templates/angular/src/main/webapp/app/shared/auth/has-any-authority.directive.spec.ts.ejs +4 -4
  37. package/generators/client/templates/angular/src/main/webapp/app/shared/date/duration.pipe.ts.ejs +1 -1
  38. package/generators/client/templates/angular/src/main/webapp/app/shared/date/format-medium-date.pipe.spec.ts.ejs +1 -1
  39. package/generators/client/templates/angular/src/main/webapp/app/shared/date/format-medium-date.pipe.ts.ejs +1 -1
  40. package/generators/client/templates/angular/src/main/webapp/app/shared/date/format-medium-datetime.pipe.spec.ts.ejs +1 -1
  41. package/generators/client/templates/angular/src/main/webapp/app/shared/date/format-medium-datetime.pipe.ts.ejs +1 -1
  42. package/generators/client/templates/angular/src/main/webapp/app/shared/language/translate.directive.ts.ejs +6 -6
  43. package/generators/client/templates/angular/src/main/webapp/app/shared/language/translation.module.ts.ejs +83 -0
  44. package/generators/client/templates/angular/src/main/webapp/declarations.d.ts.ejs +16 -2
  45. package/generators/client/templates/angular/tsconfig.json.ejs +2 -0
  46. package/generators/client/templates/angular/tsconfig.spec.json.ejs +0 -1
  47. package/generators/client/templates/angular/webpack/proxy.conf.js.ejs +0 -2
  48. package/generators/client/templates/angular/webpack/webpack.custom.js.ejs +0 -16
  49. package/generators/client/templates/angular/webpack/webpack.microfrontend.js.ejs +12 -5
  50. package/generators/client/templates/common/package.json +2 -2
  51. package/generators/client/templates/common/src/main/webapp/robots.txt.ejs +0 -1
  52. package/generators/client/templates/common/src/main/webapp/swagger-ui/index.html.ejs +86 -56
  53. package/generators/client/templates/react/package.json +27 -27
  54. package/generators/client/templates/react/package.json.ejs +2 -0
  55. package/generators/client/templates/react/src/main/webapp/app/config/axios-interceptor.spec.ts.ejs +3 -2
  56. package/generators/client/templates/react/src/main/webapp/app/shared/layout/header/header.scss.ejs +9 -0
  57. package/generators/client/templates/react/src/main/webapp/app/shared/layout/header/header.tsx.ejs +1 -1
  58. package/generators/client/templates/react/src/main/webapp/app/shared/reducers/authentication.spec.ts.ejs +1 -1
  59. package/generators/client/templates/react/webpack/webpack.dev.js.ejs +0 -2
  60. package/generators/client/templates/vue/package.json +22 -22
  61. package/generators/client/templates/vue/package.json.ejs +3 -3
  62. package/generators/client/templates/vue/src/main/webapp/app/account/account.service.ts.ejs +19 -9
  63. package/generators/client/templates/vue/src/main/webapp/app/entities/entities.component.ts.ejs +6 -0
  64. package/generators/client/templates/vue/src/main/webapp/app/entities/user/{user.oauth2.service.ts.ejs → user.service.ts.ejs} +1 -1
  65. package/generators/client/templates/vue/src/main/webapp/app/main.ts.ejs +0 -8
  66. package/generators/client/templates/vue/src/test/javascript/spec/app/admin/user-management/user-management-edit.component.spec.ts.ejs +4 -4
  67. package/generators/client/templates/vue/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts.ejs +2 -2
  68. package/generators/client/templates/vue/webpack/webpack.common.js.ejs +0 -2
  69. package/generators/common/templates/README.md.jhi.ejs +1 -3
  70. package/generators/common/templates/package.json +3 -3
  71. package/generators/cypress/templates/cypress.json.ejs +9 -2
  72. package/generators/cypress/templates/src/test/javascript/cypress/integration/account/login-page.spec.ts.ejs +3 -14
  73. package/generators/cypress/templates/src/test/javascript/cypress/integration/account/password-page.spec.ts.ejs +33 -39
  74. package/generators/cypress/templates/src/test/javascript/cypress/integration/account/register-page.spec.ts.ejs +52 -62
  75. package/generators/cypress/templates/src/test/javascript/cypress/integration/account/reset-password-page.spec.ts.ejs +2 -10
  76. package/generators/cypress/templates/src/test/javascript/cypress/integration/account/settings-page.spec.ts.ejs +25 -34
  77. package/generators/cypress/templates/src/test/javascript/cypress/integration/administration/administration.spec.ts.ejs +1 -22
  78. package/generators/cypress/templates/src/test/javascript/cypress/support/commands.ts.ejs +38 -6
  79. package/generators/cypress/templates/src/test/javascript/cypress/support/index.ts.ejs +1 -6
  80. package/generators/cypress/templates/src/test/javascript/cypress/support/navbar.ts.ejs +7 -7
  81. package/generators/cypress/templates/src/test/javascript/cypress/support/oauth2.ts.ejs +0 -9
  82. package/generators/docker-compose/templates/realm-config/jhipster-realm.json.ejs +1 -1
  83. package/generators/entity/index.js +45 -3
  84. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/delete/entity-management-delete-dialog.component.spec.ts.ejs +1 -1
  85. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/detail/entity-management-detail.component.html.ejs +1 -1
  86. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.module.ts.ejs +1 -35
  87. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity.model.ts.ejs +1 -1
  88. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.html.ejs +4 -4
  89. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.spec.ts.ejs +8 -8
  90. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.ts.ejs +1 -1
  91. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/infinite-scroll-template.ejs +8 -8
  92. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/no-pagination-template.ejs +8 -8
  93. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/pagination-template.ejs +8 -8
  94. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/route/entity-management-routing-resolve.service.spec.ts.ejs +15 -6
  95. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/service/entity.service.spec.ts.ejs +1 -1
  96. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/service/entity.service.ts.ejs +1 -1
  97. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.spec.ts.ejs +12 -5
  98. package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs +5 -5
  99. package/generators/entity-client/templates/angular/src/test/javascript/e2e/entities/entity.spec.ts.ejs +1 -1
  100. package/generators/entity-client/templates/common/src/test/javascript/cypress/integration/entity/entity.spec.ts.ejs +14 -37
  101. package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity.reducer.ts.ejs +5 -4
  102. package/generators/entity-client/templates/vue/src/main/webapp/app/entities/entity-update.component.ts.ejs +23 -19
  103. package/generators/entity-client/templates/vue/src/test/javascript/spec/app/entities/entity-update.component.spec.ts.ejs +4 -6
  104. package/generators/entity-server/files.js +10 -0
  105. package/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs +2 -2
  106. package/generators/entity-server/templates/src/main/java/package/common/search_template.ejs +1 -1
  107. package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.ejs +5 -8
  108. package/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs +18 -2
  109. package/generators/entity-server/templates/src/main/java/package/repository/search/SortToFieldSortBuilderConverter.java.ejs +24 -0
  110. package/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs +4 -6
  111. package/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs +2 -2
  112. package/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs +2 -2
  113. package/generators/generator-base-private.js +2 -1
  114. package/generators/generator-base.js +13 -3
  115. package/generators/generator-constants.js +7 -7
  116. package/generators/server/__snapshots__/generator.spec.mjs.snap +16 -15
  117. package/generators/server/cleanup.js +151 -0
  118. package/generators/server/files.js +16 -14
  119. package/generators/server/index.js +34 -23
  120. package/generators/server/templates/build.gradle.ejs +214 -188
  121. package/generators/server/templates/gradle.properties.ejs +8 -8
  122. package/generators/server/templates/npmw +7 -5
  123. package/generators/server/templates/npmw.cmd +12 -7
  124. package/generators/server/templates/pom.xml.ejs +419 -329
  125. package/generators/server/templates/src/main/docker/config/realm-config/jhipster-realm.json.ejs +2 -2
  126. package/generators/server/templates/src/main/java/package/config/LocaleConfiguration.java.ejs +3 -2
  127. package/generators/server/templates/src/main/java/package/config/OpenApiConfiguration.java.ejs +17 -54
  128. package/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +5 -5
  129. package/generators/server/templates/src/main/java/package/config/SecurityConfiguration_reactive.java.ejs +3 -5
  130. package/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs +0 -2
  131. package/generators/server/templates/src/main/java/package/config/neo4j/Neo4jMigrations.java.ejs +19 -9
  132. package/generators/server/templates/src/main/java/package/repository/AuthorityRepository.java.ejs +2 -2
  133. package/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs +0 -2
  134. package/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs +6 -4
  135. package/generators/server/templates/src/main/java/package/security/oauth2/CustomClaimConverter.java.ejs +2 -2
  136. package/generators/server/templates/src/main/java/package/service/UserService.java.ejs +3 -3
  137. package/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs +6 -6
  138. package/generators/server/templates/src/main/java/package/web/filter/ModifyServersOpenApiFilter.java.ejs +3 -2
  139. package/generators/server/templates/src/main/java/package/web/filter/SpaWebFilter.java.ejs +1 -1
  140. package/generators/server/templates/src/main/java/package/web/rest/PublicUserResource.java.ejs +2 -2
  141. package/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs +2 -2
  142. package/generators/server/templates/src/main/resources/config/application.yml.ejs +17 -3
  143. package/generators/server/templates/src/main/resources/logback-spring.xml.ejs +1 -2
  144. package/generators/server/templates/src/test/java/package/cucumber/CucumberIT.java.ejs +2 -6
  145. package/generators/server/templates/src/test/java/package/cucumber/CucumberTestContextConfiguration.java.ejs +2 -3
  146. package/generators/server/templates/src/test/java/package/cucumber/stepdefs/UserStepDefs.java.ejs +41 -6
  147. package/generators/server/templates/src/test/java/package/management/SecurityMetersServiceTests.java.ejs +7 -7
  148. package/generators/server/templates/src/test/java/package/security/jwt/TokenProviderSecurityMetersTests.java.ejs +10 -10
  149. package/generators/server/templates/src/test/java/package/security/oauth2/AuthorizationHeaderUtilTest.java.ejs +1 -1
  150. package/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs +1 -1
  151. package/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs +2 -3
  152. package/generators/server/templates/src/test/java/package/web/rest/ClientForwardControllerTest.java.ejs +9 -0
  153. package/generators/server/templates/src/test/resources/junit-platform.properties.ejs +2 -0
  154. package/generators/server/templates/src/test/resources/logback.xml.ejs +1 -1
  155. package/generators/server/templates/src/test/{features → resources/package/features}/gitkeep +0 -0
  156. package/generators/server/templates/src/test/{features → resources/package/features}/user/user.feature.ejs +0 -0
  157. package/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs +1 -1
  158. package/package.json +9 -9
  159. package/utils/entity.js +1 -5
  160. package/generators/server/templates/src/main/java/package/config/apidocs/GatewaySwaggerResourcesProvider.java.ejs +0 -91
  161. package/generators/server/templates/src/test/java/package/config/apidocs/GatewaySwaggerResourcesProviderTest.java.ejs +0 -79
  162. package/generators/server/templates/src/test/resources/cucumber.properties.ejs +0 -1
@@ -95,13 +95,13 @@ export class UserManagementComponent implements OnInit {
95
95
  size: this.itemsPerPage,
96
96
  sort: this.sort(),
97
97
  }<% } %>)
98
- .subscribe(
99
- (res: HttpResponse<User[]>) => {
98
+ .subscribe({
99
+ next: (res: HttpResponse<User[]>) => {
100
100
  this.isLoading = false;
101
101
  this.onSuccess(res.body<% if (!databaseTypeCassandra) { %>, res.headers<% } %>);
102
102
  },
103
- () => this.isLoading = false
104
- );
103
+ error: () => this.isLoading = false
104
+ });
105
105
  }
106
106
 
107
107
  <%_ if (!databaseTypeCassandra) { _%>
@@ -72,18 +72,18 @@ export class UserManagementUpdateComponent implements OnInit {
72
72
  this.isSaving = true;
73
73
  this.updateUser(this.user);
74
74
  if (this.user.id !== undefined) {
75
- this.userService.update(this.user).subscribe(
76
- () => this.onSaveSuccess(),
77
- () => this.onSaveError()
78
- );
75
+ this.userService.update(this.user).subscribe({
76
+ next: () => this.onSaveSuccess(),
77
+ error: () => this.onSaveError()
78
+ });
79
79
  } else {
80
80
  <%_ if (!enableTranslation) { _%>
81
81
  this.user.langKey = 'en';
82
82
  <%_ } _%>
83
- this.userService.create(this.user).subscribe(
84
- () => this.onSaveSuccess(),
85
- () => this.onSaveError()
86
- );
83
+ this.userService.create(this.user).subscribe({
84
+ next: () => this.onSaveSuccess(),
85
+ error: () => this.onSaveError()
86
+ });
87
87
  }
88
88
  }
89
89
 
@@ -26,8 +26,6 @@ import { Authority } from 'app/config/authority.constants';
26
26
 
27
27
  import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
28
28
 
29
- const LAYOUT_ROUTES = [navbarRoute, ...errorRoute];
30
-
31
29
  @NgModule({
32
30
  imports: [
33
31
  RouterModule.forRoot(
@@ -54,7 +52,20 @@ const LAYOUT_ROUTES = [navbarRoute, ...errorRoute];
54
52
  loadChildren: () => import('./login/login.module').then(m => m.LoginModule),
55
53
  },
56
54
  <%_ } _%>
57
- ...LAYOUT_ROUTES,
55
+ {
56
+ path: '<%= applicationTypeMicroservice ? lowercaseBaseName : '' %>',
57
+ loadChildren: () => import(`./entities/entity-routing.module`).then(m => m.EntityRoutingModule),
58
+ },
59
+ <%_ if (applicationTypeGateway) { _%>
60
+ <%_ for (const remote of microfrontends) { _%>
61
+ {
62
+ path: '<%= remote.lowercaseBaseName %>',
63
+ loadChildren: () => import(`<%= remote.lowercaseBaseName %>/entity-routing`).then(m => m.EntityRoutingModule),
64
+ },
65
+ <%_ } _%>
66
+ <%_ } _%>
67
+ navbarRoute,
68
+ ...errorRoute,
58
69
  ],
59
70
  { enableTracing: DEBUG_INFO_ENABLED }
60
71
  ),
@@ -21,7 +21,7 @@
21
21
  _%>
22
22
  import { NgModule, LOCALE_ID } from '@angular/core';
23
23
  import { registerLocaleData } from '@angular/common';
24
- import { <% if (enableTranslation) { %>HttpClient, <% } %>HttpClientModule } from '@angular/common/http';
24
+ import { HttpClientModule } from '@angular/common/http';
25
25
  import locale from '@angular/common/locales/<%= localeId %>';
26
26
  import { BrowserModule, Title } from '@angular/platform-browser';
27
27
  import { ServiceWorkerModule } from '@angular/service-worker';
@@ -29,19 +29,18 @@ import { FaIconLibrary } from '@fortawesome/angular-fontawesome';
29
29
  <%_ if (authenticationTypeSession && communicationSpringWebsocket) { _%>
30
30
  import { CookieService } from 'ngx-cookie-service';
31
31
  <%_ } _%>
32
- <%_ if (enableTranslation) { _%>
33
- import { TranslateModule, TranslateService, TranslateLoader, MissingTranslationHandler } from '@ngx-translate/core';
34
- <%_ } _%>
35
- import { NgxWebstorageModule<% if (enableTranslation) { %>, SessionStorageService<% } %> } from 'ngx-webstorage';
36
- import * as dayjs from 'dayjs';
32
+ import { NgxWebstorageModule } from 'ngx-webstorage';
33
+ import dayjs from 'dayjs/esm';
37
34
  import { NgbDateAdapter, NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap';
38
35
 
39
36
  import { ApplicationConfigService } from 'app/core/config/application-config.service';
40
37
  import './config/dayjs';
41
38
  import { SharedModule } from 'app/shared/shared.module';
39
+ <%_ if (enableTranslation) { _%>
40
+ import { TranslationModule } from 'app/shared/language/translation.module';
41
+ <%_ } _%>
42
42
  import { AppRoutingModule } from './app-routing.module';
43
43
  import { HomeModule } from './home/home.module';
44
- import { EntityRoutingModule } from './entities/entity-routing.module';
45
44
  // jhipster-needle-angular-add-module-import JHipster will add new module here
46
45
  import { NgbDateDayjsAdapter } from './config/datepicker-adapter';
47
46
  import { fontAwesomeIcons } from './config/font-awesome-icons';
@@ -49,9 +48,6 @@ import { httpInterceptorProviders } from 'app/core/interceptor/index';
49
48
  <%_ if (enableI18nRTL) { _%>
50
49
  import { FindLanguageFromKeyPipe } from 'app/shared/language/find-language-from-key.pipe';
51
50
  <%_ } _%>
52
- <%_ if (enableTranslation) { _%>
53
- import { translatePartialLoader, missingTranslationHandler } from './config/translation.config';
54
- <%_ } _%>
55
51
  import { MainComponent } from './layouts/main/main.component';
56
52
  import { NavbarComponent } from './layouts/navbar/navbar.component';
57
53
  import { FooterComponent } from './layouts/footer/footer.component';
@@ -67,24 +63,13 @@ import { ErrorComponent } from './layouts/error/error.component';
67
63
  SharedModule,
68
64
  HomeModule,
69
65
  // jhipster-needle-angular-add-module JHipster will add new module here
70
- EntityRoutingModule,
71
66
  AppRoutingModule,
72
67
  // Set this to true to enable service worker (PWA)
73
68
  ServiceWorkerModule.register('ngsw-worker.js', { enabled: false }),
74
69
  HttpClientModule,
75
70
  NgxWebstorageModule.forRoot({ prefix: '<%= jhiPrefixDashed %>', separator: '-', caseSensitive: true }),
76
71
  <%_ if (enableTranslation) { _%>
77
- TranslateModule.forRoot({
78
- loader: {
79
- provide: TranslateLoader,
80
- useFactory: translatePartialLoader,
81
- deps: [HttpClient],
82
- },
83
- missingTranslationHandler: {
84
- provide: MissingTranslationHandler,
85
- useFactory: missingTranslationHandler,
86
- },
87
- }),
72
+ TranslationModule,
88
73
  <%_ } _%>
89
74
  ],
90
75
  providers: [
@@ -112,7 +97,7 @@ import { ErrorComponent } from './layouts/error/error.component';
112
97
  bootstrap: [MainComponent],
113
98
  })
114
99
  export class AppModule {
115
- constructor(applicationConfigService: ApplicationConfigService, iconLibrary: FaIconLibrary, dpConfig: NgbDatepickerConfig<% if (enableTranslation) { %>, translateService: TranslateService, sessionStorageService: SessionStorageService<% } %>) {
100
+ constructor(applicationConfigService: ApplicationConfigService, iconLibrary: FaIconLibrary, dpConfig: NgbDatepickerConfig) {
116
101
  <%_ if (applicationTypeMicroservice) { _%>
117
102
  applicationConfigService.setMicrofrontend();
118
103
  <%_ } _%>
@@ -120,11 +105,5 @@ export class AppModule {
120
105
  registerLocaleData(locale);
121
106
  iconLibrary.addIcons(...fontAwesomeIcons);
122
107
  dpConfig.minDate = { year: dayjs().subtract(100, 'year').year(), month: 1, day: 1 };
123
- <%_ if (enableTranslation) { _%>
124
- translateService.setDefaultLang('<%= nativeLanguage %>');
125
- // if user have changed language and navigates away from the application and back to the application then use previously choosed language
126
- const langKey = sessionStorageService.retrieve('locale') ?? '<%= nativeLanguage %>';
127
- translateService.use(langKey);
128
- <%_ } _%>
129
108
  }
130
109
  }
@@ -21,7 +21,7 @@
21
21
  */
22
22
  import { Injectable } from '@angular/core';
23
23
  import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
24
- import * as dayjs from 'dayjs';
24
+ import dayjs from 'dayjs/esm';
25
25
 
26
26
  @Injectable()
27
27
  export class NgbDateDayjsAdapter extends NgbDateAdapter<dayjs.Dayjs> {
@@ -16,10 +16,10 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- import * as dayjs from 'dayjs';
20
- import * as customParseFormat from 'dayjs/plugin/customParseFormat';
21
- import * as duration from 'dayjs/plugin/duration';
22
- import * as relativeTime from 'dayjs/plugin/relativeTime';
19
+ import dayjs from 'dayjs/esm';
20
+ import customParseFormat from 'dayjs/esm/plugin/customParseFormat';
21
+ import duration from 'dayjs/esm/plugin/duration';
22
+ import relativeTime from 'dayjs/esm/plugin/relativeTime';
23
23
 
24
24
  // jhipster-needle-i18n-language-dayjs-imports - JHipster will import languages from dayjs here
25
25
 
@@ -16,20 +16,18 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- jest.mock('@angular/router');
20
- <%_ if (enableTranslation) { _%>
21
- jest.mock('@ngx-translate/core');
22
- <%_ } _%>
23
19
  jest.mock('app/core/auth/state-storage.service');
24
20
  <%_ if (communicationSpringWebsocket) { _%>
25
21
  jest.mock('app/core/tracker/tracker.service');
26
22
  <%_ } _%>
27
23
 
28
24
  import { Router } from '@angular/router';
25
+ import { RouterTestingModule } from '@angular/router/testing';
29
26
  import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
30
27
  import { TestBed } from '@angular/core/testing';
31
28
  <%_ if (enableTranslation) { _%>
32
- import { TranslateService } from '@ngx-translate/core';
29
+ import { TranslateModule, TranslateService } from '@ngx-translate/core';
30
+ import { of } from 'rxjs';
33
31
  <%_ } _%>
34
32
  import { NgxWebstorageModule<% if (enableTranslation) { %>, SessionStorageService<% } %> } from 'ngx-webstorage';
35
33
 
@@ -76,16 +74,19 @@ describe('Account Service', () => {
76
74
 
77
75
  beforeEach(() => {
78
76
  TestBed.configureTestingModule({
79
- imports: [HttpClientTestingModule, NgxWebstorageModule.forRoot()],
80
- providers: [
77
+ imports: [
78
+ HttpClientTestingModule,
79
+ RouterTestingModule.withRoutes([]),
81
80
  <%_ if (enableTranslation) { _%>
82
- TranslateService,
81
+ TranslateModule.forRoot(),
83
82
  <%_ } _%>
83
+ NgxWebstorageModule.forRoot()
84
+ ],
85
+ providers: [
84
86
  <%_ if (communicationSpringWebsocket) { _%>
85
87
  TrackerService,
86
88
  <%_ } _%>
87
89
  StateStorageService,
88
- Router,
89
90
  ],
90
91
  });
91
92
 
@@ -96,11 +97,15 @@ describe('Account Service', () => {
96
97
  httpMock = TestBed.inject(HttpTestingController);
97
98
  mockStorageService = TestBed.inject(StateStorageService);
98
99
  mockRouter = TestBed.inject(Router);
100
+ jest.spyOn(mockRouter, 'navigateByUrl').mockImplementation(() => Promise.resolve(true));
99
101
  <%_ if (communicationSpringWebsocket) { _%>
102
+
100
103
  mockTrackerService = TestBed.inject(TrackerService);
101
104
  <%_ } _%>
102
105
  <%_ if (enableTranslation) { _%>
106
+
103
107
  mockTranslateService = TestBed.inject(TranslateService);
108
+ jest.spyOn(mockTranslateService, 'use').mockImplementation(() => of(''));
104
109
  sessionStorageService = TestBed.inject(SessionStorageService);
105
110
  <%_ } _%>
106
111
  });
@@ -21,8 +21,8 @@ import { Location } from '@angular/common';
21
21
  import { Router, NavigationEnd, Event } from '@angular/router';
22
22
  import { Subscription, ReplaySubject, Subject } from 'rxjs';
23
23
  import { filter } from 'rxjs/operators';
24
- import * as SockJS from 'sockjs-client';
25
- import * as Stomp from 'webstomp-client';
24
+ import SockJS from 'sockjs-client';
25
+ import Stomp, { Client, Subscription as StompSubscription, ConnectionHeaders, Message } from 'webstomp-client';
26
26
 
27
27
  <%_ if (authenticationTypeSession) { _%>
28
28
  import { CSRFService } from 'app/core/auth/csrf.service';
@@ -34,11 +34,11 @@ import { TrackerActivity } from './tracker-activity.model';
34
34
 
35
35
  @Injectable({ providedIn: 'root' })
36
36
  export class TrackerService {
37
- private stompClient: Stomp.Client | null = null;
37
+ private stompClient: Client | null = null;
38
38
  private routerSubscription: Subscription | null = null;
39
39
  private connectionSubject: ReplaySubject<void> = new ReplaySubject(1);
40
40
  private connectionSubscription: Subscription | null = null;
41
- private stompSubscription: Stomp.Subscription | null = null;
41
+ private stompSubscription: StompSubscription | null = null;
42
42
  private listenerSubject: Subject<TrackerActivity> = new Subject();
43
43
 
44
44
  constructor(
@@ -67,7 +67,7 @@ export class TrackerService {
67
67
  <%_ } _%>
68
68
  const socket: WebSocket = new SockJS(url);
69
69
  this.stompClient = Stomp.over(socket, { protocols: ['v12.stomp'] });
70
- const headers: Stomp.ConnectionHeaders = {};
70
+ const headers: ConnectionHeaders = {};
71
71
  <%_ if (authenticationTypeSession) { _%>
72
72
  headers['X-XSRF-TOKEN'] = this.csrfService.getCSRF('XSRF-TOKEN');
73
73
  <%_ } _%>
@@ -111,7 +111,7 @@ export class TrackerService {
111
111
 
112
112
  this.connectionSubscription = this.connectionSubject.subscribe(() => {
113
113
  if (this.stompClient) {
114
- this.stompSubscription = this.stompClient.subscribe('/topic/tracker', (data: Stomp.Message) => {
114
+ this.stompSubscription = this.stompClient.subscribe('/topic/tracker', (data: Message) => {
115
115
  this.listenerSubject.next(JSON.parse(data.body));
116
116
  });
117
117
  }
@@ -49,7 +49,7 @@ export class ParseLinks {
49
49
  const queryString: { [key: string]: string | undefined } = {};
50
50
 
51
51
  url.replace(
52
- new RegExp('([^?=&]+)(=([^&]*))?', 'g'),
52
+ /([^?=&]+)(=([^&]*))?/g,
53
53
  ($0: string, $1: string | undefined, $2: string | undefined, $3: string | undefined) => {
54
54
  if ($1 !== undefined) {
55
55
  queryString[$1] = $3;
@@ -0,0 +1,29 @@
1
+ <%#
2
+ Copyright 2013-2021 the original author or authors from the JHipster project.
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ export const EntityNavbarItems = [
20
+ <%_ for (const entity of localEntities) { _%>
21
+ {
22
+ name: '<%= entity.entityAngularName %>',
23
+ route: '<%= entity.entityPage %>',
24
+ <%_ if (enableTranslation) { _%>
25
+ translationKey: 'global.menu.entities.<%= entity.entityTranslationKey %>',
26
+ <%_ } _%>
27
+ },
28
+ <%_ } _%>
29
+ ];
@@ -17,15 +17,14 @@
17
17
  limitations under the License.
18
18
  -%>
19
19
  jest.mock('app/core/auth/account.service');
20
- <%_ if (!authenticationTypeOauth2) { _%>
21
- jest.mock('@angular/router');
22
- <% } else { %>
20
+ <%_ if (authenticationTypeOauth2) { _%>
23
21
  jest.mock('app/login/login.service');
24
22
  <%_ } _%>
25
23
 
26
24
  import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
27
25
  <%_ if (!authenticationTypeOauth2) { _%>
28
26
  import { Router } from '@angular/router';
27
+ import { RouterTestingModule } from '@angular/router/testing';
29
28
  <%_ } _%>
30
29
  import { of<% if (!authenticationTypeOauth2) { %>, Subject<% } %> } from 'rxjs';
31
30
 
@@ -60,8 +59,16 @@ describe('Home Component', () => {
60
59
  beforeEach(
61
60
  waitForAsync(() => {
62
61
  TestBed.configureTestingModule({
62
+ <%_ if (!authenticationTypeOauth2) { _%>
63
+ imports: [RouterTestingModule.withRoutes([])],
64
+ <%_ } _%>
63
65
  declarations: [HomeComponent],
64
- providers: [AccountService, <% if (!authenticationTypeOauth2) { %>Router<% } else { %>LoginService<% } %>],
66
+ providers: [
67
+ AccountService,
68
+ <%_ if (authenticationTypeOauth2) { _%>
69
+ LoginService
70
+ <%_ } _%>
71
+ ],
65
72
  })
66
73
  .overrideTemplate(HomeComponent, '')
67
74
  .compileComponents();
@@ -75,7 +82,10 @@ describe('Home Component', () => {
75
82
  mockAccountService.identity = jest.fn(() => of(null));
76
83
  mockAccountService.getAuthenticationState = jest.fn(() => of(null));
77
84
  <%_ if (!authenticationTypeOauth2) { _%>
85
+
78
86
  mockRouter = TestBed.inject(Router);
87
+ jest.spyOn(mockRouter, 'navigate').mockImplementation(() => Promise.resolve(true));
88
+
79
89
  <%_ } else { _%>
80
90
  mockLoginService = TestBed.inject(LoginService);
81
91
  <%_ } _%>
@@ -21,7 +21,7 @@ import { Title } from '@angular/platform-browser';
21
21
  import { Router, ActivatedRouteSnapshot, NavigationEnd } from '@angular/router';
22
22
  <%_ if (enableTranslation) { _%>
23
23
  import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
24
- import * as dayjs from 'dayjs';
24
+ import dayjs from 'dayjs/esm';
25
25
  <%_ } _%>
26
26
 
27
27
  import { AccountService } from 'app/core/auth/account.service';
@@ -60,6 +60,26 @@
60
60
  </span>
61
61
  </a>
62
62
  <ul class="dropdown-menu" ngbDropdownMenu aria-labelledby="entity-menu">
63
+ <%_ if (applicationTypeGateway) { _%>
64
+ <%_ for (const remote of microfrontends) { _%>
65
+ <li *ngFor="let entityNavbarItem of <%= remote.lowercaseBaseName %>EntityNavbarItems">
66
+ <a
67
+ class="dropdown-item"
68
+ [routerLink]="entityNavbarItem.route"
69
+ routerLinkActive="active"
70
+ [routerLinkActiveOptions]="{ exact: true }"
71
+ (click)="collapseNavbar()"
72
+ >
73
+ <fa-icon icon="asterisk" [fixedWidth]="true"></fa-icon>
74
+ <span
75
+ <%_ if (enableTranslation) { _%>
76
+ [jhiTranslate]="entityNavbarItem.translationKey"
77
+ <%_ } _%>
78
+ >{{entityNavbarItem.name}}</span>
79
+ </a>
80
+ </li>
81
+ <%_ } _%>
82
+ <%_ } _%>
63
83
  <!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
64
84
  </ul>
65
85
  </li>
@@ -16,12 +16,11 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- jest.mock('@angular/router');
20
19
  jest.mock('app/login/login.service');
21
20
 
22
21
  import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
23
22
  import { HttpClientTestingModule } from '@angular/common/http/testing';
24
- import { Router } from '@angular/router';
23
+ import { RouterTestingModule } from '@angular/router/testing';
25
24
  import { of } from 'rxjs';
26
25
  import { NgxWebstorageModule } from 'ngx-webstorage';
27
26
  <%_ if (enableTranslation) { _%>
@@ -55,9 +54,16 @@ describe('Navbar Component', () => {
55
54
  beforeEach(
56
55
  waitForAsync(() => {
57
56
  TestBed.configureTestingModule({
58
- imports: [HttpClientTestingModule, NgxWebstorageModule.forRoot()<% if (enableTranslation) { %>, TranslateModule.forRoot()<% } %>],
57
+ imports: [
58
+ HttpClientTestingModule,
59
+ RouterTestingModule.withRoutes([]),
60
+ <%_ if (enableTranslation) { _%>
61
+ TranslateModule.forRoot(),
62
+ <%_ } _%>
63
+ NgxWebstorageModule.forRoot()
64
+ ],
59
65
  declarations: [NavbarComponent],
60
- providers: [Router, LoginService],
66
+ providers: [LoginService],
61
67
  })
62
68
  .overrideTemplate(NavbarComponent, '')
63
69
  .compileComponents();
@@ -16,7 +16,7 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- import { Component, OnInit } from '@angular/core';
19
+ import { Component, OnInit<% if (enableTranslation && applicationTypeGateway) { %>, Compiler, Injector, NgModuleFactory, Type<% } %> } from '@angular/core';
20
20
  import { Router } from '@angular/router';
21
21
  <%_ if (enableTranslation) { _%>
22
22
  import { TranslateService } from '@ngx-translate/core';
@@ -31,6 +31,7 @@ import { Account } from 'app/core/auth/account.model';
31
31
  import { AccountService } from 'app/core/auth/account.service';
32
32
  import { LoginService } from 'app/login/login.service';
33
33
  import { ProfileService } from 'app/layouts/profiles/profile.service';
34
+ import { EntityNavbarItems } from 'app/entities/entity-navbar-items';
34
35
 
35
36
  @Component({
36
37
  selector: '<%= jhiPrefixDashed %>-navbar',
@@ -46,12 +47,22 @@ export class NavbarComponent implements OnInit {
46
47
  openAPIEnabled?: boolean;
47
48
  version = '';
48
49
  account: Account | null = null;
50
+ entitiesNavbarItems: any[] = [];
51
+ <%_ if (applicationTypeGateway) { _%>
52
+ <%_ for (const remote of microfrontends) { _%>
53
+ <%= remote.lowercaseBaseName %>EntityNavbarItems: any[] = [];
54
+ <%_ } _%>
55
+ <%_ } _%>
49
56
 
50
57
  constructor(
51
58
  private loginService: LoginService,
52
59
  <%_ if (enableTranslation) { _%>
53
60
  private translateService: TranslateService,
54
61
  private sessionStorageService: SessionStorageService,
62
+ <%_ if (applicationTypeGateway) { _%>
63
+ private compiler: Compiler,
64
+ private injector: Injector,
65
+ <%_ } _%>
55
66
  <%_ } _%>
56
67
  private accountService: AccountService,
57
68
  private profileService: ProfileService,
@@ -63,11 +74,32 @@ export class NavbarComponent implements OnInit {
63
74
  }
64
75
 
65
76
  ngOnInit(): void {
77
+ this.entitiesNavbarItems = EntityNavbarItems;
66
78
  this.profileService.getProfileInfo().subscribe(profileInfo => {
67
79
  this.inProduction = profileInfo.inProduction;
68
80
  this.openAPIEnabled = profileInfo.openAPIEnabled;
69
81
  });
70
- this.accountService.getAuthenticationState().subscribe(account => (this.account = account));
82
+
83
+ this.accountService.getAuthenticationState().subscribe(account => {
84
+ this.account = account;
85
+ <%_ if (applicationTypeGateway) { _%>
86
+ <%_ for (const remote of microfrontends) { _%>
87
+ import('<%= remote.lowercaseBaseName %>/entity-navbar-items').then(
88
+ <%= enableTranslation ? 'async ' : '' %>({ EntityNavbarItems: <%= remote.capitalizedBaseName %>EntityNavbarItems }) => {
89
+ this.<%= remote.lowercaseBaseName %>EntityNavbarItems = <%= remote.capitalizedBaseName %>EntityNavbarItems;
90
+ <%_ if (enableTranslation) { _%>
91
+ const { LazyTranslationModule } = await import('<%= remote.lowercaseBaseName %>/translation-module');
92
+ this.loadModule(LazyTranslationModule as Type<any>);
93
+ <%_ } _%>
94
+ },
95
+ error => {
96
+ // eslint-disable-next-line no-console
97
+ console.log('Error loading <%= remote.lowercaseBaseName %> entities', error);
98
+ }
99
+ );
100
+ <%_ } _%>
101
+ <%_ } _%>
102
+ });
71
103
  }
72
104
 
73
105
  <%_ if (enableTranslation) { _%>
@@ -98,4 +130,11 @@ export class NavbarComponent implements OnInit {
98
130
  toggleNavbar(): void {
99
131
  this.isNavbarCollapsed = !this.isNavbarCollapsed;
100
132
  }
133
+ <%_ if (enableTranslation && applicationTypeGateway) { _%>
134
+
135
+ private loadModule(moduleType: Type<any>): void {
136
+ const moduleFactory = this.compiler.compileModuleAndAllComponentsSync(moduleType);
137
+ moduleFactory.ngModuleFactory.create(this.injector);
138
+ }
139
+ <%_ } _%>
101
140
  }
@@ -16,7 +16,6 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- jest.mock('@angular/router');
20
19
  jest.mock('app/core/auth/account.service');
21
20
  jest.mock('app/login/login.service');
22
21
 
@@ -24,6 +23,7 @@ import { ElementRef } from '@angular/core';
24
23
  import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
25
24
  import { FormBuilder } from '@angular/forms';
26
25
  import { Router, Navigation } from '@angular/router';
26
+ import { RouterTestingModule } from '@angular/router/testing';
27
27
  import { of, throwError } from 'rxjs';
28
28
 
29
29
  import { AccountService } from 'app/core/auth/account.service';
@@ -41,11 +41,11 @@ describe('LoginComponent', () => {
41
41
  beforeEach(
42
42
  waitForAsync(() => {
43
43
  TestBed.configureTestingModule({
44
+ imports: [RouterTestingModule.withRoutes([])],
44
45
  declarations: [LoginComponent],
45
46
  providers: [
46
47
  FormBuilder,
47
48
  AccountService,
48
- Router,
49
49
  {
50
50
  provide: LoginService,
51
51
  useValue: {
@@ -63,6 +63,7 @@ describe('LoginComponent', () => {
63
63
  fixture = TestBed.createComponent(LoginComponent);
64
64
  comp = fixture.componentInstance;
65
65
  mockRouter = TestBed.inject(Router);
66
+ jest.spyOn(mockRouter, 'navigate').mockImplementation(() => Promise.resolve(true));
66
67
  mockLoginService = TestBed.inject(LoginService);
67
68
  mockAccountService = TestBed.inject(AccountService);
68
69
  });
@@ -66,15 +66,15 @@ export class LoginComponent implements OnInit, AfterViewInit {
66
66
  password: this.loginForm.get('password')!.value,
67
67
  rememberMe: this.loginForm.get('rememberMe')!.value,
68
68
  })
69
- .subscribe(
70
- () => {
69
+ .subscribe({
70
+ next: () => {
71
71
  this.authenticationError = false;
72
72
  if (!this.router.getCurrentNavigation()) {
73
73
  // There were no routing during login (eg from navigationToStoredUrl)
74
74
  this.router.navigate(['']);
75
75
  }
76
76
  },
77
- () => this.authenticationError = true
78
- );
77
+ error: () => this.authenticationError = true
78
+ });
79
79
  }
80
80
  }
@@ -99,7 +99,7 @@ describe('HasAnyAuthorityDirective tests', () => {
99
99
  mockAccountService.hasAnyAuthority = jest.fn(() => false);
100
100
 
101
101
  // WHEN
102
- authenticationState.next();
102
+ authenticationState.next(null);
103
103
  fixture.detectChanges();
104
104
 
105
105
  // THEN
@@ -109,7 +109,7 @@ describe('HasAnyAuthorityDirective tests', () => {
109
109
  mockAccountService.hasAnyAuthority = jest.fn(() => true);
110
110
 
111
111
  // WHEN
112
- authenticationState.next();
112
+ authenticationState.next(null);
113
113
  fixture.detectChanges();
114
114
 
115
115
  // THEN
@@ -133,7 +133,7 @@ describe('HasAnyAuthorityDirective tests', () => {
133
133
 
134
134
  // WHEN
135
135
  jest.clearAllMocks();
136
- authenticationState.next();
136
+ authenticationState.next(null);
137
137
 
138
138
  // THEN
139
139
  expect(mockAccountService.hasAnyAuthority).toHaveBeenCalled();
@@ -141,7 +141,7 @@ describe('HasAnyAuthorityDirective tests', () => {
141
141
  // WHEN
142
142
  jest.clearAllMocks();
143
143
  hasAnyAuthorityDirective.ngOnDestroy();
144
- authenticationState.next();
144
+ authenticationState.next(null);
145
145
 
146
146
  // THEN
147
147
  expect(mockAccountService.hasAnyAuthority).not.toHaveBeenCalled();
@@ -18,7 +18,7 @@
18
18
  -%>
19
19
  import { Pipe, PipeTransform } from '@angular/core';
20
20
 
21
- import * as dayjs from 'dayjs';
21
+ import dayjs from 'dayjs/esm';
22
22
 
23
23
  @Pipe({
24
24
  name: 'duration',
@@ -16,7 +16,7 @@
16
16
  See the License for the specific language governing permissions and
17
17
  limitations under the License.
18
18
  -%>
19
- import * as dayjs from 'dayjs';
19
+ import dayjs from 'dayjs/esm';
20
20
 
21
21
  import { FormatMediumDatePipe } from './format-medium-date.pipe';
22
22