tsv2-library 1.0.61-alpha.99 → 1.0.61-beta.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/dist/node_modules/@googlemaps/js-api-loader/src/deprecated.d.ts +7 -0
- package/dist/node_modules/@googlemaps/js-api-loader/src/index.d.ts +52 -0
- package/dist/node_modules/@googlemaps/js-api-loader/src/messages.d.ts +9 -0
- package/dist/src/build-entry.d.ts +4 -3
- package/dist/src/components/v2/CustomColumn/CustomColumn.vue.d.ts +10 -0
- package/dist/src/components/v2/CustomColumn/DialogColumnSetup.vue.d.ts +4 -0
- package/dist/src/components/v2/DataTable/DataTable.vue.d.ts +22 -2
- package/dist/src/components/v2/DialogCoordinate/AssetList.vue.d.ts +4 -0
- package/dist/src/components/v2/DialogCoordinate/AssetListFilter.vue.d.ts +4 -0
- package/dist/src/components/v2/DialogCoordinate/DialogCoordinate.vue.d.ts +99 -0
- package/dist/src/components/v2/DialogCoordinate/FullscreenToggle.vue.d.ts +4 -0
- package/dist/src/components/v2/DialogCoordinate/MapSearch.vue.d.ts +15 -0
- package/dist/src/components/v2/DialogCoordinate/Marker.vue.d.ts +13 -0
- package/dist/src/components/v2/DialogCoordinate/PopupDetail.vue.d.ts +13 -0
- package/dist/src/components/v2/DialogCoordinate/services/googleMapsService.d.ts +10 -0
- package/dist/src/components/v2/DialogCoordinate/services/openStreetMapService.d.ts +59 -0
- package/dist/src/components/v2/DialogForm/DialogForm.vue.d.ts +6 -0
- package/dist/src/components/v2/DisposalReport/DisposalReportTable.vue.d.ts +8 -0
- package/dist/src/components/v2/Icon/Icon.vue.d.ts +11 -0
- package/dist/src/components/v2/InputCoordinate/InputCoordinate.vue.d.ts +64 -0
- package/dist/src/components/v2/InputText/InputText.vue.d.ts +6 -0
- package/dist/src/components/v2/LazyLoadTrigger/LazyLoadTrigger.vue.d.ts +4 -0
- package/dist/src/components/v2/TransactionRoles/TransactionRoles.vue.d.ts +1 -0
- package/dist/src/components/v2/index.d.ts +3 -1
- package/dist/src/dto/assets.dto.d.ts +15 -0
- package/dist/src/event-bus/index.d.ts +8 -0
- package/dist/src/event-bus/mitt.d.ts +26 -0
- package/dist/src/presets/multiselect/index.js +1 -0
- package/dist/src/presets/paginator/index.js +1 -1
- package/dist/src/services/assets.service.d.ts +6 -2
- package/dist/src/services/column.service.d.ts +13 -0
- package/dist/src/types/assets.type.d.ts +24 -6
- package/dist/src/utils/changelog.util.d.ts +69 -0
- package/dist/src/utils/createVueControl.d.ts +8 -0
- package/dist/src/utils/customMarker.util.d.ts +64 -0
- package/dist/src/utils/debounce.util.d.ts +1 -0
- package/dist/src/utils/exportToExcel.util.d.ts +1 -0
- package/dist/src/utils/googleMapLoader.util.d.ts +1 -0
- package/dist/src/utils/index.d.ts +4 -2
- package/dist/src/utils/textFormater.util.d.ts +3 -0
- package/dist/style.css +1 -1
- package/dist/tsv2-library.es.js +5739 -1972
- package/dist/tsv2-library.umd.js +7 -7
- package/package.json +4 -1
- package/src/components/v2/CustomColumn/CustomColumn.vue.d.ts +10 -0
- package/src/components/v2/DataTable/DataTable.vue.d.ts +22 -2
- package/src/components/v2/DialogCoordinate/DialogCoordinate.vue.d.ts +99 -0
- package/src/components/v2/DialogForm/DialogForm.vue.d.ts +6 -0
- package/src/components/v2/Icon/Icon.vue.d.ts +11 -0
- package/src/components/v2/InputCoordinate/InputCoordinate.vue.d.ts +64 -0
- package/src/components/v2/InputText/InputText.vue.d.ts +6 -0
- package/src/components/v2/TransactionRoles/TransactionRoles.vue.d.ts +1 -0
- package/src/presets/multiselect/index.js +1 -0
- package/src/presets/paginator/index.js +1 -1
- package/src/services/assets.service.ts +40 -1
- package/src/services/column.service.ts +42 -0
- package/dist/src/components/v2/DataTable/store/dataTable.store.d.ts +0 -22
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsv2-library",
|
|
3
3
|
"author": "fixedassetv2-fe",
|
|
4
|
-
"version": "1.0.61-
|
|
4
|
+
"version": "1.0.61-beta.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"homepage": "https://github.com/fixedassetv2-fe/tsv2-library#readme",
|
|
7
7
|
"repository": {
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"cy:test-all": "npm run tailwind && start-server-and-test dev cy:run-e2e && npm run cy:run-ct"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@googlemaps/js-api-loader": "^2.0.2",
|
|
42
|
+
"@googlemaps/markerclusterer": "^2.6.2",
|
|
43
|
+
"@types/google.maps": "^3.58.1",
|
|
41
44
|
"@types/lodash": "^4.17.7",
|
|
42
45
|
"@vueuse/core": "^10.7.2",
|
|
43
46
|
"axios": "^1.3.4",
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { ClassComponent } from '../ts-helpers';
|
|
2
2
|
|
|
3
|
+
export interface DataTableColumnConfig {
|
|
4
|
+
field: string;
|
|
5
|
+
pinned: boolean;
|
|
6
|
+
width: number | string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export interface CustomColumnProps {
|
|
4
11
|
tableId: string;
|
|
12
|
+
tableKey: string;
|
|
13
|
+
tableName: string;
|
|
14
|
+
tableData: Data[] | undefined;
|
|
5
15
|
defaultColumns: TableColumn[];
|
|
6
16
|
visibleColumns: TableColumn[];
|
|
7
17
|
/**
|
|
@@ -9,11 +9,21 @@ export type QueryParams = {
|
|
|
9
9
|
[key: string]: unknown;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export type FetchResponse = {
|
|
13
|
-
data:
|
|
12
|
+
export type FetchResponse<T = Data> = {
|
|
13
|
+
data: T[];
|
|
14
14
|
totalRecords: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
export type TableFetchResponse<T = Data> = {
|
|
18
|
+
message: string;
|
|
19
|
+
data: FetchResponse<T>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ShortFetchResponse<T = Data> = {
|
|
23
|
+
message: string;
|
|
24
|
+
data: T;
|
|
25
|
+
};
|
|
26
|
+
|
|
17
27
|
export type TableCellComponent = {
|
|
18
28
|
component: string | Component;
|
|
19
29
|
props?: object;
|
|
@@ -149,8 +159,14 @@ export type TableColumn = {
|
|
|
149
159
|
reorderable?: boolean;
|
|
150
160
|
/**
|
|
151
161
|
* Make the column cannot reordered by disabled dragability.
|
|
162
|
+
* Unlike `reorderable`, the column will still appear in the column visibility
|
|
163
|
+
* overlay if this is set to false.
|
|
152
164
|
*/
|
|
153
165
|
dragable?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether the column is pinned to the left of the table.
|
|
168
|
+
*/
|
|
169
|
+
pinned?: boolean;
|
|
154
170
|
fixed?: boolean;
|
|
155
171
|
visible?: boolean;
|
|
156
172
|
/**
|
|
@@ -468,6 +484,10 @@ export interface TSDataTableProps {
|
|
|
468
484
|
* The return value is added to the row's :classes array (see Vue.js class bindings).
|
|
469
485
|
*/
|
|
470
486
|
rowClass?: (data: any) => string | object | undefined;
|
|
487
|
+
/**
|
|
488
|
+
* An array of arrays to display in the exported excel file before the main data.
|
|
489
|
+
*/
|
|
490
|
+
preContentData?: (string | number)[][];
|
|
471
491
|
}
|
|
472
492
|
|
|
473
493
|
export type TSDataTableEmits = {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type MapEngine = 'leaflet' | 'maplibre' | 'openlayers' | 'google';
|
|
2
|
+
|
|
3
|
+
export interface RasterSource {
|
|
4
|
+
type: 'raster';
|
|
5
|
+
urlTemplate: string;
|
|
6
|
+
attribution?: string;
|
|
7
|
+
maxZoom?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface MapLibreStyleSource {
|
|
11
|
+
type: 'maplibre-style';
|
|
12
|
+
styleUrl: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OpenLayersOsmSource {
|
|
16
|
+
type: 'openlayers-osm';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GoogleMapsSource {
|
|
20
|
+
type: 'google';
|
|
21
|
+
mapId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type BaseMapSource =
|
|
25
|
+
| RasterSource
|
|
26
|
+
| MapLibreStyleSource
|
|
27
|
+
| OpenLayersOsmSource
|
|
28
|
+
| GoogleMapsSource;
|
|
29
|
+
|
|
30
|
+
export interface BaseMapMarker {
|
|
31
|
+
id?: string | number;
|
|
32
|
+
lat: number;
|
|
33
|
+
lng: number;
|
|
34
|
+
popup?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface LatLngValue {
|
|
38
|
+
lat: number | null;
|
|
39
|
+
lng: number | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CoordinateValue extends LatLngValue {
|
|
43
|
+
address?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type InputMapMode = 'click' | 'drag' | 'center';
|
|
47
|
+
|
|
48
|
+
export type MarkerConfig =
|
|
49
|
+
| {
|
|
50
|
+
kind: 'pin';
|
|
51
|
+
pinOptions?: google.maps.marker.PinElementOptions;
|
|
52
|
+
title?: string;
|
|
53
|
+
}
|
|
54
|
+
| {
|
|
55
|
+
kind: 'img';
|
|
56
|
+
src: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
}
|
|
59
|
+
| {
|
|
60
|
+
kind: 'svgString';
|
|
61
|
+
svg: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
}
|
|
64
|
+
| {
|
|
65
|
+
kind: 'customElement';
|
|
66
|
+
createElement: () => HTMLElement;
|
|
67
|
+
title?: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export interface MapControl {
|
|
71
|
+
position?: google.maps.ControlPosition;
|
|
72
|
+
index?: number;
|
|
73
|
+
createElement: (ctx: { map: google.maps.Map }) => HTMLElement;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface MapFocusConfig {
|
|
77
|
+
name: string;
|
|
78
|
+
featureType: google.maps.FeatureType;
|
|
79
|
+
featureStyleOptions: google.maps.FeatureStyleOptions;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DialogCoordinateProps {
|
|
83
|
+
value?: LatLngValue & { _id?: string };
|
|
84
|
+
center?: [number, number];
|
|
85
|
+
zoom?: number;
|
|
86
|
+
mode?: InputMapMode;
|
|
87
|
+
colorScheme?: 'LIGHT' | 'DARK';
|
|
88
|
+
mapOptions?: google.maps.MapOptions;
|
|
89
|
+
customMarkers?: CustomMarker[];
|
|
90
|
+
inputMarkerConfig?: MarkerConfig;
|
|
91
|
+
type: 'input' | 'detail';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface CustomMarker {
|
|
95
|
+
lat: number;
|
|
96
|
+
lng: number;
|
|
97
|
+
title?: string;
|
|
98
|
+
desc?: string;
|
|
99
|
+
}
|
|
@@ -122,6 +122,12 @@ export interface DialogFormProps extends FormProps {
|
|
|
122
122
|
* The severity will determine the dialog icons and color scheme.
|
|
123
123
|
*/
|
|
124
124
|
severity?: 'success' | 'danger' | 'primary';
|
|
125
|
+
maskClass?: string | string[];
|
|
126
|
+
/**
|
|
127
|
+
* Whether to automatically manage layering.
|
|
128
|
+
* @defaultValue true
|
|
129
|
+
*/
|
|
130
|
+
autoZIndex?: boolean | undefined;
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
export interface ConfirmSlots {
|
|
@@ -20,10 +20,12 @@ export type TSVueIcons =
|
|
|
20
20
|
| 'arrow-left-right'
|
|
21
21
|
| 'arrow-right'
|
|
22
22
|
| 'arrow-right-fill'
|
|
23
|
+
| 'asset'
|
|
23
24
|
| 'asset-view'
|
|
24
25
|
| 'asset-name-view'
|
|
25
26
|
| 'assignment'
|
|
26
27
|
| 'audit'
|
|
28
|
+
| 'award-fill'
|
|
27
29
|
| 'bell'
|
|
28
30
|
| 'bell-alert'
|
|
29
31
|
| 'borrow'
|
|
@@ -68,6 +70,8 @@ export type TSVueIcons =
|
|
|
68
70
|
| 'file-shield-2-line'
|
|
69
71
|
| 'filter-fill'
|
|
70
72
|
| 'filter-line'
|
|
73
|
+
| 'fullscreen-line'
|
|
74
|
+
| 'fullscreen-exit-line'
|
|
71
75
|
| 'folder-line'
|
|
72
76
|
| 'gate'
|
|
73
77
|
| 'group'
|
|
@@ -77,8 +81,11 @@ export type TSVueIcons =
|
|
|
77
81
|
| 'image-add'
|
|
78
82
|
| 'indeterminate-circle-fill'
|
|
79
83
|
| 'info'
|
|
84
|
+
| 'layout-grid-line'
|
|
80
85
|
| 'link-unlink-m'
|
|
81
86
|
| 'list-settings-line'
|
|
87
|
+
| 'list-check'
|
|
88
|
+
| 'list-check-2'
|
|
82
89
|
| 'loader-4'
|
|
83
90
|
| 'logout-box-r-line'
|
|
84
91
|
| 'mail-open-line'
|
|
@@ -86,6 +93,7 @@ export type TSVueIcons =
|
|
|
86
93
|
| 'map-2-line'
|
|
87
94
|
| 'map-pin-line'
|
|
88
95
|
| 'menu-line'
|
|
96
|
+
| 'menu-fold'
|
|
89
97
|
| 'menu-unfold'
|
|
90
98
|
| 'more'
|
|
91
99
|
| 'move-to'
|
|
@@ -97,6 +105,8 @@ export type TSVueIcons =
|
|
|
97
105
|
| 'phone-line'
|
|
98
106
|
| 'printer'
|
|
99
107
|
| 'price-tag-3-line'
|
|
108
|
+
| 'pushpin-2-line'
|
|
109
|
+
| 'pushpin-fill'
|
|
100
110
|
| 'qr'
|
|
101
111
|
| 'qr-scan-line'
|
|
102
112
|
| 'recycle-bin'
|
|
@@ -125,6 +135,7 @@ export type TSVueIcons =
|
|
|
125
135
|
| 'user'
|
|
126
136
|
| 'user-add-line'
|
|
127
137
|
| 'user-follow-line'
|
|
138
|
+
| 'user-unfollow-line'
|
|
128
139
|
| 'user-search'
|
|
129
140
|
| 'user-settings'
|
|
130
141
|
| 'verification';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DefineComponent } from 'vue';
|
|
2
|
+
import { Nullable } from '../ts-helpers';
|
|
3
|
+
import { CoordinateValue } from '../DialogCoordinate/DialogCoordinate.vue.d';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* InputCoordinate component props
|
|
7
|
+
*/
|
|
8
|
+
export interface InputCoordinateProps {
|
|
9
|
+
modelValue?: Nullable<CoordinateValue>;
|
|
10
|
+
/**
|
|
11
|
+
* Disabled state for both input fields.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Wether the input should be validated with vee-validator or not.
|
|
16
|
+
* If you use this component within form input, you need to set this props as true.
|
|
17
|
+
*/
|
|
18
|
+
useValidator?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* This prop is required if you use this component in a form input.
|
|
21
|
+
* Specify the unique field name, match with your needs for API request.
|
|
22
|
+
*
|
|
23
|
+
* @default 'coordinate'
|
|
24
|
+
*/
|
|
25
|
+
fieldName?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Wether this input field is required or not.
|
|
29
|
+
*/
|
|
30
|
+
mandatory?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Invalid input state.
|
|
33
|
+
*/
|
|
34
|
+
invalid?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Set custom validator message.
|
|
37
|
+
* It is rarely use, this component has handled the validator message.
|
|
38
|
+
*/
|
|
39
|
+
validatorMessage?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* InputCoordinate component emits
|
|
44
|
+
*/
|
|
45
|
+
export type InputCoordinateEmits = {
|
|
46
|
+
'update:modelValue': [payload?: Nullable<CoordinateValue>];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* **TSVue - InputCoordinate**
|
|
51
|
+
*
|
|
52
|
+
* _Handle coordinate input with latitude and longitude fields._
|
|
53
|
+
*
|
|
54
|
+
* --- ---
|
|
55
|
+
* 
|
|
56
|
+
*
|
|
57
|
+
* @group form
|
|
58
|
+
*/
|
|
59
|
+
declare const InputCoordinate: DefineComponent<
|
|
60
|
+
InputCoordinateProps,
|
|
61
|
+
InputCoordinateEmits
|
|
62
|
+
>;
|
|
63
|
+
|
|
64
|
+
export default InputCoordinate;
|
|
@@ -2,6 +2,8 @@ import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
|
2
2
|
import {
|
|
3
3
|
GetAllAssetsQueryParams,
|
|
4
4
|
GetAssetDetailParams,
|
|
5
|
+
GetAssetMapParams,
|
|
6
|
+
GetAssetMapResponse,
|
|
5
7
|
GetAvailableAssetsQueryParams,
|
|
6
8
|
GetLinkedAssetFamiliesResponse,
|
|
7
9
|
} from '@/dto/assets.dto';
|
|
@@ -11,17 +13,19 @@ import { buildBodyParams } from '@/utils';
|
|
|
11
13
|
export interface ServiceOptions {
|
|
12
14
|
headers?: Record<string, unknown>;
|
|
13
15
|
params?: Record<string, unknown>;
|
|
16
|
+
usePrefix?: boolean;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export const API = ({
|
|
17
20
|
headers = {},
|
|
18
21
|
params = {},
|
|
22
|
+
usePrefix = true,
|
|
19
23
|
}: ServiceOptions = {}): AxiosInstance => {
|
|
20
24
|
const user = JSON.parse(localStorage.getItem('user') ?? '{}');
|
|
21
25
|
const BASE_URL = import.meta.env.VITE_APP_TAGSAMURAI_API;
|
|
22
26
|
|
|
23
27
|
const instance = axios.create({
|
|
24
|
-
baseURL: `${BASE_URL}/assets/v2/assets`,
|
|
28
|
+
baseURL: `${BASE_URL}/assets/v2${usePrefix ? '/assets' : ''}`,
|
|
25
29
|
headers: {
|
|
26
30
|
'Content-type': 'application/json',
|
|
27
31
|
'Authorization': `Bearer ${user.token}`,
|
|
@@ -33,6 +37,20 @@ export const API = ({
|
|
|
33
37
|
return instance;
|
|
34
38
|
};
|
|
35
39
|
|
|
40
|
+
const postAssetList = (
|
|
41
|
+
params?: GetAllAssetsQueryParams,
|
|
42
|
+
): Promise<AxiosResponse> => {
|
|
43
|
+
const body = buildBodyParams(params);
|
|
44
|
+
return API().post('/list', body);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const postAssetOption = (
|
|
48
|
+
params?: GetAllAssetsQueryParams,
|
|
49
|
+
): Promise<AxiosResponse> => {
|
|
50
|
+
const body = buildBodyParams(params);
|
|
51
|
+
return API().post('/list/options', body);
|
|
52
|
+
};
|
|
53
|
+
|
|
36
54
|
const getAllAssets = (
|
|
37
55
|
params: GetAllAssetsQueryParams,
|
|
38
56
|
): Promise<AxiosResponse> => {
|
|
@@ -104,8 +122,28 @@ const matchAssetWithTag = (
|
|
|
104
122
|
return API({ params }).get('/by-id');
|
|
105
123
|
};
|
|
106
124
|
|
|
125
|
+
const getAssetMaps = (
|
|
126
|
+
params?: GetAssetMapParams,
|
|
127
|
+
): Promise<AxiosResponse<GetAssetMapResponse>> => {
|
|
128
|
+
let abortController: AbortController | null = null;
|
|
129
|
+
|
|
130
|
+
// Cancel previous request
|
|
131
|
+
if (abortController) {
|
|
132
|
+
(abortController as AbortController).abort();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
abortController = new AbortController();
|
|
136
|
+
|
|
137
|
+
return API({
|
|
138
|
+
usePrefix: false,
|
|
139
|
+
params: params as Record<string, unknown>,
|
|
140
|
+
}).get('/asset-maps', { signal: abortController.signal });
|
|
141
|
+
};
|
|
142
|
+
|
|
107
143
|
export default {
|
|
108
144
|
getAllAssets,
|
|
145
|
+
postAssetList,
|
|
146
|
+
postAssetOption,
|
|
109
147
|
getAvailableAssets,
|
|
110
148
|
postAssetAvailableList,
|
|
111
149
|
getAssetsById,
|
|
@@ -115,4 +153,5 @@ export default {
|
|
|
115
153
|
getUnlinkedAssets,
|
|
116
154
|
getOptions,
|
|
117
155
|
scanAsset,
|
|
156
|
+
getAssetMaps,
|
|
118
157
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DataTableColumnConfig } from '@/components/v2/CustomColumn/CustomColumn.vue.d';
|
|
2
|
+
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
|
+
|
|
4
|
+
const getUser = (): Record<string, string> =>
|
|
5
|
+
JSON.parse(localStorage.getItem('user') ?? '{}');
|
|
6
|
+
|
|
7
|
+
export const API = ({ headers = {}, params = {} } = {}): AxiosInstance => {
|
|
8
|
+
const user = getUser();
|
|
9
|
+
|
|
10
|
+
const BASE_URL = import.meta.env.VITE_APP_GLOBAL_SETTINGS_API;
|
|
11
|
+
|
|
12
|
+
const instance = axios.create({
|
|
13
|
+
baseURL: `${BASE_URL}/v1/global-settings`,
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-type': 'application/json',
|
|
16
|
+
'Authorization': `Bearer ${user.token}`,
|
|
17
|
+
...headers,
|
|
18
|
+
},
|
|
19
|
+
params,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return instance;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ColumnServices = {
|
|
26
|
+
getColumnSetup: (
|
|
27
|
+
tableId: string,
|
|
28
|
+
): Promise<AxiosResponse<{ data: DataTableColumnConfig[] }>> => {
|
|
29
|
+
const user = getUser();
|
|
30
|
+
return API().get(`/columns/${user._id}/${tableId}`);
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
editColumnSetup: (
|
|
34
|
+
tableId: string,
|
|
35
|
+
body: DataTableColumnConfig[],
|
|
36
|
+
): Promise<AxiosResponse> => {
|
|
37
|
+
const user = getUser();
|
|
38
|
+
return API().put(`/columns/${user._id}/${tableId}`, { data: body });
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ColumnServices;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface DataTableStore {
|
|
2
|
-
/**
|
|
3
|
-
* Get the config object from the store.
|
|
4
|
-
*/
|
|
5
|
-
config: DataTableConfig;
|
|
6
|
-
/**
|
|
7
|
-
* Update config for specific Table.
|
|
8
|
-
*
|
|
9
|
-
* @param id The table ID
|
|
10
|
-
* @param columnsConfig The columns configuration
|
|
11
|
-
*/
|
|
12
|
-
setConfig: (id: string, columnsConfig: DataTableColumnConfig[]) => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export type DataTableConfig = Record<string, DataTableColumnConfig[]>;
|
|
15
|
-
export interface DataTableColumnConfig {
|
|
16
|
-
field: string;
|
|
17
|
-
width: number | string;
|
|
18
|
-
fixed: boolean;
|
|
19
|
-
visible: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare const useDataTableStore: () => Promise<DataTableStore>;
|
|
22
|
-
export default useDataTableStore;
|