rez_core 2.0.88 → 2.0.89
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/dist/module/layout_preference/controller/layout_preference.controller.d.ts +3 -0
- package/dist/module/layout_preference/controller/layout_preference.controller.js +15 -0
- package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.d.ts +4 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +38 -2
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/layout_preference/controller/layout_preference.controller.ts +18 -9
- package/src/module/layout_preference/service/layout_preference.service.ts +59 -1
|
@@ -5,4 +5,7 @@ export declare class LayoutPreferenceController {
|
|
|
5
5
|
getFilterById(entity_type: string, req: Request & {
|
|
6
6
|
user: any;
|
|
7
7
|
}): Promise<import("../entity/layout_preference.entity").LayoutPreference | null>;
|
|
8
|
+
getColumnValues(entity_type: string, column: string, sort_by: string, req: Request & {
|
|
9
|
+
user: any;
|
|
10
|
+
}): Promise<string[]>;
|
|
8
11
|
}
|
|
@@ -24,6 +24,10 @@ let LayoutPreferenceController = class LayoutPreferenceController {
|
|
|
24
24
|
const userId = req.user.userData.id;
|
|
25
25
|
return this.layoutPreferenceService.getLayoutPreferenceByUserID(userId, entity_type);
|
|
26
26
|
}
|
|
27
|
+
async getColumnValues(entity_type, column, sort_by, req) {
|
|
28
|
+
const userId = req.user.userData.id;
|
|
29
|
+
return this.layoutPreferenceService.getColumnValue(entity_type, column, sort_by);
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
exports.LayoutPreferenceController = LayoutPreferenceController;
|
|
29
33
|
__decorate([
|
|
@@ -35,6 +39,17 @@ __decorate([
|
|
|
35
39
|
__metadata("design:paramtypes", [String, Object]),
|
|
36
40
|
__metadata("design:returntype", Promise)
|
|
37
41
|
], LayoutPreferenceController.prototype, "getFilterById", null);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, common_1.Get)('column'),
|
|
44
|
+
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
45
|
+
__param(0, (0, common_1.Query)('entity_type')),
|
|
46
|
+
__param(1, (0, common_1.Query)('column')),
|
|
47
|
+
__param(2, (0, common_1.Query)('sort_by')),
|
|
48
|
+
__param(3, (0, common_1.Req)()),
|
|
49
|
+
__metadata("design:type", Function),
|
|
50
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
51
|
+
__metadata("design:returntype", Promise)
|
|
52
|
+
], LayoutPreferenceController.prototype, "getColumnValues", null);
|
|
38
53
|
exports.LayoutPreferenceController = LayoutPreferenceController = __decorate([
|
|
39
54
|
(0, common_1.Controller)('layout-preference'),
|
|
40
55
|
__param(0, (0, common_1.Inject)('LayoutPreferenceService')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout_preference.controller.js","sourceRoot":"","sources":["../../../../src/module/layout_preference/controller/layout_preference.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"layout_preference.controller.js","sourceRoot":"","sources":["../../../../src/module/layout_preference/controller/layout_preference.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgF;AAChF,oFAA+E;AAC/E,2DAAgE;AAGzD,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YAEmB,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;IAChE,CAAC;IAIE,AAAN,KAAK,CAAC,aAAa,CACK,WAAmB,EAClC,GAA4B;QAEnC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAEpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,2BAA2B,CAC7D,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,eAAe,CACG,WAAmB,EACxB,MAAc,EACb,OAAe,EAC1B,GAA4B;QAEnC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAEpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAChD,WAAW,EACX,MAAM,EACN,OAAO,CACR,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,gEAA0B;AAQ/B;IAFL,IAAA,YAAG,EAAC,EAAE,CAAC;IACP,IAAA,kBAAS,EAAC,wBAAY,CAAC;IAErB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;IACpB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;+DAQP;AAIK;IAFL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,kBAAS,EAAC,wBAAY,CAAC;IAErB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;IACpB,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;iEASP;qCAnCU,0BAA0B;IADtC,IAAA,mBAAU,EAAC,mBAAmB,CAAC;IAG3B,WAAA,IAAA,eAAM,EAAC,yBAAyB,CAAC,CAAA;qCACQ,mDAAuB;GAHxD,0BAA0B,CAoCtC"}
|
|
@@ -2,9 +2,12 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
3
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
4
|
import { LayoutPreferenceRepository } from '../repository/layout_preference.repository';
|
|
5
|
+
import { DataSource } from 'typeorm';
|
|
5
6
|
export declare class LayoutPreferenceService extends EntityServiceImpl {
|
|
6
7
|
private layoutPreferenceRepository;
|
|
7
|
-
|
|
8
|
+
private readonly dataSource;
|
|
9
|
+
constructor(layoutPreferenceRepository: LayoutPreferenceRepository, dataSource: DataSource);
|
|
8
10
|
createEntity(entityData: BaseEntity, loggedInUser: UserData | null): Promise<any>;
|
|
9
11
|
getLayoutPreferenceByUserID(user_id: any, mapped_entity_type: any): Promise<import("../entity/layout_preference.entity").LayoutPreference | null>;
|
|
12
|
+
getColumnValue(entity_type: string, column: string, sort_by: string): Promise<string[]>;
|
|
10
13
|
}
|
|
@@ -13,10 +13,12 @@ exports.LayoutPreferenceService = void 0;
|
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
|
|
15
15
|
const layout_preference_repository_1 = require("../repository/layout_preference.repository");
|
|
16
|
+
const typeorm_1 = require("typeorm");
|
|
16
17
|
let LayoutPreferenceService = class LayoutPreferenceService extends entity_service_impl_service_1.EntityServiceImpl {
|
|
17
|
-
constructor(layoutPreferenceRepository) {
|
|
18
|
+
constructor(layoutPreferenceRepository, dataSource) {
|
|
18
19
|
super();
|
|
19
20
|
this.layoutPreferenceRepository = layoutPreferenceRepository;
|
|
21
|
+
this.dataSource = dataSource;
|
|
20
22
|
}
|
|
21
23
|
async createEntity(entityData, loggedInUser) {
|
|
22
24
|
const { mapped_entity_type } = entityData;
|
|
@@ -33,10 +35,44 @@ let LayoutPreferenceService = class LayoutPreferenceService extends entity_servi
|
|
|
33
35
|
async getLayoutPreferenceByUserID(user_id, mapped_entity_type) {
|
|
34
36
|
return await this.layoutPreferenceRepository.findByEntityUserId(mapped_entity_type, user_id);
|
|
35
37
|
}
|
|
38
|
+
async getColumnValue(entity_type, column, sort_by) {
|
|
39
|
+
const getTableMeta = await this.entityTableService.findByEntityTypeAndListTypeAndDisplayType(entity_type, entity_type, 'LIST');
|
|
40
|
+
const tableName = getTableMeta?.data_source;
|
|
41
|
+
if (!tableName) {
|
|
42
|
+
throw new Error('Invalid or missing table name in metadata');
|
|
43
|
+
}
|
|
44
|
+
const rawData = await this.dataSource
|
|
45
|
+
.createQueryBuilder()
|
|
46
|
+
.select(`${column} AS column_value`)
|
|
47
|
+
.addSelect(`COUNT(*) AS count`)
|
|
48
|
+
.from(tableName, tableName)
|
|
49
|
+
.groupBy(column)
|
|
50
|
+
.getRawMany();
|
|
51
|
+
const result = Object.fromEntries(rawData.map((row) => [row.column_value, Number(row.count)]));
|
|
52
|
+
let entries = Object.entries(result);
|
|
53
|
+
switch (sort_by) {
|
|
54
|
+
case 'asc':
|
|
55
|
+
entries.sort(([a], [b]) => a.localeCompare(b));
|
|
56
|
+
break;
|
|
57
|
+
case 'dsc':
|
|
58
|
+
entries.sort(([a], [b]) => b.localeCompare(a));
|
|
59
|
+
break;
|
|
60
|
+
case 'count_asc':
|
|
61
|
+
entries.sort(([, countA], [, countB]) => countA - countB);
|
|
62
|
+
break;
|
|
63
|
+
case 'count_dsc':
|
|
64
|
+
entries.sort(([, countA], [, countB]) => countB - countA);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return entries.map(([value]) => value);
|
|
70
|
+
}
|
|
36
71
|
};
|
|
37
72
|
exports.LayoutPreferenceService = LayoutPreferenceService;
|
|
38
73
|
exports.LayoutPreferenceService = LayoutPreferenceService = __decorate([
|
|
39
74
|
(0, common_1.Injectable)(),
|
|
40
|
-
__metadata("design:paramtypes", [layout_preference_repository_1.LayoutPreferenceRepository
|
|
75
|
+
__metadata("design:paramtypes", [layout_preference_repository_1.LayoutPreferenceRepository,
|
|
76
|
+
typeorm_1.DataSource])
|
|
41
77
|
], LayoutPreferenceService);
|
|
42
78
|
//# sourceMappingURL=layout_preference.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout_preference.service.js","sourceRoot":"","sources":["../../../../src/module/layout_preference/service/layout_preference.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,gGAAwF;AAExF,6FAAwF;
|
|
1
|
+
{"version":3,"file":"layout_preference.service.js","sourceRoot":"","sources":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