datastake-daf 0.6.721 → 0.6.722

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.
Files changed (29) hide show
  1. package/dist/components/index.js +1 -1
  2. package/dist/context/index.js +7 -1
  3. package/dist/hooks/index.js +2 -1
  4. package/dist/pages/index.js +1481 -38
  5. package/dist/services/index.js +7 -1
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +1 -1
  8. package/src/@daf/hooks/useWidgetFetch.js +1 -0
  9. package/src/@daf/pages/dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +1 -1
  10. package/src/@daf/pages/dashboards/UserDashboard/components/AccumulationGraph/hook.js +139 -0
  11. package/src/@daf/pages/dashboards/UserDashboard/components/AccumulationGraph/index.jsx +78 -0
  12. package/src/@daf/pages/dashboards/UserDashboard/components/ContributionsGraph/helper.js +75 -0
  13. package/src/@daf/pages/dashboards/UserDashboard/components/ContributionsGraph/hook.js +46 -0
  14. package/src/@daf/pages/dashboards/UserDashboard/components/ContributionsGraph/index.jsx +49 -0
  15. package/src/@daf/pages/dashboards/UserDashboard/components/CustomSegment/index.jsx +26 -0
  16. package/src/@daf/pages/dashboards/UserDashboard/components/DataChainOfCustody/index.jsx +18 -0
  17. package/src/@daf/pages/dashboards/UserDashboard/components/DataCompilation/index.jsx +69 -0
  18. package/src/@daf/pages/dashboards/UserDashboard/components/DataConsilidation/index.jsx +72 -0
  19. package/src/@daf/pages/dashboards/UserDashboard/components/KeyIndicators/config.js +120 -0
  20. package/src/@daf/pages/dashboards/UserDashboard/components/KeyIndicators/index.jsx +52 -0
  21. package/src/@daf/pages/dashboards/UserDashboard/components/MineSites/config.js +22 -0
  22. package/src/@daf/pages/dashboards/UserDashboard/components/MineSites/helper.js +142 -0
  23. package/src/@daf/pages/dashboards/UserDashboard/components/MineSites/index.jsx +209 -0
  24. package/src/@daf/pages/dashboards/UserDashboard/components/Triangulation/config.js +20 -0
  25. package/src/@daf/pages/dashboards/UserDashboard/components/Triangulation/hook.js +87 -0
  26. package/src/@daf/pages/dashboards/UserDashboard/components/Triangulation/index.jsx +68 -0
  27. package/src/@daf/pages/dashboards/UserDashboard/config.js +24 -24
  28. package/src/@daf/pages/dashboards/UserDashboard/index.jsx +56 -0
  29. package/src/@daf/services/AuthenticationService.js +7 -1
@@ -872,7 +872,13 @@ class AuthenticationService extends BaseService {
872
872
  url: `/companies/${id}`
873
873
  });
874
874
  }
