-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed issue when access token expires * Fixed issue when refresh token is revoked * Fixed mobile styles * Updated libraries * Added link to hosted app
- Loading branch information
1 parent
3dc3867
commit e618822
Showing
12 changed files
with
438 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"prettier.tabWidth": 2, | ||
"editor.tabSize": 2 | ||
"editor.tabSize": 2, | ||
"typescript.tsdk": "node_modules\\typescript\\lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { apiUrl } from "./config"; | ||
import { getAccessToken, logout } from "./authentication"; | ||
import { | ||
GraphicsLayer, | ||
Dimensions, | ||
Boundary, | ||
TileCoordinates | ||
} from "@rapal/optimaze-viewer"; | ||
|
||
export async function getFloorGraphics(companyId: number, floorId: string) { | ||
const url = `${apiUrl}/${companyId}/floors/${floorId}/graphics`; | ||
return getJson<FloorGraphics>(url); | ||
} | ||
|
||
export async function getSeats(companyId: number, floorId: string) { | ||
const url = `${apiUrl}/${companyId}/seats?floorId=${floorId}`; | ||
return getJson<List<Seat>>(url); | ||
} | ||
|
||
export async function getTile( | ||
companyId: number, | ||
floorId: string, | ||
layer: GraphicsLayer, | ||
coordinates: TileCoordinates | ||
): Promise<string> { | ||
const url = | ||
`${apiUrl}/${companyId}/floors/${floorId}/tiles?` + | ||
`layer=${layer}&x=${coordinates.x}&y=${coordinates.y}&z=${coordinates.z}`; | ||
return getJson<string>(url); | ||
} | ||
|
||
/** | ||
* Authenticated JSON request. | ||
*/ | ||
async function getJson<TData>(url: string): Promise<TData> { | ||
try { | ||
const accessToken = await getAccessToken(); | ||
|
||
const response = await fetch(url, { | ||
headers: [["Authorization", "Bearer " + accessToken]] | ||
}); | ||
|
||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
throw new Error(response.statusText); | ||
} | ||
} catch (e) { | ||
logout(); | ||
throw e; | ||
} | ||
} | ||
|
||
interface FloorGraphics { | ||
dimensions: Dimensions; | ||
graphicsLayers: GraphicsLayer[]; | ||
spaceGraphics: SpaceGraphics[]; | ||
scale: number; | ||
} | ||
|
||
interface SpaceGraphics { | ||
id: string; | ||
boundaries: Boundary[]; | ||
} | ||
|
||
interface List<TItem> { | ||
items: TItem[]; | ||
} | ||
|
||
interface Seat { | ||
id: number; | ||
x: number; | ||
y: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.