diff --git a/packages/webapp/public/runtime-config.json b/packages/webapp/public/runtime-config.json deleted file mode 100644 index 20210bb3..00000000 --- a/packages/webapp/public/runtime-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "apiBaseUrl": "http://localhost:8080" -} \ No newline at end of file diff --git a/packages/webapp/src/client/index.ts b/packages/webapp/src/client/index.ts index 84732406..3ad3cea1 100644 --- a/packages/webapp/src/client/index.ts +++ b/packages/webapp/src/client/index.ts @@ -17,6 +17,12 @@ export type MapInfo = { isPublic: boolean; } +export type HistoryChange = { + id: number; + creator: string; + modified: string; +} + export type BasicMapInfo = { title: string; description?: string; @@ -44,8 +50,7 @@ interface Client { renameMap(id: number, basicInfo: BasicMapInfo): Promise; duplicateMap(id: number, basicInfo: BasicMapInfo): Promise; loadMapInfo(id: number): Promise; - changeStarred(id: number): Promise; - + changeStarred(id: number, starred: boolean): Promise; } diff --git a/packages/webapp/src/client/mock-client/index.ts b/packages/webapp/src/client/mock-client/index.ts index d076e06a..3ae640a2 100644 --- a/packages/webapp/src/client/mock-client/index.ts +++ b/packages/webapp/src/client/mock-client/index.ts @@ -47,7 +47,7 @@ class MockClient implements Client { return Promise.resolve(this.labels); } - changeStarred(id: number): Promise { + changeStarred(id: number, starred: boolean): Promise { const mapInfo = this.maps.find(m => m.id == id); if (!mapInfo) { console.log(`Could not find the map iwth id ${id}`); diff --git a/packages/webapp/src/client/rest-client/index.ts b/packages/webapp/src/client/rest-client/index.ts index 4cdaf034..57c3416f 100644 --- a/packages/webapp/src/client/rest-client/index.ts +++ b/packages/webapp/src/client/rest-client/index.ts @@ -56,6 +56,10 @@ export default class RestClient extends MockClient { return result; } + renameMap(id: number, basicInfo: BasicMapInfo): Promise { + throw "Method not implemented yet"; + } + createMap(model: BasicMapInfo): Promise { const handler = (success: (mapId: number) => void, reject: (error: ErrorInfo) => void) => { axios.post(this.baseUrl + `/c/restful/maps?title=${model.title}&description=${model.description ? model.description : ''}`, @@ -73,7 +77,6 @@ export default class RestClient extends MockClient { return new Promise(handler); } - fetchAllMaps(): Promise { const handler = (success: (mapsInfo: MapInfo[]) => void, reject: (error: ErrorInfo) => void) => { axios.get( @@ -142,7 +145,6 @@ export default class RestClient extends MockClient { return new Promise(handler); } - resetPassword(email: string): Promise { const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { @@ -178,5 +180,21 @@ export default class RestClient extends MockClient { } return new Promise(handler); } + + changeStarred(id: number, starred: boolean): Promise { + const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { + axios.put(this.baseUrl + `/c/restful/maps/${id}/starred`, + starred, + { headers: { 'Content-Type': 'text/plain' } } + ).then(() => { + success(); + }).catch(error => { + const response = error.response; + const errorInfo = this.parseResponseOnError(response); + reject(errorInfo); + }); + } + return new Promise(handler); + } } diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/action-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx similarity index 100% rename from packages/webapp/src/components/maps-page/action-dispatcher/action-dialog/index.tsx rename to packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/action-dialog/style.ts b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/style.ts similarity index 100% rename from packages/webapp/src/components/maps-page/action-dispatcher/action-dialog/style.ts rename to packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/style.ts diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/create/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx similarity index 97% rename from packages/webapp/src/components/maps-page/action-dispatcher/create/index.tsx rename to packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx index d8fa9b05..25cabca9 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/create/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx @@ -8,7 +8,7 @@ import { FormControl } from '@material-ui/core'; import Client, { BasicMapInfo, ErrorInfo } from '../../../../client'; import { activeInstance } from '../../../../reducers/serviceSlice'; import Input from '../../../form/input'; -import BaseDialog from '../action-dialog'; +import BaseDialog from '../base-dialog'; export type CreateModel = { title: string; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/delete/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx similarity index 95% rename from packages/webapp/src/components/maps-page/action-dispatcher/delete/index.tsx rename to packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx index ef08221d..73c01a52 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/delete/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx @@ -6,7 +6,7 @@ import { useSelector } from "react-redux"; import Client from "../../../../client"; import { activeInstance } from '../../../../reducers/serviceSlice'; import { DialogProps, fetchMapById, handleOnMutationSuccess } from ".."; -import BaseDialog from "../action-dialog"; +import BaseDialog from "../base-dialog"; const DeleteDialog = (props: DialogProps) => { diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx similarity index 95% rename from packages/webapp/src/components/maps-page/action-dispatcher/duplicate/index.tsx rename to packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx index 4e51d059..cc6c7fdf 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx @@ -1,14 +1,14 @@ import React, { useEffect } from "react"; import { useIntl } from "react-intl"; import { useMutation, useQueryClient } from "react-query"; -import { useSelector } from "react-redux"; import { FormControl } from "@material-ui/core"; +import { useSelector } from "react-redux"; import Client, { BasicMapInfo, ErrorInfo } from "../../../../client"; import { activeInstance } from '../../../../reducers/serviceSlice'; import Input from "../../../form/input"; -import { DialogProps, fetchMapById, handleOnMutationSuccess } from ".."; -import BaseDialog from "../action-dialog"; +import { DialogProps, fetchMapById } from ".."; +import BaseDialog from "../base-dialog"; export type DuplicateModel = { id: number; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx index b1f955dd..4ed88f21 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx @@ -1,17 +1,15 @@ import React from 'react'; import RenameDialog from './rename'; -import DeleteDialog from './delete'; +import DeleteDialog from './delete-dialog'; import { ActionType } from '../action-chooser'; import { ErrorInfo, MapInfo } from '../../../client'; import Client from '../../../client'; -import { useSelector } from 'react-redux'; +import { useSelector } from "react-redux"; import { QueryClient, useQuery } from 'react-query'; import { activeInstance } from '../../../reducers/serviceSlice'; -import DuplicateDialog from './duplicate'; +import DuplicateDialog from './duplicate-dialog'; import { useHistory } from 'react-router-dom'; -import InfoDialog from './info'; -import CreateDialog from './create'; - +import CreateDialog from './create-dialog'; export type BasicMapInfo = { name: string; @@ -35,10 +33,10 @@ const ActionDispatcher = (props: ActionDialogProps) => { switch (action) { case 'open': - history.push(`/c/maps/${mapId}/edit`); + window.location.href = `/c/maps/${mapId}/edit`; break; case 'print': - history.push(`/c/maps/${mapId}/print`); + window.open(`/c/maps/${mapId}/print`,'print'); break; } @@ -48,7 +46,6 @@ const ActionDispatcher = (props: ActionDialogProps) => { - ); } diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/info/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/info/index.tsx deleted file mode 100644 index 950a96b9..00000000 --- a/packages/webapp/src/components/maps-page/action-dispatcher/info/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; -import { useQueryClient } from "react-query"; -import { useSelector } from "react-redux"; -import Client from "../../../../client"; -import { activeInstance } from '../../../../reducers/serviceSlice'; -import { DialogProps, fetchMapById } from ".."; -import BaseDialog from "../action-dialog"; -import { useIntl } from "react-intl"; - - -const InfoDialog = (props: DialogProps) => { - const service: Client = useSelector(activeInstance); - const queryClient = useQueryClient(); - const intl = useIntl(); - - - const mapId = props.mapId; - const handleOnClose = (): void => { - props.onClose(); - }; - - const { map } = fetchMapById(mapId); - return ( -
- - -