@mapcomponents/react-maplibre 0.1.11 → 0.1.15
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/.github/workflows/storybook.yml +10 -5
- package/coverage/clover.xml +894 -747
- package/coverage/coverage-final.json +22 -17
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +188 -122
- package/coverage/lcov-report/sorter.js +26 -0
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +84 -69
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +27 -21
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +73 -61
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +56 -71
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +32 -26
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +162 -48
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +311 -0
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +35 -29
- package/coverage/lcov-report/{components/MlImageMarkerLayer/MlImageMarkerLayer.js.html → src/components/MlLayer/MlLayer.js.html} +123 -126
- package/coverage/lcov-report/src/components/MlLayer/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +48 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +45 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +31 -25
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +18 -12
- package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +57 -42
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +25 -19
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +224 -26
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +25 -19
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +37 -55
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +20 -14
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +21 -15
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +38 -20
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +23 -17
- package/coverage/lcov-report/src/hooks/index.html +147 -0
- package/coverage/lcov-report/{components/MlLayer/MlLayer.js.html → src/hooks/useMap.js.html} +86 -119
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +98 -92
- package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +25 -19
- package/coverage/lcov-report/src/i18n.js.html +167 -0
- package/coverage/lcov-report/src/index.html +117 -0
- package/coverage/lcov-report/src/translations/english.js.html +95 -0
- package/coverage/lcov-report/src/translations/german.js.html +95 -0
- package/coverage/lcov-report/src/translations/index.html +132 -0
- package/coverage/lcov.info +1620 -1306
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +976 -688
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -1
- package/public/assets/dop.png +0 -0
- package/public/assets/historic.png +0 -0
- package/public/assets/osm.png +0 -0
- package/public/thumbnails/MlFollowGps.png +0 -0
- package/public/thumbnails/MlThreeJsLayer.png +0 -0
- package/rollup.config.js +7 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +53 -67
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +49 -46
- package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
- package/src/components/MlFollowGps/assets/marker.png +0 -0
- package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
- package/src/components/MlGPXViewer/gpxConverter.js +22 -29
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +45 -9
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -57
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +28 -6
- package/src/components/MlLayer/MlLayer.test.js +12 -10
- package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
- package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
- package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
- package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
- package/src/components/MlMarker/MlMarker.js +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.js +29 -26
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlShareMapState/MlShareMapState.js +73 -9
- package/src/components/MlShareMapState/MlShareMapState.stories.js +24 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +3 -3
- package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
- package/src/decorators/EmptyMapContextDecorator.js +11 -6
- package/src/decorators/MapContext3DDecorator.js +25 -20
- package/src/decorators/MapContextDashboardDecorator.js +7 -2
- package/src/decorators/MapContextDecorator.js +7 -3
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
- package/src/decorators/MultiMapContextDecorator.js +2 -1
- package/src/hooks/useMap.js +36 -62
- package/src/hooks/useMapState.js +3 -3
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/index.js +3 -0
- package/src/translations/english.js +4 -0
- package/src/translations/german.js +4 -0
- package/src/ui_components/ImageLoader.js +73 -0
- package/src/ui_components/Sidebar.js +76 -22
- package/src/ui_components/TopToolbar.js +18 -18
- package/coverage/lcov-report/components/MlLayer/index.html +0 -111
- package/coverage/lcov-report/hooks/index.html +0 -141
- package/coverage/lcov-report/hooks/useMap.js.html +0 -377
package/src/hooks/useMap.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { useContext, useState, useEffect, useRef } from "react";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
import { MapContext } from "@mapcomponents/react-core";
|
|
4
|
+
import useMapState from "./useMapState";
|
|
4
5
|
|
|
5
6
|
function useMap(props) {
|
|
6
7
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
7
8
|
const mapContext = useContext(MapContext);
|
|
8
9
|
|
|
10
|
+
const mapState = useMapState({
|
|
11
|
+
mapId: props.mapId,
|
|
12
|
+
watch: {
|
|
13
|
+
viewport: false,
|
|
14
|
+
layers: true,
|
|
15
|
+
sources: false,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
9
19
|
const initializedRef = useRef(false);
|
|
10
20
|
const mapRef = useRef(undefined);
|
|
11
21
|
|
|
12
|
-
const [center, setCenter] = useState(undefined);
|
|
13
|
-
const [layerIds, setLayerIds] = useState(undefined);
|
|
14
|
-
const layerIdsRef = useRef(undefined);
|
|
15
|
-
|
|
16
|
-
const [layers, setLayers] = useState(undefined);
|
|
17
|
-
const layersRef = useRef(undefined);
|
|
18
|
-
//const mapRef = useRef(props.map);
|
|
19
22
|
const componentId = useRef(uuidv4());
|
|
20
23
|
|
|
24
|
+
const [mapIsReady, setMapIsReady] = useState(undefined);
|
|
25
|
+
|
|
21
26
|
useEffect(() => {
|
|
22
27
|
let _componentId = componentId.current;
|
|
23
28
|
|
|
@@ -27,72 +32,41 @@ function useMap(props) {
|
|
|
27
32
|
mapRef.current = undefined;
|
|
28
33
|
}
|
|
29
34
|
initializedRef.current = false;
|
|
35
|
+
setMapIsReady(false);
|
|
30
36
|
};
|
|
31
37
|
}, []);
|
|
32
38
|
|
|
33
|
-
const buildLayerObjects = (layers) => {
|
|
34
|
-
let res = {};
|
|
35
|
-
Object.keys(layers).forEach((layerId) => {
|
|
36
|
-
if (mapRef.current.baseLayers.indexOf(layerId) === -1) {
|
|
37
|
-
res[layerId] = {
|
|
38
|
-
//filter: layers[layerId].filter,
|
|
39
|
-
id: layers[layerId].id,
|
|
40
|
-
//layout: layers[layerId].layout,
|
|
41
|
-
//maxzoom: layers[layerId].maxzoom,
|
|
42
|
-
//metadata: layers[layerId].metadata,
|
|
43
|
-
//minzoom: layers[layerId].minzoom,
|
|
44
|
-
paint: layers[layerId].paint,
|
|
45
|
-
//source: layers[layerId].source,
|
|
46
|
-
//sourceLayer: layers[layerId].sourceLayer,
|
|
47
|
-
type: layers[layerId].type,
|
|
48
|
-
visibility: layers[layerId].visibility,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return res;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
39
|
useEffect(() => {
|
|
56
40
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
41
|
+
|
|
42
|
+
console.log("initialize useMap hook");
|
|
43
|
+
//check if insertBeforeLayer exists
|
|
44
|
+
if (props.waitForLayer) {
|
|
45
|
+
let layerFound = false;
|
|
46
|
+
|
|
47
|
+
mapState?.layers?.forEach((layer) => {
|
|
48
|
+
console.log(layer.id + " " + props.waitForLayer);
|
|
49
|
+
if (layer.id === props.waitForLayer) {
|
|
50
|
+
layerFound = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (!layerFound) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.log("done initialize useMap hook");
|
|
57
58
|
// the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
58
59
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
59
60
|
initializedRef.current = true;
|
|
60
61
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
mapRef.current.on(
|
|
64
|
-
"idle",
|
|
65
|
-
() => {
|
|
66
|
-
if (JSON.stringify(mapRef.current.style._order) !== layerIdsRef.current) {
|
|
67
|
-
let layerIds = [...mapRef.current.style._order];
|
|
68
|
-
layerIdsRef.current = JSON.stringify(layerIds);
|
|
69
|
-
setLayerIds(layerIds);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let layerStates = buildLayerObjects(mapRef.current.style._layers);
|
|
73
|
-
let layerStatesString = JSON.stringify(layerStates);
|
|
74
|
-
if (layerStatesString !== layersRef.current) {
|
|
75
|
-
layersRef.current = layerStatesString;
|
|
76
|
-
setLayers(layerStates);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
componentId.current
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
setCenter(mapRef.current.getCenter());
|
|
83
|
-
mapRef.current.on(
|
|
84
|
-
"move",
|
|
85
|
-
() => {
|
|
86
|
-
setCenter(mapRef.current.getCenter());
|
|
87
|
-
},
|
|
88
|
-
componentId.current
|
|
89
|
-
);
|
|
90
|
-
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
62
|
+
setMapIsReady(true);
|
|
63
|
+
}, [mapContext.mapIds, mapState.layers, mapContext, props.mapId]);
|
|
91
64
|
|
|
92
65
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
map: mapRef.current,
|
|
67
|
+
mapIsReady,
|
|
68
|
+
componentId: componentId.current,
|
|
69
|
+
layers: mapState.layers,
|
|
96
70
|
};
|
|
97
71
|
}
|
|
98
72
|
|
package/src/hooks/useMapState.js
CHANGED
|
@@ -34,11 +34,11 @@ function useMapState(props) {
|
|
|
34
34
|
*/
|
|
35
35
|
const layerIdFilter = useCallback(
|
|
36
36
|
(layer) => {
|
|
37
|
-
if (!props
|
|
37
|
+
if (!props?.filter?.includeBaseLayers && layer.baseLayer) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (typeof props.filter
|
|
41
|
+
if (typeof props.filter?.matchLayerIds !== "undefined") {
|
|
42
42
|
if (props.filter.matchLayerIds instanceof RegExp) {
|
|
43
43
|
return props.filter.matchLayerIds.test(layer.id);
|
|
44
44
|
} else {
|
|
@@ -58,7 +58,7 @@ function useMapState(props) {
|
|
|
58
58
|
layersRef.current = _layerStateString;
|
|
59
59
|
setLayers(_layerState);
|
|
60
60
|
}
|
|
61
|
-
},[layerIdFilter]);
|
|
61
|
+
}, [layerIdFilter]);
|
|
62
62
|
|
|
63
63
|
useEffect(() => {
|
|
64
64
|
let _componentId = componentId.current;
|
package/src/hooks/useWms.js
CHANGED
|
@@ -25,12 +25,13 @@ function useWms(props) {
|
|
|
25
25
|
// extract URL parameters from the given URL
|
|
26
26
|
clearState();
|
|
27
27
|
setError(undefined);
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
if (!url) return;
|
|
29
30
|
|
|
30
31
|
let _propsUrlParams;
|
|
31
|
-
let _wmsUrl =
|
|
32
|
-
if (
|
|
33
|
-
_propsUrlParams =
|
|
32
|
+
let _wmsUrl = url;
|
|
33
|
+
if (url.indexOf("?") !== -1) {
|
|
34
|
+
_propsUrlParams = url.split("?");
|
|
34
35
|
_wmsUrl = _propsUrlParams[0];
|
|
35
36
|
}
|
|
36
37
|
let _urlParamsFromUrl = new URLSearchParams(_propsUrlParams?.[1]);
|
|
@@ -62,7 +63,7 @@ function useWms(props) {
|
|
|
62
63
|
console.log(error);
|
|
63
64
|
setError(error.message);
|
|
64
65
|
});
|
|
65
|
-
}, [
|
|
66
|
+
}, [url, props.urlParameters]);
|
|
66
67
|
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
if (!capabilities?.Service) return;
|
|
@@ -92,4 +93,4 @@ useWms.defaultProps = {
|
|
|
92
93
|
},
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
export default useWms;
|
|
96
|
+
export default useWms;
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import i18n from "i18next";
|
|
2
|
+
import { initReactI18next } from "react-i18next";
|
|
3
|
+
import english from "./translations/english.js"
|
|
4
|
+
import german from "./translations/german.js"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// the translations
|
|
8
|
+
// (tip move them in a JSON file and import them,
|
|
9
|
+
// or even better, manage them separated from your code: https://react.i18next.com/guides/multiple-translation-files)
|
|
10
|
+
const resources = { ...english, ...german };
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
i18n
|
|
14
|
+
.use(initReactI18next) // passes i18n down to react-i18next
|
|
15
|
+
.init({
|
|
16
|
+
resources,
|
|
17
|
+
lng: "de", // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
|
|
18
|
+
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
|
|
19
|
+
// if you're using a language detector, do not define the lng option
|
|
20
|
+
|
|
21
|
+
interpolation: {
|
|
22
|
+
escapeValue: false // react already safes from xss
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export default i18n;
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as MapLibreMap } from "./components/MapLibreMap/MapLibreMap";
|
|
2
2
|
export { default as MlComponentTemplate } from "./components/MlComponentTemplate/MlComponentTemplate";
|
|
3
3
|
export { default as MlFillExtrusionLayer } from "./components/MlFillExtrusionLayer/MlFillExtrusionLayer";
|
|
4
|
+
export { default as MlFollowGps } from "./components/MlFollowGps/MlFollowGps";
|
|
4
5
|
export { default as MlCreatePdfButton } from "./components/MlCreatePdfButton/MlCreatePdfButton";
|
|
5
6
|
export { default as MlGeoJsonLayer } from "./components/MlGeoJsonLayer/MlGeoJsonLayer";
|
|
6
7
|
export { default as MlImageMarkerLayer } from "./components/MlImageMarkerLayer/MlImageMarkerLayer";
|
|
@@ -17,5 +18,7 @@ export { default as MlLayerSwipe } from "./components/MlLayerSwipe/MlLayerSwipe"
|
|
|
17
18
|
export { default as MlGPXViewer } from "./components/MlGPXViewer/MlGPXViewer";
|
|
18
19
|
export { default as GeoJsonProvider } from "./components/MlGPXViewer/util/GeoJsonProvider";
|
|
19
20
|
export { default as GeoJsonContext } from "./components/MlGPXViewer/util/GeoJsonContext";
|
|
21
|
+
export { default as MlSpatialElevationProfile } from "./components/MlSpatialElevationProfile/MlSpatialElevationProfile";
|
|
20
22
|
|
|
21
23
|
export { default as useMapState } from "./hooks/useMapState";
|
|
24
|
+
export { default as useMap } from "./hooks/useMap";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
import { useEffect, useState } from "react"
|
|
3
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
4
|
+
|
|
5
|
+
import ErrorIcon from '@mui/icons-material/Error';
|
|
6
|
+
import { Box } from "@mui/system";
|
|
7
|
+
const ImageLoader = (props) => {
|
|
8
|
+
const [state, setState] = useState("loading");
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!props.src) {
|
|
12
|
+
setState("error");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
fetch(props.src)
|
|
16
|
+
.then(({ ok }) => {
|
|
17
|
+
if (ok) {
|
|
18
|
+
setState("ready");
|
|
19
|
+
} else {
|
|
20
|
+
setState("error");
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.catch((e) => {
|
|
24
|
+
console.error(e);
|
|
25
|
+
setState("error");
|
|
26
|
+
});
|
|
27
|
+
}, [props.src]);
|
|
28
|
+
|
|
29
|
+
const boxStyle = {
|
|
30
|
+
width: "100%",
|
|
31
|
+
height: "100%",
|
|
32
|
+
border: 2,
|
|
33
|
+
borderRadius: "8px",
|
|
34
|
+
textAlign: "center",
|
|
35
|
+
display: "flex",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const LoadingImage = () => {
|
|
39
|
+
return (
|
|
40
|
+
<Box className={props.className} sx={{ ...boxStyle, ...props.style }}>
|
|
41
|
+
<CircularProgress />
|
|
42
|
+
</Box>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const ReadyImage = () => {
|
|
47
|
+
return (
|
|
48
|
+
<img className={props.className} style={{ ...boxStyle, ...props.style }} src={props.src} />
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
const ErrorImage = () => {
|
|
52
|
+
return (
|
|
53
|
+
<Box className={props.className} sx={{ boxStyle, ...props.style }}>
|
|
54
|
+
<ErrorIcon sx={{ display: "block", margin: "auto" }} />
|
|
55
|
+
</Box>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const renderImage = (state) => {
|
|
60
|
+
switch (state) {
|
|
61
|
+
case "ready":
|
|
62
|
+
return <ReadyImage />;
|
|
63
|
+
case "error":
|
|
64
|
+
return <ErrorImage />;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <LoadingImage />;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return <>{renderImage(state)}</>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default ImageLoader
|
|
@@ -1,46 +1,100 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, {useState} from "react";
|
|
2
|
+
import { useTheme, styled } from "@mui/material/styles";
|
|
2
3
|
import makeStyles from "@mui/styles/makeStyles";
|
|
3
4
|
import Drawer from "@mui/material/Drawer";
|
|
5
|
+
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
6
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
7
|
+
import { IconButton } from "@mui/material";
|
|
8
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
4
9
|
|
|
5
10
|
const useStyles = makeStyles((theme) => ({
|
|
6
11
|
drawer: {
|
|
7
12
|
flexGrow: 1,
|
|
8
|
-
zIndex:
|
|
13
|
+
zIndex: 105,
|
|
9
14
|
position: "absolute",
|
|
10
15
|
top: 0,
|
|
11
16
|
left: 0,
|
|
12
17
|
bottom: 0,
|
|
13
18
|
backgroundColor: "#fafafa",
|
|
14
|
-
},
|
|
15
|
-
drawerPaper: {
|
|
16
|
-
position: "static",
|
|
17
19
|
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
18
21
|
alignItems: "stretch",
|
|
19
22
|
alignContent: "stretch",
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
},
|
|
24
|
+
drawerPaper: {
|
|
25
|
+
position: "initial !important",
|
|
22
26
|
boxSizing: "border-box",
|
|
23
|
-
|
|
27
|
+
padding: "40px",
|
|
28
|
+
visibility: "visible !important",
|
|
29
|
+
zIndex: "initial !important",
|
|
24
30
|
},
|
|
31
|
+
drawerHeader: {
|
|
32
|
+
alignContent: "flex-start",
|
|
33
|
+
display: "flex",
|
|
34
|
+
},
|
|
35
|
+
drawerContent: {},
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
25
41
|
}));
|
|
26
42
|
|
|
27
43
|
export default function Sidebar(props) {
|
|
28
44
|
const classes = useStyles();
|
|
45
|
+
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
46
|
+
|
|
47
|
+
const [drawerOpen, setDrawerOpen] = useState(true);
|
|
48
|
+
|
|
49
|
+
const handleDrawerOpen = () => {
|
|
50
|
+
setDrawerOpen(true);
|
|
51
|
+
};
|
|
52
|
+
const handleDrawerClose = () => {
|
|
53
|
+
setDrawerOpen(false);
|
|
54
|
+
};
|
|
29
55
|
|
|
30
56
|
return (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
<>
|
|
58
|
+
<IconButton
|
|
59
|
+
onClick={handleDrawerOpen}
|
|
60
|
+
style={{
|
|
61
|
+
zIndex: 101,
|
|
62
|
+
position: "relative",
|
|
63
|
+
padding: "20px",
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<MenuIcon />
|
|
67
|
+
</IconButton>
|
|
68
|
+
<Drawer
|
|
69
|
+
transitionDuration={0}
|
|
70
|
+
className={classes.drawer}
|
|
71
|
+
variant="persistent"
|
|
72
|
+
anchor="left"
|
|
73
|
+
open={drawerOpen}
|
|
74
|
+
classes={{
|
|
75
|
+
paper: classes.drawerPaper,
|
|
76
|
+
}}
|
|
77
|
+
sx={{
|
|
78
|
+
...props.sx,
|
|
79
|
+
...{
|
|
80
|
+
maxWidth: mediaIsMobile ? "90vw" : "20vw",
|
|
81
|
+
},
|
|
82
|
+
...(drawerOpen ? {} : { left: mediaIsMobile ? "-90vw" : "-20vw" }),
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<DrawerHeader className={classes.drawerHeader}>
|
|
86
|
+
<IconButton onClick={handleDrawerClose}>
|
|
87
|
+
<ChevronLeftIcon
|
|
88
|
+
style={
|
|
89
|
+
{
|
|
90
|
+
//paddingBottom: "40px",
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
</IconButton>
|
|
95
|
+
</DrawerHeader>
|
|
96
|
+
<div style={{ maxWidth: "100%" }}>{props.children}</div>
|
|
97
|
+
</Drawer>
|
|
98
|
+
</>
|
|
45
99
|
);
|
|
46
100
|
}
|
|
@@ -3,27 +3,27 @@ import makeStyles from "@mui/styles/makeStyles";
|
|
|
3
3
|
import AppBar from "@mui/material/AppBar";
|
|
4
4
|
import Toolbar from "@mui/material/Toolbar";
|
|
5
5
|
|
|
6
|
-
const useStyles = makeStyles((theme) => ({
|
|
7
|
-
root: {
|
|
8
|
-
flexGrow: 1,
|
|
9
|
-
zIndex: 120,
|
|
10
|
-
position: "absolute",
|
|
11
|
-
top: 0,
|
|
12
|
-
left: 0,
|
|
13
|
-
right: 0,
|
|
14
|
-
},
|
|
15
|
-
AppBar: {
|
|
16
|
-
backgroundColor: "#fafafa",
|
|
17
|
-
minHeight: "62px",
|
|
18
|
-
},
|
|
19
|
-
}));
|
|
20
6
|
|
|
21
7
|
export default function TopToolbar(props) {
|
|
22
|
-
const classes = useStyles();
|
|
23
|
-
|
|
24
8
|
return (
|
|
25
|
-
<div
|
|
26
|
-
|
|
9
|
+
<div
|
|
10
|
+
style={{
|
|
11
|
+
flexGrow: 1,
|
|
12
|
+
zIndex: 120,
|
|
13
|
+
position: "absolute",
|
|
14
|
+
top: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
<AppBar
|
|
20
|
+
sx={{
|
|
21
|
+
minHeight: "62px",
|
|
22
|
+
backgroundColor: "#f1f1f1",
|
|
23
|
+
}}
|
|
24
|
+
color="primary"
|
|
25
|
+
position="static"
|
|
26
|
+
>
|
|
27
27
|
<Toolbar>{props.children}</Toolbar>
|
|
28
28
|
</AppBar>
|
|
29
29
|
</div>
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for components/MlLayer</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> components/MlLayer</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">86.48% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>32/37</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">75% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>21/28</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>5/5</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">86.11% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>31/36</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
</div>
|
|
58
|
-
<div class='status-line high'></div>
|
|
59
|
-
<div class="pad1">
|
|
60
|
-
<table class="coverage-summary">
|
|
61
|
-
<thead>
|
|
62
|
-
<tr>
|
|
63
|
-
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
64
|
-
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
65
|
-
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
66
|
-
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
67
|
-
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
68
|
-
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
69
|
-
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
70
|
-
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
71
|
-
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
72
|
-
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
73
|
-
</tr>
|
|
74
|
-
</thead>
|
|
75
|
-
<tbody><tr>
|
|
76
|
-
<td class="file high" data-value="MlLayer.js"><a href="MlLayer.js.html">MlLayer.js</a></td>
|
|
77
|
-
<td data-value="86.48" class="pic high">
|
|
78
|
-
<div class="chart"><div class="cover-fill" style="width: 86%"></div><div class="cover-empty" style="width: 14%"></div></div>
|
|
79
|
-
</td>
|
|
80
|
-
<td data-value="86.48" class="pct high">86.48%</td>
|
|
81
|
-
<td data-value="37" class="abs high">32/37</td>
|
|
82
|
-
<td data-value="75" class="pct medium">75%</td>
|
|
83
|
-
<td data-value="28" class="abs medium">21/28</td>
|
|
84
|
-
<td data-value="100" class="pct high">100%</td>
|
|
85
|
-
<td data-value="5" class="abs high">5/5</td>
|
|
86
|
-
<td data-value="86.11" class="pct high">86.11%</td>
|
|
87
|
-
<td data-value="36" class="abs high">31/36</td>
|
|
88
|
-
</tr>
|
|
89
|
-
|
|
90
|
-
</tbody>
|
|
91
|
-
</table>
|
|
92
|
-
</div>
|
|
93
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
94
|
-
</div><!-- /wrapper -->
|
|
95
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
96
|
-
Code coverage generated by
|
|
97
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
98
|
-
at Wed Dec 01 2021 11:10:48 GMT+0000 (Coordinated Universal Time)
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
<script src="../../prettify.js"></script>
|
|
102
|
-
<script>
|
|
103
|
-
window.onload = function () {
|
|
104
|
-
prettyPrint();
|
|
105
|
-
};
|
|
106
|
-
</script>
|
|
107
|
-
<script src="../../sorter.js"></script>
|
|
108
|
-
<script src="../../block-navigation.js"></script>
|
|
109
|
-
</body>
|
|
110
|
-
</html>
|
|
111
|
-
|