Revize f220395e
Přidáno uživatelem Fantič před více než 1 rok
src/stores/actions/planThunks.ts | ||
---|---|---|
2 | 2 |
import { SortOptions } from "../../types/general"; |
3 | 3 |
import { Note } from "../../types/note"; |
4 | 4 |
import { getPlanAllRequest, getPlanFloorImageRequest, getPlanItemsRequest } from "../../api/planservice"; |
5 |
import { Floor, Room } from "../../types/plan"; |
|
5 |
import { Floor, PlanImage, Room } from "../../types/plan";
|
|
6 | 6 |
import { ItemPreviewType } from "../../types/listViewTypes"; |
7 | 7 |
import { StringLiteralType } from "typescript"; |
8 | 8 |
import { Inventory } from "../../types/searchFormTypes"; |
9 | 9 |
|
10 |
// @ts-ignore |
|
11 |
import { parseString } from 'react-native-xml2js'; |
|
12 |
|
|
10 | 13 |
export const getFloorList = createAsyncThunk( |
11 | 14 |
"plan/getFloorList", |
12 | 15 |
async () => { |
... | ... | |
125 | 128 |
const response = await getPlanFloorImageRequest(floorId) |
126 | 129 |
|
127 | 130 |
if (response.status === 200) { |
128 |
return response.data |
|
131 |
|
|
132 |
const svg : string = response.data |
|
133 |
|
|
134 |
const output : PlanImage = { |
|
135 |
svg: svg, |
|
136 |
} |
|
137 |
|
|
138 |
parseString(svg, (err : any, result: any) => { |
|
139 |
if (!err && result && result.svg && result.svg.$.viewBox) { |
|
140 |
const [x, y, width, height] = result.svg.$.viewBox.split(' ').map(Number); |
|
141 |
|
|
142 |
// Set the SVG information in your component's state or use it as needed |
|
143 |
output.viewBox = { x, y, width, height }; |
|
144 |
} |
|
145 |
}); |
|
146 |
|
|
147 |
return output |
|
129 | 148 |
} else { |
130 | 149 |
return Promise.reject(response.data ? response.data : "Get plan floor image request failed") |
131 | 150 |
} |
Také k dispozici: Unified diff
re #10871: PlanViewPage: Parse map xml