Cannot load map, check your internet connection
@@ -210,47 +156,61 @@ export const LocatePage = ({
}
return (
-
-
- {(!isReady() || submitting) && (
-
-
-
- )}
- {editting && (
-
- )}
-
+ <>
+ {(!isReady() || submitting) && (
+
+
+
+ )}
+ {isReady() && (
+
+
+
+
+
+
+
+
+
+
+
+
+ {nodeMarker && (
+
+ )}
+ {editting && (
+
+ )}
+
+ )}
{isReady() && (
- {/* Actions while editting */}
{editting && (
)}
- {editting && (
-
- )}
- {/* Actions while not editting */}
- {!editting && hasLocation && (
-
- )}
- {!editting && !hasLocation && (
-
- )}
{!editting && (
)}
+
+
)}
-
+ >
);
};
-
-const mapStateToProps = (state) => ({
- stationLat: getLat(state),
- stationLon: getLon(state),
- isCommunityLocation: isCommunityLocation(state),
- nodesData: state.locate.nodesData,
- submitting: state.locate.submitting,
- editting: state.locate.editting,
-});
-
-
-const mapDispatchToProps = (dispatch) => ({
- loadLocation: bindActionCreators(loadLocation, dispatch),
- loadLocationLinks: bindActionCreators(loadLocationLinks, dispatch),
- changeLocation: bindActionCreators(changeLocation, dispatch),
- toogleEdit: bindActionCreators(toogleEdit, dispatch),
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(LocatePage);
+export default LocatePage;
diff --git a/plugins/lime-plugin-locate/src/locateQueries.tsx b/plugins/lime-plugin-locate/src/locateQueries.tsx
new file mode 100644
index 00000000..45c1f399
--- /dev/null
+++ b/plugins/lime-plugin-locate/src/locateQueries.tsx
@@ -0,0 +1,74 @@
+import { useMutation, useQuery } from "@tanstack/react-query";
+
+import { loadLeafLet } from "plugins/lime-plugin-locate/src/leafletUtils";
+import {
+ changeLocation,
+ getLocation,
+ getNodesandlinks,
+} from "plugins/lime-plugin-locate/src/locateApi";
+
+import queryCache from "utils/queryCache";
+
+export interface INodeLocation {
+ location: {
+ lon: string;
+ lat: string;
+ };
+ default: boolean;
+}
+
+export function useLocation(params) {
+ return useQuery
(["lime-location", "get"], getLocation, {
+ placeholderData: {
+ default: false,
+ location: {
+ lon: "FIXME",
+ lat: "FIXME",
+ },
+ },
+ ...params,
+ });
+}
+
+export function useNodesandlinks(params) {
+ return useQuery(
+ ["lime-location", "all_nodes_and_links"],
+ getNodesandlinks,
+ {
+ ...params,
+ }
+ );
+}
+
+interface IChangeUserParams {
+ lat: number;
+ lon: number;
+}
+
+export function useChangeLocation(params) {
+ return useMutation({
+ mutationFn: changeLocation,
+ onSuccess: (data: { lat: string; lon: string }) => {
+ queryCache.setQueryData(
+ ["lime-location", "get"],
+ (oldData: INodeLocation) =>
+ oldData
+ ? {
+ ...oldData,
+ location: {
+ lat: data.lat,
+ lon: data.lon,
+ },
+ }
+ : oldData
+ );
+ },
+ ...params,
+ });
+}
+
+export function useLoadLeaflet(params) {
+ return useQuery(["lime-location", "load_leaflet"], loadLeafLet, {
+ ...params,
+ });
+}
diff --git a/plugins/lime-plugin-locate/src/locateReducer.js b/plugins/lime-plugin-locate/src/locateReducer.js
deleted file mode 100644
index 5864e51f..00000000
--- a/plugins/lime-plugin-locate/src/locateReducer.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- LOCATION_CHANGE,
- LOCATION_CHANGE_SUCCESS,
- LOCATION_LOAD_LINKS_SUCCESS,
- LOCATION_LOAD_SUCCESS,
- LOCATION_TOOGLE_EDIT,
- LOCATION_USER_SET,
-} from "./locateConstants";
-
-export const initialState = {
- station: undefined,
- user: {
- lon: 0,
- lat: 0,
- },
- submitting: false,
- editting: false,
- isCommunity: false,
- nodesData: {},
-};
-
-export const reducer = (state = initialState, { type, payload }) => {
- switch (type) {
- case LOCATION_CHANGE:
- return Object.assign({}, state, {
- submitting: true,
- editting: false,
- });
-
- case LOCATION_CHANGE_SUCCESS:
- return Object.assign({}, state, { submitting: false });
-
- case LOCATION_LOAD_SUCCESS:
- return Object.assign({}, state, {
- station: payload.location || payload,
- isCommunity: payload.default || false,
- });
-
- case LOCATION_LOAD_LINKS_SUCCESS:
- return Object.assign({}, state, { nodesData: payload });
-
- case LOCATION_USER_SET:
- return Object.assign({}, state, { user: payload });
-
- case LOCATION_TOOGLE_EDIT:
- return Object.assign({}, state, { editting: payload });
-
- default:
- return state;
- }
-};
diff --git a/plugins/lime-plugin-locate/src/locateSelectors.js b/plugins/lime-plugin-locate/src/locateSelectors.js
deleted file mode 100755
index d6105732..00000000
--- a/plugins/lime-plugin-locate/src/locateSelectors.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const getCoordinate = (coord) => (state) => {
- // Not yet retrieved from the node.
- if (typeof state.locate.station === "undefined") {
- return undefined;
- }
- // Neither community nor node has location configured
- const latlong = state.locate.station;
- if (latlong[coord] === "FIXME") {
- return null;
- }
- return latlong[coord];
-};
-
-export const getLat = getCoordinate("lat");
-export const getLon = getCoordinate("lon");
-export const getUserLocation = (state) => state.locate.user;
-export const isCommunityLocation = (state) => state.locate.isCommunity;
diff --git a/plugins/lime-plugin-locate/src/style.less b/plugins/lime-plugin-locate/src/style.less
index 6f11917a..5a6fc9ec 100644
--- a/plugins/lime-plugin-locate/src/style.less
+++ b/plugins/lime-plugin-locate/src/style.less
@@ -14,7 +14,7 @@
top: calc(50% - 5px);
}
-.editAction{
+.editAction {
display: flex;
flex-direction: column;
position: absolute;
@@ -30,10 +30,11 @@
}
}
-.loadingContainer{
+.loadingContainer {
z-index: 999;
- position: relative;
+ position: absolute;
top: calc(50% - 5px);
+ left: calc(50% - 35px);
}
.hasAssetError {
diff --git a/plugins/lime-plugin-node-admin/src/components/config/config.js b/plugins/lime-plugin-node-admin/src/components/config/config.js
new file mode 100644
index 00000000..f72bbd5d
--- /dev/null
+++ b/plugins/lime-plugin-node-admin/src/components/config/config.js
@@ -0,0 +1,33 @@
+import { ListItem } from "components/list";
+import Loading from "components/loading";
+
+import style from "./config.style.less";
+
+export const Config = ({
+ title,
+ subtitle,
+ value,
+ onClick,
+ isLoading,
+ ...props
+}) => {
+ return (
+
+
+
+
{title}
+ {isLoading &&
}
+ {!isLoading && (
+
+ )}
+
+
+
+
+ );
+};
diff --git a/plugins/lime-plugin-node-admin/src/components/config/config.tsx b/plugins/lime-plugin-node-admin/src/components/config/config.tsx
deleted file mode 100644
index f3c4792e..00000000
--- a/plugins/lime-plugin-node-admin/src/components/config/config.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { ComponentChildren } from "preact";
-
-import { ListItem } from "components/list";
-import Loading from "components/loading";
-
-import style from "./config.style.less";
-
-type ConfigProps = {
- title: ComponentChildren;
- subtitle?: ComponentChildren;
- value: ComponentChildren;
- onClick: () => void;
- isLoading: boolean;
-};
-
-export const Config = ({
- title,
- subtitle,
- value,
- onClick,
- isLoading,
- ...props
-}: ConfigProps) => {
- return (
-
-
-
-
{title}
- {isLoading &&
}
- {!isLoading && (
-
- {subtitle && (
-
- {" "}
- {subtitle}{" "}
-
- )}
-
{value}
-
- )}
-
-
-
-
- );
-};
diff --git a/plugins/lime-plugin-node-admin/src/nodeAdminPage.js b/plugins/lime-plugin-node-admin/src/nodeAdminPage.js
index 656a468b..be563b37 100644
--- a/plugins/lime-plugin-node-admin/src/nodeAdminPage.js
+++ b/plugins/lime-plugin-node-admin/src/nodeAdminPage.js
@@ -15,6 +15,7 @@ const Hostname = () => {
const { data: boardData, isLoading } = useBoardData();
const hostname = boardData && boardData.hostname;
return (
+ // @ts-ignore
Node Name}
value={hostname}
@@ -28,6 +29,7 @@ const ApPassword = () => {
const { data: wifiData, isLoading } = useWifiData();
const has_password = wifiData && wifiData.node_ap.has_password;
return (
+ // @ts-ignore
Wifi Password}
value={has_password ? "********" : No password}
@@ -63,6 +65,7 @@ export const Hotspot = () => {
const { data, isLoading } = useHotspotData();
const enabled = data?.enabled;
return (
+ // @ts-ignore
Connect to a Mobile Hotspot}
diff --git a/plugins/lime-plugin-pirania/nodeAdmin/PortalConfigItem.tsx b/plugins/lime-plugin-pirania/nodeAdmin/PortalConfigItem.tsx
index 977da407..1cb42c7b 100644
--- a/plugins/lime-plugin-pirania/nodeAdmin/PortalConfigItem.tsx
+++ b/plugins/lime-plugin-pirania/nodeAdmin/PortalConfigItem.tsx
@@ -21,6 +21,7 @@ export const PortalConfigItem = () => {
}
}
return (
+ // @ts-ignore
Community Portal}
diff --git a/tsconfig.json b/tsconfig.json
index db4284e0..32e04bb0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,34 +1,34 @@
{
"compilerOptions": {
- /* Basic Options */
- "target": "ES5",
- "allowJs": true,
- "checkJs": true,
+ /* Basic Options */
+ "target": "ES5",
+ "allowJs": true,
+ "checkJs": true,
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
- "jsxImportSource": "preact",
- "noEmit": true,
+ "jsxImportSource": "preact",
+ "noEmit": true,
- /* Strict Type-Checking Options */
- "strict": false,
+ /* Strict Type-Checking Options */
+ "strict": false,
- /* Module Resolution Options */
- "moduleResolution": "node",
- "esModuleInterop": true,
- "baseUrl": "./",
- "paths": {
- "react/*": ["./node_modules/preact/compat/*"],
- "react-dom/*": ["./node_modules/preact/compat/*"],
- "components/*": ["./src/components/*"],
- "containers/*": ["./src/containers/*"],
- "utils/*": ["./src/utils/*"],
- "plugins/*": ["./plugins/*"]
- },
- "allowSyntheticDefaultImports": true,
+ /* Module Resolution Options */
+ "moduleResolution": "node",
+ "esModuleInterop": true,
+ "baseUrl": ".",
+ "paths": {
+ "react": ["node_modules/preact/compat"],
+ "react-dom": ["node_modules/preact/compat"],
+ "components/*": ["./src/components/*"],
+ "containers/*": ["./src/containers/*"],
+ "utils/*": ["./src/utils/*"],
+ "plugins/*": ["./plugins/*"]
+ },
+ "allowSyntheticDefaultImports": true,
- /* Advanced Options */
- "skipLibCheck": true
+ /* Advanced Options */
+ "skipLibCheck": true
},
"include": ["plugins/**/*", "src/**/*", "stories/**/*"],
"exclude": [