datastake-daf 0.6.803 → 0.6.804
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 +2378 -2340
- package/dist/pages/index.js +248 -67
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/package.json +1 -1
- package/public/Biodiversity/others-default.svg +38 -0
- package/public/Biodiversity/others.svg +38 -0
- package/public/Biodiversity/unidentified-pests-default.svg +33 -0
- package/public/Biodiversity/unidentified-pests.svg +33 -0
- package/src/@daf/core/components/Dashboard/Widget/FaunaWidget/config.js +15 -0
- package/src/@daf/core/components/Dashboard/Widget/FaunaWidget/index.jsx +83 -0
- package/src/@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/config.js +11 -0
- package/src/@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/index.jsx +87 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx +34 -31
- package/src/index.js +2 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Widget from "../index.jsx";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { getInvasiveSpeciesConfig } from "./config.js";
|
|
4
|
+
import { Tooltip } from "antd";
|
|
5
|
+
|
|
6
|
+
export default function InvasiveSpeciesWidget({
|
|
7
|
+
title = "Invasive Species",
|
|
8
|
+
invasiveSpecies = [],
|
|
9
|
+
hasInvasiveSpecies,
|
|
10
|
+
filterKeys = null,
|
|
11
|
+
columnsPerRow = 3,
|
|
12
|
+
itemWidth = 100,
|
|
13
|
+
itemHeight = 100,
|
|
14
|
+
t = (key) => key,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
let invasiveSpeciesConfig = getInvasiveSpeciesConfig();
|
|
18
|
+
|
|
19
|
+
// Filter to show only specific keys if filterKeys is provided
|
|
20
|
+
if (filterKeys && Array.isArray(filterKeys)) {
|
|
21
|
+
invasiveSpeciesConfig = invasiveSpeciesConfig.filter(item => filterKeys.includes(item.key));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Widget title={title} className={`with-border-header no-p-body`} {...props}>
|
|
26
|
+
<InvasiveSpeciesWrapper $columnsPerRow={columnsPerRow}>
|
|
27
|
+
<InvasiveSpeciesContainer
|
|
28
|
+
$columnsPerRow={columnsPerRow}
|
|
29
|
+
$itemWidth={itemWidth}
|
|
30
|
+
$itemHeight={itemHeight}
|
|
31
|
+
>
|
|
32
|
+
{invasiveSpeciesConfig.map((item) => {
|
|
33
|
+
// If hasInvasiveSpecies is 'no', show all as inactive
|
|
34
|
+
// If hasInvasiveSpecies is 'yes', show present ones as active
|
|
35
|
+
const shouldShowAllAsNotPresent = hasInvasiveSpecies === 'no';
|
|
36
|
+
const isPresent = !shouldShowAllAsNotPresent &&
|
|
37
|
+
Array.isArray(invasiveSpecies) &&
|
|
38
|
+
invasiveSpecies.includes(item.key);
|
|
39
|
+
const shouldUseColored = isPresent;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Tooltip key={item.key} title={t(`straatos::${item.key}`)}>
|
|
43
|
+
<img
|
|
44
|
+
src={shouldUseColored ? item.img : item.disabled}
|
|
45
|
+
key={item.key}
|
|
46
|
+
className={`invasive-species-item`}
|
|
47
|
+
alt={item.key}
|
|
48
|
+
></img>
|
|
49
|
+
</Tooltip>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</InvasiveSpeciesContainer>
|
|
53
|
+
</InvasiveSpeciesWrapper>
|
|
54
|
+
</Widget>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const InvasiveSpeciesWrapper = styled.div`
|
|
59
|
+
padding: 24px;
|
|
60
|
+
width: 100%;
|
|
61
|
+
${props => props.$columnsPerRow ? `
|
|
62
|
+
overflow-x: auto;
|
|
63
|
+
` : ''}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
const InvasiveSpeciesContainer = styled.div`
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns: ${props =>
|
|
69
|
+
props.$columnsPerRow
|
|
70
|
+
? `repeat(${props.$columnsPerRow}, 1fr)`
|
|
71
|
+
: `repeat(auto-fit, minmax(${props.$itemWidth}px, 1fr))`
|
|
72
|
+
};
|
|
73
|
+
gap: 24px;
|
|
74
|
+
width: 100%;
|
|
75
|
+
|
|
76
|
+
.invasive-species-item {
|
|
77
|
+
width: 100%;
|
|
78
|
+
aspect-ratio: ${props => props.$itemWidth / props.$itemHeight};
|
|
79
|
+
border-radius: 7px;
|
|
80
|
+
flex-shrink: 0;
|
|
81
|
+
display: block;
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 0;
|
|
84
|
+
object-fit: contain;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
|
package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Widget, FaunaWidget, InvasiveSpeciesWidget } from '../../../../../../../../src/index.js';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import {
|
|
5
|
-
generateFaunaConfig,
|
|
6
|
-
generateInvasiveSpeciesConfig
|
|
7
|
-
} from './helper';
|
|
8
4
|
|
|
9
|
-
const
|
|
10
|
-
display:
|
|
11
|
-
grid-template-columns: 70% 28.5%;
|
|
5
|
+
const BiodiversityContainer = styled.div`
|
|
6
|
+
display: flex;
|
|
12
7
|
gap: 24px;
|
|
13
8
|
width: 100%;
|
|
9
|
+
|
|
14
10
|
@media (max-width: 768px) {
|
|
15
|
-
|
|
11
|
+
flex-direction: column;
|
|
16
12
|
}
|
|
17
13
|
`;
|
|
18
14
|
|
|
15
|
+
const FaunaSection = styled.section`
|
|
16
|
+
width: 60%;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const InvasiveSpeciesSection = styled.section`
|
|
21
|
+
width: 38.5%;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
|
|
19
25
|
const BiodiversityAndHabitat = ({
|
|
20
26
|
faunaPresent = [],
|
|
21
27
|
invasiveSpecies = [],
|
|
@@ -23,40 +29,37 @@ const BiodiversityAndHabitat = ({
|
|
|
23
29
|
loading = false,
|
|
24
30
|
t = (s) => s
|
|
25
31
|
}) => {
|
|
26
|
-
const observedFaunaConfig = useMemo(() =>
|
|
27
|
-
generateFaunaConfig(faunaPresent, t),
|
|
28
|
-
[faunaPresent, t]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const invasiveSpeciesConfig = useMemo(() =>
|
|
32
|
-
generateInvasiveSpeciesConfig(invasiveSpecies, hasInvasiveSpecies, t),
|
|
33
|
-
[invasiveSpecies, hasInvasiveSpecies, t]
|
|
34
|
-
);
|
|
35
|
-
|
|
36
32
|
return (
|
|
37
33
|
<Widget
|
|
38
34
|
title={t("Biodiversity & Habitat")}
|
|
39
35
|
className="with-border-header h-w-btn-header"
|
|
40
36
|
>
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
<
|
|
37
|
+
<BiodiversityContainer>
|
|
38
|
+
<FaunaSection>
|
|
39
|
+
<FaunaWidget
|
|
44
40
|
title={t("Observed Fauna")}
|
|
45
|
-
|
|
41
|
+
faunaPresent={faunaPresent}
|
|
42
|
+
columnsPerRow={5}
|
|
43
|
+
itemWidth={120}
|
|
44
|
+
itemHeight={120}
|
|
46
45
|
loading={loading}
|
|
47
|
-
widgetClassName="h-w-btn-header"
|
|
48
46
|
t={t}
|
|
49
47
|
/>
|
|
50
|
-
|
|
48
|
+
</FaunaSection>
|
|
49
|
+
|
|
50
|
+
<InvasiveSpeciesSection>
|
|
51
|
+
<InvasiveSpeciesWidget
|
|
51
52
|
title={t("Invasive Species")}
|
|
52
|
-
|
|
53
|
+
invasiveSpecies={invasiveSpecies}
|
|
54
|
+
hasInvasiveSpecies={hasInvasiveSpecies}
|
|
55
|
+
columnsPerRow={3}
|
|
56
|
+
itemWidth={100}
|
|
57
|
+
itemHeight={100}
|
|
53
58
|
loading={loading}
|
|
54
|
-
className="single-column"
|
|
55
|
-
widgetClassName="h-w-btn-header"
|
|
56
59
|
t={t}
|
|
57
60
|
/>
|
|
58
|
-
</
|
|
59
|
-
</
|
|
61
|
+
</InvasiveSpeciesSection>
|
|
62
|
+
</BiodiversityContainer>
|
|
60
63
|
</Widget>
|
|
61
64
|
);
|
|
62
65
|
};
|
package/src/index.js
CHANGED
|
@@ -79,6 +79,8 @@ export { default as CarouselWidget } from "./@daf/core/components/Dashboard/Widg
|
|
|
79
79
|
export { default as ImageCarousel } from "./@daf/core/components/Dashboard/Widget/ImageCarousel/index.jsx";
|
|
80
80
|
export { default as StatCard } from "./@daf/core/components/Dashboard/Widget/StatCard/index.js";
|
|
81
81
|
export { default as VegetationHealth } from "./@daf/core/components/Dashboard/Widget/VegetationWidget/index.jsx";
|
|
82
|
+
export { default as FaunaWidget } from "./@daf/core/components/Dashboard/Widget/FaunaWidget/index.jsx";
|
|
83
|
+
export { default as InvasiveSpeciesWidget } from "./@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/index.jsx";
|
|
82
84
|
// export { default as WidgetCatalogue } from "./@daf/core/components/Dashboard/Widget/WidgetCatalogue/index.jsx";
|
|
83
85
|
|
|
84
86
|
// Forms
|