mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 15:47:55 +01:00
Complete starred support for rest
This commit is contained in:
parent
0d7cf3e5b1
commit
858050096f
@ -1,3 +0,0 @@
|
||||
{
|
||||
"apiBaseUrl": "http://localhost:8080"
|
||||
}
|
@ -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<void>;
|
||||
duplicateMap(id: number, basicInfo: BasicMapInfo): Promise<number>;
|
||||
loadMapInfo(id: number): Promise<BasicMapInfo>;
|
||||
changeStarred(id: number): Promise<void>;
|
||||
|
||||
changeStarred(id: number, starred: boolean): Promise<void>;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ class MockClient implements Client {
|
||||
return Promise.resolve(this.labels);
|
||||
}
|
||||
|
||||
changeStarred(id: number): Promise<void> {
|
||||
changeStarred(id: number, starred: boolean): Promise<void> {
|
||||
const mapInfo = this.maps.find(m => m.id == id);
|
||||
if (!mapInfo) {
|
||||
console.log(`Could not find the map iwth id ${id}`);
|
||||
|
@ -56,6 +56,10 @@ export default class RestClient extends MockClient {
|
||||
return result;
|
||||
}
|
||||
|
||||
renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> {
|
||||
throw "Method not implemented yet";
|
||||
}
|
||||
|
||||
createMap(model: BasicMapInfo): Promise<number> {
|
||||
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<MapInfo[]> {
|
||||
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<void> {
|
||||
|
||||
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<void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
@ -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) => {
|
@ -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;
|
@ -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) => {
|
||||
<DeleteDialog open={action === 'delete'} onClose={handleOnClose} mapId={mapId} />
|
||||
<RenameDialog open={action === 'rename'} onClose={handleOnClose} mapId={mapId} />
|
||||
<DuplicateDialog open={action === 'duplicate'} onClose={handleOnClose} mapId={mapId} />
|
||||
<InfoDialog open={action === 'info'} onClose={handleOnClose} mapId={mapId} />
|
||||
</span >
|
||||
);
|
||||
}
|
||||
|
@ -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 (
|
||||
<div>
|
||||
<BaseDialog
|
||||
open={props.open} onClose={handleOnClose}
|
||||
title={intl.formatMessage({ id: "action.info-title", defaultMessage: "Info" })}>
|
||||
|
||||
<iframe src="http://www.clarin.com" style={{ width: '100%', height: '400px' }} />
|
||||
|
||||
</BaseDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default InfoDialog;
|
@ -7,7 +7,7 @@ import { activeInstance } from '../../../../reducers/serviceSlice';
|
||||
import { DialogProps, fetchMapById, handleOnMutationSuccess } from "..";
|
||||
import Input from "../../../form/input";
|
||||
import { FormControl } from "@material-ui/core";
|
||||
import BaseDialog from "../action-dialog";
|
||||
import BaseDialog from "../base-dialog";
|
||||
|
||||
export type RenameModel = {
|
||||
id: number;
|
||||
|
@ -317,7 +317,7 @@ const HelpToobarButton = () => {
|
||||
}}>
|
||||
|
||||
<MenuItem onClick={handleClose}>
|
||||
<Link color="textSecondary" href="https://www.wisemapping.com/termsofuse.html">
|
||||
<Link color="textSecondary" href="https://www.wisemapping.com/termsofuse.html" target="help">
|
||||
<ListItemIcon>
|
||||
<PolicyOutlined fontSize="small" />
|
||||
</ListItemIcon>
|
||||
@ -335,7 +335,7 @@ const HelpToobarButton = () => {
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem onClick={handleClose}>
|
||||
<Link color="textSecondary" href="feedback@wisemapping.com">
|
||||
<Link color="textSecondary" href="mailto:feedback@wisemapping.com">
|
||||
<ListItemIcon>
|
||||
<FeedbackOutlined fontSize="small" />
|
||||
</ListItemIcon>
|
||||
@ -344,7 +344,7 @@ const HelpToobarButton = () => {
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem onClick={handleClose}>
|
||||
<Link color="textSecondary" href="https://www.wisemapping.com/aboutus.html">
|
||||
<Link color="textSecondary" href="https://www.wisemapping.com/aboutus.html" target="help">
|
||||
<ListItemIcon>
|
||||
<EmojiPeopleOutlined fontSize="small" />
|
||||
</ListItemIcon>
|
||||
|
@ -276,7 +276,8 @@ export const MapsList = (props: MapsListProps) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const starredMultation = useMutation<void, ErrorInfo, number>((id: number) => {
|
||||
return client.changeStarred(id);
|
||||
const map = mapsInfo.find(m => m.id == id);
|
||||
return client.changeStarred(id, !Boolean(map?.starred));
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
|
Loading…
Reference in New Issue
Block a user