@mediusinc/mng-commons-audit 4.2.0 → 5.0.0-rc.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/README.md +12 -26
- package/esm2022/lib/api/models/entityChange.mjs +10 -10
- package/esm2022/lib/api/models/guiEntityModel.mjs +10 -10
- package/esm2022/lib/api/models/guiPropertyModel.mjs +10 -10
- package/esm2022/lib/api/models/guiPropertyType.mjs +13 -13
- package/esm2022/lib/api/models/guiRelationModel.mjs +10 -10
- package/esm2022/lib/api/models/revEntityWithChangesDto.mjs +10 -10
- package/esm2022/lib/api/models/revEntityWithStateDto.mjs +10 -10
- package/esm2022/lib/api/models/revisionType.mjs +11 -9
- package/esm2022/lib/api/services/audit-revisions-api.service.mjs +29 -20
- package/esm2022/lib/api/services/audit.service.mjs +12 -11
- package/esm2022/lib/audit.routes.mjs +17 -19
- package/esm2022/lib/components/entity-changes-field/entity-changes-field.component.mjs +17 -14
- package/esm2022/lib/components/pages/audit/audit.page.component.mjs +7 -7
- package/esm2022/lib/components/pages/entity-revisions/audit-entity-revisions.page.component.mjs +114 -99
- package/esm2022/lib/components/pages/revisions/audit-revisions.page.component.mjs +61 -70
- package/esm2022/lib/models/config.model.mjs +1 -1
- package/esm2022/lib/models/entity-revision-change-state.model.mjs +6 -6
- package/esm2022/lib/models/entity-revision-changes.model.mjs +6 -6
- package/esm2022/lib/models/guiEntityModelWithI18n.model.mjs +7 -7
- package/esm2022/lib/models/rev-entity-detailed.model.mjs +7 -7
- package/esm2022/lib/models/rev-entity.model.mjs +6 -6
- package/esm2022/lib/models/revEntityWithId.model.mjs +8 -8
- package/esm2022/lib/service/module-config.token.mjs +2 -2
- package/esm2022/lib/utils/audit.util.mjs +66 -117
- package/fesm2022/mediusinc-mng-commons-audit.mjs +386 -442
- package/fesm2022/mediusinc-mng-commons-audit.mjs.map +1 -1
- package/lib/api/models/entityChange.d.ts +4 -4
- package/lib/api/models/guiEntityModel.d.ts +4 -4
- package/lib/api/models/guiPropertyModel.d.ts +6 -6
- package/lib/api/models/guiPropertyType.d.ts +1 -1
- package/lib/api/models/guiRelationModel.d.ts +2 -2
- package/lib/api/models/revEntityWithChangesDto.d.ts +4 -4
- package/lib/api/models/revEntityWithStateDto.d.ts +4 -4
- package/lib/api/models/revisionType.d.ts +2 -1
- package/lib/api/services/audit-revisions-api.service.d.ts +14 -13
- package/lib/api/services/audit.service.d.ts +7 -7
- package/lib/audit.routes.d.ts +5 -5
- package/lib/components/entity-changes-field/entity-changes-field.component.d.ts +6 -6
- package/lib/components/pages/audit/audit.page.component.d.ts +3 -3
- package/lib/components/pages/entity-revisions/audit-entity-revisions.page.component.d.ts +24 -23
- package/lib/components/pages/revisions/audit-revisions.page.component.d.ts +11 -14
- package/lib/models/config.model.d.ts +1 -1
- package/lib/models/entity-revision-change-state.model.d.ts +3 -3
- package/lib/models/entity-revision-changes.model.d.ts +3 -3
- package/lib/models/guiEntityModelWithI18n.model.d.ts +2 -2
- package/lib/models/rev-entity-detailed.model.d.ts +4 -4
- package/lib/models/rev-entity.model.d.ts +2 -2
- package/lib/models/revEntityWithId.model.d.ts +2 -2
- package/lib/service/module-config.token.d.ts +2 -2
- package/lib/utils/audit.util.d.ts +17 -14
- package/package.json +3 -2
- package/esm2022/lib/models/new-filter-match-type.model.mjs +0 -19
- package/lib/models/new-filter-match-type.model.d.ts +0 -17
- /package/{assets/i18n → i18n}/en.json +0 -0
- /package/{assets/i18n → i18n}/sl.json +0 -0
|
@@ -1,22 +1,103 @@
|
|
|
1
|
-
import { TypeName, TypeRegistry,
|
|
1
|
+
import { TypeName, TypeRegistry, CommonsConfigurationService, DataListParamsUtil, CommonsInternalError, itemIdToDefined, RouteBuilder, RoutesBuilder } from '@mediusinc/mng-commons/core';
|
|
2
|
+
import { TableviewComponent, TableviewRouteBuilder } from '@mediusinc/mng-commons/tableview';
|
|
2
3
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, inject, Injectable, Component,
|
|
4
|
+
import { InjectionToken, inject, Injectable, Component, ChangeDetectionStrategy, computed, signal, effect, DestroyRef, Input, Injector } from '@angular/core';
|
|
5
|
+
import { shareReplay, throwError, BehaviorSubject } from 'rxjs';
|
|
4
6
|
import { map } from 'rxjs/operators';
|
|
7
|
+
import { ACommonsBaseV1ApiService } from '@mediusinc/mng-commons-data-api-class/v1';
|
|
5
8
|
import { __decorate } from 'tslib';
|
|
6
|
-
import {
|
|
7
|
-
import * as i1 from '@angular/router';
|
|
8
|
-
import { RouterOutlet } from '@angular/router';
|
|
9
|
+
import { RouterOutlet, Router, ActivatedRoute } from '@angular/router';
|
|
9
10
|
import { AsyncPipe, JsonPipe } from '@angular/common';
|
|
10
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
11
|
-
import * as
|
|
11
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
12
|
+
import * as i1 from '@angular/forms';
|
|
12
13
|
import { FormsModule } from '@angular/forms';
|
|
13
14
|
import { FormlyModule } from '@ngx-formly/core';
|
|
14
|
-
import * as
|
|
15
|
-
import { TranslateModule } from '@ngx-translate/core';
|
|
15
|
+
import * as i2 from '@ngx-translate/core';
|
|
16
|
+
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
17
|
+
import { DropdownComponent } from '@mediusinc/mng-commons/form';
|
|
18
|
+
import { LookupDataProvider } from '@mediusinc/mng-commons/form/api';
|
|
19
|
+
import { TableviewDescriptor, TableviewDataProvider, ActionEditorDetailsDescriptor, AFormlyCustomFieldComponent, EditorDescriptor, TableviewEditorTypeEnum } from '@mediusinc/mng-commons/tableview/api';
|
|
20
|
+
import { HttpParams } from '@angular/common/http';
|
|
21
|
+
import { enumModel, enumModelGeneric, ModelDescriptor } from '@mediusinc/mng-commons/model';
|
|
22
|
+
import { TableComponent } from '@mediusinc/mng-commons/table';
|
|
23
|
+
import { TableDescriptor, TablePaginationModeEnum } from '@mediusinc/mng-commons/table/api';
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const COMMONS_AUDIT_MODULE_CONFIG_IT = new InjectionToken('CommonsAuditModuleConfig');
|
|
26
|
+
|
|
27
|
+
var GuiEntityModelDto_1;
|
|
28
|
+
let GuiEntityModelDto = class GuiEntityModelDto {
|
|
29
|
+
static { GuiEntityModelDto_1 = this; }
|
|
30
|
+
static { this.attributeTypeMap = [
|
|
31
|
+
{
|
|
32
|
+
name: 'entityName',
|
|
33
|
+
baseName: 'entityName',
|
|
34
|
+
type: 'string'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'properties',
|
|
38
|
+
baseName: 'properties',
|
|
39
|
+
type: 'Array<GuiPropertyModel>'
|
|
40
|
+
}
|
|
41
|
+
]; }
|
|
42
|
+
static getAttributeTypeMap() {
|
|
43
|
+
return GuiEntityModelDto_1.attributeTypeMap;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
GuiEntityModelDto = GuiEntityModelDto_1 = __decorate([
|
|
47
|
+
TypeName('MngGuiEntityModelDto')
|
|
48
|
+
], GuiEntityModelDto);
|
|
49
|
+
TypeRegistry.get().registerType(GuiEntityModelDto);
|
|
50
|
+
|
|
51
|
+
class AuditService extends ACommonsBaseV1ApiService {
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
this.CACHE_SIZE = 1;
|
|
55
|
+
this.moduleConfig = inject(COMMONS_AUDIT_MODULE_CONFIG_IT);
|
|
56
|
+
this.configService = CommonsConfigurationService.get();
|
|
57
|
+
}
|
|
58
|
+
getServiceBasePath() {
|
|
59
|
+
return this.moduleConfig.apiServiceBasePath ?? '';
|
|
60
|
+
}
|
|
61
|
+
getBasePath() {
|
|
62
|
+
return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
|
|
63
|
+
}
|
|
64
|
+
get revModel$() {
|
|
65
|
+
if (!this.revModelObs) {
|
|
66
|
+
this.revModelObs = this.requestRevModel().pipe(shareReplay(this.CACHE_SIZE));
|
|
67
|
+
}
|
|
68
|
+
return this.revModelObs;
|
|
69
|
+
}
|
|
70
|
+
get auditModel$() {
|
|
71
|
+
if (!this.auditModelObs) {
|
|
72
|
+
this.auditModelObs = this.requestAuditModel().pipe(shareReplay(this.CACHE_SIZE));
|
|
73
|
+
}
|
|
74
|
+
return this.auditModelObs;
|
|
75
|
+
}
|
|
76
|
+
requestRevModel() {
|
|
77
|
+
return this.http.get(this.getUrl('/rev-model'));
|
|
78
|
+
}
|
|
79
|
+
requestAuditModel() {
|
|
80
|
+
return this.http.get(this.getUrl('/audit-models')).pipe(map(response => this.deserializeClassArray(response, GuiEntityModelDto)));
|
|
81
|
+
}
|
|
82
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
83
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditService }); }
|
|
84
|
+
}
|
|
85
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditService, decorators: [{
|
|
86
|
+
type: Injectable
|
|
87
|
+
}], ctorParameters: () => [] });
|
|
88
|
+
|
|
89
|
+
class AuditPageComponent {
|
|
90
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
91
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: AuditPageComponent, isStandalone: true, selector: "mng-audit-page", ngImport: i0, template: "<router-outlet></router-outlet>\n", dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
92
|
+
}
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditPageComponent, decorators: [{
|
|
94
|
+
type: Component,
|
|
95
|
+
args: [{ standalone: true, selector: 'mng-audit-page', imports: [RouterOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: "<router-outlet></router-outlet>\n" }]
|
|
96
|
+
}] });
|
|
97
|
+
|
|
98
|
+
var RevEntityWithStateDto_1;
|
|
99
|
+
let RevEntityWithStateDto = class RevEntityWithStateDto {
|
|
100
|
+
static { RevEntityWithStateDto_1 = this; }
|
|
20
101
|
static { this.attributeTypeMap = [
|
|
21
102
|
{
|
|
22
103
|
name: 'revEntity',
|
|
@@ -40,22 +121,20 @@ let MngRevEntityWithStateDto = class MngRevEntityWithStateDto {
|
|
|
40
121
|
}
|
|
41
122
|
]; }
|
|
42
123
|
static getAttributeTypeMap() {
|
|
43
|
-
return
|
|
124
|
+
return RevEntityWithStateDto_1.attributeTypeMap;
|
|
44
125
|
}
|
|
45
126
|
};
|
|
46
|
-
|
|
127
|
+
RevEntityWithStateDto = RevEntityWithStateDto_1 = __decorate([
|
|
47
128
|
TypeName('MngRevEntityWithStateDto')
|
|
48
|
-
],
|
|
49
|
-
TypeRegistry.get().registerType(
|
|
129
|
+
], RevEntityWithStateDto);
|
|
130
|
+
TypeRegistry.get().registerType(RevEntityWithStateDto);
|
|
50
131
|
|
|
51
|
-
let
|
|
132
|
+
let RevEntityWithId = class RevEntityWithId extends RevEntityWithStateDto {
|
|
52
133
|
};
|
|
53
|
-
|
|
134
|
+
RevEntityWithId = __decorate([
|
|
54
135
|
TypeName('MngRevEntityWithId')
|
|
55
|
-
],
|
|
56
|
-
TypeRegistry.get().registerType(
|
|
57
|
-
|
|
58
|
-
const MNG_AUDIT_MODULE_CONFIG_IT = new InjectionToken('MngAuditModuleConfig');
|
|
136
|
+
], RevEntityWithId);
|
|
137
|
+
TypeRegistry.get().registerType(RevEntityWithId);
|
|
59
138
|
|
|
60
139
|
/**
|
|
61
140
|
* Medius quarkus sampler
|
|
@@ -68,17 +147,17 @@ const MNG_AUDIT_MODULE_CONFIG_IT = new InjectionToken('MngAuditModuleConfig');
|
|
|
68
147
|
* https://openapi-generator.tech
|
|
69
148
|
* Do not edit the class manually.
|
|
70
149
|
*/
|
|
71
|
-
var
|
|
72
|
-
(function (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})(
|
|
81
|
-
TypeRegistry.get().registerEnum(
|
|
150
|
+
var GuiPropertyTypeDto;
|
|
151
|
+
(function (GuiPropertyTypeDto) {
|
|
152
|
+
GuiPropertyTypeDto["LocalDate"] = "LOCAL_DATE";
|
|
153
|
+
GuiPropertyTypeDto["OffsetDateTime"] = "OFFSET_DATE_TIME";
|
|
154
|
+
GuiPropertyTypeDto["String"] = "STRING";
|
|
155
|
+
GuiPropertyTypeDto["Number"] = "NUMBER";
|
|
156
|
+
GuiPropertyTypeDto["Boolean"] = "BOOLEAN";
|
|
157
|
+
GuiPropertyTypeDto["Enum"] = "ENUM";
|
|
158
|
+
GuiPropertyTypeDto["Wildcard"] = "WILDCARD";
|
|
159
|
+
})(GuiPropertyTypeDto || (GuiPropertyTypeDto = {}));
|
|
160
|
+
TypeRegistry.get().registerEnum(GuiPropertyTypeDto, 'MngGuiPropertyTypeDto');
|
|
82
161
|
|
|
83
162
|
/**
|
|
84
163
|
* Medius quarkus sampler
|
|
@@ -91,44 +170,26 @@ TypeRegistry.get().registerEnum(MngGuiPropertyTypeDto, 'MngGuiPropertyTypeDto');
|
|
|
91
170
|
* https://openapi-generator.tech
|
|
92
171
|
* Do not edit the class manually.
|
|
93
172
|
*/
|
|
94
|
-
var
|
|
95
|
-
(function (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})(
|
|
100
|
-
TypeRegistry.get().registerEnum(
|
|
173
|
+
var RevisionTypeDto;
|
|
174
|
+
(function (RevisionTypeDto) {
|
|
175
|
+
RevisionTypeDto["Add"] = "ADD";
|
|
176
|
+
RevisionTypeDto["Mod"] = "MOD";
|
|
177
|
+
RevisionTypeDto["Del"] = "DEL";
|
|
178
|
+
})(RevisionTypeDto || (RevisionTypeDto = {}));
|
|
179
|
+
TypeRegistry.get().registerEnum(RevisionTypeDto, 'MngRevisionTypeDto');
|
|
180
|
+
const revisionTypeEnum = enumModel(RevisionTypeDto.Add, RevisionTypeDto, 'MngRevisionTypeDto');
|
|
101
181
|
|
|
102
|
-
let
|
|
182
|
+
let EntityRevisionChangeState = class EntityRevisionChangeState {
|
|
103
183
|
};
|
|
104
|
-
|
|
184
|
+
EntityRevisionChangeState = __decorate([
|
|
105
185
|
TypeName('MngEntityRevisionChangeState')
|
|
106
|
-
],
|
|
186
|
+
], EntityRevisionChangeState);
|
|
107
187
|
|
|
108
|
-
let
|
|
188
|
+
let EntityRevisionChanges = class EntityRevisionChanges {
|
|
109
189
|
};
|
|
110
|
-
|
|
190
|
+
EntityRevisionChanges = __decorate([
|
|
111
191
|
TypeName('MngEntityChanges')
|
|
112
|
-
],
|
|
113
|
-
|
|
114
|
-
var NewMediusFilterMatchType;
|
|
115
|
-
(function (NewMediusFilterMatchType) {
|
|
116
|
-
NewMediusFilterMatchType["Equals"] = "eq";
|
|
117
|
-
NewMediusFilterMatchType["NotEquals"] = "ne";
|
|
118
|
-
NewMediusFilterMatchType["Between"] = "bt";
|
|
119
|
-
NewMediusFilterMatchType["Contains"] = "cn";
|
|
120
|
-
NewMediusFilterMatchType["NotContains"] = "nc";
|
|
121
|
-
NewMediusFilterMatchType["StartsWith"] = "sw";
|
|
122
|
-
NewMediusFilterMatchType["EndsWith"] = "ew";
|
|
123
|
-
NewMediusFilterMatchType["In"] = "in";
|
|
124
|
-
NewMediusFilterMatchType["NotIn"] = "ni";
|
|
125
|
-
NewMediusFilterMatchType["LessThan"] = "lt";
|
|
126
|
-
NewMediusFilterMatchType["LessThanOrEqualTo"] = "le";
|
|
127
|
-
NewMediusFilterMatchType["GreaterThan"] = "gt";
|
|
128
|
-
NewMediusFilterMatchType["GreaterThanOrEqualTo"] = "ge";
|
|
129
|
-
NewMediusFilterMatchType["Exists"] = "ex";
|
|
130
|
-
NewMediusFilterMatchType["DoesNotExist"] = "nx";
|
|
131
|
-
})(NewMediusFilterMatchType || (NewMediusFilterMatchType = {}));
|
|
192
|
+
], EntityRevisionChanges);
|
|
132
193
|
|
|
133
194
|
class AuditUtil {
|
|
134
195
|
static { this._dateRegex = /\d{4}-[01]\d-[0-3]\d/; }
|
|
@@ -137,37 +198,37 @@ class AuditUtil {
|
|
|
137
198
|
if (!property.resolvedPropertyName) {
|
|
138
199
|
continue;
|
|
139
200
|
}
|
|
140
|
-
const isEnum = property.propertyType ===
|
|
201
|
+
const isEnum = property.propertyType === GuiPropertyTypeDto.Enum;
|
|
141
202
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
203
|
let column = null;
|
|
143
204
|
if (isEnum) {
|
|
144
205
|
if (!property.possibleEnumValues) {
|
|
145
206
|
continue;
|
|
146
207
|
}
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
column = descriptor.
|
|
208
|
+
const enumModel = AuditUtil.findEnum(property);
|
|
209
|
+
if (enumModel) {
|
|
210
|
+
column = descriptor.addColumnEnum(property.resolvedPropertyName, enumModel);
|
|
150
211
|
if (addFilters) {
|
|
151
|
-
column.
|
|
212
|
+
descriptor.addFilterLookupEnum(column.property, enumModel, property.possibleEnumValues);
|
|
152
213
|
}
|
|
153
214
|
}
|
|
154
215
|
else {
|
|
155
216
|
column = descriptor.addColumnUnsafe(property.resolvedPropertyName);
|
|
156
217
|
if (addFilters) {
|
|
157
|
-
(column
|
|
218
|
+
descriptor.addFilterLookupUnsafe(column.property, LookupDataProvider.create().withLookup(() => property.possibleEnumValues ?? []));
|
|
158
219
|
}
|
|
159
220
|
}
|
|
160
221
|
}
|
|
161
|
-
else if (property.propertyType ===
|
|
222
|
+
else if (property.propertyType === GuiPropertyTypeDto.Number) {
|
|
162
223
|
column = descriptor.addColumnUnsafe(property.resolvedPropertyName).asNumber();
|
|
163
224
|
}
|
|
164
|
-
else if (property.propertyType ===
|
|
225
|
+
else if (property.propertyType === GuiPropertyTypeDto.Boolean) {
|
|
165
226
|
column = descriptor.addColumnUnsafe(property.resolvedPropertyName).asBoolean();
|
|
166
227
|
}
|
|
167
|
-
else if (property.propertyType ===
|
|
228
|
+
else if (property.propertyType === GuiPropertyTypeDto.LocalDate) {
|
|
168
229
|
column = descriptor.addColumnUnsafe(property.resolvedPropertyName).asDate('dd. MM yyyy');
|
|
169
230
|
}
|
|
170
|
-
else if (property.propertyType ===
|
|
231
|
+
else if (property.propertyType === GuiPropertyTypeDto.OffsetDateTime) {
|
|
171
232
|
column = descriptor.addColumnUnsafe(property.resolvedPropertyName).asDate('dd. MM yyyy HH:mm');
|
|
172
233
|
}
|
|
173
234
|
else {
|
|
@@ -179,10 +240,10 @@ class AuditUtil {
|
|
|
179
240
|
}
|
|
180
241
|
column.withTitle(AuditUtil.getPropertyTitleKey(property, modelType));
|
|
181
242
|
if (!isEnum && addFilters) {
|
|
182
|
-
column?.
|
|
243
|
+
column?.withFilterUnsafe();
|
|
183
244
|
}
|
|
184
245
|
if (addSorts) {
|
|
185
|
-
column?.
|
|
246
|
+
column?.withSortUnsafe();
|
|
186
247
|
}
|
|
187
248
|
}
|
|
188
249
|
return descriptor;
|
|
@@ -199,39 +260,39 @@ class AuditUtil {
|
|
|
199
260
|
continue;
|
|
200
261
|
}
|
|
201
262
|
const fieldPrepend = `${modelType}.`;
|
|
202
|
-
if (property.propertyType ===
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
263
|
+
if (property.propertyType === GuiPropertyTypeDto.Enum) {
|
|
264
|
+
const enumModel = AuditUtil.findEnum(property);
|
|
265
|
+
if (enumModel) {
|
|
205
266
|
if (!property.possibleEnumValues) {
|
|
206
267
|
continue;
|
|
207
268
|
}
|
|
208
|
-
descriptor.
|
|
269
|
+
descriptor.addFieldLookupEnum((fieldPrepend + property.resolvedPropertyName), enumModel, property.possibleEnumValues).withDisabled();
|
|
209
270
|
}
|
|
210
271
|
else {
|
|
211
272
|
descriptor.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName).withLabel(AuditUtil.getPropertyTitleKey(property, modelType));
|
|
212
273
|
}
|
|
213
274
|
}
|
|
214
|
-
else if (property.propertyType ===
|
|
275
|
+
else if (property.propertyType === GuiPropertyTypeDto.Number) {
|
|
215
276
|
descriptor
|
|
216
277
|
.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName)
|
|
217
278
|
.withLabel(AuditUtil.getPropertyTitleKey(property, modelType))
|
|
218
279
|
.asNumber()
|
|
219
280
|
.withDisabled();
|
|
220
281
|
}
|
|
221
|
-
else if (property.propertyType ===
|
|
282
|
+
else if (property.propertyType === GuiPropertyTypeDto.Boolean) {
|
|
222
283
|
descriptor
|
|
223
284
|
.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName)
|
|
224
285
|
.withLabel(AuditUtil.getPropertyTitleKey(property, modelType))
|
|
225
286
|
.withDisabled();
|
|
226
287
|
}
|
|
227
|
-
else if (property.propertyType ===
|
|
288
|
+
else if (property.propertyType === GuiPropertyTypeDto.LocalDate) {
|
|
228
289
|
descriptor
|
|
229
290
|
.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName)
|
|
230
291
|
.withLabel(AuditUtil.getPropertyTitleKey(property, modelType))
|
|
231
292
|
.asDatePicker({ format: 'dd. MMM yyyy' })
|
|
232
293
|
.withDisabled();
|
|
233
294
|
}
|
|
234
|
-
else if (property.propertyType ===
|
|
295
|
+
else if (property.propertyType === GuiPropertyTypeDto.OffsetDateTime) {
|
|
235
296
|
descriptor
|
|
236
297
|
.addFieldUnsafe(fieldPrepend + property.resolvedPropertyName)
|
|
237
298
|
.withLabel(AuditUtil.getPropertyTitleKey(property, modelType))
|
|
@@ -253,8 +314,8 @@ class AuditUtil {
|
|
|
253
314
|
return descriptor;
|
|
254
315
|
}
|
|
255
316
|
static buildDescriptorForEntityRevision(descriptor, revModel, entityModel) {
|
|
256
|
-
descriptor.
|
|
257
|
-
descriptor.addFieldLookupEnum('revType',
|
|
317
|
+
descriptor.addColumnEnum('revType', revisionTypeEnum).withTitle('MngEntityRevisionChangeState.properties.revType').withFilterUnsafe();
|
|
318
|
+
descriptor.addFieldLookupEnum('revType', revisionTypeEnum).withLabel('MngEntityRevisionChangeState.properties.revType');
|
|
258
319
|
if (revModel.properties) {
|
|
259
320
|
AuditUtil.addColumnsFromModel(descriptor.table, revModel.properties, 'revEntity');
|
|
260
321
|
AuditUtil.addFieldsFromModel(descriptor.detailsEditor, revModel.properties, 'revEntity');
|
|
@@ -265,15 +326,31 @@ class AuditUtil {
|
|
|
265
326
|
}
|
|
266
327
|
return descriptor;
|
|
267
328
|
}
|
|
268
|
-
static
|
|
329
|
+
static findEnum(property) {
|
|
269
330
|
if (!property.enumClassSimpleName) {
|
|
270
331
|
return undefined;
|
|
271
332
|
}
|
|
272
|
-
let
|
|
333
|
+
let i18n = property.enumClassSimpleName;
|
|
334
|
+
let enumType = TypeRegistry.get().findEnum(i18n);
|
|
273
335
|
if (!enumType) {
|
|
274
|
-
|
|
336
|
+
i18n = property.enumClassSimpleName + 'Dto';
|
|
337
|
+
enumType = TypeRegistry.get().findEnum(i18n);
|
|
338
|
+
}
|
|
339
|
+
if (!enumType && Array.isArray(property.possibleEnumValues)) {
|
|
340
|
+
i18n = null;
|
|
341
|
+
enumType = property.possibleEnumValues?.reduce((acc, v) => {
|
|
342
|
+
const constName = v
|
|
343
|
+
.split('_')
|
|
344
|
+
.map(s => (s.length > 1 ? s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase() : s))
|
|
345
|
+
.join('');
|
|
346
|
+
if (constName !== v) {
|
|
347
|
+
acc[constName] = v;
|
|
348
|
+
}
|
|
349
|
+
acc[v] = constName;
|
|
350
|
+
return acc;
|
|
351
|
+
}, {});
|
|
275
352
|
}
|
|
276
|
-
return enumType;
|
|
353
|
+
return enumModelGeneric(enumType, i18n);
|
|
277
354
|
}
|
|
278
355
|
static extractPropertyName(fullPropertyName) {
|
|
279
356
|
if (fullPropertyName?.includes('entityState.')) {
|
|
@@ -284,109 +361,41 @@ class AuditUtil {
|
|
|
284
361
|
}
|
|
285
362
|
return fullPropertyName;
|
|
286
363
|
}
|
|
287
|
-
static
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
url += sortingQPs.join(',');
|
|
296
|
-
}
|
|
297
|
-
if (queryParams.filterParams && queryParams.filterParams.length > 0) {
|
|
298
|
-
const filterQPs = [];
|
|
299
|
-
for (const mfp of queryParams.filterParams) {
|
|
300
|
-
switch (mfp.filterMatchType) {
|
|
301
|
-
case MediusFilterMatchType.Equals: {
|
|
302
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Equals}:${mfp.filterValue}`);
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
case MediusFilterMatchType.NotEquals: {
|
|
306
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.NotEquals}:${mfp.filterValue}`);
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
case MediusFilterMatchType.FromTo: {
|
|
310
|
-
if (this._dateRegex.test(mfp.filterValue)) {
|
|
311
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Between}:${new Date(mfp.filterValue).toISOString()},${new Date(mfp.filterValueTo).toISOString()}`);
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Between}:${mfp.filterValue},${mfp.filterValueTo}`);
|
|
315
|
-
}
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case MediusFilterMatchType.Contains: {
|
|
319
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.Contains}:${mfp.filterValue}`);
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
case MediusFilterMatchType.StartsWith: {
|
|
323
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.StartsWith}:${mfp.filterValue}`);
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
case MediusFilterMatchType.EndsWith: {
|
|
327
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.EndsWith}:${mfp.filterValue}`);
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
case MediusFilterMatchType.In: {
|
|
331
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.In}:${mfp.filterValue}`);
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
case MediusFilterMatchType.NotIn: {
|
|
335
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.NotIn}:${mfp.filterValue}`);
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
case MediusFilterMatchType.SmallerThan: {
|
|
339
|
-
if (this._dateRegex.test(mfp.filterValue)) {
|
|
340
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.LessThan}:${new Date(mfp.filterValue).toISOString()}`);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.LessThan}:${mfp.filterValue}`);
|
|
344
|
-
}
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
case MediusFilterMatchType.GreaterThan: {
|
|
348
|
-
if (this._dateRegex.test(mfp.filterValue)) {
|
|
349
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.GreaterThan}:${new Date(mfp.filterValue).toISOString()}`);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
filterQPs.push(`${this.extractPropertyName(mfp.property)}=${NewMediusFilterMatchType.GreaterThan}:${mfp.filterValue}`);
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
url += '&';
|
|
359
|
-
url += filterQPs.join('&');
|
|
360
|
-
}
|
|
361
|
-
return url;
|
|
364
|
+
static paramsToHttpParams(params) {
|
|
365
|
+
const routeParams = DataListParamsUtil.toUrlQueryParams(params, null);
|
|
366
|
+
let httpParams = new HttpParams();
|
|
367
|
+
Object.entries(routeParams).forEach(([key, value]) => {
|
|
368
|
+
httpParams = httpParams.append(key, value);
|
|
369
|
+
});
|
|
370
|
+
return httpParams;
|
|
362
371
|
}
|
|
363
372
|
static mapItemsToEntityChangesArray(fieldValue) {
|
|
364
373
|
const entityChanges = [];
|
|
365
374
|
for (const key of Object.keys(fieldValue)) {
|
|
366
|
-
const ec = new
|
|
375
|
+
const ec = new EntityRevisionChanges();
|
|
367
376
|
ec.entityType = key;
|
|
368
377
|
ec.items = [];
|
|
369
378
|
for (const change of fieldValue[key]) {
|
|
370
|
-
if (change.revType ===
|
|
371
|
-
const item = new
|
|
379
|
+
if (change.revType === RevisionTypeDto.Add && change.entityNewState) {
|
|
380
|
+
const item = new EntityRevisionChangeState();
|
|
372
381
|
item.revType = change.revType;
|
|
373
382
|
item.color = 'green';
|
|
374
383
|
Object.entries(change.entityNewState).forEach(([key, value]) => (item[key] = value));
|
|
375
384
|
ec.items.push(item);
|
|
376
385
|
}
|
|
377
|
-
else if (change.revType ===
|
|
378
|
-
const item = new
|
|
386
|
+
else if (change.revType === RevisionTypeDto.Del && change.entityOldState) {
|
|
387
|
+
const item = new EntityRevisionChangeState();
|
|
379
388
|
item.revType = change.revType;
|
|
380
389
|
item.color = 'red';
|
|
381
390
|
Object.entries(change.entityOldState).forEach(([key, value]) => (item[key] = value));
|
|
382
391
|
ec.items.push(item);
|
|
383
392
|
}
|
|
384
|
-
else if (change.revType ===
|
|
385
|
-
const itemOld = new
|
|
393
|
+
else if (change.revType === RevisionTypeDto.Mod && change.entityOldState && change.entityNewState) {
|
|
394
|
+
const itemOld = new EntityRevisionChangeState();
|
|
386
395
|
itemOld.revType = change.revType;
|
|
387
396
|
itemOld.color = 'red';
|
|
388
397
|
Object.entries(change.entityOldState).forEach(([key, value]) => (itemOld[key] = value));
|
|
389
|
-
const itemNew = new
|
|
398
|
+
const itemNew = new EntityRevisionChangeState();
|
|
390
399
|
itemNew.revType = change.revType;
|
|
391
400
|
itemNew.color = 'green';
|
|
392
401
|
Object.entries(change.entityNewState).forEach(([key, value]) => (itemNew[key] = value));
|
|
@@ -400,11 +409,11 @@ class AuditUtil {
|
|
|
400
409
|
}
|
|
401
410
|
}
|
|
402
411
|
|
|
403
|
-
class
|
|
412
|
+
class AuditRevisionsApiService extends ACommonsBaseV1ApiService {
|
|
404
413
|
constructor() {
|
|
405
414
|
super();
|
|
406
|
-
this.moduleConfig = inject(
|
|
407
|
-
this.configService =
|
|
415
|
+
this.moduleConfig = inject(COMMONS_AUDIT_MODULE_CONFIG_IT);
|
|
416
|
+
this.configService = CommonsConfigurationService.get();
|
|
408
417
|
}
|
|
409
418
|
getServiceBasePath() {
|
|
410
419
|
return this.moduleConfig.apiServiceBasePath ?? '';
|
|
@@ -412,122 +421,131 @@ class MngAuditRevisionsApiService extends AMngBaseApiService {
|
|
|
412
421
|
getBasePath() {
|
|
413
422
|
return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
|
|
414
423
|
}
|
|
415
|
-
getRevisionList(
|
|
416
|
-
return this.http.get(this.getUrl(
|
|
424
|
+
getRevisionList(params) {
|
|
425
|
+
return this.http.get(this.getUrl(''), {
|
|
426
|
+
params: AuditUtil.paramsToHttpParams(params)
|
|
427
|
+
});
|
|
417
428
|
}
|
|
418
429
|
getAllChangesForRevision(revId) {
|
|
419
430
|
return this.http.get(this.getUrl(`/changes/${revId}`));
|
|
420
431
|
}
|
|
421
|
-
listRevisionsWithStateForEntityType(
|
|
422
|
-
return this.http
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
})
|
|
432
|
+
listRevisionsWithStateForEntityType(params, entityType) {
|
|
433
|
+
return this.http
|
|
434
|
+
.get(this.getUrl(`/states/${entityType}`), {
|
|
435
|
+
params: AuditUtil.paramsToHttpParams(params)
|
|
436
|
+
})
|
|
437
|
+
.pipe(map(res => {
|
|
438
|
+
return {
|
|
439
|
+
data: this.deserializeClassArray(res.data, RevEntityWithStateDto),
|
|
440
|
+
totalCount: res.totalCount
|
|
441
|
+
};
|
|
442
|
+
}));
|
|
426
443
|
}
|
|
427
444
|
fetchRevisionsWithStateForEntityType(entityType, revId, itemId) {
|
|
428
|
-
return this.http.get(this.getUrl(`/states/${entityType}?rev=eq:${revId}&id=eq:${itemId}`)).pipe(map(
|
|
445
|
+
return this.http.get(this.getUrl(`/states/${entityType}?rev=eq:${revId}&id=eq:${itemId}`)).pipe(map(res => this.deserializeClassArray(res.data, RevEntityWithId).map(i => {
|
|
429
446
|
i.mergedId = i.revEntity?.['rev'] + '_' + i.entityState?.['id'];
|
|
430
447
|
return i;
|
|
431
448
|
})), map(items => {
|
|
432
449
|
if (items.length > 0) {
|
|
433
450
|
return items[0];
|
|
434
451
|
}
|
|
435
|
-
throw new
|
|
452
|
+
throw new CommonsInternalError(`Entity revision ${revId} for ${entityType} with id ${itemId} was not found`);
|
|
436
453
|
}));
|
|
437
454
|
}
|
|
438
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type:
|
|
439
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type:
|
|
440
|
-
}
|
|
441
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditRevisionsApiService, decorators: [{
|
|
442
|
-
type: Injectable
|
|
443
|
-
}], ctorParameters: () => [] });
|
|
444
|
-
|
|
445
|
-
var MngGuiEntityModelDto_1;
|
|
446
|
-
let MngGuiEntityModelDto = class MngGuiEntityModelDto {
|
|
447
|
-
static { MngGuiEntityModelDto_1 = this; }
|
|
448
|
-
static { this.attributeTypeMap = [
|
|
449
|
-
{
|
|
450
|
-
name: 'entityName',
|
|
451
|
-
baseName: 'entityName',
|
|
452
|
-
type: 'string'
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
name: 'properties',
|
|
456
|
-
baseName: 'properties',
|
|
457
|
-
type: 'Array<GuiPropertyModel>'
|
|
458
|
-
}
|
|
459
|
-
]; }
|
|
460
|
-
static getAttributeTypeMap() {
|
|
461
|
-
return MngGuiEntityModelDto_1.attributeTypeMap;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
MngGuiEntityModelDto = MngGuiEntityModelDto_1 = __decorate([
|
|
465
|
-
TypeName('MngGuiEntityModelDto')
|
|
466
|
-
], MngGuiEntityModelDto);
|
|
467
|
-
TypeRegistry.get().registerType(MngGuiEntityModelDto);
|
|
468
|
-
|
|
469
|
-
class MngAuditService extends AMngBaseApiService {
|
|
470
|
-
constructor() {
|
|
471
|
-
super();
|
|
472
|
-
this.CACHE_SIZE = 1;
|
|
473
|
-
this.moduleConfig = inject(MNG_AUDIT_MODULE_CONFIG_IT);
|
|
474
|
-
this.configService = MngConfigurationService.get();
|
|
475
|
-
}
|
|
476
|
-
getServiceBasePath() {
|
|
477
|
-
return this.moduleConfig.apiServiceBasePath ?? '';
|
|
478
|
-
}
|
|
479
|
-
getBasePath() {
|
|
480
|
-
return `${this.configService.getConfigValue(this.moduleConfig.apiBasePathConfigKey)}`;
|
|
481
|
-
}
|
|
482
|
-
get revModel$() {
|
|
483
|
-
if (!this.revModelObs) {
|
|
484
|
-
this.revModelObs = this.requestRevModel().pipe(shareReplay(this.CACHE_SIZE));
|
|
485
|
-
}
|
|
486
|
-
return this.revModelObs;
|
|
487
|
-
}
|
|
488
|
-
get auditModel$() {
|
|
489
|
-
if (!this.auditModelObs) {
|
|
490
|
-
this.auditModelObs = this.requestAuditModel().pipe(shareReplay(this.CACHE_SIZE));
|
|
491
|
-
}
|
|
492
|
-
return this.auditModelObs;
|
|
493
|
-
}
|
|
494
|
-
requestRevModel() {
|
|
495
|
-
return this.http.get(this.getUrl('/rev-model'));
|
|
496
|
-
}
|
|
497
|
-
requestAuditModel() {
|
|
498
|
-
return this.http.get(this.getUrl('/audit-models')).pipe(map(response => this.deserializeClassArray(response, MngGuiEntityModelDto)));
|
|
499
|
-
}
|
|
500
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
501
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditService }); }
|
|
455
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditRevisionsApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
456
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditRevisionsApiService }); }
|
|
502
457
|
}
|
|
503
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type:
|
|
458
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditRevisionsApiService, decorators: [{
|
|
504
459
|
type: Injectable
|
|
505
460
|
}], ctorParameters: () => [] });
|
|
506
461
|
|
|
507
|
-
class
|
|
508
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
509
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: MngAuditPageComponent, isStandalone: true, selector: "mng-audit-page", ngImport: i0, template: "<router-outlet></router-outlet>\n", dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
|
|
510
|
-
}
|
|
511
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditPageComponent, decorators: [{
|
|
512
|
-
type: Component,
|
|
513
|
-
args: [{ standalone: true, selector: 'mng-audit-page', imports: [RouterOutlet], template: "<router-outlet></router-outlet>\n" }]
|
|
514
|
-
}] });
|
|
515
|
-
|
|
516
|
-
let MngGuiEntityModelWithI18n = class MngGuiEntityModelWithI18n extends MngGuiEntityModelDto {
|
|
462
|
+
let GuiEntityModelWithI18n = class GuiEntityModelWithI18n extends GuiEntityModelDto {
|
|
517
463
|
};
|
|
518
|
-
|
|
464
|
+
GuiEntityModelWithI18n = __decorate([
|
|
519
465
|
TypeName('MngGuiEntityModelWithI18n')
|
|
520
|
-
],
|
|
466
|
+
], GuiEntityModelWithI18n);
|
|
521
467
|
|
|
522
|
-
class
|
|
523
|
-
constructor(
|
|
524
|
-
|
|
525
|
-
this.
|
|
526
|
-
this.
|
|
527
|
-
this.auditService = inject(
|
|
528
|
-
this.
|
|
529
|
-
this.
|
|
530
|
-
this.
|
|
468
|
+
class AuditEntityRevisionsPageComponent {
|
|
469
|
+
constructor() {
|
|
470
|
+
this.router = inject(Router);
|
|
471
|
+
this.route = inject(ActivatedRoute);
|
|
472
|
+
this.translate = inject(TranslateService);
|
|
473
|
+
this.auditService = inject(AuditService);
|
|
474
|
+
this.revModel = toSignal(this.auditService.revModel$);
|
|
475
|
+
this.auditModel = toSignal(this.auditService.auditModel$);
|
|
476
|
+
this.entityClass = toSignal(this.route.paramMap.pipe(map(pm => pm.get('entityClass') ?? undefined)));
|
|
477
|
+
this.selectedRevisionEntity = computed(() => {
|
|
478
|
+
const entities = this.auditModel();
|
|
479
|
+
const entityClass = this.entityClass();
|
|
480
|
+
if (entityClass && entities) {
|
|
481
|
+
for (const e of entities) {
|
|
482
|
+
if (e.entityName === entityClass) {
|
|
483
|
+
return e;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return undefined;
|
|
488
|
+
});
|
|
489
|
+
this.descriptor = computed(() => {
|
|
490
|
+
const revModel = this.revModel();
|
|
491
|
+
const selectedRevisionEntity = this.selectedRevisionEntity();
|
|
492
|
+
if (!revModel || !selectedRevisionEntity?.entityName) {
|
|
493
|
+
return undefined;
|
|
494
|
+
}
|
|
495
|
+
const desc = TableviewDescriptor.fromClass(RevEntityWithId, 'mergedId', undefined, selectedRevisionEntity.entityName);
|
|
496
|
+
AuditUtil.buildDescriptorForEntityRevision(desc, revModel, selectedRevisionEntity);
|
|
497
|
+
desc.table.withColumnsResizable();
|
|
498
|
+
desc.table.withCurrentColumnsReorderable();
|
|
499
|
+
desc.table.withCurrentColumnsToggleable();
|
|
500
|
+
return desc;
|
|
501
|
+
});
|
|
502
|
+
this.dataProvider = computed(() => {
|
|
503
|
+
const revModel = this.revModel();
|
|
504
|
+
const selectedRevisionEntity = this.selectedRevisionEntity();
|
|
505
|
+
if (!revModel || !selectedRevisionEntity?.entityName) {
|
|
506
|
+
return undefined;
|
|
507
|
+
}
|
|
508
|
+
const entityName = selectedRevisionEntity.entityName;
|
|
509
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
510
|
+
return TableviewDataProvider.fromClassWithService(RevEntityWithId, AuditRevisionsApiService).withGetAll((params, service) => selectedRevisionEntity.entityName
|
|
511
|
+
? service.listRevisionsWithStateForEntityType(params, entityName).pipe(map(res => {
|
|
512
|
+
const revEntityWithStateAndIdList = [];
|
|
513
|
+
for (const revEntityWithState of res.data) {
|
|
514
|
+
const revEntityWithStateAndId = new RevEntityWithId();
|
|
515
|
+
revEntityWithStateAndId.mergedId = revEntityWithState.revEntity?.['rev'] + '_' + revEntityWithState.entityState?.['id'];
|
|
516
|
+
revEntityWithStateAndId.revType = revEntityWithState.revType;
|
|
517
|
+
revEntityWithStateAndId.revEntity = revEntityWithState.revEntity;
|
|
518
|
+
revEntityWithStateAndId.entityState = revEntityWithState.entityState;
|
|
519
|
+
revEntityWithStateAndId.entityClassName = revEntityWithState.entityClassName;
|
|
520
|
+
revEntityWithStateAndIdList.push(revEntityWithStateAndId);
|
|
521
|
+
}
|
|
522
|
+
return { data: revEntityWithStateAndIdList, totalCount: res.totalCount };
|
|
523
|
+
}))
|
|
524
|
+
: throwError(() => new CommonsInternalError('No revision entity is provided for list.')));
|
|
525
|
+
});
|
|
526
|
+
this.actions = computed(() => {
|
|
527
|
+
const selectedRevisionEntity = this.selectedRevisionEntity();
|
|
528
|
+
const descriptor = this.descriptor();
|
|
529
|
+
if (!selectedRevisionEntity?.entityName || !descriptor) {
|
|
530
|
+
return [];
|
|
531
|
+
}
|
|
532
|
+
const entityName = selectedRevisionEntity.entityName;
|
|
533
|
+
const detailsAction = ActionEditorDetailsDescriptor.createWithProvider(descriptor.detailsEditor, AuditRevisionsApiService)
|
|
534
|
+
.withFetchFunction(ctx => {
|
|
535
|
+
if (!entityName) {
|
|
536
|
+
return throwError(() => new CommonsInternalError('No revision entity is provided for details.'));
|
|
537
|
+
}
|
|
538
|
+
if (!ctx.parameters.itemId) {
|
|
539
|
+
return throwError(() => new CommonsInternalError('No item id for revision entity details is provided.'));
|
|
540
|
+
}
|
|
541
|
+
const revId = ctx.parameters.itemId.toString().split('_')[0];
|
|
542
|
+
const itemId = ctx.parameters.itemId.toString().split('_')[1];
|
|
543
|
+
return ctx.serviceInstance.fetchRevisionsWithStateForEntityType(entityName, revId, itemId);
|
|
544
|
+
})
|
|
545
|
+
.withEditorTitle('pages.entityRevisions.actions.details.editor.title');
|
|
546
|
+
return [detailsAction];
|
|
547
|
+
});
|
|
548
|
+
this.revisionEntitiesLookupProvider = LookupDataProvider.fromClass(GuiEntityModelWithI18n).withLookup(() => this.auditService.auditModel$.pipe(map(model => {
|
|
531
549
|
const modelI18n = model;
|
|
532
550
|
modelI18n.sort((m1, m2) => {
|
|
533
551
|
if (m1.entityName && m2.entityName) {
|
|
@@ -541,101 +559,41 @@ class MngAuditEntityRevisionsPageComponent extends AMngTableviewRouteComponent {
|
|
|
541
559
|
}
|
|
542
560
|
});
|
|
543
561
|
modelI18n.forEach(item => {
|
|
544
|
-
const translatedEntityName = this.
|
|
562
|
+
const translatedEntityName = this.translate.instant('AuditEntities.' + item.entityName);
|
|
545
563
|
item.entityNameI18n = translatedEntityName.includes('AuditEntities.') ? item.entityName : translatedEntityName;
|
|
546
564
|
});
|
|
547
565
|
return modelI18n;
|
|
548
566
|
})));
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
this.revModel = revModel;
|
|
556
|
-
for (const e of entities) {
|
|
557
|
-
if (e.entityName === entityClass) {
|
|
558
|
-
this.selectedRevisionEntity = e;
|
|
559
|
-
super.ngOnInit();
|
|
560
|
-
setTimeout(() => this.showTableview.set(true));
|
|
561
|
-
}
|
|
562
|
-
}
|
|
567
|
+
this.showTableview = signal(false);
|
|
568
|
+
effect(() => {
|
|
569
|
+
const descriptor = this.descriptor();
|
|
570
|
+
if (descriptor) {
|
|
571
|
+
setTimeout(() => {
|
|
572
|
+
this.showTableview.set(true);
|
|
563
573
|
});
|
|
564
574
|
}
|
|
565
|
-
});
|
|
575
|
+
}, { allowSignalWrites: true });
|
|
566
576
|
}
|
|
567
|
-
onRevisionEntityChange() {
|
|
577
|
+
onRevisionEntityChange(value) {
|
|
568
578
|
this.showTableview.set(false);
|
|
569
|
-
if (
|
|
570
|
-
this.router.navigate(['/audit/entity-revisions/' +
|
|
579
|
+
if (value) {
|
|
580
|
+
this.router.navigate(['/audit/entity-revisions/' + value.entityName]);
|
|
571
581
|
}
|
|
572
582
|
else {
|
|
573
583
|
this.router.navigate(['/audit/entity-revisions/']);
|
|
574
584
|
}
|
|
575
585
|
}
|
|
576
|
-
|
|
577
|
-
if (!
|
|
578
|
-
throw new MngInternalError('No revision model or revision entity is provided for tableview.');
|
|
579
|
-
}
|
|
580
|
-
const desc = TableviewDescriptor.fromClass(MngRevEntityWithId, 'mergedId', undefined, this.selectedRevisionEntity.entityName);
|
|
581
|
-
AuditUtil.buildDescriptorForEntityRevision(desc, this.revModel, this.selectedRevisionEntity);
|
|
582
|
-
desc.table.withColumnsResizable();
|
|
583
|
-
desc.table.withCurrentColumnsReorderable();
|
|
584
|
-
desc.table.withCurrentColumnsToggleable();
|
|
585
|
-
return desc;
|
|
586
|
-
}
|
|
587
|
-
createTableviewDataProvider() {
|
|
588
|
-
if (!this.revModel || !this.selectedRevisionEntity?.entityName) {
|
|
589
|
-
throw new MngInternalError('No revision model or revision entity is provided for tableview.');
|
|
590
|
-
}
|
|
591
|
-
const entityName = this.selectedRevisionEntity.entityName;
|
|
592
|
-
return TableviewDataProvider.fromClass(MngRevEntityWithId).withGetAll(qp => this.selectedRevisionEntity?.entityName
|
|
593
|
-
? this.revisionsApiService.listRevisionsWithStateForEntityType(qp, entityName).pipe(map(res => {
|
|
594
|
-
const revEntityWithStateAndIdList = [];
|
|
595
|
-
for (const revEntityWithState of res.data) {
|
|
596
|
-
const revEntityWithStateAndId = new MngRevEntityWithId();
|
|
597
|
-
revEntityWithStateAndId.mergedId = revEntityWithState.revEntity?.['rev'] + '_' + revEntityWithState.entityState?.['id'];
|
|
598
|
-
revEntityWithStateAndId.revType = revEntityWithState.revType;
|
|
599
|
-
revEntityWithStateAndId.revEntity = revEntityWithState.revEntity;
|
|
600
|
-
revEntityWithStateAndId.entityState = revEntityWithState.entityState;
|
|
601
|
-
revEntityWithStateAndId.entityClassName = revEntityWithState.entityClassName;
|
|
602
|
-
revEntityWithStateAndIdList.push(revEntityWithStateAndId);
|
|
603
|
-
}
|
|
604
|
-
return MediusQueryResult.fromArray(revEntityWithStateAndIdList, res.totalCount);
|
|
605
|
-
}))
|
|
606
|
-
: throwError(() => new MngInternalError('No revision entity is provided for list.')));
|
|
607
|
-
}
|
|
608
|
-
createActionDescriptors() {
|
|
609
|
-
if (!this.revModel || !this.selectedRevisionEntity?.entityName) {
|
|
610
|
-
throw new MngInternalError('No revision model or revision entity is provided for tableview.');
|
|
611
|
-
}
|
|
612
|
-
const entityName = this.selectedRevisionEntity.entityName;
|
|
613
|
-
const detailsAction = ActionEditorDetailsDescriptor.create(this.descriptor.detailsEditor)
|
|
614
|
-
.withFetchFunction(ctx => {
|
|
615
|
-
if (!entityName) {
|
|
616
|
-
return throwError(() => new MngInternalError('No revision entity is provided for details.'));
|
|
617
|
-
}
|
|
618
|
-
if (!ctx.parameters.itemId) {
|
|
619
|
-
return throwError(() => new MngInternalError('No item id for revision entity details is provided.'));
|
|
620
|
-
}
|
|
621
|
-
const revId = ctx.parameters.itemId.toString().split('_')[0];
|
|
622
|
-
const itemId = ctx.parameters.itemId.toString().split('_')[1];
|
|
623
|
-
return this.revisionsApiService.fetchRevisionsWithStateForEntityType(entityName, revId, itemId);
|
|
624
|
-
})
|
|
625
|
-
.withEditorTitle('pages.entityRevisions.actions.details.editor.title');
|
|
626
|
-
return [detailsAction];
|
|
627
|
-
}
|
|
628
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditEntityRevisionsPageComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
629
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditEntityRevisionsPageComponent, isStandalone: true, selector: "mng-audit-entity-revisions-page", usesInheritance: true, ngImport: i0, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [(ngModel)]=\"selectedRevisionEntity\"\n (valueChange)=\"onRevisionEntityChange()\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"></mng-dropdown>\n @if (!selectedRevisionEntity) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n", dependencies: [{ kind: "component", type: MngDropdownComponent, selector: "mng-dropdown", inputs: ["dataProvider", "options", "optionsTrackProperty", "optionsLabelProperty", "optionsLabelTranslate", "optionsValueProperty", "optionsDisabledProperty", "multiselect", "placeholder", "showClear", "selectFirstItem", "className", "dropdownClassName", "changeValueOnBlur"], outputs: ["valueChange"] }, { kind: "component", type: MngTableviewRouteComponent, selector: "mng-tableview-route", inputs: ["descriptor", "dataProvider", "actions"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: FormlyModule }] }); }
|
|
586
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditEntityRevisionsPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
587
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: AuditEntityRevisionsPageComponent, isStandalone: true, selector: "mng-audit-entity-revisions-page", providers: [AuditRevisionsApiService], ngImport: i0, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [ngModel]=\"selectedRevisionEntity()\"\n (valueChange)=\"onRevisionEntityChange($event)\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"\n [showClear]=\"true\"></mng-dropdown>\n @if (!selectedRevisionEntity()) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview() && descriptor()) {\n <mng-tableview [descriptor]=\"descriptor()!\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n", dependencies: [{ kind: "component", type: DropdownComponent, selector: "mng-dropdown", inputs: ["dataProvider", "options", "optionsTrackProperty", "optionsLabelProperty", "optionsLabelTranslate", "optionsValueProperty", "optionsDisabledProperty", "multiselect", "placeholder", "showClear", "selectFirstItem", "className", "dropdownClassName", "changeValueOnBlur"], outputs: ["valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: FormlyModule }, { kind: "component", type: TableviewComponent, selector: "mng-tableview", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
630
588
|
}
|
|
631
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type:
|
|
589
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditEntityRevisionsPageComponent, decorators: [{
|
|
632
590
|
type: Component,
|
|
633
|
-
args: [{ standalone: true, selector: 'mng-audit-entity-revisions-page', imports: [
|
|
634
|
-
}], ctorParameters: () => [
|
|
591
|
+
args: [{ standalone: true, selector: 'mng-audit-entity-revisions-page', imports: [DropdownComponent, FormsModule, AsyncPipe, TranslateModule, FormlyModule, TableviewComponent], providers: [AuditRevisionsApiService], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"card\">\n <div class=\"field mb-0\">\n <mng-dropdown\n id=\"revisionEntityDropdown\"\n [placeholder]=\"'pages.entityRevisions.dropdown.placeholder' | translate\"\n optionsLabelProperty=\"entityNameI18n\"\n [ngModel]=\"selectedRevisionEntity()\"\n (valueChange)=\"onRevisionEntityChange($event)\"\n [dataProvider]=\"revisionEntitiesLookupProvider\"\n [showClear]=\"true\"></mng-dropdown>\n @if (!selectedRevisionEntity()) {\n <small class=\"block\">\n {{ 'pages.entityRevisions.dropdown.helpText' | translate }}\n </small>\n }\n </div>\n</div>\n@if (showTableview() && descriptor()) {\n <mng-tableview [descriptor]=\"descriptor()!\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n" }]
|
|
592
|
+
}], ctorParameters: () => [] });
|
|
635
593
|
|
|
636
|
-
var
|
|
637
|
-
let
|
|
638
|
-
static {
|
|
594
|
+
var RevEntityWithChangesDto_1;
|
|
595
|
+
let RevEntityWithChangesDto = class RevEntityWithChangesDto {
|
|
596
|
+
static { RevEntityWithChangesDto_1 = this; }
|
|
639
597
|
static { this.attributeTypeMap = [
|
|
640
598
|
{
|
|
641
599
|
name: 'revEntity',
|
|
@@ -649,27 +607,27 @@ let MngRevEntityWithChangesDto = class MngRevEntityWithChangesDto {
|
|
|
649
607
|
}
|
|
650
608
|
]; }
|
|
651
609
|
static getAttributeTypeMap() {
|
|
652
|
-
return
|
|
610
|
+
return RevEntityWithChangesDto_1.attributeTypeMap;
|
|
653
611
|
}
|
|
654
612
|
};
|
|
655
|
-
|
|
613
|
+
RevEntityWithChangesDto = RevEntityWithChangesDto_1 = __decorate([
|
|
656
614
|
TypeName('MngRevEntityWithChangesDto')
|
|
657
|
-
],
|
|
658
|
-
TypeRegistry.get().registerType(
|
|
615
|
+
], RevEntityWithChangesDto);
|
|
616
|
+
TypeRegistry.get().registerType(RevEntityWithChangesDto);
|
|
659
617
|
|
|
660
|
-
let
|
|
618
|
+
let RevEntity = class RevEntity {
|
|
661
619
|
};
|
|
662
|
-
|
|
620
|
+
RevEntity = __decorate([
|
|
663
621
|
TypeName('MngRevEntity')
|
|
664
|
-
],
|
|
622
|
+
], RevEntity);
|
|
665
623
|
|
|
666
|
-
let
|
|
624
|
+
let RevEntityDetailed = class RevEntityDetailed extends RevEntity {
|
|
667
625
|
};
|
|
668
|
-
|
|
626
|
+
RevEntityDetailed = __decorate([
|
|
669
627
|
TypeName('MngRevEntityDetailed')
|
|
670
|
-
],
|
|
628
|
+
], RevEntityDetailed);
|
|
671
629
|
|
|
672
|
-
class EntityChangesFieldComponent extends
|
|
630
|
+
class EntityChangesFieldComponent extends AFormlyCustomFieldComponent {
|
|
673
631
|
constructor() {
|
|
674
632
|
super(...arguments);
|
|
675
633
|
this.destroyRef = inject(DestroyRef);
|
|
@@ -680,7 +638,7 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
|
|
|
680
638
|
ngOnInit() {
|
|
681
639
|
this.fieldValue = this.formControl.value;
|
|
682
640
|
this.injector
|
|
683
|
-
?.get(
|
|
641
|
+
?.get(AuditService, undefined, { optional: true })
|
|
684
642
|
?.auditModel$.pipe(takeUntilDestroyed(this.destroyRef))
|
|
685
643
|
.subscribe({
|
|
686
644
|
next: model => {
|
|
@@ -691,13 +649,13 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
|
|
|
691
649
|
}
|
|
692
650
|
},
|
|
693
651
|
error: err => {
|
|
694
|
-
throw new
|
|
652
|
+
throw new CommonsInternalError('Error while trying to fetch audit model from audit service', { name: 'EntityChangesFieldComponentError', cause: err });
|
|
695
653
|
}
|
|
696
654
|
});
|
|
697
655
|
}
|
|
698
656
|
createDescriptor(entityChanges) {
|
|
699
657
|
const changedFields = [];
|
|
700
|
-
if (entityChanges.items && entityChanges.items[0].revType ===
|
|
658
|
+
if (entityChanges.items && entityChanges.items[0].revType === RevisionTypeDto.Mod) {
|
|
701
659
|
for (const key in entityChanges.items[0]) {
|
|
702
660
|
if (entityChanges.items[0][key] !== entityChanges.items[1][key]) {
|
|
703
661
|
changedFields.push(key);
|
|
@@ -705,11 +663,11 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
|
|
|
705
663
|
}
|
|
706
664
|
}
|
|
707
665
|
const guiEntityModel = this.auditModel.filter(m => m.entityName === entityChanges.entityType)[0];
|
|
708
|
-
const desc = TableDescriptor.fromClass(
|
|
666
|
+
const desc = TableDescriptor.fromClass(EntityRevisionChangeState, undefined, undefined, guiEntityModel.entityName).withClassName('py-2');
|
|
709
667
|
if (guiEntityModel.entityName) {
|
|
710
668
|
desc.withTitle(guiEntityModel.entityName);
|
|
711
669
|
}
|
|
712
|
-
desc.
|
|
670
|
+
desc.addColumnEnum('revType', revisionTypeEnum).withTitle('MngEntityRevisionChangeState.properties.revType');
|
|
713
671
|
if (guiEntityModel.properties) {
|
|
714
672
|
AuditUtil.addColumnsFromModel(desc, guiEntityModel.properties, undefined, false, false);
|
|
715
673
|
}
|
|
@@ -726,83 +684,71 @@ class EntityChangesFieldComponent extends AMngFormlyCustomFieldComponent {
|
|
|
726
684
|
return desc;
|
|
727
685
|
}
|
|
728
686
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: EntityChangesFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
729
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: EntityChangesFieldComponent, isStandalone: true, selector: "mng-entity-changes-field", inputs: { injector: "injector" }, usesInheritance: true, ngImport: i0, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"], dependencies: [{ kind: "component", type:
|
|
687
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: EntityChangesFieldComponent, isStandalone: true, selector: "mng-entity-changes-field", inputs: { injector: "injector" }, usesInheritance: true, ngImport: i0, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"], dependencies: [{ kind: "component", type: TableComponent, selector: "mng-table", inputs: ["descriptor", "items", "result", "loading", "dataProvider", "useQueryParams", "selectionMode", "selectionEnabled", "columnLastMinWidth", "captionComponent", "columnCustomLastComponent", "globalFilterFields"], outputs: ["tableLoad", "cellClick", "selectionChange", "captionComponentInstance", "columnCustomLastComponentInstance"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
730
688
|
}
|
|
731
689
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: EntityChangesFieldComponent, decorators: [{
|
|
732
690
|
type: Component,
|
|
733
|
-
args: [{ standalone: true, selector: 'mng-entity-changes-field', imports: [
|
|
691
|
+
args: [{ standalone: true, selector: 'mng-entity-changes-field', imports: [TableComponent, AsyncPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (modelFetched | async) {\n <div>\n @for (ec of entityChanges; track ec) {\n <mng-table [items]=\"ec.items\" [descriptor]=\"createDescriptor(ec)\"></mng-table>\n }\n </div>\n} @else {\n <div class=\"text-center\">\n <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\n </div>\n}\n", styles: ["::ng-deep tr.audit-row-deleted{background:#ff3d331a!important}::ng-deep tr.audit-row-deleted .audit-cell{background:#f6544c4d!important}::ng-deep tr.audit-row-added{background-color:#1bc5621a!important}::ng-deep tr.audit-row-added .audit-cell{background:#1bc5624d!important}\n"] }]
|
|
734
692
|
}], propDecorators: { injector: [{
|
|
735
693
|
type: Input
|
|
736
694
|
}] } });
|
|
737
695
|
|
|
738
|
-
class
|
|
696
|
+
class AuditRevisionsPageComponent {
|
|
739
697
|
constructor() {
|
|
740
|
-
super(...arguments);
|
|
741
|
-
this.destroyRef = inject(DestroyRef);
|
|
742
698
|
this.injector = inject(Injector);
|
|
743
|
-
this.auditService = inject(
|
|
744
|
-
this.
|
|
745
|
-
this.showTableview =
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
699
|
+
this.auditService = inject(AuditService);
|
|
700
|
+
this.revModel = toSignal(this.auditService.revModel$);
|
|
701
|
+
this.showTableview = computed(() => this.revModel() != null);
|
|
702
|
+
this.descriptor = computed(() => {
|
|
703
|
+
const revModel = this.revModel();
|
|
704
|
+
if (revModel) {
|
|
705
|
+
const idProperty = revModel.properties?.filter(prop => prop.isId).map(prop => prop.resolvedPropertyName)[0];
|
|
706
|
+
const model = ModelDescriptor.fromClass(RevEntity);
|
|
707
|
+
if (revModel.entityName)
|
|
708
|
+
model.withI18nBase(revModel.entityName);
|
|
709
|
+
if (idProperty)
|
|
710
|
+
model.withIdPropertyUnsafe(idProperty);
|
|
711
|
+
const desc = TableviewDescriptor.fromModel(model);
|
|
712
|
+
const detailsDescriptor = EditorDescriptor.fromClass(RevEntityWithChangesDto, undefined, undefined, undefined, TableviewEditorTypeEnum.Details);
|
|
713
|
+
detailsDescriptor.model.withIdPropertyUnsafe('revEntity.' + idProperty);
|
|
714
|
+
if (revModel.properties) {
|
|
715
|
+
AuditUtil.addColumnsFromModel(desc.table, revModel.properties);
|
|
716
|
+
AuditUtil.addFieldsFromModel(detailsDescriptor, revModel.properties);
|
|
717
|
+
}
|
|
718
|
+
detailsDescriptor
|
|
719
|
+
.addField('entityNameChangesMap')
|
|
720
|
+
.asCustomComponent(EntityChangesFieldComponent, {
|
|
721
|
+
fieldWrappers: ['field-no-label'],
|
|
722
|
+
inputs: { injector: this.injector }
|
|
723
|
+
})
|
|
724
|
+
.withDisabled();
|
|
725
|
+
desc.withDetailsDescriptor(detailsDescriptor); // MngRevEntity is extended by MngRevEntityWithChangesDto, so no real harm here
|
|
726
|
+
return desc;
|
|
753
727
|
}
|
|
728
|
+
return TableviewDescriptor.fromClass(RevEntity);
|
|
729
|
+
});
|
|
730
|
+
this.dataProvider = signal(TableviewDataProvider.fromClassWithService(RevEntity, AuditRevisionsApiService).withGetAll((params, service) => service.getRevisionList(params).pipe(map(res => ({ data: res.data, totalCount: res.totalCount })))));
|
|
731
|
+
this.actions = computed(() => {
|
|
732
|
+
console.log(this.descriptor());
|
|
733
|
+
const detailsAction = ActionEditorDetailsDescriptor.createWithProvider(this.descriptor().detailsEditor, AuditRevisionsApiService).withFetchFunction(ctx => {
|
|
734
|
+
console.log(ctx);
|
|
735
|
+
return ctx.serviceInstance.getAllChangesForRevision(itemIdToDefined(ctx.parameters.itemId)).pipe(map(item => {
|
|
736
|
+
const revEntityWithChanges = new RevEntityDetailed();
|
|
737
|
+
revEntityWithChanges.rev = ctx.parameters.itemId;
|
|
738
|
+
revEntityWithChanges.revEntity = item.revEntity;
|
|
739
|
+
revEntityWithChanges.entityNameChangesMap = item.entityNameChangesMap;
|
|
740
|
+
return revEntityWithChanges;
|
|
741
|
+
}));
|
|
742
|
+
});
|
|
743
|
+
return [detailsAction];
|
|
754
744
|
});
|
|
755
745
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const idProperty = this.revModel.properties?.filter(prop => prop.isId).map(prop => prop.resolvedPropertyName)[0];
|
|
759
|
-
const model = ModelDescriptor.fromClass(MngRevEntity);
|
|
760
|
-
if (this.revModel.entityName)
|
|
761
|
-
model.withI18nBase(this.revModel.entityName);
|
|
762
|
-
if (idProperty)
|
|
763
|
-
model.withIdPropertyUnsafe(idProperty);
|
|
764
|
-
const desc = TableviewDescriptor.fromModel(model);
|
|
765
|
-
const detailsDescriptor = EditorDescriptor.fromClass(MngRevEntityWithChangesDto, undefined, undefined, undefined, TableviewEditorTypeEnum.Details);
|
|
766
|
-
detailsDescriptor.model.withIdPropertyUnsafe('revEntity.' + idProperty);
|
|
767
|
-
if (this.revModel.properties) {
|
|
768
|
-
AuditUtil.addColumnsFromModel(desc.table, this.revModel.properties);
|
|
769
|
-
AuditUtil.addFieldsFromModel(detailsDescriptor, this.revModel.properties);
|
|
770
|
-
}
|
|
771
|
-
detailsDescriptor
|
|
772
|
-
.addField('entityNameChangesMap')
|
|
773
|
-
.asCustomComponent(EntityChangesFieldComponent, {
|
|
774
|
-
fieldWrappers: ['field-no-label'],
|
|
775
|
-
inputs: { injector: this.injector }
|
|
776
|
-
})
|
|
777
|
-
.withDisabled();
|
|
778
|
-
desc.withDetailsDescriptor(detailsDescriptor); // MngRevEntity is extended by MngRevEntityWithChangesDto, so no real harm here
|
|
779
|
-
desc.table.withFilterDisplay(TableFilterDisplayEnum.Row);
|
|
780
|
-
return desc;
|
|
781
|
-
}
|
|
782
|
-
return TableviewDescriptor.fromClass(MngRevEntity);
|
|
783
|
-
}
|
|
784
|
-
createTableviewDataProvider() {
|
|
785
|
-
if (this.revModel) {
|
|
786
|
-
return TableviewDataProvider.fromClass(MngRevEntity).withGetAll(qp => this.revisisonsApiService.getRevisionList(qp).pipe(map(res => MediusQueryResult.fromArray(res.data, res.totalCount))));
|
|
787
|
-
}
|
|
788
|
-
return TableviewDataProvider.fromClass(MngRevEntity);
|
|
789
|
-
}
|
|
790
|
-
createActionDescriptors() {
|
|
791
|
-
const detailsAction = ActionEditorDetailsDescriptor.create(this.descriptor.detailsEditor).withFetchFunction(ctx => this.revisisonsApiService.getAllChangesForRevision(itemIdToDefined(ctx.parameters.itemId)).pipe(map(item => {
|
|
792
|
-
const revEntityWithChanges = new MngRevEntityDetailed();
|
|
793
|
-
revEntityWithChanges.rev = ctx.parameters.itemId;
|
|
794
|
-
revEntityWithChanges.revEntity = item.revEntity;
|
|
795
|
-
revEntityWithChanges.entityNameChangesMap = item.entityNameChangesMap;
|
|
796
|
-
return revEntityWithChanges;
|
|
797
|
-
})));
|
|
798
|
-
return [detailsAction];
|
|
799
|
-
}
|
|
800
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: MngAuditRevisionsPageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
801
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: MngAuditRevisionsPageComponent, isStandalone: true, selector: "mng-audit-revisions-page", usesInheritance: true, ngImport: i0, template: "@if (showTableview()) {\n <mng-tableview-route [descriptor]=\"descriptor\" [dataProvider]=\"dataProvider\" [actions]=\"actions\"></mng-tableview-route>\n}\n", dependencies: [{ kind: "component", type: MngTableviewRouteComponent, selector: "mng-tableview-route", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
746
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditRevisionsPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
747
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.2.1", type: AuditRevisionsPageComponent, isStandalone: true, selector: "mng-audit-revisions-page", providers: [AuditRevisionsApiService], ngImport: i0, template: "@if (showTableview()) {\n <mng-tableview [descriptor]=\"descriptor()\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n", dependencies: [{ kind: "component", type: TableviewComponent, selector: "mng-tableview", inputs: ["descriptor", "dataProvider", "actions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
802
748
|
}
|
|
803
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type:
|
|
749
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: AuditRevisionsPageComponent, decorators: [{
|
|
804
750
|
type: Component,
|
|
805
|
-
args: [{ standalone: true, selector: 'mng-audit-revisions-page', imports: [
|
|
751
|
+
args: [{ standalone: true, selector: 'mng-audit-revisions-page', imports: [TableviewComponent, AsyncPipe, RouterOutlet, JsonPipe], providers: [AuditRevisionsApiService], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (showTableview()) {\n <mng-tableview [descriptor]=\"descriptor()\" [dataProvider]=\"dataProvider()\" [actions]=\"actions()\"></mng-tableview>\n}\n" }]
|
|
806
752
|
}] });
|
|
807
753
|
|
|
808
754
|
/**
|
|
@@ -810,33 +756,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
810
756
|
* @param config Module config for audit section.
|
|
811
757
|
* @param routeConfig Optionally provide route configs.
|
|
812
758
|
*/
|
|
813
|
-
function
|
|
814
|
-
const routeBuilder = RouteBuilder.create('', config.rootPageComponent ??
|
|
815
|
-
.withProvider(
|
|
816
|
-
.withProvider(MngAuditService)
|
|
817
|
-
.withProvider(MngAuditRevisionsApiService)
|
|
759
|
+
function provideAuditRoutes(config, routeConfig) {
|
|
760
|
+
const routeBuilder = RouteBuilder.create('', config.rootPageComponent ?? AuditPageComponent)
|
|
761
|
+
.withProvider(AuditService)
|
|
818
762
|
.withProvider({
|
|
819
|
-
provide:
|
|
763
|
+
provide: COMMONS_AUDIT_MODULE_CONFIG_IT,
|
|
820
764
|
useValue: config
|
|
821
765
|
})
|
|
822
766
|
.addChildBuilder(RouteBuilder.createRedirect('', routeConfig?.defaultRedirect ?? 'revisions', 'full'));
|
|
823
767
|
if (routeConfig?.preRevisionRoutes?.length) {
|
|
824
768
|
routeConfig.preRevisionRoutes.forEach(r => routeBuilder.addChildBuilder(r));
|
|
825
769
|
}
|
|
826
|
-
const revisionsRouteBuilder = TableviewRouteBuilder.fromComponent('revisions', config.revisionsPageComponent ??
|
|
770
|
+
const revisionsRouteBuilder = TableviewRouteBuilder.fromComponent('revisions', config.revisionsPageComponent ?? AuditRevisionsPageComponent)
|
|
827
771
|
.withTitle('pages.revisions.title')
|
|
828
772
|
.withAdd(false)
|
|
829
773
|
.withDelete(false)
|
|
830
774
|
.withEdit(false);
|
|
831
775
|
if (routeConfig?.revisionsMenuItem) {
|
|
832
|
-
revisionsRouteBuilder.
|
|
776
|
+
revisionsRouteBuilder.withCommonsMenuItem(routeConfig.revisionsMenuItem);
|
|
833
777
|
}
|
|
834
778
|
else {
|
|
835
779
|
revisionsRouteBuilder.withMenuItem('pi pi-book', 'pages.revisions.title');
|
|
836
780
|
}
|
|
837
|
-
const entityRevisionsRouteBuilder = RouteBuilder.create('entity-revisions', config.entityRevisionsPageComponent ??
|
|
781
|
+
const entityRevisionsRouteBuilder = RouteBuilder.create('entity-revisions', config.entityRevisionsPageComponent ?? AuditEntityRevisionsPageComponent).withTitle('pages.entityRevisions.title');
|
|
838
782
|
if (routeConfig?.entityRevisionsMenuItem) {
|
|
839
|
-
entityRevisionsRouteBuilder.
|
|
783
|
+
entityRevisionsRouteBuilder.withCommonsMenuItem(routeConfig.entityRevisionsMenuItem);
|
|
840
784
|
}
|
|
841
785
|
else {
|
|
842
786
|
entityRevisionsRouteBuilder.withMenuItem('pi pi-building', 'pages.entityRevisions.title');
|
|
@@ -844,7 +788,7 @@ function provideMngAuditRoutes(config, routeConfig) {
|
|
|
844
788
|
routeBuilder
|
|
845
789
|
.addChildBuilder(revisionsRouteBuilder)
|
|
846
790
|
.addChildBuilder(entityRevisionsRouteBuilder)
|
|
847
|
-
.addChildBuilder(TableviewRouteBuilder.fromComponent('entity-revisions/:entityClass', config.entityRevisionsPageComponent ??
|
|
791
|
+
.addChildBuilder(TableviewRouteBuilder.fromComponent('entity-revisions/:entityClass', config.entityRevisionsPageComponent ?? AuditEntityRevisionsPageComponent).withTitle('pages.entityRevisions.title'));
|
|
848
792
|
if (routeConfig?.postRevisionRoutes?.length) {
|
|
849
793
|
routeConfig.postRevisionRoutes.forEach(r => routeBuilder.addChildBuilder(r));
|
|
850
794
|
}
|
|
@@ -855,5 +799,5 @@ function provideMngAuditRoutes(config, routeConfig) {
|
|
|
855
799
|
* Generated bundle index. Do not edit.
|
|
856
800
|
*/
|
|
857
801
|
|
|
858
|
-
export {
|
|
802
|
+
export { AuditEntityRevisionsPageComponent, AuditPageComponent, AuditRevisionsPageComponent, EntityChangesFieldComponent, provideAuditRoutes };
|
|
859
803
|
//# sourceMappingURL=mediusinc-mng-commons-audit.mjs.map
|