Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion public/reearth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ extensions:
field: data_source_type
type: string
value: cms_integration_api
- id: cms_workspace_id
title: CMS Workspace ID
type: string
availableIf:
field: data_source_type
type: string
value: cms_integration_api
- id: cms_project_id
title: CMS Project ID
type: string
Expand Down Expand Up @@ -119,7 +126,7 @@ extensions:
fields:
- id: display_fields
title: Display Fields
description: "Specify the fields to display in the infobox, separated by commas. Left empty to show all fields."
description: "Specify the fields to display in the infobox, please use field keys separated by commas. Left empty to show all fields."
type: string
ui: multiline
- id: inspector_block
Expand Down
12 changes: 8 additions & 4 deletions src/extensions/visualizer/main/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type WidgetProperty = {
server_api_key?: string;
integration_api_base_url?: string;
integration_api_key?: string;
cms_workspace_id?: string;
cms_project_id?: string;
cms_model_id?: string;
value_filters?: string;
Expand Down Expand Up @@ -99,19 +100,21 @@ export default () => {
if (
!widgetProperty.api.integration_api_base_url ||
!widgetProperty.api.integration_api_key ||
!widgetProperty.api.cms_workspace_id ||
!widgetProperty.api.cms_project_id ||
!widgetProperty.api.cms_model_id
) {
console.warn(
"Please set the Integration API Base URL, Integration API Key, CMS Project ID, and CMS Model ID in the widget properties."
"Please set the Integration API Base URL, Integration API Key, CMS Workspace ID, CMS Project ID, and CMS Model ID in the widget properties."
);
return;
}

// Fetch Assets with pagination
let assets: Asset[];
try {
const baseUrl = `${widgetProperty.api.integration_api_base_url}/projects/${widgetProperty.api.cms_project_id}/assets`;
const baseUrl = `${widgetProperty.api.integration_api_base_url}/${widgetProperty.api.cms_workspace_id}/projects/${widgetProperty.api.cms_project_id}/assets`;

const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${widgetProperty.api.integration_api_key}`,
Expand Down Expand Up @@ -163,7 +166,7 @@ export default () => {
// Fetch Schema
let schema: Schema;
try {
const url = `${widgetProperty.api.integration_api_base_url}/models/${widgetProperty.api.cms_model_id}`;
const url = `${widgetProperty.api.integration_api_base_url}/${widgetProperty.api.cms_workspace_id}/projects/${widgetProperty.api.cms_project_id}/models/${widgetProperty.api.cms_model_id}`;
const response = await fetch(url, {
method: "GET",
headers: {
Expand All @@ -184,7 +187,8 @@ export default () => {

// Fetch Items with pagination
try {
const baseUrl = `${widgetProperty.api.integration_api_base_url}/models/${widgetProperty.api.cms_model_id}/items`;
const baseUrl = `${widgetProperty.api.integration_api_base_url}/${widgetProperty.api.cms_workspace_id}/projects/${widgetProperty.api.cms_project_id}/models/${widgetProperty.api.cms_model_id}/items`;

const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${widgetProperty.api.integration_api_key}`,
Expand Down