@gisce/react-ooui 1.1.2-rc.3 → 1.1.2-rc.5
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/hooks/useSearch.d.ts +5 -2
- package/dist/hooks/useSearch.d.ts.map +1 -1
- package/dist/react-ooui.es.js +3540 -3480
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +14 -14
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/views/actionViews/GraphActionView.d.ts.map +1 -1
- package/dist/views/actionViews/TreeActionView.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
- package/dist/widgets/views/Graph/Graph.d.ts +1 -0
- package/dist/widgets/views/Graph/Graph.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphChart.d.ts +1 -0
- package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphIndicator.d.ts +1 -0
- package/dist/widgets/views/Graph/GraphIndicator.d.ts.map +1 -1
- package/dist/widgets/views/Graph/useGraphData.d.ts +2 -0
- package/dist/widgets/views/Graph/useGraphData.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts +1 -0
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/searchHelper.ts +1 -1
- package/src/hooks/useSearch.ts +107 -106
- package/src/views/actionViews/GraphActionView.tsx +63 -50
- package/src/views/actionViews/TreeActionView.tsx +0 -1
- package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -27
- package/src/widgets/views/Graph/Graph.tsx +4 -1
- package/src/widgets/views/Graph/GraphChart.tsx +7 -2
- package/src/widgets/views/Graph/GraphIndicator.tsx +52 -6
- package/src/widgets/views/Graph/useGraphData.tsx +34 -2
- package/src/widgets/views/searchFilter/SearchFilter.tsx +5 -1
|
@@ -24,6 +24,7 @@ export type GraphInidicatorProps = {
|
|
|
24
24
|
suffix?: string;
|
|
25
25
|
field?: string;
|
|
26
26
|
operator?: Operator;
|
|
27
|
+
manualIds?: number[];
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export const GraphIndicator = (props: GraphInidicatorProps) => {
|
|
@@ -38,6 +39,7 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
|
|
|
38
39
|
suffix,
|
|
39
40
|
field,
|
|
40
41
|
operator,
|
|
42
|
+
manualIds,
|
|
41
43
|
} = props;
|
|
42
44
|
const [loading, setLoading] = useState(false);
|
|
43
45
|
const [value, setValue] = useState<number>();
|
|
@@ -53,10 +55,52 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
|
|
|
53
55
|
fetchData();
|
|
54
56
|
}, [model, colorCondition]);
|
|
55
57
|
|
|
56
|
-
async function
|
|
58
|
+
async function fetchValue({
|
|
59
|
+
domain,
|
|
60
|
+
isTotal,
|
|
61
|
+
}: {
|
|
62
|
+
domain: any;
|
|
63
|
+
isTotal: boolean;
|
|
64
|
+
}) {
|
|
65
|
+
if (isTotal) {
|
|
66
|
+
return await fetchTotalValue({ domain });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (field && operator) {
|
|
70
|
+
const resultIds =
|
|
71
|
+
manualIds ||
|
|
72
|
+
(await ConnectionProvider.getHandler().searchAllIds({
|
|
73
|
+
params: domain,
|
|
74
|
+
model,
|
|
75
|
+
context,
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
const results = await ConnectionProvider.getHandler().readObjects({
|
|
79
|
+
model,
|
|
80
|
+
ids: resultIds,
|
|
81
|
+
fieldsToRetrieve: [field],
|
|
82
|
+
context,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return getValueForOperator({
|
|
86
|
+
values: results.map((r: any) => r[field]),
|
|
87
|
+
operator,
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
return manualIds
|
|
91
|
+
? manualIds.length
|
|
92
|
+
: await ConnectionProvider.getHandler().searchCount({
|
|
93
|
+
model,
|
|
94
|
+
params: domain,
|
|
95
|
+
context,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function fetchTotalValue({ domain }: { domain: any }) {
|
|
57
101
|
if (field && operator) {
|
|
58
102
|
const resultIds = await ConnectionProvider.getHandler().searchAllIds({
|
|
59
|
-
params:
|
|
103
|
+
params: domain,
|
|
60
104
|
model,
|
|
61
105
|
context,
|
|
62
106
|
});
|
|
@@ -75,19 +119,18 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
|
|
|
75
119
|
} else {
|
|
76
120
|
return await ConnectionProvider.getHandler().searchCount({
|
|
77
121
|
model,
|
|
78
|
-
params:
|
|
122
|
+
params: domain,
|
|
79
123
|
context,
|
|
80
124
|
});
|
|
81
125
|
}
|
|
82
126
|
}
|
|
83
|
-
|
|
84
127
|
async function fetchData() {
|
|
85
128
|
setLoading(true);
|
|
86
129
|
let totalRetrievedValue;
|
|
87
130
|
let percent;
|
|
88
131
|
|
|
89
132
|
try {
|
|
90
|
-
const retrievedValue = await
|
|
133
|
+
const retrievedValue = await fetchValue({ domain, isTotal: false });
|
|
91
134
|
|
|
92
135
|
setValue(retrievedValue);
|
|
93
136
|
|
|
@@ -97,7 +140,10 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
|
|
|
97
140
|
values: {},
|
|
98
141
|
context,
|
|
99
142
|
});
|
|
100
|
-
totalRetrievedValue = await
|
|
143
|
+
totalRetrievedValue = await fetchValue({
|
|
144
|
+
domain: parsedDomain,
|
|
145
|
+
isTotal: true,
|
|
146
|
+
});
|
|
101
147
|
|
|
102
148
|
setTotalValue(totalRetrievedValue);
|
|
103
149
|
}
|
|
@@ -17,6 +17,7 @@ export type GraphDataQueryOpts = {
|
|
|
17
17
|
domain?: any;
|
|
18
18
|
context?: any;
|
|
19
19
|
limit?: number;
|
|
20
|
+
manualIds?: number[];
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export type GraphDataOpts = GraphDataQueryOpts & {
|
|
@@ -32,10 +33,12 @@ export const useGraphData = (opts: GraphDataOpts) => {
|
|
|
32
33
|
xml,
|
|
33
34
|
limit,
|
|
34
35
|
uninformedString,
|
|
36
|
+
manualIds,
|
|
35
37
|
} = opts;
|
|
36
38
|
const [loading, setLoading] = useState(false);
|
|
37
39
|
const [error, setError] = useState<any>();
|
|
38
40
|
const [processedValues, setProcessedValues] = useState<any>();
|
|
41
|
+
const [evaluatedEntries, setEvaluatedEntries] = useState<any[]>();
|
|
39
42
|
const [type, setType] = useState<GraphType>("line");
|
|
40
43
|
|
|
41
44
|
useDeepCompareEffect(() => {
|
|
@@ -60,6 +63,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
|
|
|
60
63
|
limit,
|
|
61
64
|
order: ooui.timerange ? ooui.x.name : null,
|
|
62
65
|
fields: fieldsToRetrieve,
|
|
66
|
+
manualIds,
|
|
63
67
|
}));
|
|
64
68
|
} catch (e) {
|
|
65
69
|
setError("Error fetching graph data values: " + JSON.stringify(e));
|
|
@@ -74,6 +78,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
|
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
setEvaluatedEntries(values);
|
|
77
82
|
const _processedValues = processGraphData({
|
|
78
83
|
ooui,
|
|
79
84
|
values,
|
|
@@ -93,7 +98,13 @@ export const useGraphData = (opts: GraphDataOpts) => {
|
|
|
93
98
|
})();
|
|
94
99
|
}, [xml, model, limit, context, domain]);
|
|
95
100
|
|
|
96
|
-
return {
|
|
101
|
+
return {
|
|
102
|
+
loading,
|
|
103
|
+
error,
|
|
104
|
+
type,
|
|
105
|
+
values: processedValues,
|
|
106
|
+
evaluatedEntries,
|
|
107
|
+
};
|
|
97
108
|
};
|
|
98
109
|
|
|
99
110
|
async function getFieldsForModel({
|
|
@@ -120,6 +131,7 @@ async function retrieveData({
|
|
|
120
131
|
context,
|
|
121
132
|
order,
|
|
122
133
|
limit,
|
|
134
|
+
manualIds,
|
|
123
135
|
}: {
|
|
124
136
|
fields: string[];
|
|
125
137
|
model: string;
|
|
@@ -127,7 +139,28 @@ async function retrieveData({
|
|
|
127
139
|
context: any;
|
|
128
140
|
order: string | null;
|
|
129
141
|
limit?: number;
|
|
142
|
+
manualIds?: number[];
|
|
130
143
|
}) {
|
|
144
|
+
const fieldsDefinition = await getFieldsForModel({ model, context, fields });
|
|
145
|
+
|
|
146
|
+
if (manualIds) {
|
|
147
|
+
let values: any[] = (await ConnectionProvider.getHandler().readObjects({
|
|
148
|
+
model,
|
|
149
|
+
ids: manualIds,
|
|
150
|
+
fieldsToRetrieve: fields,
|
|
151
|
+
context,
|
|
152
|
+
})) as any;
|
|
153
|
+
|
|
154
|
+
if (order) {
|
|
155
|
+
values = [...values].sort((a, b) => a[order] - b[order]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
values,
|
|
160
|
+
fields: fieldsDefinition,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
131
164
|
const values: any[] = (await ConnectionProvider.getHandler().search({
|
|
132
165
|
model,
|
|
133
166
|
params: domain,
|
|
@@ -136,7 +169,6 @@ async function retrieveData({
|
|
|
136
169
|
limit,
|
|
137
170
|
order,
|
|
138
171
|
})) as any;
|
|
139
|
-
const fieldsDefinition = await getFieldsForModel({ model, context, fields });
|
|
140
172
|
return {
|
|
141
173
|
values,
|
|
142
174
|
fields: fieldsDefinition,
|
|
@@ -29,6 +29,7 @@ type Props = {
|
|
|
29
29
|
setSearchFilterHeight?: (height: number) => void;
|
|
30
30
|
searchError?: string;
|
|
31
31
|
searchValues?: any;
|
|
32
|
+
showLimitOptions?: boolean;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
function SearchFilter(props: Props) {
|
|
@@ -45,6 +46,7 @@ function SearchFilter(props: Props) {
|
|
|
45
46
|
setSearchFilterHeight,
|
|
46
47
|
searchError,
|
|
47
48
|
searchValues,
|
|
49
|
+
showLimitOptions = true,
|
|
48
50
|
} = props;
|
|
49
51
|
|
|
50
52
|
const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
|
|
@@ -116,7 +118,9 @@ function SearchFilter(props: Props) {
|
|
|
116
118
|
initialValues={{ offset, limit }}
|
|
117
119
|
>
|
|
118
120
|
{rows}
|
|
119
|
-
{advancedFilter &&
|
|
121
|
+
{advancedFilter && showLimitOptions && (
|
|
122
|
+
<SearchParams onLimitChange={onLimitChange} />
|
|
123
|
+
)}
|
|
120
124
|
<SearchBottomBar
|
|
121
125
|
advancedFilter={advancedFilter}
|
|
122
126
|
onAdvancedFilterToggle={() => {
|