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;
|
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);
|
||||||
|
@ -6,34 +6,47 @@ import MockClient from '../mock-client/';
|
|||||||
export default class RestClient extends MockClient {
|
export default class RestClient extends MockClient {
|
||||||
private baseUrl: string;
|
private baseUrl: string;
|
||||||
private authFailed: () => void
|
private authFailed: () => void
|
||||||
|
|
||||||
constructor(baseUrl: string, authFailed: () => void) {
|
constructor(baseUrl: string, authFailed: () => void) {
|
||||||
super();
|
super();
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
||||||
// const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
|
this.baseUrl + '/c/restful/maps/',
|
||||||
// axios.post(this.baseUrl + '/service/users/',
|
{ headers: { 'Content-Type': 'application/json' }
|
||||||
// JSON.stringify(user),
|
}
|
||||||
// { headers: { 'Content-Type': 'application/json' } }
|
).then(response => {
|
||||||
// ).then(response => {
|
console.log("Maps List Response=>")
|
||||||
// // All was ok, let's sent to success page ...;
|
console.log(response.data)
|
||||||
// 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 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")
|
console.log("Maps List Error=>")
|
||||||
return Promise.resolve([]);
|
console.log(error)
|
||||||
|
|
||||||
|
const response = error.response;
|
||||||
|
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