datastake-daf 0.6.746 → 0.6.748
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/components/index.js +769 -461
- package/dist/hooks/index.js +2 -2
- package/dist/layouts/index.js +497 -440
- package/dist/pages/index.js +3414 -683
- package/dist/services/index.js +23 -1
- package/dist/utils/index.js +497 -440
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/ActivityIndicators.stories.js +252 -0
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/config.js +76 -0
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +184 -0
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/style.js +119 -0
- package/src/@daf/core/components/Icon/configs/Aid.js +10 -0
- package/src/@daf/core/components/Icon/configs/Bear.js +8 -0
- package/src/@daf/core/components/Icon/configs/Minus.js +10 -0
- package/src/@daf/core/components/Icon/configs/Security.js +12 -0
- package/src/@daf/core/components/Icon/configs/index.js +8 -0
- package/src/@daf/hooks/useSources.js +1 -1
- package/src/@daf/pages/Summary/Activities/Restoration/helper.js +86 -2
- package/src/@daf/pages/Summary/Activities/Restoration/index.jsx +20 -19
- package/src/@daf/pages/Summary/Minesite/components/LocationMap/index.js +61 -0
- package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/config.js +77 -0
- package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/index.js +47 -0
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +26 -0
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +64 -0
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +56 -0
- package/src/@daf/pages/Summary/Minesite/index.jsx +162 -0
- package/src/@daf/pages/Summary/Operator/components/Governance/config.js +26 -0
- package/src/@daf/pages/Summary/Operator/components/Governance/helper.js +61 -0
- package/src/@daf/pages/Summary/Operator/components/Governance/index.js +55 -0
- package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +84 -0
- package/src/@daf/pages/Summary/Operator/components/KeyInformation/index.js +46 -0
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/config.js +40 -0
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +98 -0
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +160 -0
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +83 -0
- package/src/@daf/pages/Summary/Operator/hook.js +176 -0
- package/src/@daf/pages/Summary/Operator/index.jsx +170 -0
- package/src/@daf/pages/Summary/components/InformationAvailability/components/Contributions/index.js +36 -0
- package/src/@daf/pages/Summary/components/InformationAvailability/components/InformationCompleteness/index.js +58 -0
- package/src/@daf/pages/Summary/components/InformationAvailability/index.js +42 -0
- package/src/@daf/pages/Summary/hook.js +188 -0
- package/src/@daf/services/OperatorService.js +16 -0
- package/src/@daf/services/SourceService.js +1 -1
- package/src/helpers/StringHelper.js +7 -0
- package/src/index.js +1 -0
- package/src/pages.js +2 -2
- package/src/@daf/pages/Summary/minesite/index.js +0 -0
- package/src/@daf/pages/Summary/operator/index.jsx +0 -76
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { useWidgetFetch } from '../../../../hooks/useWidgetFetch.js';
|
|
3
|
+
import Widget from '../../../../core/components/Dashboard/Widget/index.jsx';
|
|
4
|
+
import InformationCompleteness from './components/InformationCompleteness/index.js';
|
|
5
|
+
import Contributions from './components/Contributions/index.js';
|
|
6
|
+
|
|
7
|
+
const InformationAvailability = ({
|
|
8
|
+
selectedPartners = {},
|
|
9
|
+
t = () => {},
|
|
10
|
+
id,
|
|
11
|
+
}) => {
|
|
12
|
+
const defaultFetchConfig = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
basepath: "analytics",
|
|
15
|
+
url: "/widgets/completeness",
|
|
16
|
+
defaultData: [],
|
|
17
|
+
stop: selectedPartners?.loading,
|
|
18
|
+
filters: {
|
|
19
|
+
datastakeId: id,
|
|
20
|
+
sources: selectedPartners?.partners || [],
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
[id, selectedPartners],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const { data, loading } = useWidgetFetch({config: defaultFetchConfig});
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Widget
|
|
30
|
+
title={t("Information Availability")}
|
|
31
|
+
loading={loading}
|
|
32
|
+
className="with-border-header h-w-btn-header"
|
|
33
|
+
>
|
|
34
|
+
<div className="flex flex-row flex-col-mobile gap-6">
|
|
35
|
+
<InformationCompleteness data={data} loading={loading} t={t} />
|
|
36
|
+
<Contributions data={data} loading={loading} t={t} />
|
|
37
|
+
</div>
|
|
38
|
+
</Widget>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default InformationAvailability
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { useState, useMemo, useCallback, useEffect } from "react"
|
|
2
|
+
import { debounce } from "lodash";
|
|
3
|
+
import { StorageManager } from "../../../helpers/StorageManager.js";
|
|
4
|
+
|
|
5
|
+
export const useSummary = ({
|
|
6
|
+
getOne,
|
|
7
|
+
getMultiple,
|
|
8
|
+
id,
|
|
9
|
+
hasSelect = false,
|
|
10
|
+
storageKey,
|
|
11
|
+
data,
|
|
12
|
+
isPdf,
|
|
13
|
+
params,
|
|
14
|
+
partners,
|
|
15
|
+
selectedPartners,
|
|
16
|
+
user,
|
|
17
|
+
t,
|
|
18
|
+
theme = {},
|
|
19
|
+
service,
|
|
20
|
+
onIdChange = () => {}
|
|
21
|
+
}) => {
|
|
22
|
+
const [search, setSearch] = useState("");
|
|
23
|
+
const [debouncedSearch, setDebouncedSearch] = useState("");
|
|
24
|
+
const [hasInitialized, setHasInitialized] = useState(false);
|
|
25
|
+
const [singleItemData, setSingleItemData] = useState();
|
|
26
|
+
const [loading, setLoading] = useState(false);
|
|
27
|
+
const [_partners, _setPartners] = useState();
|
|
28
|
+
|
|
29
|
+
const [selectedItem, setSelectedItem] = useState(undefined);
|
|
30
|
+
|
|
31
|
+
const dataOptions = useMemo(() => {
|
|
32
|
+
if(hasSelect) {
|
|
33
|
+
const mappedData = Array.isArray(data) ? data.map((item) => ({
|
|
34
|
+
label: item?.name,
|
|
35
|
+
value: item?.datastakeId
|
|
36
|
+
})) : [];
|
|
37
|
+
|
|
38
|
+
const storedData = StorageManager.get(storageKey);
|
|
39
|
+
if (storedData) {
|
|
40
|
+
try {
|
|
41
|
+
const parsedStoredData = JSON.parse(storedData);
|
|
42
|
+
const existsInData = mappedData?.find(item => item.value === parsedStoredData.value);
|
|
43
|
+
|
|
44
|
+
if (!existsInData) {
|
|
45
|
+
return [...mappedData, parsedStoredData];
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.log('Error parsing stored data:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return mappedData;
|
|
53
|
+
}
|
|
54
|
+
}, [data, hasSelect, storageKey])
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (hasSelect && dataOptions && dataOptions.length > 0 && !debouncedSearch && !hasInitialized) {
|
|
58
|
+
let selectedValue;
|
|
59
|
+
|
|
60
|
+
if (isPdf) {
|
|
61
|
+
selectedValue = id;
|
|
62
|
+
} else {
|
|
63
|
+
const storedData = StorageManager.get(storageKey);
|
|
64
|
+
if (storedData) {
|
|
65
|
+
try {
|
|
66
|
+
const parsedData = JSON.parse(storedData);
|
|
67
|
+
const existsInOptions = dataOptions?.find((item) => item?.value === parsedData?.value);
|
|
68
|
+
selectedValue = existsInOptions ? parsedData?.value : (Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.log('Error parsing stored data:', error);
|
|
71
|
+
selectedValue = Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined;
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
selectedValue = Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setSelectedItem(selectedValue);
|
|
79
|
+
setHasInitialized(true);
|
|
80
|
+
}
|
|
81
|
+
}, [hasSelect, storageKey, isPdf, id, debouncedSearch, hasInitialized, dataOptions]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (selectedItem && Array.isArray(data)) {
|
|
85
|
+
const selectedData = data.find((item) => item?.datastakeId === selectedItem);
|
|
86
|
+
if(selectedData) {
|
|
87
|
+
const saved = {
|
|
88
|
+
label: selectedData.name,
|
|
89
|
+
value: selectedData.datastakeId,
|
|
90
|
+
}
|
|
91
|
+
StorageManager.set(storageKey, JSON.stringify(saved));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [selectedItem, storageKey, data]);
|
|
95
|
+
|
|
96
|
+
const debouncedSetSearch = useMemo(
|
|
97
|
+
() => debounce((value) => setDebouncedSearch(value), 300),
|
|
98
|
+
[]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const onSearch = useCallback((value) => {
|
|
102
|
+
setSearch(value);
|
|
103
|
+
debouncedSetSearch(value);
|
|
104
|
+
}, [debouncedSetSearch]);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
setDebouncedSearch("");
|
|
109
|
+
}, [selectedItem]);
|
|
110
|
+
|
|
111
|
+
const filters = useMemo(() => {
|
|
112
|
+
return {
|
|
113
|
+
pagination: { size: 20, page: 1 },
|
|
114
|
+
...(debouncedSearch
|
|
115
|
+
? { search: { qs: debouncedSearch, fields: ["name","datastakeId","orgShortName"] } }
|
|
116
|
+
: {}),
|
|
117
|
+
};
|
|
118
|
+
}, [debouncedSearch]);
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (_partners !== undefined) {
|
|
122
|
+
if ((params?.id !== null || (isPdf && id !== null)) && !hasSelect) {
|
|
123
|
+
getOne({ datastakeId: params?.id || id, sources: _partners });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (hasSelect && !params?.id) {
|
|
127
|
+
getMultiple(filters);
|
|
128
|
+
}
|
|
129
|
+
}, [params?.id, hasSelect, getOne, getMultiple, _partners, isPdf, id, filters]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (selectedItem && _partners !== undefined) {
|
|
133
|
+
const fetchSingleItem = async () => {
|
|
134
|
+
setLoading(true);
|
|
135
|
+
try {
|
|
136
|
+
const { data } = await service.getOne(selectedItem, { sources: _partners });
|
|
137
|
+
setSingleItemData(data);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.log(error);
|
|
140
|
+
} finally {
|
|
141
|
+
setLoading(false);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
fetchSingleItem();
|
|
145
|
+
}
|
|
146
|
+
}, [selectedItem, service, _partners]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
_setPartners(selectedPartners?.partners);
|
|
150
|
+
}, [selectedPartners]);
|
|
151
|
+
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const currentId = params?.id || selectedItem;
|
|
154
|
+
if(typeof onIdChange === 'function') {
|
|
155
|
+
if (currentId) {
|
|
156
|
+
onIdChange(currentId);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, [params?.id, selectedItem, onIdChange]);
|
|
160
|
+
|
|
161
|
+
const sourceOptions = useMemo(() => {
|
|
162
|
+
return (partners || [])?.map((partner) => {
|
|
163
|
+
const isOwnData = partner.id === user?.company?.id;
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
label: isOwnData ? t("Own Data") : partner.nickName,
|
|
167
|
+
value: partner.id,
|
|
168
|
+
avatar: isOwnData ? <span>OWN</span> : undefined,
|
|
169
|
+
background: isOwnData ? theme.colorPrimary7 : undefined,
|
|
170
|
+
color: isOwnData ? "white" : undefined,
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
}, [partners, user, hasSelect]);
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
selectedItem,
|
|
177
|
+
setSelectedItem,
|
|
178
|
+
dataOptions,
|
|
179
|
+
search,
|
|
180
|
+
debouncedSearch,
|
|
181
|
+
onSearch,
|
|
182
|
+
setSearch,
|
|
183
|
+
setDebouncedSearch,
|
|
184
|
+
sourceOptions,
|
|
185
|
+
singleItemData,
|
|
186
|
+
loading,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -14,8 +14,24 @@ const namespaceEnums = {
|
|
|
14
14
|
|
|
15
15
|
class OperatorService extends BaseService {
|
|
16
16
|
get(params) {
|
|
17
|
+
const { datastakeId, ...rest } = params;
|
|
18
|
+
if(datastakeId) {
|
|
19
|
+
return this.apiGet({
|
|
20
|
+
url: `/stakeholder/${datastakeId}`,
|
|
21
|
+
params: {...rest},
|
|
22
|
+
isApp: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
17
25
|
return this.apiGet({
|
|
18
26
|
url: "/stakeholder",
|
|
27
|
+
params: {...rest},
|
|
28
|
+
isApp: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getOne(id, params) {
|
|
33
|
+
return this.apiGet({
|
|
34
|
+
url: `/stakeholder/${id}`,
|
|
19
35
|
params,
|
|
20
36
|
isApp: true,
|
|
21
37
|
});
|
|
@@ -190,4 +190,11 @@ export function formatToKebabCase(str) {
|
|
|
190
190
|
return str
|
|
191
191
|
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
192
192
|
.toLowerCase();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const getLinkValue = (value, linkingObject) => {
|
|
196
|
+
if(linkingObject && linkingObject?.[value]) {
|
|
197
|
+
return linkingObject?.[value]?.name;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
193
200
|
}
|
package/src/index.js
CHANGED
|
@@ -57,6 +57,7 @@ export { default as WidgetImage } from "./@daf/core/components/Dashboard/Widget/
|
|
|
57
57
|
export { default as FlowWidget } from "./@daf/core/components/Dashboard/Widget/FlowWidgets/index.jsx";
|
|
58
58
|
export { default as ActionWidget } from "./@daf/core/components/Dashboard/Widget/ActionWidget/index.jsx";
|
|
59
59
|
export { default as KeyIndicators } from "./@daf/core/components/Dashboard/Widget/KeyIndicators/index.jsx";
|
|
60
|
+
export { default as ActivityIndicators } from "./@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx";
|
|
60
61
|
export { default as WidgetLoader } from "./@daf/core/components/Dashboard/Widget/WidgetLoader/index.jsx";
|
|
61
62
|
export { default as TooltipIcon } from "./@daf/core/components/Icon/TooltipIcon.jsx";
|
|
62
63
|
export { default as MineSiteMap } from "./@daf/core/components/Dashboard/Map/index.jsx";
|
package/src/pages.js
CHANGED
|
@@ -14,6 +14,6 @@ export { default as ProductionSitesTable } from './@daf/pages/Locations/MineSite
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// Summary
|
|
17
|
-
export { default as OperatorSummary } from './@daf/pages/Summary/
|
|
17
|
+
export { default as OperatorSummary } from './@daf/pages/Summary/Operator/index.jsx';
|
|
18
18
|
export { default as RestorationActivitySummary } from './@daf/pages/Summary/Activities/Restoration/index.jsx';
|
|
19
|
-
|
|
19
|
+
export { default as MineSummary } from './@daf/pages/Summary/Minesite/index.jsx';
|
|
File without changes
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useEffect } from 'react'
|
|
2
|
-
import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
|
|
3
|
-
import DashboardLayout from '../../../core/components/Dashboard/DashboardLayout/index.jsx';
|
|
4
|
-
import Header from '../../../core/components/Header/index.jsx';
|
|
5
|
-
import Multiselect from '../../../core/components/Select/MultiSelect/index.jsx';
|
|
6
|
-
|
|
7
|
-
function OperatorSummary({
|
|
8
|
-
t = () => { },
|
|
9
|
-
goTo = () => { },
|
|
10
|
-
getRedirectLink = () => { },
|
|
11
|
-
theme = {},
|
|
12
|
-
user = {},
|
|
13
|
-
options = {},
|
|
14
|
-
partners,
|
|
15
|
-
selectedPartners,
|
|
16
|
-
setSelectedPartners,
|
|
17
|
-
informationSources,
|
|
18
|
-
hardcodedData,
|
|
19
|
-
breadCrumbs = [],
|
|
20
|
-
}) {
|
|
21
|
-
|
|
22
|
-
const sourceOptions = useMemo(() => {
|
|
23
|
-
if (!partners?.length) return [];
|
|
24
|
-
|
|
25
|
-
return partners?.map((partner) => {
|
|
26
|
-
const isOwnData = partner.id === user?.company?.id;
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
label: partner.nickName,
|
|
30
|
-
value: partner.id,
|
|
31
|
-
avatar: isOwnData ? <span>OWN</span> : <CustomIcon name={"Search02"} size={14} />,
|
|
32
|
-
background: isOwnData ? theme.colorPrimary7 : undefined,
|
|
33
|
-
color: isOwnData ? "white" : undefined,
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
}, [partners, user]);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
window.theme = theme;
|
|
40
|
-
}, [theme])
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<DashboardLayout
|
|
45
|
-
header={
|
|
46
|
-
<Header
|
|
47
|
-
title={t('Operator Summary')}
|
|
48
|
-
addedHeader={
|
|
49
|
-
<div>
|
|
50
|
-
<Multiselect
|
|
51
|
-
options={[...sourceOptions]}
|
|
52
|
-
isAvatarGroup
|
|
53
|
-
selectionType="checkbox"
|
|
54
|
-
canUnselectLast={false}
|
|
55
|
-
key={partners?.length}
|
|
56
|
-
onChange={(selected) => {
|
|
57
|
-
setSelectedPartners((prev) => ({
|
|
58
|
-
...prev,
|
|
59
|
-
partners: selected,
|
|
60
|
-
loading: false,
|
|
61
|
-
}));
|
|
62
|
-
}}
|
|
63
|
-
dropDownWidth={200}
|
|
64
|
-
defaultSelected={partners?.map((p) => p.id) || []}
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
}
|
|
68
|
-
breadcrumbs={breadCrumbs}
|
|
69
|
-
/>
|
|
70
|
-
}
|
|
71
|
-
>
|
|
72
|
-
</DashboardLayout>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default OperatorSummary;
|