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