generator-jhipster 7.2.0 → 7.3.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.
- package/cli/environment-builder.js +1 -0
- package/cli/import-jdl.js +2 -2
- package/cli/jdl.js +1 -0
- package/generators/bootstrap/index.js +2 -1
- package/generators/client/__workflow/devserver-angular.json +1 -1
- package/generators/client/__workflow/devserver-react.json +1 -1
- package/generators/client/__workflow/devserver-vue.json +1 -1
- package/generators/client/files-vue.js +2 -0
- package/generators/client/index.js +69 -0
- package/generators/client/templates/angular/package.json +12 -12
- package/generators/client/templates/angular/package.json.ejs +2 -1
- package/generators/client/templates/angular/src/main/webapp/app/admin/configuration/configuration.service.spec.ts.ejs +50 -52
- package/generators/client/templates/angular/src/main/webapp/app/admin/logs/logs.service.spec.ts.ejs +19 -21
- package/generators/client/templates/angular/src/main/webapp/app/admin/metrics/metrics.service.spec.ts.ejs +62 -64
- package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/service/user-management.service.spec.ts.ejs +41 -43
- package/generators/client/templates/angular/src/main/webapp/app/app.module.ts.ejs +3 -0
- package/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.spec.ts.ejs +178 -180
- package/generators/client/templates/angular/src/main/webapp/app/core/config/application-config.service.ts.ejs +9 -0
- package/generators/client/templates/angular/src/main/webapp/app/entities/user/user.service.spec.ts.ejs +87 -89
- package/generators/client/templates/angular/webpack/webpack.custom.js.ejs +2 -3
- package/generators/client/templates/common/README.md.jhi.client.ejs +34 -0
- package/generators/client/templates/common/package.json +3 -3
- package/generators/client/templates/react/package.json +29 -29
- package/generators/client/templates/react/package.json.ejs +1 -1
- package/generators/client/templates/vue/package.json +22 -22
- package/generators/client/templates/vue/package.json.ejs +1 -1
- package/generators/client/templates/vue/src/main/webapp/app/account/account.service.ts.ejs +2 -2
- package/generators/client/templates/vue/src/main/webapp/app/admin/configuration/configuration.service.ts.ejs +1 -1
- package/generators/client/templates/vue/src/main/webapp/app/admin/tracker/tracker.service.ts.ejs +5 -4
- package/generators/client/templates/vue/src/main/webapp/app/admin/user-management/user-management-edit.component.ts.ejs +9 -0
- package/generators/client/templates/vue/src/main/webapp/app/admin/user-management/user-management-view.component.ts.ejs +5 -0
- package/generators/client/templates/vue/src/main/webapp/app/admin/user-management/user-management.component.ts.ejs +5 -0
- package/generators/client/templates/vue/src/main/webapp/app/main.ts.ejs +4 -2
- package/generators/client/templates/vue/src/main/webapp/app/router/admin.ts.ejs +4 -4
- package/generators/client/templates/vue/src/main/webapp/app/shared/alert/alert.service.ts.ejs +61 -0
- package/generators/client/templates/vue/src/test/javascript/spec/app/account/account.service.spec.ts.ejs +2 -2
- package/generators/client/templates/vue/src/test/javascript/spec/app/account/login-form/login-form.component.spec.ts.ejs +1 -1
- package/generators/client/templates/vue/src/test/javascript/spec/app/admin/tracker/tracker.component.spec.ts.ejs +12 -12
- package/generators/client/templates/vue/src/test/javascript/spec/app/admin/tracker/tracker.service.spec.ts.ejs +2 -1
- package/generators/client/templates/vue/src/test/javascript/spec/app/admin/user-management/user-management-edit.component.spec.ts.ejs +3 -1
- package/generators/client/templates/vue/src/test/javascript/spec/app/admin/user-management/user-management-view.component.spec.ts.ejs +2 -1
- package/generators/client/templates/vue/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts.ejs +3 -1
- package/generators/client/templates/vue/src/test/javascript/spec/app/shared/alert/alert.service.spec.ts.ejs +124 -0
- package/generators/common/templates/.husky/pre-commit +1 -1
- package/generators/common/templates/package.json +3 -3
- package/generators/docker-compose/templates/realm-config/jhipster-realm.json.ejs +13 -12
- package/generators/entity/index.js +13 -0
- package/generators/entity-client/index.js +53 -0
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.module.ts.ejs +1 -1
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/route/entity-management-routing-resolve.service.spec.ts.ejs +52 -54
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/service/entity.service.spec.ts.ejs +173 -175
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.html.ejs +2 -4
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs +7 -0
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-delete-dialog.tsx.ejs +5 -2
- package/generators/entity-client/templates/vue/src/main/webapp/app/entities/entity-details.component.ts.ejs +5 -0
- package/generators/entity-client/templates/vue/src/main/webapp/app/entities/entity-update.component.ts.ejs +14 -2
- package/generators/entity-client/templates/vue/src/main/webapp/app/entities/entity.component.ts.ejs +7 -0
- package/generators/entity-client/templates/vue/src/test/javascript/spec/app/entities/entity-details.component.spec.ts.ejs +2 -1
- package/generators/entity-client/templates/vue/src/test/javascript/spec/app/entities/entity-update.component.spec.ts.ejs +2 -0
- package/generators/entity-client/templates/vue/src/test/javascript/spec/app/entities/entity.component.spec.ts.ejs +3 -1
- package/generators/entity-server/files-couchbase.js +2 -2
- package/generators/entity-server/files.js +31 -30
- package/generators/entity-server/templates/couchbase/src/main/java/package/repository/EntityRepository.java.ejs +2 -2
- package/generators/entity-server/templates/couchbase/src/main/resources/config/couchmove/changelog/entity.fts.ejs +1 -1
- package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/domain/enumeration/Enum.java.ejs +1 -1
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs +7 -7
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs +4 -4
- package/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs +8 -8
- package/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs +4 -4
- package/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs +4 -4
- package/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs +3 -3
- package/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +8 -8
- package/generators/entity-server/templates/src/main/java/package/service/mapper/BaseEntityMapper.java.ejs +1 -1
- package/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs +3 -3
- package/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs +12 -12
- package/generators/entity-server/templates/src/test/java/package/domain/EntityTest.java.ejs +1 -1
- package/generators/entity-server/templates/src/test/java/package/repository/search/EntitySearchRepositoryMockConfiguration.java.ejs +1 -1
- package/generators/entity-server/templates/src/test/java/package/service/dto/EntityDTOTest.java.ejs +1 -1
- package/generators/entity-server/templates/src/test/java/package/service/mapper/EntityMapperTest.java.ejs +1 -1
- package/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs +18 -15
- package/generators/generator-base.js +10 -3
- package/generators/generator-constants.js +6 -5
- package/generators/heroku/index.js +13 -15
- package/generators/init/templates/.husky/pre-commit +1 -1
- package/generators/kubernetes-helm/templates/app/Chart.yml.ejs +22 -0
- package/generators/kubernetes-helm/templates/app/requirements.yml.ejs +2 -2
- package/generators/kubernetes-helm/templates/csvc/Chart.yml.ejs +17 -0
- package/generators/kubernetes-helm/templates/csvc/requirements.yml.ejs +3 -3
- package/generators/languages/templates/src/main/webapp/i18n/hr/reset.json.ejs +1 -2
- package/generators/maven/templates/.mvn/wrapper/maven-wrapper.properties +1 -1
- package/generators/server/index.js +38 -13
- package/generators/server/needle-api/needle-server-cache.js +4 -6
- package/generators/server/templates/.mvn/wrapper/maven-wrapper.properties +1 -1
- package/generators/server/templates/build.gradle.ejs +1 -1
- package/generators/server/templates/gradle.properties.ejs +1 -1
- package/generators/server/templates/pom.xml.ejs +4 -3
- package/generators/server/templates/settings.gradle.ejs +9 -0
- package/generators/server/templates/src/main/docker/app.yml.ejs +1 -0
- package/generators/server/templates/src/main/docker/config/realm-config/jhipster-realm.json.ejs +13 -12
- package/generators/server/templates/src/main/java/package/aop/logging/LoggingAspect.java.ejs +1 -1
- package/generators/server/templates/src/main/java/package/config/DatabaseConfiguration_cassandra.java.ejs +0 -6
- package/generators/server/templates/src/main/java/package/config/DatabaseConfiguration_sql.java.ejs +2 -2
- package/generators/server/templates/src/main/java/package/config/JacksonConfiguration.java.ejs +1 -1
- package/generators/server/templates/src/main/java/package/config/LocaleConfiguration.java.ejs +0 -2
- package/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +2 -5
- package/generators/server/templates/src/main/java/package/config/SecurityConfiguration_reactive.java.ejs +9 -1
- package/generators/server/templates/src/main/java/package/security/PersistentTokenRememberMeServices.java.ejs +0 -2
- package/generators/server/templates/src/main/resources/config/application-dev.yml.ejs +1 -1
- package/generators/server/templates/src/main/resources/config/application-prod.yml.ejs +1 -1
- package/generators/server/templates/src/main/resources/config/application.yml.ejs +2 -2
- package/package.json +12 -12
- package/utils/field.js +1 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Component, Inject, Vue } from 'vue-property-decorator';
|
|
2
2
|
import Vue2Filters from 'vue2-filters';
|
|
3
3
|
import UserManagementService from './user-management.service';
|
|
4
|
+
import AlertService from '@/shared/alert/alert.service';
|
|
4
5
|
|
|
5
6
|
@Component({
|
|
6
7
|
mixins: [Vue2Filters.mixin]
|
|
7
8
|
})
|
|
8
9
|
export default class <%=jhiPrefixCapitalized%>UserManagementComponent extends Vue {
|
|
9
10
|
@Inject('userService') private userManagementService: () => UserManagementService;
|
|
11
|
+
@Inject('alertService') private alertService: () => AlertService;
|
|
12
|
+
|
|
10
13
|
public error = '';
|
|
11
14
|
public success = '';
|
|
12
15
|
public users: any[] = [];
|
|
@@ -110,6 +113,8 @@ _%>
|
|
|
110
113
|
this.removeId = null;
|
|
111
114
|
this.loadAll();
|
|
112
115
|
this.closeDialog();
|
|
116
|
+
}).catch(error => {
|
|
117
|
+
this.alertService().showHttpError(this,error.response);
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
120
|
|
|
@@ -24,6 +24,7 @@ import UserManagementService from '@/admin/user-management/user-management.servi
|
|
|
24
24
|
<%_ } _%>
|
|
25
25
|
import LoginService from './account/login.service';
|
|
26
26
|
import AccountService from './account/account.service';
|
|
27
|
+
import AlertService from './shared/alert/alert.service';
|
|
27
28
|
|
|
28
29
|
import '../content/scss/vendor.scss';
|
|
29
30
|
<%_ if (enableTranslation) { _%>
|
|
@@ -59,7 +60,7 @@ const i18n = config.initI18N(Vue);
|
|
|
59
60
|
const store = config.initVueXStore(Vue);
|
|
60
61
|
|
|
61
62
|
<%_ if (communicationSpringWebsocket) { _%>
|
|
62
|
-
const trackerService = new TrackerService(router);
|
|
63
|
+
const trackerService = new TrackerService(router<%_ if (authenticationTypeSession) { _%>, (<any>Vue).cookie<%_ } _%>);
|
|
63
64
|
<%_ } _%>
|
|
64
65
|
<%_ if (enableTranslation) { _%>
|
|
65
66
|
const translationService = new TranslationService(store, i18n);
|
|
@@ -120,7 +121,8 @@ new Vue({
|
|
|
120
121
|
translationService: () => translationService,
|
|
121
122
|
<%_ } _%>
|
|
122
123
|
// jhipster-needle-add-entity-service-to-main - JHipster will import entities services here
|
|
123
|
-
accountService: () => accountService
|
|
124
|
+
accountService: () => accountService,
|
|
125
|
+
alertService: () => new AlertService()
|
|
124
126
|
|
|
125
127
|
},
|
|
126
128
|
<%_ if (enableTranslation) { _%> i18n,<%_ } _%>
|
|
@@ -76,17 +76,17 @@ export default [
|
|
|
76
76
|
name: '<%= jhiPrefixCapitalized %>ConfigurationComponent',
|
|
77
77
|
component: <%= jhiPrefixCapitalized %>ConfigurationComponent,
|
|
78
78
|
meta: { authorities: [Authority.ADMIN] }
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
80
|
<%_ } _%>
|
|
81
|
-
<%_ if (applicationTypeGateway && serviceDiscoveryType) { _
|
|
81
|
+
<%_ if (applicationTypeGateway && serviceDiscoveryType) { _%>
|
|
82
82
|
{
|
|
83
83
|
path: '/admin/gateway',
|
|
84
84
|
name: '<%= jhiPrefixCapitalized %>GatewayComponent',
|
|
85
85
|
component: <%= jhiPrefixCapitalized %>GatewayComponent,
|
|
86
86
|
meta: { authorities: [Authority.ADMIN] }
|
|
87
|
-
}
|
|
87
|
+
},
|
|
88
88
|
<%_ } _%>
|
|
89
|
-
<%_ if (communicationSpringWebsocket) { _
|
|
89
|
+
<%_ if (communicationSpringWebsocket) { _%>
|
|
90
90
|
{
|
|
91
91
|
path: '/admin/tracker',
|
|
92
92
|
name: '<%= jhiPrefixCapitalized %>TrackerComponent',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
|
|
3
|
+
export default class AlertService {
|
|
4
|
+
public showError(instance: Vue, message: string, params?: any) {
|
|
5
|
+
<%_ if (enableTranslation) { _%>
|
|
6
|
+
const alertMessage = instance.$t(message, params);
|
|
7
|
+
<%_ } else {_%>
|
|
8
|
+
const alertMessage = message;
|
|
9
|
+
<%_ } _%>
|
|
10
|
+
instance.$root.$bvToast.toast(alertMessage.toString(), {
|
|
11
|
+
toaster: 'b-toaster-top-center',
|
|
12
|
+
title: 'Error',
|
|
13
|
+
variant: 'danger',
|
|
14
|
+
solid: true,
|
|
15
|
+
autoHideDelay: 5000,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public showHttpError(instance: Vue, httpErrorResponse: any) {
|
|
20
|
+
switch (httpErrorResponse.status) {
|
|
21
|
+
case 0:
|
|
22
|
+
this.showError(instance,<% if (enableTranslation) { %> 'error.server.not.reachable'<% } else { %> 'Server not reachable'<% } %>);
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case 400: {
|
|
26
|
+
const arr = Object.keys(httpErrorResponse.headers);
|
|
27
|
+
let errorHeader: string | null = null;
|
|
28
|
+
<%_ if (enableTranslation) { _%>
|
|
29
|
+
let entityKey: string | null = null;
|
|
30
|
+
<%_ } _%>
|
|
31
|
+
for (const entry of arr) {
|
|
32
|
+
if (entry.toLowerCase().endsWith('app-error')) {
|
|
33
|
+
errorHeader = httpErrorResponse.headers[entry];
|
|
34
|
+
<%_ if (enableTranslation) { _%>
|
|
35
|
+
} else if (entry.toLowerCase().endsWith('app-params')) {
|
|
36
|
+
entityKey = httpErrorResponse.headers[entry];
|
|
37
|
+
<%_ } _%>
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (errorHeader) {
|
|
41
|
+
<%_ if (enableTranslation) { _%>
|
|
42
|
+
const alertData = entityKey ? { entityName: instance.$t(`global.menu.entities.${entityKey}`) } : undefined;
|
|
43
|
+
<%_ } _%>
|
|
44
|
+
this.showError(instance, errorHeader<% if (enableTranslation) { %>, alertData<% } %>);
|
|
45
|
+
} else if (httpErrorResponse.data !== '' && httpErrorResponse.data.fieldErrors) {
|
|
46
|
+
this.showError(instance, <% if (enableTranslation) { %>httpErrorResponse.data.message<% } else { %>'Validation error'<% } %>);
|
|
47
|
+
} else {
|
|
48
|
+
this.showError(instance, httpErrorResponse.data.message);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case 404:
|
|
54
|
+
this.showError(instance, <% if (enableTranslation) { %>'error.http.404'<% } else { %>'Not found'<% } %>);
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
default:
|
|
58
|
+
this.showError(instance, httpErrorResponse.data.message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -80,7 +80,7 @@ describe('Account Service test suite', () => {
|
|
|
80
80
|
|
|
81
81
|
it('should init service and check for authority after retrieving account but getAccount failed', async () => {
|
|
82
82
|
<%_ if (communicationSpringWebsocket) { _%>
|
|
83
|
-
const trackerService = new TrackerService(null);
|
|
83
|
+
const trackerService = new TrackerService(null<%_ if (authenticationTypeSession) { _%>,null<%_ } %>);
|
|
84
84
|
trackerService.connect = jest.fn();
|
|
85
85
|
<%_ } _%>
|
|
86
86
|
<%_ if (authenticationTypeJwt) { _%>
|
|
@@ -96,7 +96,7 @@ describe('Account Service test suite', () => {
|
|
|
96
96
|
|
|
97
97
|
it('should init service and check for authority after retrieving account', async () => {
|
|
98
98
|
<%_ if (communicationSpringWebsocket) { _%>
|
|
99
|
-
const trackerService = new TrackerService(null);
|
|
99
|
+
const trackerService = new TrackerService(null<%_ if (authenticationTypeSession) { _%>,null<%_ } %>);
|
|
100
100
|
trackerService.connect = jest.fn();
|
|
101
101
|
<%_ } _%>
|
|
102
102
|
<%_ if (authenticationTypeJwt) { _%>
|
|
@@ -50,7 +50,7 @@ describe('LoginForm Component', () => {
|
|
|
50
50
|
<%_ } _%>
|
|
51
51
|
localVue,
|
|
52
52
|
provide: {
|
|
53
|
-
accountService: () => new AccountService(store, <% if (enableTranslation) { %>new TranslationService(store, i18n), <% } %><% if (authenticationTypeSession) { %> { get: () => {} }, <% } %><% if (communicationSpringWebsocket) { %>new TrackerService(router), <% } %>router)
|
|
53
|
+
accountService: () => new AccountService(store, <% if (enableTranslation) { %>new TranslationService(store, i18n), <% } %><% if (authenticationTypeSession) { %> { get: () => {} }, <% } %><% if (communicationSpringWebsocket) { %>new TrackerService(router<%_ if (authenticationTypeSession) { _%>,{ get: jest.fn()}<%_ } %>), <% } %>router)
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
loginForm = wrapper.vm;
|
|
@@ -6,7 +6,7 @@ import { Observable, Observer } from 'rxjs';
|
|
|
6
6
|
|
|
7
7
|
import * as config from '@/shared/config/config';
|
|
8
8
|
import <%=jhiPrefixCapitalized%>Tracker from '@/admin/tracker/tracker.vue';
|
|
9
|
-
import <%=jhiPrefixCapitalized%>
|
|
9
|
+
import <%=jhiPrefixCapitalized%>TrackerComponent from '@/admin/tracker/tracker.component';
|
|
10
10
|
import TrackerService from '@/admin/tracker/tracker.service';
|
|
11
11
|
|
|
12
12
|
const localVue = createLocalVue();
|
|
@@ -25,14 +25,14 @@ const axiosStub = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
describe('<%=jhiPrefixCapitalized%>Tracker', () => {
|
|
28
|
-
let wrapper: Wrapper<<%=jhiPrefixCapitalized%>
|
|
29
|
-
let <%=jhiPrefix%>
|
|
28
|
+
let wrapper: Wrapper<<%=jhiPrefixCapitalized%>TrackerComponent>;
|
|
29
|
+
let <%=jhiPrefix%>TrackerView: <%=jhiPrefixCapitalized%>TrackerComponent;
|
|
30
30
|
|
|
31
31
|
beforeEach(() => {
|
|
32
32
|
axiosStub.get.resolves({ data: {} });
|
|
33
33
|
trackerServiceStub = sinon.createStubInstance<TrackerService>(TrackerService);
|
|
34
34
|
trackerServiceStub.receive = sinon.stub().callsFake(() => new Observable(observer => listenerObserver = observer));
|
|
35
|
-
wrapper = shallowMount<<%=jhiPrefixCapitalized%>
|
|
35
|
+
wrapper = shallowMount<<%=jhiPrefixCapitalized%>TrackerComponent>(<%=jhiPrefixCapitalized%>Tracker, {
|
|
36
36
|
store,
|
|
37
37
|
<%_ if (enableTranslation) { _%>
|
|
38
38
|
i18n,
|
|
@@ -42,7 +42,7 @@ describe('<%=jhiPrefixCapitalized%>Tracker', () => {
|
|
|
42
42
|
trackerService: () => trackerServiceStub
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
<%=jhiPrefix%>
|
|
45
|
+
<%=jhiPrefix%>TrackerView = wrapper.vm;
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('should subscribe', () => {
|
|
@@ -60,14 +60,14 @@ describe('<%=jhiPrefixCapitalized%>Tracker', () => {
|
|
|
60
60
|
it('should add new activity', () => {
|
|
61
61
|
// GIVEN
|
|
62
62
|
const activity1 = { page: 'login', sessionId: '123' };
|
|
63
|
-
<%=jhiPrefix%>
|
|
63
|
+
<%=jhiPrefix%>TrackerView.activities = [activity1];
|
|
64
64
|
|
|
65
65
|
// WHEN
|
|
66
66
|
const activity2 = { page: 'login', sessionId: '456' };
|
|
67
67
|
listenerObserver.next(activity2);
|
|
68
68
|
|
|
69
69
|
// THEN
|
|
70
|
-
expect(<%=jhiPrefix%>
|
|
70
|
+
expect(<%=jhiPrefix%>TrackerView.activities).toEqual([activity1, activity2]);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('should not add logout activity', () => {
|
|
@@ -75,29 +75,29 @@ describe('<%=jhiPrefixCapitalized%>Tracker', () => {
|
|
|
75
75
|
listenerObserver.next({ page: 'logout', sessionId: '123' });
|
|
76
76
|
|
|
77
77
|
// THEN
|
|
78
|
-
expect(<%=jhiPrefix%>
|
|
78
|
+
expect(<%=jhiPrefix%>TrackerView.activities).toEqual([]);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
it('should update user activity', () => {
|
|
82
82
|
// GIVEN
|
|
83
|
-
<%=jhiPrefix%>
|
|
83
|
+
<%=jhiPrefix%>TrackerView.activities = [{ page: 'login', sessionId: '123' }];
|
|
84
84
|
|
|
85
85
|
// WHEN
|
|
86
86
|
const activity = { page: 'login', sessionId: '123' };
|
|
87
87
|
listenerObserver.next(activity);
|
|
88
88
|
|
|
89
89
|
// THEN
|
|
90
|
-
expect(<%=jhiPrefix%>
|
|
90
|
+
expect(<%=jhiPrefix%>TrackerView.activities).toEqual([activity]);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('should remove user activity', () => {
|
|
94
94
|
// GIVEN
|
|
95
|
-
<%=jhiPrefix%>
|
|
95
|
+
<%=jhiPrefix%>TrackerView.activities = [{ page: 'login', sessionId: '123' }];
|
|
96
96
|
|
|
97
97
|
// WHEN
|
|
98
98
|
listenerObserver.next({ page: 'logout', sessionId: '123' });
|
|
99
99
|
|
|
100
100
|
// THEN
|
|
101
|
-
expect(<%=jhiPrefix%>
|
|
101
|
+
expect(<%=jhiPrefix%>TrackerView.activities).toEqual([]);
|
|
102
102
|
});
|
|
103
103
|
});
|
|
@@ -9,7 +9,8 @@ describe('Tracker Service', () => {
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
routerStub = sinon.createStubInstance<VueRouter>(VueRouter);
|
|
11
11
|
routerStub.afterEach = sinon.spy();
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
trackerService = new TrackerService(routerStub<%_ if (authenticationTypeSession) { _%>,{ get: jest.fn()}<%_ } %>);
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
it('Should connetion and listener be initialized', () => {
|
|
@@ -11,6 +11,7 @@ import UserManagementEdit from '@/admin/user-management/user-management-edit.vue
|
|
|
11
11
|
import UserManagementEditClass from '@/admin/user-management/user-management-edit.component';
|
|
12
12
|
import UserManagementService from '@/admin/user-management/user-management.service';
|
|
13
13
|
import VueRouter from 'vue-router';
|
|
14
|
+
import AlertService from '@/shared/alert/alert.service';
|
|
14
15
|
|
|
15
16
|
const localVue = createLocalVue();
|
|
16
17
|
localVue.use(VueRouter);
|
|
@@ -42,7 +43,8 @@ describe('UserManagementEdit Component', () => {
|
|
|
42
43
|
<%_ } _%>
|
|
43
44
|
localVue,
|
|
44
45
|
provide: {
|
|
45
|
-
userService: () => new UserManagementService()
|
|
46
|
+
userService: () => new UserManagementService(),
|
|
47
|
+
alertService: () => new AlertService(),
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
50
|
userManagementEdit = wrapper.vm;
|
|
@@ -11,6 +11,7 @@ import UserManagementView from '@/admin/user-management/user-management-view.vue
|
|
|
11
11
|
import UserManagementViewClass from '@/admin/user-management/user-management-view.component';
|
|
12
12
|
import UserManagementService from '@/admin/user-management/user-management.service';
|
|
13
13
|
import {Authority} from '@/shared/security/authority';
|
|
14
|
+
import AlertService from '@/shared/alert/alert.service';
|
|
14
15
|
|
|
15
16
|
const localVue = createLocalVue();
|
|
16
17
|
|
|
@@ -32,7 +33,7 @@ describe('UserManagementView Component', () => {
|
|
|
32
33
|
let userManagementView: UserManagementViewClass;
|
|
33
34
|
|
|
34
35
|
beforeEach(() => {
|
|
35
|
-
wrapper = shallowMount<UserManagementViewClass>(UserManagementView, { store, <% if (enableTranslation) { %>i18n, <% } %>localVue, provide: { userService: () => new UserManagementService() } });
|
|
36
|
+
wrapper = shallowMount<UserManagementViewClass>(UserManagementView, { store, <% if (enableTranslation) { %>i18n, <% } %>localVue, provide: { userService: () => new UserManagementService(), alertService: () => new AlertService(), } });
|
|
36
37
|
userManagementView = wrapper.vm;
|
|
37
38
|
});
|
|
38
39
|
|
|
@@ -10,6 +10,7 @@ import * as config from '@/shared/config/config';
|
|
|
10
10
|
import UserManagement from '@/admin/user-management/user-management.vue';
|
|
11
11
|
import UserManagementClass from '@/admin/user-management/user-management.component';
|
|
12
12
|
import UserManagementService from '@/admin/user-management/user-management.service';
|
|
13
|
+
import AlertService from '@/shared/alert/alert.service';
|
|
13
14
|
|
|
14
15
|
const localVue = createLocalVue();
|
|
15
16
|
|
|
@@ -57,7 +58,8 @@ describe('UserManagement Component', () => {
|
|
|
57
58
|
bModal: true
|
|
58
59
|
},
|
|
59
60
|
provide: {
|
|
60
|
-
userService: () => new UserManagementService()
|
|
61
|
+
userService: () => new UserManagementService(),
|
|
62
|
+
alertService: () => new AlertService(),
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
userManagement = wrapper.vm;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
|
|
3
|
+
import AlertService from '@/shared/alert/alert.service';
|
|
4
|
+
import Vue from 'vue';
|
|
5
|
+
import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
|
|
6
|
+
<%_ if (enableTranslation) { _%>
|
|
7
|
+
const translationStub = sinon.stub();
|
|
8
|
+
<%_ } _%>
|
|
9
|
+
const toastStub = sinon.stub();
|
|
10
|
+
|
|
11
|
+
const vueInstance = {
|
|
12
|
+
<% if (enableTranslation) { %>$t: translationStub,<% } %>
|
|
13
|
+
$root: {
|
|
14
|
+
$bvToast: {
|
|
15
|
+
toast: toastStub,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('Alert Service test suite', () => {
|
|
21
|
+
let alertService: AlertService;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
<%_ if (enableTranslation) { _%>
|
|
25
|
+
translationStub.reset();
|
|
26
|
+
<%_ } _%>
|
|
27
|
+
toastStub.reset();
|
|
28
|
+
alertService = new AlertService();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should show error toast with translation/message', async () => {
|
|
32
|
+
const message = 'translatedMessage';
|
|
33
|
+
<%_ if (enableTranslation) { _%>
|
|
34
|
+
const translationKey = 'err.code';
|
|
35
|
+
|
|
36
|
+
// GIVEN
|
|
37
|
+
translationStub.withArgs(translationKey).returns(message);
|
|
38
|
+
<%_ } _%>
|
|
39
|
+
|
|
40
|
+
// WHEN
|
|
41
|
+
alertService.showError((<any>vueInstance) as Vue, <% if (enableTranslation) { %>translationKey<%} else {%>message<% } %>);
|
|
42
|
+
|
|
43
|
+
//THEN
|
|
44
|
+
<%_ if (enableTranslation) { _%>
|
|
45
|
+
expect(translationStub.withArgs(translationKey).callCount).toEqual(1);
|
|
46
|
+
<%_ } _%>
|
|
47
|
+
expect(
|
|
48
|
+
toastStub.calledOnceWith(message, {
|
|
49
|
+
toaster: 'b-toaster-top-center',
|
|
50
|
+
title: 'Error',
|
|
51
|
+
variant: 'danger',
|
|
52
|
+
solid: true,
|
|
53
|
+
autoHideDelay: 5000,
|
|
54
|
+
})
|
|
55
|
+
).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should show not reachable toast when http status = 0', async () => {
|
|
59
|
+
<%_ if (enableTranslation) { _%>
|
|
60
|
+
const translationKey = 'error.server.not.reachable';
|
|
61
|
+
<%_ } _%>
|
|
62
|
+
const message = 'Server not reachable';
|
|
63
|
+
const httpErrorResponse = {
|
|
64
|
+
status: 0,
|
|
65
|
+
};
|
|
66
|
+
<%_ if (enableTranslation) { _%>
|
|
67
|
+
// GIVEN
|
|
68
|
+
translationStub.withArgs(translationKey).returns(message);
|
|
69
|
+
<%_ } _%>
|
|
70
|
+
|
|
71
|
+
// WHEN
|
|
72
|
+
alertService.showHttpError((<any>vueInstance) as Vue, httpErrorResponse);
|
|
73
|
+
|
|
74
|
+
//THEN
|
|
75
|
+
<%_ if (enableTranslation) { _%>
|
|
76
|
+
expect(translationStub.withArgs(translationKey).callCount).toEqual(1);
|
|
77
|
+
<%_ } _%>
|
|
78
|
+
expect(
|
|
79
|
+
toastStub.calledOnceWith(message, {
|
|
80
|
+
toaster: 'b-toaster-top-center',
|
|
81
|
+
title: 'Error',
|
|
82
|
+
variant: 'danger',
|
|
83
|
+
solid: true,
|
|
84
|
+
autoHideDelay: 5000,
|
|
85
|
+
})
|
|
86
|
+
).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should show parameterized error toast when http status = 400 and entity headers', async () => {
|
|
90
|
+
<%_ if (enableTranslation) { _%>
|
|
91
|
+
const translationKey = 'error.update';
|
|
92
|
+
<%_ } _%>
|
|
93
|
+
const message = 'Updation Error';
|
|
94
|
+
const httpErrorResponse = {
|
|
95
|
+
status: 400,
|
|
96
|
+
headers: {
|
|
97
|
+
'x-jhipsterapp-error': <% if (enableTranslation) { %>translationKey<% } else {%>message<% } %>,
|
|
98
|
+
'x-jhipsterapp-params': 'dummyEntity',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
<%_ if (enableTranslation) { _%>
|
|
102
|
+
// GIVEN
|
|
103
|
+
translationStub.withArgs(translationKey).returns(message);
|
|
104
|
+
translationStub.withArgs('global.menu.entities.dummyEntity').returns('DummyEntity');
|
|
105
|
+
<%_ } _%>
|
|
106
|
+
|
|
107
|
+
// WHEN
|
|
108
|
+
alertService.showHttpError((<any>vueInstance) as Vue, httpErrorResponse);
|
|
109
|
+
|
|
110
|
+
//THEN
|
|
111
|
+
<%_ if (enableTranslation) { _%>
|
|
112
|
+
expect(translationStub.withArgs(translationKey, { entityName: 'DummyEntity' }).callCount).toEqual(1);
|
|
113
|
+
<%_ } _%>
|
|
114
|
+
expect(
|
|
115
|
+
toastStub.calledOnceWith(message, {
|
|
116
|
+
toaster: 'b-toaster-top-center',
|
|
117
|
+
title: 'Error',
|
|
118
|
+
variant: 'danger',
|
|
119
|
+
solid: true,
|
|
120
|
+
autoHideDelay: 5000,
|
|
121
|
+
})
|
|
122
|
+
).toBeTruthy();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -1672,14 +1672,14 @@
|
|
|
1672
1672
|
"subComponents": {},
|
|
1673
1673
|
"config": {
|
|
1674
1674
|
"allowed-protocol-mapper-types": [
|
|
1675
|
-
"oidc-
|
|
1675
|
+
"oidc-usermodel-property-mapper",
|
|
1676
|
+
"oidc-sha256-pairwise-sub-mapper",
|
|
1677
|
+
"saml-user-attribute-mapper",
|
|
1676
1678
|
"saml-user-property-mapper",
|
|
1677
|
-
"oidc-usermodel-attribute-mapper",
|
|
1678
|
-
"saml-role-list-mapper",
|
|
1679
1679
|
"oidc-address-mapper",
|
|
1680
|
-
"
|
|
1681
|
-
"
|
|
1682
|
-
"oidc-
|
|
1680
|
+
"oidc-full-name-mapper",
|
|
1681
|
+
"saml-role-list-mapper",
|
|
1682
|
+
"oidc-usermodel-attribute-mapper"
|
|
1683
1683
|
]
|
|
1684
1684
|
}
|
|
1685
1685
|
},
|
|
@@ -1750,14 +1750,14 @@
|
|
|
1750
1750
|
"subComponents": {},
|
|
1751
1751
|
"config": {
|
|
1752
1752
|
"allowed-protocol-mapper-types": [
|
|
1753
|
-
"oidc-
|
|
1753
|
+
"oidc-address-mapper",
|
|
1754
1754
|
"oidc-usermodel-attribute-mapper",
|
|
1755
|
-
"
|
|
1755
|
+
"saml-user-property-mapper",
|
|
1756
1756
|
"saml-user-attribute-mapper",
|
|
1757
|
-
"oidc-address-mapper",
|
|
1758
|
-
"oidc-usermodel-property-mapper",
|
|
1759
1757
|
"saml-role-list-mapper",
|
|
1760
|
-
"
|
|
1758
|
+
"oidc-full-name-mapper",
|
|
1759
|
+
"oidc-usermodel-property-mapper",
|
|
1760
|
+
"oidc-sha256-pairwise-sub-mapper"
|
|
1761
1761
|
]
|
|
1762
1762
|
}
|
|
1763
1763
|
},
|
|
@@ -2488,10 +2488,11 @@
|
|
|
2488
2488
|
"oauth2DevicePollingInterval": "5",
|
|
2489
2489
|
"clientSessionIdleTimeout": "0",
|
|
2490
2490
|
"clientSessionMaxLifespan": "0",
|
|
2491
|
+
"parRequestUriLifespan": "60",
|
|
2491
2492
|
"clientOfflineSessionIdleTimeout": "0",
|
|
2492
2493
|
"cibaInterval": "5"
|
|
2493
2494
|
},
|
|
2494
|
-
"keycloakVersion": "
|
|
2495
|
+
"keycloakVersion": "15.0.2",
|
|
2495
2496
|
"userManagedAccessAllowed": false,
|
|
2496
2497
|
"clientProfiles": {
|
|
2497
2498
|
"profiles": []
|
|
@@ -587,6 +587,19 @@ class EntityGenerator extends BaseBlueprintGenerator {
|
|
|
587
587
|
const entity = this.context;
|
|
588
588
|
prepareEntityForTemplates(entity, this);
|
|
589
589
|
},
|
|
590
|
+
|
|
591
|
+
loadDomain() {
|
|
592
|
+
const entity = this.context;
|
|
593
|
+
const { entityPackage, packageName, packageFolder, persistClass } = entity;
|
|
594
|
+
let { entityAbsolutePackage = packageName, entityAbsoluteFolder = packageFolder } = entity;
|
|
595
|
+
if (entityPackage) {
|
|
596
|
+
entityAbsolutePackage = [packageName, entityPackage].join('.');
|
|
597
|
+
entityAbsoluteFolder = path.join(packageFolder, entityPackage);
|
|
598
|
+
}
|
|
599
|
+
entity.entityAbsolutePackage = entityAbsolutePackage;
|
|
600
|
+
entity.entityAbsoluteFolder = entityAbsoluteFolder;
|
|
601
|
+
entity.entityAbsoluteClass = `${entityAbsolutePackage}.domain.${persistClass}`;
|
|
602
|
+
},
|
|
590
603
|
};
|
|
591
604
|
}
|
|
592
605
|
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
/* eslint-disable consistent-return */
|
|
20
20
|
const _ = require('lodash');
|
|
21
21
|
const { writeFiles, addToMenu, replaceTranslations } = require('./files');
|
|
22
|
+
const { entityClientI18nFiles } = require('../entity-i18n/files');
|
|
23
|
+
|
|
22
24
|
const utils = require('../utils');
|
|
23
25
|
const BaseBlueprintGenerator = require('../generator-base-blueprint');
|
|
24
26
|
const {
|
|
@@ -38,6 +40,20 @@ module.exports = class extends BaseBlueprintGenerator {
|
|
|
38
40
|
useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_ENTITY_CLIENT, { context: this.options.context });
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
// Public API method used by the getter and also by Blueprints
|
|
44
|
+
_preparing() {
|
|
45
|
+
return {
|
|
46
|
+
async loadNativeLanguage() {
|
|
47
|
+
await this._loadEntityClientTranslations(this.entity, this.jhipsterConfig);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get preparing() {
|
|
53
|
+
if (useBlueprints) return;
|
|
54
|
+
return this._preparing();
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
// Public API method used by the getter and also by Blueprints
|
|
42
58
|
_default() {
|
|
43
59
|
return {
|
|
@@ -141,4 +157,41 @@ module.exports = class extends BaseBlueprintGenerator {
|
|
|
141
157
|
if (useBlueprints) return;
|
|
142
158
|
return this._postWriting();
|
|
143
159
|
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @experimental
|
|
163
|
+
* Load entity client native translation.
|
|
164
|
+
*/
|
|
165
|
+
async _loadEntityClientTranslations(entity, configContext = this) {
|
|
166
|
+
const { frontendAppName = this.getFrontendAppName(), nativeLanguage = 'en' } = configContext;
|
|
167
|
+
entity.entityClientTranslations = entity.entityClientTranslations || {};
|
|
168
|
+
const { entityClientTranslations } = entity;
|
|
169
|
+
const rootTemplatesPath = this.fetchFromInstalledJHipster('entity-i18n/templates/');
|
|
170
|
+
const translationFiles = await this.writeFiles({
|
|
171
|
+
sections: entityClientI18nFiles,
|
|
172
|
+
rootTemplatesPath,
|
|
173
|
+
context: { ...entity, clientSrcDir: '__tmp__', frontendAppName, lang: 'en' },
|
|
174
|
+
});
|
|
175
|
+
if (nativeLanguage && nativeLanguage !== 'en') {
|
|
176
|
+
translationFiles.push(
|
|
177
|
+
...(await this.writeFiles({
|
|
178
|
+
sections: entityClientI18nFiles,
|
|
179
|
+
rootTemplatesPath,
|
|
180
|
+
context: { ...entity, clientSrcDir: '__tmp__', frontendAppName, lang: nativeLanguage },
|
|
181
|
+
}))
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
for (const translationFile of translationFiles) {
|
|
185
|
+
_.merge(entityClientTranslations, this.readDestinationJSON(translationFile));
|
|
186
|
+
delete this.env.sharedFs.get(translationFile).state;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @experimental
|
|
192
|
+
* Get translation value for a key.
|
|
193
|
+
*/
|
|
194
|
+
_getEntityClientTranslation(translationKey) {
|
|
195
|
+
return _.get(this.entityClientTranslations, translationKey, `Translation missing for ${translationKey}`);
|
|
196
|
+
}
|
|
144
197
|
};
|
|
@@ -35,7 +35,7 @@ import { <%= entityAngularName %>RoutingModule } from './route/<%= entityFileNam
|
|
|
35
35
|
|
|
36
36
|
<%_ if (applicationTypeMicroservice && enableTranslation) { _%>
|
|
37
37
|
function translatePartialLoader(http: HttpClient, applicationConfigService: ApplicationConfigService): TranslateLoader {
|
|
38
|
-
const prefix = applicationConfigService.getEndpointFor('i18n/', '<%= microserviceName %>');
|
|
38
|
+
const prefix = applicationConfigService.isMicrofrontend() ? 'i18n/' : applicationConfigService.getEndpointFor('i18n/', '<%= microserviceName %>');
|
|
39
39
|
return new TranslateHttpLoader(http, prefix, `.json?_=${I18N_HASH}`);
|
|
40
40
|
}
|
|
41
41
|
|