mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 06:37:56 +01:00
Comple client maps loading
This commit is contained in:
parent
b10360fe6f
commit
a6951b850e
@ -12,7 +12,7 @@ export type MapInfo = {
|
||||
name: string;
|
||||
labels: string[];
|
||||
creator: string;
|
||||
modified: number;
|
||||
modified: string;
|
||||
description: string;
|
||||
isPublic: boolean;
|
||||
}
|
||||
|
@ -14,25 +14,25 @@ class MockClient implements Client {
|
||||
name: string,
|
||||
labels: string[],
|
||||
creator: string,
|
||||
modified: number,
|
||||
modified: string,
|
||||
description: string,
|
||||
isPublic: boolean
|
||||
): MapInfo {
|
||||
return { id, name, labels, creator, modified, starred, description, isPublic };
|
||||
}
|
||||
this.maps = [
|
||||
createMapInfo(1, true, "El Mapa", [""], "Paulo", 67, "", true),
|
||||
createMapInfo(2, false, "El Mapa2", [""], "Paulo2", 67, "", false),
|
||||
createMapInfo(3, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(4, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(5, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(6, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(7, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(8, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(9, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(10, false, "El Mapa3", [""], "Paulo3", 67, "", false),
|
||||
createMapInfo(11, false, "El Mapa3", ["label 3", "label3"], "Paulo3", 67, "", false),
|
||||
createMapInfo(12, false, "El Mapa3", ["label 2"], "Paulo3", 67, "", false)
|
||||
createMapInfo(1, true, "El Mapa", [""], "Paulo", "2008-06-02T00:00:00Z", "", true),
|
||||
createMapInfo(2, false, "El Mapa2", [""], "Paulo2", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(3, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(4, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(5, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(6, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(7, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(8, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(9, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(10, false, "El Mapa3", [""], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(11, false, "El Mapa3", ["label 3", "label3"], "Paulo3", "2008-06-02T00:00:00Z", "", false),
|
||||
createMapInfo(12, false, "El Mapa3", ["label 2"], "Paulo3", "2008-06-02T00:00:00Z", "", false)
|
||||
];
|
||||
|
||||
this.labels = ["label 1,", "label 2", "label 3"];
|
||||
@ -105,7 +105,7 @@ class MockClient implements Client {
|
||||
starred: false,
|
||||
creator: "current user",
|
||||
labels: [],
|
||||
modified: -1,
|
||||
modified: "2008-06-02T00:00:00Z",
|
||||
isPublic: false
|
||||
};
|
||||
this.maps.push(newMap);
|
||||
|
@ -6,34 +6,47 @@ import MockClient from '../mock-client/';
|
||||
export default class RestClient extends MockClient {
|
||||
private baseUrl: string;
|
||||
private authFailed: () => void
|
||||
|
||||
|
||||
constructor(baseUrl: string, authFailed: () => void) {
|
||||
super();
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
|
||||
fetchAllMaps(): Promise<MapInfo[]> {
|
||||
// https://app.wisemapping.com/c/restful/maps/
|
||||
|
||||
// const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
|
||||
// axios.post(this.baseUrl + '/service/users/',
|
||||
// JSON.stringify(user),
|
||||
// { headers: { 'Content-Type': 'application/json' } }
|
||||
// ).then(response => {
|
||||
// // All was ok, let's sent to success page ...;
|
||||
// success();
|
||||
// }).catch(error => {
|
||||
// const response = error.response;
|
||||
// const errorInfo = parseResponseOnError(response);
|
||||
// reject(errorInfo);
|
||||
// });
|
||||
// }
|
||||
// return new Promise(handler);
|
||||
// https://app.wisemapping.com/c/restful/maps/
|
||||
const handler = (success: (mapsInfo: MapInfo[]) => void, reject: (error: ErrorInfo) => void) => {
|
||||
axios.get(
|
||||
this.baseUrl + '/c/restful/maps/',
|
||||
{ headers: { 'Content-Type': 'application/json' }
|
||||
}
|
||||
).then(response => {
|
||||
console.log("Maps List Response=>")
|
||||
console.log(response.data)
|
||||
|
||||
const data = response.data;
|
||||
const maps: MapInfo[] = (data.mindmapsInfo as any[]).map(m => {
|
||||
return {
|
||||
id: m.id,
|
||||
starred: Boolean(m.starred),
|
||||
name: m.title,
|
||||
labels: [],
|
||||
creator: m.creator,
|
||||
modified: m.lastModificationTime,
|
||||
description: m.description,
|
||||
isPublic: false
|
||||
}
|
||||
})
|
||||
success(maps);
|
||||
}).catch(error => {
|
||||
|
||||
// console.log("Fetching maps from server")
|
||||
return Promise.resolve([]);
|
||||
console.log("Maps List Error=>")
|
||||
console.log(error)
|
||||
|
||||
const response = error.response;
|
||||
const errorInfo = parseResponseOnError(response);
|
||||
reject(errorInfo);
|
||||
});
|
||||
}
|
||||
return new Promise(handler);
|
||||
}
|
||||
|
||||
registerNewUser(user: NewUser): Promise<void> {
|
||||
|
@ -13,7 +13,8 @@ const GlobalError = (props: GlobalErrorProps) => {
|
||||
const hasError = Boolean(error?.msg);
|
||||
const errorMsg = error?.msg;
|
||||
|
||||
return (hasError ? <StyledAlert severity="error" variant="filled" hidden={!hasError}> {errorMsg}</StyledAlert> : null);
|
||||
return (hasError ?
|
||||
<StyledAlert severity="error" variant="filled" hidden={!hasError}> {errorMsg}</StyledAlert> : null);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user