Skip to content

Commit ca60715

Browse files
committed
Switch imagery def settings to dedicated endpoints
1 parent f499a02 commit ca60715

3 files changed

Lines changed: 56 additions & 12 deletions

File tree

components/settings/panel/Imagery.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,20 @@ const { isLead } = useWorkspaceRole();
9090
const imagerySchemaUrl = import.meta.env.VITE_IMAGERY_SCHEMA;
9191
const imageryExampleUrl = import.meta.env.VITE_IMAGERY_EXAMPLE_URL;
9292
93-
let imageryListDefInit = '';
94-
95-
if (Array.isArray(workspace.imageryListDef)) {
96-
imageryListDefInit = JSON.stringify(workspace.imageryListDef, null, 2);
97-
}
98-
9993
const imagerySchema = ref<object | undefined>();
100-
const imageryListDef = ref(imageryListDefInit);
94+
const imageryListDef = ref('');
10195
const imageryError = ref<string | null>(null);
10296
const imagerySaveStatus = ref<{ type: 'success' | 'error'; message: string } | null>(null);
10397
const isDraggingImagery = ref(false);
10498
99+
onMounted(async () => {
100+
const settings = await workspacesClient.getImagerySettings(workspace.id);
101+
102+
if (Array.isArray(settings.definition)) {
103+
imageryListDef.value = JSON.stringify(settings.definition, null, 2);
104+
}
105+
});
106+
105107
function clearImageryMessages() {
106108
imageryError.value = null;
107109
imagerySaveStatus.value = null;
@@ -127,8 +129,8 @@ async function saveImageryConfiguration() {
127129
}
128130
129131
try {
130-
await workspacesClient.updateWorkspace(workspace.id, {
131-
imageryListDef: imageryResult.data,
132+
await workspacesClient.saveImageryDefSettings(workspace.id, {
133+
definition: imageryResult.data,
132134
});
133135
imagerySaveStatus.value = { type: 'success', message: 'Changes saved.' };
134136
}

services/workspaces.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { compareStringAsc } from '~/util/compare';
55
import type { ICancelableClient } from '~/services/loading';
66
import type { OsmApiClient } from '~/services/osm';
77
import type { TdeiAuthStore, TdeiClient } from '~/services/tdei';
8-
import type { BoundingBox } from '~/types/bbox'
8+
import type { BoundingBox } from '~/types/bbox';
9+
import type { ImagerySettings } from '~/types/imagery';
910
import type {
1011
QuestSettings,
1112
QuestSettingsPatch,
@@ -146,8 +147,14 @@ export class WorkspacesClient extends BaseHttpClient implements ICancelableClien
146147
await this.#newApi._patch(`workspaces/${id}/quests/long/settings`, settings);
147148
}
148149

149-
async saveImageryDefSettings(workspaceId: number, settings: object): Promise<void> {
150-
await this.#newApi._patch(`workspaces/${workspaceId}/imagery/settings`, settings);
150+
async getImagerySettings(id: WorkspaceId): Promise<ImagerySettings> {
151+
const response = await this.#newApi._get(`workspaces/${id}/imagery/settings`);
152+
153+
return await response.json();
154+
}
155+
156+
async saveImageryDefSettings(id: WorkspaceId, settings: object): Promise<void> {
157+
await this.#newApi._patch(`workspaces/${id}/imagery/settings`, settings);
151158
}
152159

153160
async getTeams(id: WorkspaceId): Promise<WorkspaceTeam[]> {

types/imagery.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Each ring is an array of [lon, lat] pairs. The first and last elements must
2+
// be equal (closed):
3+
type LinearRing = [number, number][];
4+
5+
type ImagerySourceType = 'tms' | 'wmts' | 'xyz';
6+
7+
interface ImagerySourceAttribution {
8+
required: boolean;
9+
text: string;
10+
url: string;
11+
}
12+
13+
interface ImagerySourceExtent {
14+
max_zoom: number;
15+
polygon: LinearRing[];
16+
}
17+
18+
export interface ImagerySource {
19+
attribution: ImagerySourceAttribution;
20+
description: string;
21+
extent: ImagerySourceExtent;
22+
icon: string;
23+
id: string;
24+
name: string;
25+
type: ImagerySourceType;
26+
url: string;
27+
}
28+
29+
export interface ImagerySettings {
30+
workspace_id: number;
31+
definition: ImagerySource[] | null;
32+
modifiedAt: string;
33+
modifiedBy: string;
34+
modifiedByName: string;
35+
}

0 commit comments

Comments
 (0)