mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
router spinner
This commit is contained in:
parent
663890dca6
commit
9adc93b3cc
8 changed files with 70 additions and 17 deletions
|
@ -4,10 +4,12 @@ import {
|
||||||
routerCancel as routerCancelAction,
|
routerCancel as routerCancelAction,
|
||||||
routerSubmit as routerSubmitAction,
|
routerSubmit as routerSubmitAction,
|
||||||
} from "$redux/user/actions";
|
} from "$redux/user/actions";
|
||||||
|
import classnames from "classnames";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
routerPoints: number,
|
routerPoints: number,
|
||||||
width: number,
|
width: number,
|
||||||
|
is_routing: boolean,
|
||||||
|
|
||||||
routerCancel: typeof routerCancelAction,
|
routerCancel: typeof routerCancelAction,
|
||||||
routerSubmit: typeof routerSubmitAction,
|
routerSubmit: typeof routerSubmitAction,
|
||||||
|
@ -81,9 +83,11 @@ const draggablePoints = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
export const RouterDialog = ({
|
export const RouterDialog = ({
|
||||||
routerPoints, routerCancel, routerSubmit, width
|
routerPoints, routerCancel, routerSubmit, width, is_routing,
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
<div className="control-dialog" style={{ width }}>
|
<div className="control-dialog" style={{ width }}>
|
||||||
|
<div className={classnames('save-loader', { active: is_routing })} />
|
||||||
|
|
||||||
{!routerPoints && noPoints({ routerCancel })}
|
{!routerPoints && noPoints({ routerCancel })}
|
||||||
{routerPoints === 1 && firstPoint({ routerCancel })}
|
{routerPoints === 1 && firstPoint({ routerCancel })}
|
||||||
{routerPoints >= 2 && draggablePoints({ routerCancel, routerSubmit })}
|
{routerPoints >= 2 && draggablePoints({ routerCancel, routerSubmit })}
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
|
|
||||||
## FEATURES
|
## FEATURES
|
||||||
|
|
||||||
done check if osrm available
|
todo arrows on screenshot
|
||||||
done selecting map on dialog in edit mode opens it at view mode
|
|
||||||
todo routing spinner
|
|
||||||
todo polyline editing only in manual mode (or by click)
|
|
||||||
|
|
||||||
done make arrows and distance points
|
todo refactor reducer to use is_editing and etc (mb move them to status object)
|
||||||
|
todo tower sticker
|
||||||
|
todo route description
|
||||||
|
|
||||||
|
todo polyline editing only in manual mode (or by click)
|
||||||
todo selecting logo on crop
|
todo selecting logo on crop
|
||||||
|
|
||||||
done public maps
|
done public maps
|
||||||
|
@ -24,11 +25,18 @@
|
||||||
todo check canvas support at startup
|
todo check canvas support at startup
|
||||||
todo check osrm is up
|
todo check osrm is up
|
||||||
|
|
||||||
todo maybe: map preview on save (nope)
|
todo maybe: map preview on save (dont think so)
|
||||||
|
|
||||||
|
## DONE
|
||||||
|
|
||||||
|
done routing spinner
|
||||||
done maybe: stickers clusterization?
|
done maybe: stickers clusterization?
|
||||||
done moving out the screen makes stickers editable again
|
done moving out the screen makes stickers editable again
|
||||||
|
|
||||||
## DONE
|
done check if osrm available
|
||||||
|
done selecting map on dialog in edit mode opens it at view mode
|
||||||
|
done make arrows and distance points
|
||||||
|
|
||||||
done fix arrows (can't reproduce now :-( )
|
done fix arrows (can't reproduce now :-( )
|
||||||
done adding route, applying it and adding again and deleting it makes ghost points on the map
|
done adding route, applying it and adding again and deleting it makes ghost points on the map
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
setAddress,
|
setAddress,
|
||||||
setChanged,
|
setChanged,
|
||||||
setDistance,
|
setDistance,
|
||||||
setIsEmpty,
|
setIsEmpty, setIsRouting,
|
||||||
setLogo,
|
setLogo,
|
||||||
setMarkersShown,
|
setMarkersShown,
|
||||||
setMode,
|
setMode,
|
||||||
|
@ -81,9 +81,19 @@ export class Editor {
|
||||||
map, routerMoveStart, lockMapClicks, setDistance: this.setDistance, triggerOnChange, editor: this,
|
map, routerMoveStart, lockMapClicks, setDistance: this.setDistance, triggerOnChange, editor: this,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stickers = new Stickers({ map, lockMapClicks, triggerOnChange, editor: this });
|
this.stickers = new Stickers({
|
||||||
|
map,
|
||||||
|
lockMapClicks,
|
||||||
|
triggerOnChange,
|
||||||
|
editor: this
|
||||||
|
});
|
||||||
|
|
||||||
this.router = new Router({
|
this.router = new Router({
|
||||||
map, lockMapClicks, setRouterPoints: this.setRouterPoints, pushPolyPoints
|
map,
|
||||||
|
lockMapClicks,
|
||||||
|
pushPolyPoints,
|
||||||
|
setRouterPoints: this.setRouterPoints,
|
||||||
|
setIsRouting: this.setIsRouting,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.switches = {
|
this.switches = {
|
||||||
|
@ -176,6 +186,7 @@ export class Editor {
|
||||||
setAddress: typeof setAddress = value => store.dispatch(setAddress(value));
|
setAddress: typeof setAddress = value => store.dispatch(setAddress(value));
|
||||||
setPublic: typeof setPublic = value => store.dispatch(setPublic(value));
|
setPublic: typeof setPublic = value => store.dispatch(setPublic(value));
|
||||||
setIsEmpty: typeof setIsEmpty = value => store.dispatch(setIsEmpty(value));
|
setIsEmpty: typeof setIsEmpty = value => store.dispatch(setIsEmpty(value));
|
||||||
|
setIsRouting: typeof setIsRouting = value => store.dispatch(setIsRouting(value));
|
||||||
|
|
||||||
setMarkersShown = (value: boolean): void => {
|
setMarkersShown = (value: boolean): void => {
|
||||||
if (this.getState().markers_shown !== value) store.dispatch(setMarkersShown(value));
|
if (this.getState().markers_shown !== value) store.dispatch(setMarkersShown(value));
|
||||||
|
|
|
@ -13,6 +13,7 @@ interface IWaypoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
setIsRouting: typeof editor.setIsRouting,
|
||||||
map: Map,
|
map: Map,
|
||||||
setRouterPoints: typeof editor.setRouterPoints,
|
setRouterPoints: typeof editor.setRouterPoints,
|
||||||
pushPolyPoints: typeof editor.pushPolyPoints,
|
pushPolyPoints: typeof editor.pushPolyPoints,
|
||||||
|
@ -21,12 +22,13 @@ interface Props {
|
||||||
|
|
||||||
export class Router {
|
export class Router {
|
||||||
constructor({
|
constructor({
|
||||||
map, lockMapClicks, setRouterPoints, pushPolyPoints
|
map, lockMapClicks, setRouterPoints, pushPolyPoints, setIsRouting,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
this.waypoints = [];
|
this.waypoints = [];
|
||||||
this.lockMapClicks = lockMapClicks;
|
this.lockMapClicks = lockMapClicks;
|
||||||
this.setRouterPoints = setRouterPoints;
|
this.setRouterPoints = setRouterPoints;
|
||||||
this.pushPolyPoints = pushPolyPoints;
|
this.pushPolyPoints = pushPolyPoints;
|
||||||
|
this.setIsRouting = setIsRouting;
|
||||||
|
|
||||||
const routeLine = r => Routing.line(r, {
|
const routeLine = r => Routing.line(r, {
|
||||||
styles: [
|
styles: [
|
||||||
|
@ -58,11 +60,22 @@ export class Router {
|
||||||
geometryOnly: false,
|
geometryOnly: false,
|
||||||
},
|
},
|
||||||
useHints: false,
|
useHints: false,
|
||||||
}).on('waypointschanged', this.updateWaypointsCount);
|
})
|
||||||
|
.on('routingstart', this.showSpinner)
|
||||||
|
.on('routesfound routingerror', this.hideSpinner)
|
||||||
|
.on('waypointschanged', this.updateWaypointsCount);
|
||||||
|
|
||||||
this.router.addTo(map);
|
this.router.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showSpinner = () => {
|
||||||
|
this.setIsRouting(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
hideSpinner = () => {
|
||||||
|
this.setIsRouting(false);
|
||||||
|
};
|
||||||
|
|
||||||
pushWaypointOnClick = ({ latlng: { lat, lng } }: { latlng: ILatLng }): void => {
|
pushWaypointOnClick = ({ latlng: { lat, lng } }: { latlng: ILatLng }): void => {
|
||||||
const waypoints = this.router.getWaypoints().filter(({ latLng }) => !!latLng);
|
const waypoints = this.router.getWaypoints().filter(({ latLng }) => !!latLng);
|
||||||
this.router.setWaypoints([...waypoints, { lat, lng }]);
|
this.router.setWaypoints([...waypoints, { lat, lng }]);
|
||||||
|
@ -153,6 +166,7 @@ export class Router {
|
||||||
};
|
};
|
||||||
|
|
||||||
waypoints: Array<IWaypoint> = [];
|
waypoints: Array<IWaypoint> = [];
|
||||||
|
setIsRouting: Props['setIsRouting'];
|
||||||
lockMapClicks: Props['lockMapClicks'];
|
lockMapClicks: Props['lockMapClicks'];
|
||||||
setRouterPoints: Props['setRouterPoints'];
|
setRouterPoints: Props['setRouterPoints'];
|
||||||
pushPolyPoints: Props['pushPolyPoints'];
|
pushPolyPoints: Props['pushPolyPoints'];
|
||||||
|
|
|
@ -70,3 +70,4 @@ export const mapsLoadMore = () => ({ type: ACTIONS.MAPS_LOAD_MORE });
|
||||||
export const mapsSetShift = (shift: number) => ({ type: ACTIONS.MAPS_SET_SHIFT, shift });
|
export const mapsSetShift = (shift: number) => ({ type: ACTIONS.MAPS_SET_SHIFT, shift });
|
||||||
|
|
||||||
export const setFeature = (features: { [x: string]: boolean }) => ({ type: ACTIONS.SET_FEATURE, features });
|
export const setFeature = (features: { [x: string]: boolean }) => ({ type: ACTIONS.SET_FEATURE, features });
|
||||||
|
export const setIsRouting = (is_routing: boolean) => ({ type: ACTIONS.SET_IS_ROUTING, is_routing });
|
||||||
|
|
|
@ -77,4 +77,5 @@ export const ACTIONS: IActions = {
|
||||||
MAPS_SET_SHIFT: 'MAPS_SET_SHIFT',
|
MAPS_SET_SHIFT: 'MAPS_SET_SHIFT',
|
||||||
|
|
||||||
SET_FEATURE: 'SET_FEATURE',
|
SET_FEATURE: 'SET_FEATURE',
|
||||||
|
SET_IS_ROUTING: 'SET_IS_ROUTING',
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,9 +33,11 @@ export interface IRootReducer {
|
||||||
address_origin: string,
|
address_origin: string,
|
||||||
changed: boolean,
|
changed: boolean,
|
||||||
provider: keyof typeof PROVIDERS,
|
provider: keyof typeof PROVIDERS,
|
||||||
is_public: boolean,
|
|
||||||
markers_shown: boolean,
|
markers_shown: boolean,
|
||||||
|
|
||||||
|
is_public: boolean,
|
||||||
is_empty: boolean,
|
is_empty: boolean,
|
||||||
|
is_routing: boolean,
|
||||||
|
|
||||||
save_error: string,
|
save_error: string,
|
||||||
save_finished: boolean,
|
save_finished: boolean,
|
||||||
|
@ -297,6 +299,11 @@ const setFeature: ActionHandler<typeof ActionCreators.setFeature> = (state, { fe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const setIsRouting: ActionHandler<typeof ActionCreators.setIsRouting> = (state, { is_routing }) => ({
|
||||||
|
...state,
|
||||||
|
is_routing,
|
||||||
|
});
|
||||||
|
|
||||||
const HANDLERS = ({
|
const HANDLERS = ({
|
||||||
[ACTIONS.SET_USER]: setUser,
|
[ACTIONS.SET_USER]: setUser,
|
||||||
[ACTIONS.SET_EDITING]: setEditing,
|
[ACTIONS.SET_EDITING]: setEditing,
|
||||||
|
@ -340,12 +347,13 @@ const HANDLERS = ({
|
||||||
[ACTIONS.MAPS_SET_SHIFT]: mapsSetShift,
|
[ACTIONS.MAPS_SET_SHIFT]: mapsSetShift,
|
||||||
|
|
||||||
[ACTIONS.SET_FEATURE]: setFeature,
|
[ACTIONS.SET_FEATURE]: setFeature,
|
||||||
|
[ACTIONS.SET_IS_ROUTING]: setIsRouting,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const INITIAL_STATE: IRootReducer = {
|
export const INITIAL_STATE: IRootReducer = {
|
||||||
ready: false,
|
ready: false,
|
||||||
user: { ...DEFAULT_USER },
|
user: { ...DEFAULT_USER },
|
||||||
editing: false,
|
|
||||||
mode: MODES.NONE,
|
mode: MODES.NONE,
|
||||||
logo: DEFAULT_LOGO,
|
logo: DEFAULT_LOGO,
|
||||||
routerPoints: 0,
|
routerPoints: 0,
|
||||||
|
@ -356,11 +364,14 @@ export const INITIAL_STATE: IRootReducer = {
|
||||||
title: '',
|
title: '',
|
||||||
address: '',
|
address: '',
|
||||||
address_origin: '',
|
address_origin: '',
|
||||||
changed: false,
|
|
||||||
provider: DEFAULT_PROVIDER,
|
provider: DEFAULT_PROVIDER,
|
||||||
is_public: false,
|
|
||||||
markers_shown: true,
|
markers_shown: true,
|
||||||
|
changed: false,
|
||||||
|
editing: false,
|
||||||
|
is_public: false,
|
||||||
is_empty: true,
|
is_empty: true,
|
||||||
|
is_routing: false,
|
||||||
|
|
||||||
save_error: '',
|
save_error: '',
|
||||||
save_finished: false,
|
save_finished: false,
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 1.2em;
|
||||||
|
color: fade(white, 70%);
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
fill: white;
|
fill: white;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue