@techextensor/tab-core-utility 2.1.5 → 2.1.7
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/.eslintrc.json +92 -0
- package/README.md +7 -0
- package/jest.config.ts +22 -0
- package/ng-package.json +7 -0
- package/package.json +18 -31
- package/project.json +42 -0
- package/{index.d.ts → src/index.ts} +77 -53
- package/src/lib/tab-core-utility/app/constants/api-constants.ts +33 -0
- package/src/lib/tab-core-utility/app/constants/common.ts +34 -0
- package/src/lib/tab-core-utility/app/constants/error-messages.ts +21 -0
- package/src/lib/tab-core-utility/app/constants/storage-constants.ts +17 -0
- package/src/lib/tab-core-utility/app/crud/tab-delete.service.ts +144 -0
- package/src/lib/tab-core-utility/app/crud/tab-get.service.ts +160 -0
- package/src/lib/tab-core-utility/app/crud/tab-insert.service.ts +75 -0
- package/src/lib/tab-core-utility/app/crud/tab-update.service.ts +105 -0
- package/src/lib/tab-core-utility/app/crud/tab-workflow.service.ts +39 -0
- package/src/lib/tab-core-utility/app/enums/controllers.enum.ts +24 -0
- package/src/lib/tab-core-utility/app/enums/dsq.enum.ts +46 -0
- package/src/lib/tab-core-utility/app/enums/permission.enum.ts +18 -0
- package/src/lib/tab-core-utility/app/enums/query.enum.ts +12 -0
- package/src/lib/tab-core-utility/app/enums/workflow.enum.ts +35 -0
- package/src/lib/tab-core-utility/app/helpers/common/app.helpers.ts +65 -0
- package/src/lib/tab-core-utility/app/helpers/common/dsq.helpers.ts +80 -0
- package/src/lib/tab-core-utility/app/helpers/common/req-res.helpers.ts +75 -0
- package/src/lib/tab-core-utility/app/helpers/common/where-clause.helpers.ts +262 -0
- package/src/lib/tab-core-utility/app/helpers/screen/forms.helpers.ts +33 -0
- package/src/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.ts +88 -0
- package/src/lib/tab-core-utility/app/helpers/screen/grid.helpers.ts +113 -0
- package/src/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.ts +74 -0
- package/src/lib/tab-core-utility/app/helpers/screen/plugin.helpers.ts +52 -0
- package/src/lib/tab-core-utility/app/helpers/screen/screen.helpers.ts +20 -0
- package/{lib/tab-core-utility/app/interfaces/auth.interface.d.ts → src/lib/tab-core-utility/app/interfaces/auth.interface.ts} +18 -15
- package/src/lib/tab-core-utility/app/interfaces/common-api.interface.ts +27 -0
- package/src/lib/tab-core-utility/app/interfaces/grid.interface.ts +118 -0
- package/src/lib/tab-core-utility/app/interfaces/orgInfo.interface.ts +34 -0
- package/src/lib/tab-core-utility/app/interfaces/schema.interface.ts +11 -0
- package/src/lib/tab-core-utility/app/interfaces/user.interface.ts +91 -0
- package/src/lib/tab-core-utility/app/models/api-query.class.ts +92 -0
- package/src/lib/tab-core-utility/app/models/app-object.class.ts +87 -0
- package/src/lib/tab-core-utility/app/models/common.class.ts +30 -0
- package/src/lib/tab-core-utility/app/models/data-source-queries.class.ts +114 -0
- package/src/lib/tab-core-utility/app/utils/filter.util.ts +78 -0
- package/src/lib/tab-core-utility/app/utils/form-builder.util.ts +31 -0
- package/src/lib/tab-core-utility/app/utils/json.util.ts +137 -0
- package/src/lib/tab-core-utility/app/utils/operators.util.ts +129 -0
- package/src/lib/tab-core-utility/app/utils/req-res.util.ts +189 -0
- package/src/lib/tab-core-utility/app/utils/tab-app.util.ts +131 -0
- package/src/lib/tab-core-utility/auth/auth.service.spec.ts +167 -0
- package/src/lib/tab-core-utility/auth/auth.service.ts +91 -0
- package/src/lib/tab-core-utility/auth/idb-storage.service.ts +77 -0
- package/src/lib/tab-core-utility/auth/local-storage.service.spec.ts +47 -0
- package/src/lib/tab-core-utility/auth/local-storage.service.ts +46 -0
- package/src/lib/tab-core-utility/auth/session-storage.service.spec.ts +47 -0
- package/src/lib/tab-core-utility/auth/session-storage.service.ts +46 -0
- package/src/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.ts +32 -0
- package/src/lib/tab-core-utility/core/error-handler/error-handler.store.spec.ts +16 -0
- package/src/lib/tab-core-utility/core/error-handler/error-handler.store.ts +26 -0
- package/src/lib/tab-core-utility/core/error-handler/models/error-handler.state.ts +9 -0
- package/src/lib/tab-core-utility/core/http-client/api-url.token.ts +4 -0
- package/src/lib/tab-core-utility/core/http-client/api.service.spec.ts +18 -0
- package/src/lib/tab-core-utility/core/http-client/api.service.ts +105 -0
- package/src/lib/tab-core-utility/core/util/auth.utils.ts +22 -0
- package/src/lib/tab-core-utility/store/auth.store.ts +54 -0
- package/src/lib/tab-core-utility/store/orginfo.store.ts +57 -0
- package/src/lib/tab-core-utility/store/schema.store.ts +85 -0
- package/src/test-setup.ts +8 -0
- package/tsconfig.json +29 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +7 -0
- package/tsconfig.spec.json +16 -0
- package/esm2022/index.mjs +0 -64
- package/esm2022/lib/tab-core-utility/app/constants/api-constants.mjs +0 -33
- package/esm2022/lib/tab-core-utility/app/constants/common.mjs +0 -23
- package/esm2022/lib/tab-core-utility/app/constants/error-messages.mjs +0 -13
- package/esm2022/lib/tab-core-utility/app/constants/storage-constants.mjs +0 -15
- package/esm2022/lib/tab-core-utility/app/crud/tab-delete.service.mjs +0 -145
- package/esm2022/lib/tab-core-utility/app/crud/tab-get.service.mjs +0 -131
- package/esm2022/lib/tab-core-utility/app/crud/tab-insert.service.mjs +0 -77
- package/esm2022/lib/tab-core-utility/app/crud/tab-update.service.mjs +0 -105
- package/esm2022/lib/tab-core-utility/app/crud/tab-workflow.service.mjs +0 -43
- package/esm2022/lib/tab-core-utility/app/enums/controllers.enum.mjs +0 -26
- package/esm2022/lib/tab-core-utility/app/enums/dsq.enum.mjs +0 -48
- package/esm2022/lib/tab-core-utility/app/enums/permission.enum.mjs +0 -20
- package/esm2022/lib/tab-core-utility/app/enums/query.enum.mjs +0 -14
- package/esm2022/lib/tab-core-utility/app/enums/workflow.enum.mjs +0 -37
- package/esm2022/lib/tab-core-utility/app/helpers/common/app.helpers.mjs +0 -68
- package/esm2022/lib/tab-core-utility/app/helpers/common/dsq.helpers.mjs +0 -70
- package/esm2022/lib/tab-core-utility/app/helpers/common/req-res.helpers.mjs +0 -64
- package/esm2022/lib/tab-core-utility/app/helpers/common/where-clause.helpers.mjs +0 -208
- package/esm2022/lib/tab-core-utility/app/helpers/screen/forms.helpers.mjs +0 -38
- package/esm2022/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.mjs +0 -78
- package/esm2022/lib/tab-core-utility/app/helpers/screen/grid.helpers.mjs +0 -112
- package/esm2022/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.mjs +0 -77
- package/esm2022/lib/tab-core-utility/app/helpers/screen/plugin.helpers.mjs +0 -55
- package/esm2022/lib/tab-core-utility/app/helpers/screen/screen.helpers.mjs +0 -26
- package/esm2022/lib/tab-core-utility/app/interfaces/auth.interface.mjs +0 -2
- package/esm2022/lib/tab-core-utility/app/interfaces/common-api.interface.mjs +0 -2
- package/esm2022/lib/tab-core-utility/app/interfaces/grid.interface.mjs +0 -3
- package/esm2022/lib/tab-core-utility/app/interfaces/orgInfo.interface.mjs +0 -2
- package/esm2022/lib/tab-core-utility/app/interfaces/schema.interface.mjs +0 -2
- package/esm2022/lib/tab-core-utility/app/interfaces/user.interface.mjs +0 -2
- package/esm2022/lib/tab-core-utility/app/models/api-query.class.mjs +0 -47
- package/esm2022/lib/tab-core-utility/app/models/app-object.class.mjs +0 -30
- package/esm2022/lib/tab-core-utility/app/models/common.class.mjs +0 -12
- package/esm2022/lib/tab-core-utility/app/models/data-source-queries.class.mjs +0 -31
- package/esm2022/lib/tab-core-utility/app/utils/filter.util.mjs +0 -75
- package/esm2022/lib/tab-core-utility/app/utils/form-builder.util.mjs +0 -39
- package/esm2022/lib/tab-core-utility/app/utils/json.util.mjs +0 -138
- package/esm2022/lib/tab-core-utility/app/utils/operators.util.mjs +0 -129
- package/esm2022/lib/tab-core-utility/app/utils/req-res.util.mjs +0 -147
- package/esm2022/lib/tab-core-utility/app/utils/tab-app.util.mjs +0 -99
- package/esm2022/lib/tab-core-utility/auth/auth.service.mjs +0 -74
- package/esm2022/lib/tab-core-utility/auth/idb-storage.service.mjs +0 -69
- package/esm2022/lib/tab-core-utility/auth/local-storage.service.mjs +0 -52
- package/esm2022/lib/tab-core-utility/auth/session-storage.service.mjs +0 -52
- package/esm2022/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.mjs +0 -26
- package/esm2022/lib/tab-core-utility/core/error-handler/error-handler.store.mjs +0 -21
- package/esm2022/lib/tab-core-utility/core/error-handler/models/error-handler.state.mjs +0 -5
- package/esm2022/lib/tab-core-utility/core/http-client/api-url.token.mjs +0 -4
- package/esm2022/lib/tab-core-utility/core/http-client/api.service.mjs +0 -99
- package/esm2022/lib/tab-core-utility/core/util/auth.utils.mjs +0 -21
- package/esm2022/lib/tab-core-utility/store/auth.store.mjs +0 -43
- package/esm2022/lib/tab-core-utility/store/orginfo.store.mjs +0 -42
- package/esm2022/lib/tab-core-utility/store/schema.store.mjs +0 -68
- package/esm2022/techextensor-tab-core-utility.mjs +0 -5
- package/lib/tab-core-utility/app/constants/api-constants.d.ts +0 -30
- package/lib/tab-core-utility/app/constants/common.d.ts +0 -8
- package/lib/tab-core-utility/app/constants/error-messages.d.ts +0 -6
- package/lib/tab-core-utility/app/constants/storage-constants.d.ts +0 -14
- package/lib/tab-core-utility/app/crud/tab-delete.service.d.ts +0 -51
- package/lib/tab-core-utility/app/crud/tab-get.service.d.ts +0 -58
- package/lib/tab-core-utility/app/crud/tab-insert.service.d.ts +0 -37
- package/lib/tab-core-utility/app/crud/tab-update.service.d.ts +0 -14
- package/lib/tab-core-utility/app/crud/tab-workflow.service.d.ts +0 -20
- package/lib/tab-core-utility/app/enums/controllers.enum.d.ts +0 -24
- package/lib/tab-core-utility/app/enums/dsq.enum.d.ts +0 -42
- package/lib/tab-core-utility/app/enums/permission.enum.d.ts +0 -16
- package/lib/tab-core-utility/app/enums/query.enum.d.ts +0 -11
- package/lib/tab-core-utility/app/enums/workflow.enum.d.ts +0 -30
- package/lib/tab-core-utility/app/helpers/common/app.helpers.d.ts +0 -31
- package/lib/tab-core-utility/app/helpers/common/dsq.helpers.d.ts +0 -32
- package/lib/tab-core-utility/app/helpers/common/req-res.helpers.d.ts +0 -62
- package/lib/tab-core-utility/app/helpers/common/where-clause.helpers.d.ts +0 -82
- package/lib/tab-core-utility/app/helpers/screen/forms.helpers.d.ts +0 -11
- package/lib/tab-core-utility/app/helpers/screen/grid-column-data.helpers.d.ts +0 -33
- package/lib/tab-core-utility/app/helpers/screen/grid.helpers.d.ts +0 -63
- package/lib/tab-core-utility/app/helpers/screen/media-upload.helpers.d.ts +0 -38
- package/lib/tab-core-utility/app/helpers/screen/plugin.helpers.d.ts +0 -25
- package/lib/tab-core-utility/app/helpers/screen/screen.helpers.d.ts +0 -11
- package/lib/tab-core-utility/app/interfaces/common-api.interface.d.ts +0 -24
- package/lib/tab-core-utility/app/interfaces/grid.interface.d.ts +0 -110
- package/lib/tab-core-utility/app/interfaces/orgInfo.interface.d.ts +0 -31
- package/lib/tab-core-utility/app/interfaces/schema.interface.d.ts +0 -11
- package/lib/tab-core-utility/app/interfaces/user.interface.d.ts +0 -84
- package/lib/tab-core-utility/app/models/api-query.class.d.ts +0 -69
- package/lib/tab-core-utility/app/models/app-object.class.d.ts +0 -74
- package/lib/tab-core-utility/app/models/common.class.d.ts +0 -24
- package/lib/tab-core-utility/app/models/data-source-queries.class.d.ts +0 -95
- package/lib/tab-core-utility/app/utils/filter.util.d.ts +0 -30
- package/lib/tab-core-utility/app/utils/form-builder.util.d.ts +0 -13
- package/lib/tab-core-utility/app/utils/json.util.d.ts +0 -25
- package/lib/tab-core-utility/app/utils/operators.util.d.ts +0 -21
- package/lib/tab-core-utility/app/utils/req-res.util.d.ts +0 -61
- package/lib/tab-core-utility/app/utils/tab-app.util.d.ts +0 -48
- package/lib/tab-core-utility/auth/auth.service.d.ts +0 -53
- package/lib/tab-core-utility/auth/idb-storage.service.d.ts +0 -14
- package/lib/tab-core-utility/auth/local-storage.service.d.ts +0 -22
- package/lib/tab-core-utility/auth/session-storage.service.d.ts +0 -22
- package/lib/tab-core-utility/core/error-handler/error-handler-interceptor.service.d.ts +0 -3
- package/lib/tab-core-utility/core/error-handler/error-handler.store.d.ts +0 -10
- package/lib/tab-core-utility/core/error-handler/models/error-handler.state.d.ts +0 -5
- package/lib/tab-core-utility/core/http-client/api-url.token.d.ts +0 -3
- package/lib/tab-core-utility/core/http-client/api.service.d.ts +0 -65
- package/lib/tab-core-utility/core/util/auth.utils.d.ts +0 -9
- package/lib/tab-core-utility/store/auth.store.d.ts +0 -19
- package/lib/tab-core-utility/store/orginfo.store.d.ts +0 -22
- package/lib/tab-core-utility/store/schema.store.d.ts +0 -32
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable } from '@angular/core';
|
|
4
|
+
import { APIFilterCriteria, APIValueSets } from '../../models/api-query.class';
|
|
5
|
+
import { QueryType } from '../../enums/query.enum';
|
|
6
|
+
@Injectable({ providedIn: 'root' })
|
|
7
|
+
export class RequestResponseHelper {
|
|
8
|
+
/**
|
|
9
|
+
* Generates the payload for inserting data into a table
|
|
10
|
+
* @param table The table name to insert data into
|
|
11
|
+
* @param whereClause The filter criteria for the insert operation
|
|
12
|
+
* @param value The value sets to be inserted
|
|
13
|
+
* @returns The payload for the insert operation
|
|
14
|
+
*/
|
|
15
|
+
insertPayload(
|
|
16
|
+
table: string,
|
|
17
|
+
whereClause: APIFilterCriteria,
|
|
18
|
+
value: APIValueSets[]
|
|
19
|
+
) {
|
|
20
|
+
return this.createPayload(table, whereClause, value, QueryType.Insert);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generates the payload for deleting data from a table
|
|
25
|
+
* @param tableName The table name to delete data from
|
|
26
|
+
* @param whereClause The filter criteria for the delete operation
|
|
27
|
+
* @returns The payload for the delete operation
|
|
28
|
+
*/
|
|
29
|
+
deletePayload(tableName: string, whereClause: APIFilterCriteria) {
|
|
30
|
+
return {
|
|
31
|
+
QueryObjectID: tableName,
|
|
32
|
+
QueryType: QueryType.Delete,
|
|
33
|
+
Joins: [],
|
|
34
|
+
WhereClause: whereClause,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generates the payload for updating data in a table
|
|
40
|
+
* @param tableName The table name to update data in
|
|
41
|
+
* @param whereClause The filter criteria for the update operation
|
|
42
|
+
* @param value The value sets to be updated
|
|
43
|
+
* @returns The payload for the update operation
|
|
44
|
+
*/
|
|
45
|
+
updateRequestPayload(
|
|
46
|
+
tableName: string,
|
|
47
|
+
whereClause: APIFilterCriteria,
|
|
48
|
+
value: APIValueSets[]
|
|
49
|
+
) {
|
|
50
|
+
return this.createPayload(tableName, whereClause, value, QueryType.Update);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Creates a payload object based on the input parameters
|
|
55
|
+
* @param table The table name for the payload
|
|
56
|
+
* @param whereClause The filter criteria for the payload
|
|
57
|
+
* @param value The value sets for the payload
|
|
58
|
+
* @param queryType The type of query for the payload
|
|
59
|
+
* @returns The payload object with QueryObjectID, QueryType, Joins, WhereClause, and Values
|
|
60
|
+
*/
|
|
61
|
+
createPayload(
|
|
62
|
+
table: string,
|
|
63
|
+
whereClause: APIFilterCriteria,
|
|
64
|
+
value: APIValueSets[],
|
|
65
|
+
queryType: QueryType
|
|
66
|
+
) {
|
|
67
|
+
return {
|
|
68
|
+
QueryObjectID: table,
|
|
69
|
+
QueryType: queryType,
|
|
70
|
+
Joins: [],
|
|
71
|
+
WhereClause: whereClause,
|
|
72
|
+
Values: value,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable } from '@angular/core';
|
|
4
|
+
import { from } from 'rxjs';
|
|
5
|
+
import { filter, map, toArray } from 'rxjs/operators';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ConjuctionClause,
|
|
9
|
+
RelationalOperator,
|
|
10
|
+
FilterValueType,
|
|
11
|
+
} from '../../enums/dsq.enum';
|
|
12
|
+
import { APIFilterCriteria } from '../../models/api-query.class';
|
|
13
|
+
import {
|
|
14
|
+
getAppObjectFromSystemDBTableName,
|
|
15
|
+
getAppObject,
|
|
16
|
+
} from '../../utils/tab-app.util';
|
|
17
|
+
|
|
18
|
+
@Injectable({ providedIn: 'root' })
|
|
19
|
+
export class WhereClauseHelper {
|
|
20
|
+
/**
|
|
21
|
+
* Binds the where clause for deleting records based on field, value, field name, and CRUD table name
|
|
22
|
+
* @param fields The fields to bind the where clause
|
|
23
|
+
* @param value The value to match in the where clause
|
|
24
|
+
* @param fieldName The field name to match in the where clause
|
|
25
|
+
* @param crudTableName The CRUD table name for the where clause
|
|
26
|
+
* @returns The bound where clause for delete operation
|
|
27
|
+
*/
|
|
28
|
+
bindWhereClauseForDelete(
|
|
29
|
+
fields: any,
|
|
30
|
+
value: any,
|
|
31
|
+
fieldName: string,
|
|
32
|
+
crudTableName: string
|
|
33
|
+
) {
|
|
34
|
+
const appobj = getAppObjectFromSystemDBTableName(crudTableName);
|
|
35
|
+
if (appobj && appobj.CRUDAppObjectId !== null) {
|
|
36
|
+
const crudAppObj = getAppObject(appobj.CRUDAppObjectId);
|
|
37
|
+
if (crudAppObj) {
|
|
38
|
+
crudTableName = crudAppObj.SystemDBTableName;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return this.bindWhereClause(fields, value, fieldName, crudTableName);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Binds the where clause for deleting records with multiple primary keys
|
|
46
|
+
* @param data The data containing primary key values
|
|
47
|
+
* @param fieldName The field name of the primary key
|
|
48
|
+
* @param crudTableName The CRUD table name for the where clause
|
|
49
|
+
* @returns The bound where clause for delete operation with multiple primary keys
|
|
50
|
+
*/
|
|
51
|
+
bindWhereClauseForDeleteWithMultiplePrimaryKeys(
|
|
52
|
+
data: any,
|
|
53
|
+
fieldName: string,
|
|
54
|
+
crudTableName: string
|
|
55
|
+
) {
|
|
56
|
+
return this.bindWhereClauseForMultiplePrimaryKeys(
|
|
57
|
+
data,
|
|
58
|
+
fieldName,
|
|
59
|
+
crudTableName
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Binds the where clause for an insert operation
|
|
65
|
+
* @returns The bound where clause for insert operation
|
|
66
|
+
*/
|
|
67
|
+
bindWhereClauseForInsert() {
|
|
68
|
+
return this.bindWhereClauseEmpty();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Binds an empty where clause
|
|
73
|
+
* @returns The bound empty where clause
|
|
74
|
+
*/
|
|
75
|
+
bindWhereClauseEmpty() {
|
|
76
|
+
const whereClause = new APIFilterCriteria();
|
|
77
|
+
whereClause.FilterLogic = '1';
|
|
78
|
+
whereClause.Filters = [];
|
|
79
|
+
return whereClause;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Binds the where clause based on provided parameters
|
|
84
|
+
* @param fields The fields to bind the where clause
|
|
85
|
+
* @param value The value to match in the where clause
|
|
86
|
+
* @param fieldName The field name to match in the where clause
|
|
87
|
+
* @param crudTableName The CRUD table name for the where clause
|
|
88
|
+
* @returns The bound where clause
|
|
89
|
+
*/
|
|
90
|
+
private bindWhereClause(
|
|
91
|
+
fields: any,
|
|
92
|
+
value: any,
|
|
93
|
+
fieldName: string,
|
|
94
|
+
crudTableName: string
|
|
95
|
+
) {
|
|
96
|
+
return from(fields).pipe(
|
|
97
|
+
filter((f: any) =>
|
|
98
|
+
fieldName
|
|
99
|
+
? f.Field?.FieldName === fieldName
|
|
100
|
+
: f.Field?.FieldName === 'Id' || f.Field?.FieldName === 'ID'
|
|
101
|
+
),
|
|
102
|
+
map((field: any) => ({
|
|
103
|
+
ConjuctionClause: ConjuctionClause.AND,
|
|
104
|
+
FieldID: crudTableName + '.' + field.Field.SystemDBFieldName,
|
|
105
|
+
RelationalOperator: RelationalOperator.EqualTo,
|
|
106
|
+
ValueType: FilterValueType.Literal,
|
|
107
|
+
value: value,
|
|
108
|
+
Sequence: 0,
|
|
109
|
+
GroupID: 0,
|
|
110
|
+
})),
|
|
111
|
+
toArray(),
|
|
112
|
+
map((filters: any[]) => {
|
|
113
|
+
const whereClause = new APIFilterCriteria();
|
|
114
|
+
whereClause.Filters = filters;
|
|
115
|
+
whereClause.FilterLogic = '1';
|
|
116
|
+
return whereClause;
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Binds the where clause for deleting records with multiple primary keys
|
|
123
|
+
* @param data The data containing primary key values
|
|
124
|
+
* @param primaryKeys The array of primary key fields
|
|
125
|
+
* @param crudTableName The CRUD table name for the where clause
|
|
126
|
+
* @returns The bound where clause for delete operation with multiple primary keys
|
|
127
|
+
*/
|
|
128
|
+
bindWhereClauseForMultiplePrimaryKeys(
|
|
129
|
+
data: any,
|
|
130
|
+
primaryKeys: any,
|
|
131
|
+
crudTableName: string
|
|
132
|
+
) {
|
|
133
|
+
const whereClause = new APIFilterCriteria();
|
|
134
|
+
whereClause.Filters = [];
|
|
135
|
+
if (primaryKeys && primaryKeys.length > 0) {
|
|
136
|
+
primaryKeys.forEach((element: any) => {
|
|
137
|
+
const value = data[element.FieldName];
|
|
138
|
+
if (value) {
|
|
139
|
+
const filter: any = {
|
|
140
|
+
ConjuctionClause: ConjuctionClause.AND,
|
|
141
|
+
FieldID: crudTableName + '.' + element.SystemDBFieldName,
|
|
142
|
+
RelationalOperator: RelationalOperator.EqualTo,
|
|
143
|
+
ValueType: FilterValueType.Literal,
|
|
144
|
+
value: value,
|
|
145
|
+
Sequence: 0,
|
|
146
|
+
GroupID: 0,
|
|
147
|
+
};
|
|
148
|
+
whereClause.Filters.push(filter);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
whereClause.FilterLogic = '1';
|
|
153
|
+
return whereClause;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Binds the where clause for updating records
|
|
158
|
+
* @param tableName The name of the table to update
|
|
159
|
+
* @param queryFieldsArray The array of fields and values for the update query
|
|
160
|
+
* @returns The bound where clause for update operation
|
|
161
|
+
*/
|
|
162
|
+
bindWhereClauseForUpdate(tableName: string, queryFieldsArray: any) {
|
|
163
|
+
const whereClause = new APIFilterCriteria();
|
|
164
|
+
whereClause.Filters = [];
|
|
165
|
+
if (queryFieldsArray.length) {
|
|
166
|
+
queryFieldsArray.forEach((element: any) => {
|
|
167
|
+
const filter: any = {
|
|
168
|
+
ConjuctionClause: ConjuctionClause.AND,
|
|
169
|
+
FieldID: tableName + '.' + element.FieldName,
|
|
170
|
+
RelationalOperator: RelationalOperator.EqualTo,
|
|
171
|
+
ValueType: FilterValueType.Literal,
|
|
172
|
+
value: element.FieldValue,
|
|
173
|
+
Sequence: 0,
|
|
174
|
+
GroupID: 0,
|
|
175
|
+
};
|
|
176
|
+
whereClause.Filters.push(filter);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
whereClause.FilterLogic = '1';
|
|
180
|
+
return whereClause;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Binds the where clause for deleting records by table and primary key
|
|
185
|
+
* @param tableName The name of the table from which to delete records
|
|
186
|
+
* @param primaryKey The name of the primary key field
|
|
187
|
+
* @param primaryKeyValue The value of the primary key
|
|
188
|
+
* @returns The bound where clause for delete operation using table and primary key
|
|
189
|
+
*/
|
|
190
|
+
bindWhereClauseForDeleteByTable(
|
|
191
|
+
tableName: string,
|
|
192
|
+
primaryKey: string,
|
|
193
|
+
primaryKeyValue: string
|
|
194
|
+
) {
|
|
195
|
+
const whereClause = new APIFilterCriteria();
|
|
196
|
+
whereClause.Filters = [];
|
|
197
|
+
const filter: any = {
|
|
198
|
+
ConjuctionClause: ConjuctionClause.AND,
|
|
199
|
+
FieldID: tableName + '.' + primaryKey,
|
|
200
|
+
RelationalOperator: RelationalOperator.EqualTo,
|
|
201
|
+
ValueType: FilterValueType.Literal,
|
|
202
|
+
value: primaryKeyValue,
|
|
203
|
+
Sequence: 0,
|
|
204
|
+
GroupID: 0,
|
|
205
|
+
};
|
|
206
|
+
whereClause.Filters.push(filter);
|
|
207
|
+
whereClause.FilterLogic = '1';
|
|
208
|
+
return whereClause;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Binds the where clause for deleting records using IN operator by table
|
|
213
|
+
* @param tableName The name of the table from which to delete records
|
|
214
|
+
* @param primaryKey The name of the primary key field
|
|
215
|
+
* @param values The array of values for the IN operator
|
|
216
|
+
* @returns The bound where clause for delete operation using IN operator and table
|
|
217
|
+
*/
|
|
218
|
+
bindWhereClauseForDeleteUsingInOperatorByTable(
|
|
219
|
+
tableName: string,
|
|
220
|
+
primaryKey: string,
|
|
221
|
+
values: []
|
|
222
|
+
) {
|
|
223
|
+
const appobj = getAppObjectFromSystemDBTableName(tableName);
|
|
224
|
+
if (appobj?.CRUDAppObjectId !== null) {
|
|
225
|
+
const crudAppObj = getAppObject(appobj.CRUDAppObjectId);
|
|
226
|
+
if (crudAppObj) {
|
|
227
|
+
tableName = crudAppObj.SystemDBTableName;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const whereClause = new APIFilterCriteria();
|
|
231
|
+
whereClause.Filters = [];
|
|
232
|
+
const filter: any = {
|
|
233
|
+
ConjuctionClause: ConjuctionClause.AND,
|
|
234
|
+
FieldID: tableName + '.' + primaryKey,
|
|
235
|
+
RelationalOperator: RelationalOperator.IN,
|
|
236
|
+
ValueType: FilterValueType.Literal,
|
|
237
|
+
value: values.join(','),
|
|
238
|
+
Sequence: 0,
|
|
239
|
+
GroupID: 0,
|
|
240
|
+
};
|
|
241
|
+
whereClause.Filters.push(filter);
|
|
242
|
+
whereClause.FilterLogic = '1';
|
|
243
|
+
return whereClause;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Binds the where clause for updating records in a grid
|
|
248
|
+
* @param Fields The fields to bind the where clause
|
|
249
|
+
* @param value The value to match in the where clause
|
|
250
|
+
* @param fieldName The field name to match in the where clause
|
|
251
|
+
* @param crudTableName The CRUD table name for the where clause
|
|
252
|
+
* @returns The bound where clause for update operation in a grid
|
|
253
|
+
*/
|
|
254
|
+
bindWhereClauseForUpdateGrid(
|
|
255
|
+
Fields: any,
|
|
256
|
+
value: any,
|
|
257
|
+
fieldName: string,
|
|
258
|
+
crudTableName: string
|
|
259
|
+
) {
|
|
260
|
+
return this.bindWhereClause(Fields, value, fieldName, crudTableName);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
@Injectable({ providedIn: 'root' })
|
|
6
|
+
export class FormDataHelper {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sets form data based on the provided data object.
|
|
10
|
+
* @param data$ An Observable emitting the data object containing form data.
|
|
11
|
+
* @returns An Observable emitting an object containing the modified form data.
|
|
12
|
+
*/
|
|
13
|
+
setFormData(data: any) {
|
|
14
|
+
const objNew: any = {};
|
|
15
|
+
if (!!data && !!data.Result) {
|
|
16
|
+
Object.entries(data.Result[0]).forEach(([key, value]) => {
|
|
17
|
+
if (key !== undefined) {
|
|
18
|
+
if (typeof value === 'number') {
|
|
19
|
+
value = value.toString();
|
|
20
|
+
}
|
|
21
|
+
if (key == 'Logo') {
|
|
22
|
+
if (value !== '' && value !== null && value !== undefined) {
|
|
23
|
+
// Additional handling can be added here if necessary
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
objNew[key] = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return objNew;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable, inject } from '@angular/core';
|
|
4
|
+
import { of } from 'rxjs';
|
|
5
|
+
import { map } from 'rxjs/operators';
|
|
6
|
+
import { ColumnDetailModel } from '../../interfaces/grid.interface';
|
|
7
|
+
import { GridHelper } from './grid.helpers';
|
|
8
|
+
|
|
9
|
+
@Injectable({ providedIn: 'root' })
|
|
10
|
+
export class GridColumnDataHelper {
|
|
11
|
+
private readonly gridHelper = inject(GridHelper);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves column data based on the provided fields.
|
|
15
|
+
* @param fields The fields to generate column data from.
|
|
16
|
+
* @returns An Observable emitting an array of column data.
|
|
17
|
+
*/
|
|
18
|
+
getColumnData(fields: any) {
|
|
19
|
+
return of(fields).pipe(
|
|
20
|
+
map((fields: any[]) => {
|
|
21
|
+
return fields.map((field) => this.mapToColumnDetailModel(field));
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Maps field data to a ColumnDetailModel.
|
|
28
|
+
* @param field The field data to map.
|
|
29
|
+
* @returns The mapped ColumnDetailModel.
|
|
30
|
+
*/
|
|
31
|
+
private mapToColumnDetailModel(field: any): ColumnDetailModel {
|
|
32
|
+
const columnD: ColumnDetailModel = {
|
|
33
|
+
text: field?.Field?.DisplayName,
|
|
34
|
+
dataField: field?.Field?.FieldName,
|
|
35
|
+
columntype: this.gridHelper.getColumnType(
|
|
36
|
+
field?.Field?.FieldType?.DataType
|
|
37
|
+
),
|
|
38
|
+
appFieldId: field?.Field?.ID,
|
|
39
|
+
seq: field?.SeqNo,
|
|
40
|
+
isPrimaryKey: field?.Field?.IsPrimaryKey,
|
|
41
|
+
SystemDBFieldName: field?.Field?.SystemDBFieldName,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (field?.FieldType == 2) {
|
|
45
|
+
columnD.dataField = field?.LookupDetails?.replaceAll('.', '_');
|
|
46
|
+
columnD.dataField = field?.FieldDetails?.replaceAll('.', '_');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (field && field?.Field_GridAttributes) {
|
|
50
|
+
const attr = JSON.parse(field?.Field_GridAttributes);
|
|
51
|
+
Object.assign(columnD, attr);
|
|
52
|
+
if (!!attr.cellsrenderer && attr.cellsrenderer !== '') {
|
|
53
|
+
columnD.cellsrenderer = this.getRendererValue(attr.cellsrenderer);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (field && field?.Field?.LookUpDetails) {
|
|
58
|
+
columnD.LookUpDetails = field?.Field?.LookUpDetails;
|
|
59
|
+
columnD.dropDownLookup = field?.Field?.dropDownData;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return columnD;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the renderer value based on the provided key.
|
|
67
|
+
* @param key The key to retrieve the renderer value for.
|
|
68
|
+
* @returns The renderer value.
|
|
69
|
+
*/
|
|
70
|
+
private getRendererValue(key: string) {
|
|
71
|
+
return key && key === 'LINKRENDERER' ? this.rowLinkRenderer : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Renderer function for rendering row links.
|
|
76
|
+
* @param row The row number.
|
|
77
|
+
* @param column The column information.
|
|
78
|
+
* @param value The value to render.
|
|
79
|
+
* @returns The HTML string for rendering the row link.
|
|
80
|
+
*/
|
|
81
|
+
private rowLinkRenderer = (
|
|
82
|
+
row: number,
|
|
83
|
+
column: any,
|
|
84
|
+
value: string
|
|
85
|
+
): string => {
|
|
86
|
+
return ` <a data-row='${row}' style='cursor:pointer;' column-name='${column}' action='redirect' class='Link_click' >${value}</a>`;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { AppObject } from '../../models/app-object.class';
|
|
4
|
+
import { getDsqIDFromQueryName } from '../../utils/tab-app.util';
|
|
5
|
+
import { of } from 'rxjs';
|
|
6
|
+
import { Common } from '../../constants/common';
|
|
7
|
+
import { JqWidghtModel } from '../../interfaces/grid.interface';
|
|
8
|
+
|
|
9
|
+
@Injectable({ providedIn: 'root' })
|
|
10
|
+
export class GridHelper {
|
|
11
|
+
/**
|
|
12
|
+
* Generates a grid schema for the master app object.
|
|
13
|
+
* @param masterAppObj The master app object.
|
|
14
|
+
* @param dsqID The data source query ID.
|
|
15
|
+
* @returns The generated grid schema.
|
|
16
|
+
*/
|
|
17
|
+
generateGridSchema(masterAppObj: AppObject, dsqID: any) {
|
|
18
|
+
const schema = {
|
|
19
|
+
label: masterAppObj?.SystemDBTableName,
|
|
20
|
+
type: 'customGrid',
|
|
21
|
+
key: masterAppObj?.SystemDBTableName,
|
|
22
|
+
input: true,
|
|
23
|
+
redrawOn: masterAppObj?.SystemDBTableName,
|
|
24
|
+
'customOptions.dataSourceQueryId': dsqID,
|
|
25
|
+
};
|
|
26
|
+
return schema;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generates a grid schema for the child relationship.
|
|
31
|
+
* @param childRel The child relationship.
|
|
32
|
+
* @param masterAppObj The master app object.
|
|
33
|
+
* @returns The generated child grid schema.
|
|
34
|
+
*/
|
|
35
|
+
generateChildGridSchema(childRel: any, masterAppObj: AppObject) {
|
|
36
|
+
const dsqNameString =
|
|
37
|
+
'FK_' +
|
|
38
|
+
childRel.childDetails.LookupObject +
|
|
39
|
+
'_' +
|
|
40
|
+
masterAppObj.SystemDBTableName;
|
|
41
|
+
const dsqObject = getDsqIDFromQueryName(
|
|
42
|
+
childRel.childDetails.LookupObject,
|
|
43
|
+
dsqNameString
|
|
44
|
+
);
|
|
45
|
+
if (dsqObject) {
|
|
46
|
+
return {
|
|
47
|
+
label: childRel?.childDetails?.LookupObject,
|
|
48
|
+
type: 'customGrid',
|
|
49
|
+
key: childRel?.childDetails?.LookupObject,
|
|
50
|
+
input: true,
|
|
51
|
+
redrawOn: masterAppObj?.SystemDBTableName,
|
|
52
|
+
'customOptions.dataSourceQueryId': dsqObject ? dsqObject.ID : '',
|
|
53
|
+
logic: [
|
|
54
|
+
{
|
|
55
|
+
name: 'Update Fields',
|
|
56
|
+
trigger: {
|
|
57
|
+
type: 'javascript',
|
|
58
|
+
javascript: 'result=true;',
|
|
59
|
+
},
|
|
60
|
+
actions: [
|
|
61
|
+
{
|
|
62
|
+
name:
|
|
63
|
+
'Refresh ' + childRel?.childDetails?.LookupObject + ' Grid',
|
|
64
|
+
type: 'property',
|
|
65
|
+
property: {
|
|
66
|
+
label: 'parameters',
|
|
67
|
+
value: 'customOptions.parameters',
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
70
|
+
text: '{{data.' + masterAppObj?.SystemDBTableName + '}}',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return of({});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves the default grid configuration.
|
|
82
|
+
* @returns The default grid configuration.
|
|
83
|
+
*/
|
|
84
|
+
getDefaultGridConfiguration(): JqWidghtModel | null {
|
|
85
|
+
const tabData: any = Common.tabJson;
|
|
86
|
+
if (tabData) {
|
|
87
|
+
const configuration = tabData?.AppConfigurations.find(
|
|
88
|
+
(c: any) => c.Setting_Key === 'GridConfig'
|
|
89
|
+
);
|
|
90
|
+
if (configuration) {
|
|
91
|
+
return JSON.parse(configuration.Value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Determines the column type based on the data type.
|
|
99
|
+
* @param dataType The data type.
|
|
100
|
+
* @returns The column type.
|
|
101
|
+
*/
|
|
102
|
+
getColumnType(dataType: number): string {
|
|
103
|
+
if (dataType === 1 || (dataType >= 7 && dataType === 15)) return 'string';
|
|
104
|
+
else if (dataType === 2 || dataType === 4 || dataType === 16)
|
|
105
|
+
return 'number';
|
|
106
|
+
else if (dataType === 3) return 'boolean';
|
|
107
|
+
else if (dataType === 4 || (dataType >= 7 && dataType <= 15))
|
|
108
|
+
return 'string';
|
|
109
|
+
else if (dataType === 5) return 'date';
|
|
110
|
+
else if (dataType === 6) return 'dateTime';
|
|
111
|
+
else return 'string';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable, inject } from '@angular/core';
|
|
4
|
+
import { ApiService } from '../../../core/http-client/api.service';
|
|
5
|
+
import { getHeaders } from '../../utils/req-res.util';
|
|
6
|
+
import { Observable, of } from 'rxjs';
|
|
7
|
+
import { API } from '../../constants/api-constants';
|
|
8
|
+
@Injectable({ providedIn: 'root' })
|
|
9
|
+
export class MediaUploadHelper {
|
|
10
|
+
private readonly apiService = inject(ApiService);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Uploads media object to the server.
|
|
14
|
+
* @param mediaObject The media object to upload.
|
|
15
|
+
* @returns An Observable that emits the response from the server.
|
|
16
|
+
*/
|
|
17
|
+
uploadMediaFile(mediaObject: any): Observable<any> {
|
|
18
|
+
const headers = getHeaders();
|
|
19
|
+
if (headers) {
|
|
20
|
+
return this.apiService.post(`${API.fileUpload}`, mediaObject, headers);
|
|
21
|
+
}
|
|
22
|
+
return of(null);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a file from the server by its media ID.
|
|
27
|
+
* @param mediaId The ID of the media file to retrieve.
|
|
28
|
+
* @returns An Observable that emits the file as a Blob.
|
|
29
|
+
*/
|
|
30
|
+
getFileByMediaId(mediaId: number, params?: any): Observable<Blob> {
|
|
31
|
+
const headers = getHeaders();
|
|
32
|
+
if (headers) {
|
|
33
|
+
return this.apiService.getBlob(`${API.getMediaFile}?mediaId=${mediaId}`, params, headers);
|
|
34
|
+
}
|
|
35
|
+
return of();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Downloads all files from the given URL.
|
|
40
|
+
* @param endPointName The URL to download files from.
|
|
41
|
+
* @returns An Observable that emits the downloaded files as a Blob.
|
|
42
|
+
*/
|
|
43
|
+
downloadAllFiles(endPointName: any): Observable<Blob> {
|
|
44
|
+
return this.apiService.getBlob(endPointName);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Downloads PDF files from the given URL.
|
|
49
|
+
* @param endPointName The URL to download PDF files from.
|
|
50
|
+
* @param data The data to send along with the request.
|
|
51
|
+
* @returns An Observable that emits the downloaded PDF files as a Blob.
|
|
52
|
+
*/
|
|
53
|
+
downloadPdfFiles(endPointName: any, data: any): Observable<Blob> {
|
|
54
|
+
const headers = getHeaders();
|
|
55
|
+
if (headers) {
|
|
56
|
+
return this.apiService.postBlob(endPointName, data, headers);
|
|
57
|
+
}
|
|
58
|
+
return of();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves an image from the server by its media ID.
|
|
63
|
+
* @param mediaId The ID of the media file to retrieve.
|
|
64
|
+
* @returns An Observable that emits the image as a Blob.
|
|
65
|
+
*/
|
|
66
|
+
getImageByMediaId(mediaId: any, params?: any): Observable<Blob> {
|
|
67
|
+
const headers = getHeaders();
|
|
68
|
+
if (headers) {
|
|
69
|
+
const endPointName = `${API.getImage}?mediaId=${mediaId}`;
|
|
70
|
+
return this.apiService.get<Blob>(endPointName, params, headers);
|
|
71
|
+
}
|
|
72
|
+
return of();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { Injectable, inject } from '@angular/core';
|
|
4
|
+
import { Observable, of } from 'rxjs';
|
|
5
|
+
import { ApiService } from '../../../core/http-client/api.service';
|
|
6
|
+
import { getHeaders } from '../../utils/req-res.util';
|
|
7
|
+
import { API } from '../../constants/api-constants';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@Injectable({ providedIn: 'root' })
|
|
11
|
+
export class PluginHelper {
|
|
12
|
+
private readonly apiService = inject(ApiService);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Uploads a plugin object to the server.
|
|
16
|
+
* @param pluginObject The plugin object to upload.
|
|
17
|
+
* @returns An Observable emitting the response from the server.
|
|
18
|
+
*/
|
|
19
|
+
uploadPlugin(pluginObject: any): Observable<any> {
|
|
20
|
+
const headers = getHeaders();
|
|
21
|
+
if (headers) {
|
|
22
|
+
return this.apiService.post(`${API.pluginUpload}`, pluginObject, headers);
|
|
23
|
+
}
|
|
24
|
+
return of(null);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves a file from the server by its ID.
|
|
29
|
+
* @param Id The ID of the file to retrieve.
|
|
30
|
+
* @returns An Observable emitting the file as a Blob.
|
|
31
|
+
*/
|
|
32
|
+
getFile(Id: number, params?: any): Observable<Blob> {
|
|
33
|
+
const headers = getHeaders();
|
|
34
|
+
if (headers) {
|
|
35
|
+
return this.apiService.getBlob(`${API.getFile}?Id=${Id}`, params, headers);
|
|
36
|
+
}
|
|
37
|
+
return of();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves all plugins by their type from the server.
|
|
42
|
+
* @param pluginType The type of plugins to retrieve.
|
|
43
|
+
* @returns An Observable emitting the response from the server.
|
|
44
|
+
*/
|
|
45
|
+
getAll(pluginType: number, params?: any): Observable<any> {
|
|
46
|
+
const headers = getHeaders();
|
|
47
|
+
if (headers) {
|
|
48
|
+
return this.apiService.get(`${API.getAllPluginByType}?PluginTypeId=${pluginType}`, params, headers);
|
|
49
|
+
}
|
|
50
|
+
return of();
|
|
51
|
+
}
|
|
52
|
+
}
|