Skip to content

Commit 71ca1f5

Browse files
jeffmakicyrossignol
authored andcommitted
Imagery method API
1 parent ad595fd commit 71ca1f5

6 files changed

Lines changed: 42 additions & 21 deletions

File tree

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@ Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introdu
66

77
## Dev Setup
88

9-
NB: This will start the dev server against the cloud-hosted backend. If you need to change both the frontend and the backend, you'll
10-
need to start a local copy of the backend (workspaces-tasking-manager) and set the environment vars appropriately below.
11-
12-
The below values are for cloud-hosted dev:
13-
149
```
10+
# set these e.g. to the dev TDEI instance--note: any tokens you get from these hosts must match the environment for other components
11+
# e.g. you can't use dev TDEI KeyCloak JWT tokens in stage or production environments.
1512
export VITE_TDEI_API_URL=https://api-dev.tdei.us/api/v1/
1613
export VITE_TDEI_USER_API_URL=https://portal-api-dev.tdei.us/api/v1/
17-
export VITE_API_URL=https://api.workspaces-dev.sidewalks.washington.edu/api/v1/
18-
export VITE_OSM_URL=https://osm.workspaces-dev.sidewalks.washington.edu/
14+
15+
# use your local workspaces-backend instance--or set to the dev instance of this component if not running locally
16+
export VITE_API_URL=http://localhost:3000/api/v1/
17+
export VITE_OSM_URL=http://localhost:3000/
18+
19+
# probably want to leave these as-is
1920
export VITE_RAPID_URL=https://rapid.workspaces-dev.sidewalks.washington.edu/
2021
export VITE_PATHWAYS_EDITOR_URL=https://pathways.workspaces-dev.sidewalks.washington.edu/
22+
23+
# probably don't need to change any of these
2124
export CODE_VERSION="local"
22-
export VITE_IMAGERY_SCHEMA=https://raw.githubusercontent.com/TaskarCenterAtUW/tdei-tools/main/docs/imagery-layer/schema.json
23-
export VITE_IMAGERY_EXAMPLE_URL=https://raw.githubusercontent.com/TaskarCenterAtUW/tdei-tools/main/docs/imagery-layer/example.json
24-
export VITE_LONG_FORM_QUEST_SCHEMA=https://raw.githubusercontent.com/TaskarCenterAtUW/tdei-tools/refs/heads/main/docs/quest-definition/schema.json
25-
export VITE_LONG_FORM_QUEST_EXAMPLE_URL=https://raw.githubusercontent.com/TaskarCenterAtUW/tdei-tools/refs/heads/main/docs/quest-definition/example.json
25+
export VITE_IMAGERY_SCHEMA=https://raw.githubusercontent.com/TaskarCenterAtUW/asr-imagery-list/refs/heads/main/schema/schema.json
26+
export VITE_IMAGERY_EXAMPLE_URL=https://github.com/TaskarCenterAtUW/asr-imagery-list/blob/main/examples/example.json
27+
export VITE_LONG_FORM_QUEST_SCHEMA=https://raw.githubusercontent.com/TaskarCenterAtUW/asr-quests/refs/heads/main/schema/schema.json
28+
export VITE_LONG_FORM_QUEST_EXAMPLE_URL=https://raw.githubusercontent.com/TaskarCenterAtUW/asr-quests/refs/heads/main/docs/quest-definition/example.json
2629
27-
# install deps
30+
# install deps (first time only)
2831
npm install
2932
3033
# start dev server

nuxt.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ export default defineNuxtConfig({
44
sourcemap: { client: 'hidden' },
55
devtools: { enabled: process.env.ENV === "dev" || process.env.ENV === "local" },
66
modules: ['@sentry/nuxt/module'],
7+
nitro: {
8+
// deal with CORS issues during development
9+
devProxy: {
10+
'/api': 'http://localhost:8000/api/',
11+
'/workspaces': 'http://localhost:8000/workspaces/',
12+
}
13+
},
714
app: {
815
head: {
916
meta: [

pages/temp.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<app-page>
33
<form @submit="submit">
4-
<textarea v-model="inputOsmXml" />
4+
<textarea v-model="inputOsmXml"></textarea>
55
<button type="submit">Upload</button>
66
</form>
77
</app-page>
@@ -13,7 +13,7 @@ import { osm2osc } from '~/services/osm';
1313
1414
const inputOsmXml = ref('');
1515
16-
async function submit(e) {
16+
async function submit(e:Event) {
1717
e.preventDefault();
1818
1919
const workspaceId = 101

pages/workspace/[id]/settings.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,11 @@ async function saveImageryConfiguration() {
469469
}
470470
471471
try {
472+
// FIXME: make both the legacy and the new backend API calls to handle both cases until we
473+
// fully deprecate the old API.
472474
await save({ imageryListDef: imageryResult.data });
475+
workspacesClient.saveImageryDefSettings(workspaceId, { definition: imageryResult.data })
476+
473477
imagerySaveStatus.value = { type: "success", message: "Changes saved." };
474478
} catch (e) {
475479
imagerySaveStatus.value = {

pages/workspace/create/tdei.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Dataset
3434
<dataset-picker
3535
v-model="tdeiRecordId"
36-
:project-group-id="projectGroupId"
36+
:project-group-id="projectGroupId ?? ''"
3737
:disabled="context.active"
3838
required
3939
/>

services/workspaces.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,20 @@ export class WorkspacesClient extends BaseHttpClient implements ICancelableClien
105105
}
106106

107107
async getLongFormQuestSettings(workspaceId: number) {
108-
const response = await this._get(`workspaces/${workspaceId}/quests/long/settings`);
109-
110-
return await response.json();
108+
const response = this._get(`workspaces/${workspaceId}/quests/long/settings`);
109+
return response.then(data => {
110+
// case when no existing settings exist, just show empty form
111+
if(data.status === 204) return {};
112+
return data.json();
113+
});
111114
}
112115

113116
async saveLongFormQuestSettings(workspaceId: number, settings: object): Promise<void> {
114-
await this._patch(`workspaces/${workspaceId}/quests/long/settings`, settings);
117+
this._patch(`workspaces/${workspaceId}/quests/long/settings`, settings);
118+
}
119+
120+
async saveImageryDefSettings(workspaceId: number, settings: object): Promise<void> {
121+
this._patch(`workspaces/${workspaceId}/imagery/settings`, settings);
115122
}
116123

117124
#setAuthHeader() {
@@ -120,13 +127,13 @@ export class WorkspacesClient extends BaseHttpClient implements ICancelableClien
120127
}
121128
}
122129

123-
async _send(url: string, method: string, body?: any, config?: object): Promise<Response> {
130+
override async _send(url: string, method: string, body?: any, config?: object): Promise<Response> {
124131
try {
125132
await this.#tdeiClient.tryRefreshAuth();
126133
this.#setAuthHeader();
127134

128135
return await super._send(url, method, body, config);
129-
} catch (e: any) {
136+
} catch (e) {
130137
if (e instanceof BaseHttpClientError) {
131138
throw new WorkspacesClientError(e.response);
132139
}

0 commit comments

Comments
 (0)