875
- inviteUser(payload) {
875
+ inviteUser(payload, id) {
876
+ if (id) {
877
+ return this.apiPost({
878
+ url: `/companies/${id}/invite`,
879
+ data: payload
880
+ });
881
+ }
876
882
  return this.apiPost({
877
883
  url: '/companies/invite',
878
884
  data: payload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.721",
3
+ "version": "0.6.722",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -80,7 +80,7 @@ export const getColumns = ({
80
80
  return <div className="daf-default-cell" />;
81
81
  }
82
82
 
83
- const role = all?.apps?.[module]?.role;
83
+ const role = all?.role ||all?.apps?.[module]?.role;
84
84
  const options = (selectOptions?.userRole || []).filter(
85
85
  (o) => all.isAdmin || o.canBeAssignedToSubUsers,
86
86
  );
@@ -40,5 +40,6 @@ export const useWidgetFetch = ({config, getData = DashboardService.getWidget, on
40
40
  return {
41
41
  data,
42
42
  loading,
43
+ setData
43
44
  }
44
45
  }
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState, useMemo } from "react";
2
2
 
3
3
 
4
- export function useIdentification({ data = undefined, theme = {}, options = {} }) {
4
+ export function useIdentification({ data, theme = {}, options = {} }) {
5
5
  const colors = [
6
6
  theme.colorPrimary10,
7
7
  theme.colorPrimary9,
@@ -0,0 +1,139 @@
1
+ import { useState, useEffect, useMemo } from "react";
2
+ import dayjs from "dayjs";
3
+ import { capitalize } from "../../../../../../helpers/StringHelper.js";
4
+
5
+ export const useKnowledgeAccumulation = ({
6
+ data: mainData = {},
7
+ timeFilter,
8
+ isConsolidation,
9
+ t = () => {},
10
+ theme = {},
11
+ currentLanguage = "en",
12
+ }) => {
13
+ const [data, setData] = useState([]);
14
+
15
+ const config = (isConsolidation) => [
16
+ {
17
+ key: "mineSites",
18
+ label: isConsolidation ? t("Locations Data") : t("Locations"),
19
+ color: theme.colorPrimary10,
20
+ },
21
+ {
22
+ key: "stakeholder",
23
+ label: isConsolidation ? t("Stakeholders Data") : t("Stakeholders"),
24
+ color: theme.colorPrimary,
25
+ },
26
+ {
27
+ key: "event",
28
+ label: isConsolidation ? t("Events Data") : t("Events"),
29
+ color: theme.colorPrimary4,
30
+ },
31
+ ];
32
+ const fill = config(isConsolidation).map((c) => c.color);
33
+
34
+ const fetchData = () => {
35
+ const timeQuantity =
36
+ timeFilter === "monthly" ? "months" : timeFilter === "daily" ? "days" : "weeks";
37
+
38
+ const getFormatDate = (date, breakLine) => {
39
+ switch (timeFilter) {
40
+ case "daily":
41
+ return date.format("DD/MM");
42
+ case "weekly":
43
+ return `W${Number(date.week())}`;
44
+ default:
45
+ return breakLine
46
+ ? `${capitalize(date.format("MMM"))}\n${date.format("YY")}`
47
+ : capitalize(date.format("MMM YY"));
48
+ }
49
+ };
50
+
51
+ const _data = [];
52
+ let end = dayjs().locale(currentLanguage);
53
+ let start = dayjs().locale(currentLanguage).add(-12, timeQuantity);
54
+ let cumulativeScores = {};
55
+ Object.entries(mainData)
56
+ .filter(([k]) =>
57
+ dayjs(k).isBefore(
58
+ start,
59
+ timeFilter === "daily" ? "day" : timeFilter === "weekly" ? "week" : "month",
60
+ ),
61
+ )
62
+ .flatMap(([, v]) => v)
63
+ .forEach((s) => {
64
+ if (!cumulativeScores[s.category]) cumulativeScores[s.category] = 0;
65
+ cumulativeScores[s.category] += s.count;
66
+ });
67
+
68
+ while (start.isBefore(end) || start.isSame(end)) {
69
+ const scores = Object.entries(mainData)
70
+ .filter(([k]) => {
71
+ switch (timeFilter) {
72
+ case "daily":
73
+ return k === start.format("YYYY-MM-DD");
74
+ case "weekly":
75
+ return dayjs(k, "YYYY-MM-DD").week() === start.week();
76
+ default:
77
+ return dayjs(k, "YYYY-MM").isSame(start, "month");
78
+ }
79
+ })
80
+ .flatMap(([, v]) => v);
81
+
82
+ config(isConsolidation).forEach((c) => {
83
+ const currentScore = scores
84
+ .filter((s) => s.category === c.key)
85
+ .reduce((sum, score) => sum + score.count, 0);
86
+
87
+ cumulativeScores[c.key] = (cumulativeScores[c.key] || 0) + currentScore;
88
+ _data.push({
89
+ date: getFormatDate(start, true),
90
+ Score: cumulativeScores[c.key] || 0,
91
+ serie: c.key,
92
+ });
93
+ });
94
+
95
+ start = start.add(1, timeQuantity);
96
+ }
97
+
98
+ setData(_data);
99
+ };
100
+
101
+ useEffect(() => {
102
+ fetchData();
103
+ }, [mainData, timeFilter]);
104
+
105
+ const chartConfig = useMemo(() => {
106
+ return {
107
+ data: data,
108
+ xFieldKey: "date",
109
+ yFieldKey: "Score",
110
+ seriesField: "serie",
111
+ color: fill,
112
+ renderTooltipContent: (title, _data) => {
113
+ if (Array.isArray(_data) && _data[0]) {
114
+ const title = _data[0].title;
115
+ const values = data.filter((d) => d.date === title);
116
+
117
+ return {
118
+ title: t("Accumulation"),
119
+ subTitle: title.replace("\n", " "),
120
+ items: [
121
+ ...config(isConsolidation).map((conf) => ({
122
+ label: conf.label,
123
+ color: conf.color,
124
+ value: Number(
125
+ values.find((v) => v.serie === conf.key)?.Score || 0,
126
+ ),
127
+ })),
128
+ ],
129
+ };
130
+ }
131
+
132
+ return "";
133
+ },
134
+
135
+ }
136
+ }, [data]);
137
+
138
+ return chartConfig;
139
+ }
@@ -0,0 +1,78 @@
1
+ import React, { useState, useMemo } from 'react'
2
+ import { Select } from 'antd'
3
+ import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx'
4
+ import LineChart from '../../../../../core/components/Charts/LineChart/index.jsx'
5
+ import { useWidgetFetch } from '../../../../../hooks/useWidgetFetch.js'
6
+ import { useKnowledgeAccumulation } from './hook.js'
7
+
8
+ const defaultFetchConfig = {
9
+ basepath: "analytics",
10
+ url: "/widgets/knowledge-accumulation",
11
+ filters: {},
12
+ defaultData: [],
13
+ };
14
+
15
+ function AccumulationGraph({
16
+ section = "data-compilation",
17
+ tabSelected = "dataFlow",
18
+ t=() => {},
19
+ user = {},
20
+ theme = {}
21
+ }) {
22
+ const [timeFilter, setTimeFilter] = useState("monthly");
23
+
24
+ const fetchConfig = useMemo(
25
+ () => ({
26
+ ...defaultFetchConfig,
27
+ filters: {
28
+ section: section,
29
+ tabSelected: tabSelected,
30
+ },
31
+ stop: false,
32
+ }),
33
+ [section,tabSelected],
34
+ );
35
+
36
+ const { data, loading } = useWidgetFetch({config: fetchConfig});
37
+
38
+ const selectOptions = useMemo(
39
+ () => [
40
+ { label: t("Daily"), value: "daily" },
41
+ { label: t("Weekly"), value: "weekly" },
42
+ { label: t("Monthly"), value: "monthly" },
43
+ ],
44
+ [t],
45
+ );
46
+
47
+ const chartConfig = useKnowledgeAccumulation({
48
+ data,
49
+ timeFilter,
50
+ isConsolidation: tabSelected === "dataPoints",
51
+ t,
52
+ theme,
53
+ currentLanguage: user?.language || "en"
54
+ });
55
+
56
+ return (
57
+ <Widget
58
+ title={t("Accumulation")}
59
+ loading={loading}
60
+ className="with-border-header no-px-body"
61
+ addedHeader={
62
+ <>
63
+ <div className="flex-1" />
64
+ <Select
65
+ value={timeFilter}
66
+ style={{ width: 100 }}
67
+ onChange={setTimeFilter}
68
+ options={selectOptions}
69
+ />
70
+ </>
71
+ }
72
+ >
73
+ <LineChart {...chartConfig} height="400px" t={t} />
74
+ </Widget>
75
+ )
76
+ }
77
+
78
+ export default AccumulationGraph
@@ -0,0 +1,75 @@
1
+ export const mapData = ({ t, data = [], tabSelected }) => {
2
+ if (!data.length) {
3
+ return [
4
+ { category: "", type: t("Stakeholders"), value: 0.5 },
5
+ { category: "", type: t("Locations"), value: 0.5 },
6
+ { category: "", type: t("Events"), value: 0.5 },
7
+ { category: " ", type: "Stakeholders", value: 0.5 },
8
+ { category: " ", type: "Locations", value: 0.5 },
9
+ { category: " ", type: t("Events"), value: 0.5 },
10
+ { category: " ", type: t("Stakeholders"), value: 0.5 },
11
+ { category: " ", type: t("Locations"), value: 0.5 },
12
+ { category: " ", type: t("Events"), value: 0.5 },
13
+ { category: " ", type: t("Stakeholders"), value: 0.5 },
14
+ { category: " ", type: t("Locations"), value: 0.5 },
15
+ { category: " ", type: t("Events"), value: 0.5 },
16
+ ];
17
+ }
18
+
19
+ const metricTypes = {
20
+ stakeholders: tabSelected === "dataPoints" ? t("Stakeholders Data") : t("Stakeholders"),
21
+ locations: tabSelected === "dataPoints" ? t("Locations Data") : t("Locations"),
22
+ events: tabSelected === "dataPoints" ? t("Events Data") : t("Events"),
23
+ };
24
+
25
+ const flattened = [];
26
+ data.forEach((item) => {
27
+ Object.entries(metricTypes).forEach(([key, type]) => {
28
+ flattened.push({
29
+ category: (item.name || "").trim(),
30
+ type,
31
+ value: item[key] || 0,
32
+ });
33
+ });
34
+ });
35
+
36
+ const categoryTotals = data.reduce((acc, item) => {
37
+ const catName = (item.name || "").trim();
38
+ const total = (item.stakeholders || 0) + (item.locations || 0) + (item.events || 0);
39
+ acc[catName] = total;
40
+ return acc;
41
+ }, {});
42
+ flattened.sort((a, b) => categoryTotals[b.category] - categoryTotals[a.category]);
43
+
44
+ const uniqueCategories = [...new Set(flattened.map((d) => d.category))];
45
+ const topCategories = uniqueCategories.slice(0, 3);
46
+
47
+ const othersTotals = Object.keys(metricTypes).reduce((acc, key) => {
48
+ acc[key] = 0;
49
+ return acc;
50
+ }, {});
51
+
52
+ const result = [];
53
+ flattened.forEach((entry) => {
54
+ if (topCategories.includes(entry.category)) {
55
+ result.push(entry);
56
+ } else {
57
+ const foundKey = Object.entries(metricTypes).find(([, v]) => v === entry.type)?.[0];
58
+ if (foundKey) {
59
+ othersTotals[foundKey] += entry.value;
60
+ }
61
+ }
62
+ });
63
+
64
+ if (data.length > 3) {
65
+ Object.entries(metricTypes).forEach(([key, type]) => {
66
+ result.push({
67
+ category: t("Others"),
68
+ type,
69
+ value: othersTotals[key],
70
+ });
71
+ });
72
+ }
73
+
74
+ return result;
75
+ }
@@ -0,0 +1,46 @@
1
+ import { useMemo } from "react";
2
+ import { mapData } from "./helper.js";
3
+
4
+ export const useContributionsGraph = ({
5
+ data,
6
+ tabSelected,
7
+ t = () => {},
8
+ theme = {}
9
+ }) => {
10
+ const _data = useMemo(() => {
11
+ return mapData({ t, data, tabSelected });
12
+ }, [data, t]);
13
+
14
+ const chartConfig = useMemo(() => {
15
+ return {
16
+ data: _data,
17
+ xField: "value",
18
+ yField: "category",
19
+ seriesField: "type",
20
+ isGroup: true,
21
+ renderTooltipContent: (title, items) => {
22
+ const isEmpty = !data.length;
23
+
24
+ const tooltipItems = items.map((item) => ({
25
+ label: item.name,
26
+ color: item.color,
27
+ value: !isEmpty ? item.value : 0,
28
+ }));
29
+
30
+ return {
31
+ title: isEmpty ? t("Contributions") : title?.replace("\n", " "),
32
+ items: tooltipItems,
33
+ fitContent: true,
34
+ };
35
+ },
36
+ color: [
37
+ theme.colorPrimary7,
38
+ theme.colorPrimary4,
39
+ theme.colorPrimary9,
40
+ ],
41
+ }
42
+
43
+ }, [_data, t, theme]);
44
+
45
+ return chartConfig;
46
+ }
@@ -0,0 +1,49 @@
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 BarChart from '../../../../../core/components/Charts/BarChart/index.jsx'
5
+ import { useContributionsGraph } from './hook.js'
6
+
7
+ const defaultFetchConfig = {
8
+ basepath: "analytics",
9
+ url: "/widgets/contributions",
10
+ filters: {},
11
+ defaultData: [],
12
+ };
13
+
14
+ function ContributionsGraph({
15
+ tabSelected = "dataFlow",
16
+ section = "data-compilation",
17
+ t=() => {},
18
+ user = {},
19
+ theme = {}
20
+ }) {
21
+
22
+ const fetchConfig = useMemo(
23
+ () => ({
24
+ ...defaultFetchConfig,
25
+ filters: {
26
+ section: section,
27
+ tabSelected: tabSelected,
28
+ },
29
+ stop: false,
30
+ }),
31
+ [section, tabSelected],
32
+ );
33
+
34
+ const { data, loading } = useWidgetFetch({config: fetchConfig});
35
+
36
+ const chartConfig = useContributionsGraph({data: data, tabSelected: tabSelected, t: t, theme: theme});
37
+
38
+ return (
39
+ <Widget
40
+ loading={loading}
41
+ title={t("Contributions")}
42
+ className="with-border-header h-w-btn-header no-px-body"
43
+ >
44
+ <BarChart {...chartConfig} height="400px" t={t} />
45
+ </Widget>
46
+ )
47
+ }
48
+
49
+ export default ContributionsGraph
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import Segment from '../../../../../core/components/Segment/index.jsx'
3
+ import CustomIcon from '../../../../../core/components/Icon/CustomIcon.jsx'
4
+
5
+ function CustomSegment({ options = [], selected, onChange }) {
6
+ return (
7
+ <Segment
8
+ optionStyle={{
9
+ padding: "6px 12px",
10
+ }}
11
+ style={{
12
+ backgroundColor: "#F3F4F6",
13
+ }}
14
+ options={options.map((option) => ({
15
+ label: <CustomIcon name={option.label} width={18} height={18} />,
16
+ value: option.value,
17
+ disabled: option.disabled,
18
+ tooltip: option.tooltip,
19
+ }))}
20
+ defaultSelected={selected}
21
+ onChange={onChange}
22
+ />
23
+ );
24
+ }
25
+
26
+ export default CustomSegment
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+
3
+
4
+ const defaultFetchConfig = {
5
+ basepath: "analytics",
6
+ url: "/widgets/datachain-of-custody",
7
+ filters: {},
8
+ defaultData: [],
9
+ };
10
+
11
+
12
+ function DataChainOfCustody({t = () => {}, }) {
13
+ return (
14
+ <div>DataChainOfCustody</div>
15
+ )
16
+ }
17
+
18
+ export default DataChainOfCustody
@@ -0,0 +1,69 @@
1
+ import React, { useState } from 'react'
2
+ import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx'
3
+ import CustomSegment from '../CustomSegment/index.jsx'
4
+ import AccumulationGraph from '../AccumulationGraph/index.jsx'
5
+ import ContributionsGraph from '../ContributionsGraph/index.jsx'
6
+ import Triangulation from '../Triangulation/index.jsx'
7
+
8
+ function DataCompilation({
9
+ t = () => {},
10
+ user = {},
11
+ theme = {}
12
+ }) {
13
+ const [dataCompilationSelected, setDataCompilationSelected] = useState("dataFlow");
14
+ return (
15
+ <Widget
16
+ title={t("Data Compilation")}
17
+ className="with-border-header"
18
+ expandable
19
+ defaultExpanded
20
+ addedHeaderFirst
21
+ addedHeader={
22
+ <>
23
+ <div className="flex-1" />
24
+ <CustomSegment
25
+ selected={dataCompilationSelected}
26
+ onChange={setDataCompilationSelected}
27
+ options={[
28
+ {
29
+ label: "DataFlow02",
30
+ value: "dataFlow",
31
+ tooltip: t("Information Subjects"),
32
+ },
33
+ {
34
+ label: "DataPoints",
35
+ value: "dataPoints",
36
+ tooltip: t("Data Points"),
37
+ },
38
+ ]}
39
+ />
40
+ </>
41
+ }
42
+ >
43
+ <div className="flex flex-row flex-col-mobile gap-6">
44
+ <AccumulationGraph
45
+ tabSelected={dataCompilationSelected}
46
+ t={t}
47
+ user={user}
48
+ theme={theme}
49
+ />
50
+ <ContributionsGraph
51
+ tabSelected={dataCompilationSelected}
52
+ t={t}
53
+ user={user}
54
+ theme={theme}
55
+ />
56
+ <Triangulation
57
+ tabSelected={dataCompilationSelected}
58
+ isDataflow={dataCompilationSelected === "dataFlow"}
59
+ t={t}
60
+ user={user}
61
+ theme={theme}
62
+ />
63
+ </div>
64
+
65
+ </Widget>
66
+ )
67
+ }
68
+
69
+ export default DataCompilation
@@ -0,0 +1,72 @@
1
+ import React, { useState } from 'react'
2
+ import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx'
3
+ import CustomSegment from '../CustomSegment/index.jsx'
4
+ import AccumulationGraph from '../AccumulationGraph/index.jsx'
5
+ import ContributionsGraph from '../ContributionsGraph/index.jsx'
6
+ import Triangulation from '../Triangulation/index.jsx'
7
+
8
+ function DataConsilidation({
9
+ t = () => {},
10
+ user = {},
11
+ theme = {}
12
+ }) {
13
+ const [dataConsolidationSelected, setDataConsolidationSelected] = useState("dataFlow");
14
+ return (
15
+ <Widget
16
+ title={t("Data Consolidation")}
17
+ className="with-border-header"
18
+ expandable
19
+ defaultExpanded
20
+ addedHeaderFirst
21
+ addedHeader={
22
+ <>
23
+ <div className="flex-1" />
24
+ <CustomSegment
25
+ selected={dataConsolidationSelected}
26
+ onChange={(val) => setDataConsolidationSelected(val)}
27
+ options={[
28
+ {
29
+ label: "DataFlow02",
30
+ value: "dataFlow",
31
+ tooltip: t("Information Subjects"),
32
+ },
33
+ {
34
+ label: "DataPoints",
35
+ value: "dataPoints",
36
+ tooltip: t("Data Points"),
37
+ },
38
+ ]}
39
+ />
40
+ </>
41
+ }
42
+ >
43
+ <div className="flex flex-row flex-col-mobile gap-6">
44
+ <AccumulationGraph
45
+ tabSelected={dataConsolidationSelected}
46
+ section="data-consolidation"
47
+ t={t}
48
+ user={user}
49
+ theme={theme}
50
+ />
51
+ <ContributionsGraph
52
+ tabSelected={dataConsolidationSelected}
53
+ section="data-consolidation"
54
+ t={t}
55
+ user={user}
56
+ theme={theme}
57
+ />
58
+ <Triangulation
59
+ tabSelected={dataConsolidationSelected}
60
+ section="data-consolidation"
61
+ isDataflow={dataConsolidationSelected === "dataFlow"}
62
+ t={t}
63
+ user={user}
64
+ theme={theme}
65
+ />
66
+ </div>
67
+
68
+ </Widget>
69
+ )
70
+ }
71
+
72
+ export default DataConsilidation