Revize b45d0300
Přidáno uživatelem Václav Honzík před téměř 3 roky(ů)
frontend/src/features/Catalog/CatalogTable.tsx | ||
---|---|---|
125 | 125 |
{mapValueOrDefault(item.countries?.join(', '))} |
126 | 126 |
{mapValueOrDefault( |
127 | 127 |
item.latitude && item.longitude |
128 |
? `${item.latitude.toFixed(2)}, ${item.longitude.toFixed( |
|
129 |
2 |
|
130 |
)}` |
|
128 |
? `${item.latitude}, ${item.longitude}` |
|
131 | 129 |
: undefined |
132 | 130 |
)} |
133 | 131 |
{mapValueOrDefault( |
... | ... | |
142 | 140 |
{loading && !displayError ? <ContentLoading /> : null} |
143 | 141 |
{!loading && !displayError ? ( |
144 | 142 |
<Fragment> |
145 |
<TableContainer sx={{ minHeight: '65vh', maxHeight: '65vh' }}>
|
|
143 |
<TableContainer sx={{ minHeight: '60vh', maxHeight: '60vh' }}>
|
|
146 | 144 |
<Table |
147 | 145 |
stickyHeader |
148 | 146 |
sx={{ minWidth: 400 }} |
frontend/src/features/Navigation/navigationSlice.ts | ||
---|---|---|
1 |
import { createSlice } from '@reduxjs/toolkit' |
|
2 |
import persistReducer from 'redux-persist/es/persistReducer' |
|
3 |
import storage from 'redux-persist/lib/storage' |
|
4 |
|
|
5 |
export interface NavigationState { |
|
6 |
selectedMenuItem?: string, |
|
7 |
open: boolean, |
|
8 |
} |
|
9 |
|
|
10 |
const persistConfig = { |
|
11 |
key: 'navigation', |
|
12 |
storage |
|
13 |
} |
|
14 |
|
|
15 |
const initialState: NavigationState = { |
|
16 |
selectedMenuItem: '', |
|
17 |
open: false |
|
18 |
} |
|
19 |
|
|
20 |
export const navigationSlice = createSlice({ |
|
21 |
name: 'navigation', |
|
22 |
initialState, |
|
23 |
reducers: { |
|
24 |
setSelectedMenuItem: (state: NavigationState, action: any) => ({...state, selectedMenuItem: action.payload}), |
|
25 |
setOpen: (state: NavigationState, action: any) => ({...state, open: action.payload}), |
|
26 |
} |
|
27 |
}) |
|
28 |
|
|
29 |
const navigationReducer = persistReducer(persistConfig, navigationSlice.reducer) |
|
30 |
|
|
31 |
export const { setSelectedMenuItem, setOpen } = navigationSlice.actions |
|
32 |
|
|
33 |
export default navigationReducer |
frontend/src/features/Navigation/navigationSlice.tsx | ||
---|---|---|
1 |
import { createSlice } from '@reduxjs/toolkit' |
|
2 |
import persistReducer from 'redux-persist/es/persistReducer' |
|
3 |
import storage from 'redux-persist/lib/storage' |
|
4 |
|
|
5 |
export interface NavigationState { |
|
6 |
selectedMenuItem?: string, |
|
7 |
open: boolean, |
|
8 |
} |
|
9 |
|
|
10 |
const persistConfig = { |
|
11 |
key: 'navigation', |
|
12 |
storage |
|
13 |
} |
|
14 |
|
|
15 |
const initialState: NavigationState = { |
|
16 |
selectedMenuItem: '', |
|
17 |
open: false |
|
18 |
} |
|
19 |
|
|
20 |
export const navigationSlice = createSlice({ |
|
21 |
name: 'navigation', |
|
22 |
initialState, |
|
23 |
reducers: { |
|
24 |
setSelectedMenuItem: (state: NavigationState, action: any) => ({...state, selectedMenuItem: action.payload}), |
|
25 |
setOpen: (state: NavigationState, action: any) => ({...state, open: action.payload}), |
|
26 |
} |
|
27 |
}) |
|
28 |
|
|
29 |
const navigationReducer = persistReducer(persistConfig, navigationSlice.reducer) |
|
30 |
|
|
31 |
export const { setSelectedMenuItem, setOpen } = navigationSlice.actions |
|
32 |
|
|
33 |
export default navigationReducer |
frontend/src/features/TrackingTool/MapMarker.tsx | ||
---|---|---|
1 |
import { LatLngTuple, Marker as MarkerPOJO } from 'leaflet' |
|
2 |
import { FunctionComponent, ReactNode, useMemo, useRef, useState } from 'react' |
|
3 |
import { Marker } from 'react-leaflet' |
|
4 |
|
|
5 |
export interface MapMarkerProps { |
|
6 |
position: LatLngTuple |
|
7 |
children?: ReactNode |
|
8 |
} |
|
9 |
|
|
10 |
// Custom Map Marker component |
|
11 |
const MapMarker: FunctionComponent<MapMarkerProps> = ({ position, children }) => { |
|
12 |
const [currentPosition, setCurrentPosition] = useState(position) |
|
13 |
const markerRef = useRef<MarkerPOJO | null>(null) |
|
14 |
const eventHandlers = useMemo( |
|
15 |
() => ({ |
|
16 |
dragend: () => { |
|
17 |
const marker = markerRef.current |
|
18 |
console.log(markerRef) |
|
19 |
if (!marker) { |
|
20 |
return |
|
21 |
} |
|
22 |
const latlng = marker.getLatLng() |
|
23 |
setCurrentPosition([latlng.lat, latlng.lng]) |
|
24 |
}, |
|
25 |
}), |
|
26 |
[] |
|
27 |
) |
|
28 |
|
|
29 |
return ( |
|
30 |
<Marker |
|
31 |
draggable={true} |
|
32 |
position={currentPosition} |
|
33 |
eventHandlers={eventHandlers} |
|
34 |
ref={markerRef} |
|
35 |
> |
|
36 |
{children} |
|
37 |
</Marker> |
|
38 |
) |
|
39 |
} |
|
40 |
|
|
41 |
export default MapMarker |
frontend/src/features/TrackingTool/MapPath.tsx | ||
---|---|---|
14 | 14 |
import { DialogCatalogItemDetail as CatalogItemDetailDialog } from '../Catalog/CatalogItemDetail' |
15 | 15 |
import { useDispatch, useSelector } from 'react-redux' |
16 | 16 |
import { RootState } from '../redux/store' |
17 |
import MapMarker from './MapMarker' |
|
17 | 18 |
|
18 | 19 |
// CatalogItemDto wrapper to keep track whether the item is active or not |
19 | 20 |
class DisplayableMapPoint { |
... | ... | |
123 | 124 |
*/ |
124 | 125 |
const buildVertices = () => { |
125 | 126 |
return mapPoints.map((mapPoint, idx) => ( |
126 |
<Marker |
|
127 |
<MapMarker
|
|
127 | 128 |
key={idx} |
128 | 129 |
position={[ |
129 | 130 |
mapPoint.catalogItem.latitude as number, |
... | ... | |
161 | 162 |
</Stack> |
162 | 163 |
</Fragment> |
163 | 164 |
</Popup> |
164 |
</Marker> |
|
165 |
</MapMarker>
|
|
165 | 166 |
)) |
166 | 167 |
} |
167 | 168 |
|
frontend/src/features/TrackingTool/trackingToolSlice.ts | ||
---|---|---|
88 | 88 |
currentPage: 0, |
89 | 89 |
} |
90 | 90 |
}) |
91 |
builder.addCase(sendTextForProcessing.rejected, (state, action) => ({
|
|
91 |
builder.addCase(sendTextForProcessing.rejected, (_, action) => ({
|
|
92 | 92 |
...initialState, |
93 | 93 |
lastError: action.error.message, |
94 | 94 |
isLoading: false, |
frontend/src/features/redux/store.ts | ||
---|---|---|
25 | 25 |
trackingTool: trackingToolReducer, |
26 | 26 |
usersDetail: usersDetailReducer, |
27 | 27 |
navigation: navigationReducer, |
28 |
usersDetail: usersDetailReducer, |
|
29 | 28 |
}), |
30 | 29 |
process.env.REACT_APP_DEV_ENV === 'true' |
31 | 30 |
? composeEnhancers( |
Také k dispozici: Unified diff
draggable map marker pt1
re #9741