Skip to content

Commit

Permalink
Almost done!
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Dec 7, 2023
1 parent e3a2bfd commit 3c7cd77
Show file tree
Hide file tree
Showing 11 changed files with 341 additions and 903 deletions.
1 change: 1 addition & 0 deletions packages/api/generated-schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -6571,6 +6571,7 @@ input InteractivitySettingPatch {
}

enum InteractivityType {
ALL_PROPERTIES_POPUP
BANNER
FIXED_BLOCK
NONE
Expand Down
19 changes: 18 additions & 1 deletion packages/api/migrations/current.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ create or replace function import_arcgis_services("projectId" int, items arcgis_
source_id_map jsonb;
layer_id_map jsonb;
item_id_map jsonb;
interactive_layers int[];
begin
source_id_map = '{}'::jsonb;
layer_id_map = '{}'::jsonb;
Expand Down Expand Up @@ -130,6 +131,7 @@ create or replace function import_arcgis_services("projectId" int, items arcgis_
select
id_lookup_set_key(layer_id_map, source.id, layer_id)
into layer_id_map;
interactive_layers = array_append(interactive_layers, layer_id);
elsif source.type = 'arcgis-raster-tiles' then
insert into data_sources (
project_id,
Expand Down Expand Up @@ -173,6 +175,7 @@ create or replace function import_arcgis_services("projectId" int, items arcgis_
source_id,
items[i].sublayer_id
) returning id into layer_id;
interactive_layers = array_append(interactive_layers, layer_id);
select
id_lookup_set_key(layer_id_map, items[i].id, layer_id)
into layer_id_map;
Expand Down Expand Up @@ -203,6 +206,18 @@ create or replace function import_arcgis_services("projectId" int, items arcgis_
items[1].stable_id::ltree
);
end if;
update interactivity_settings
set type = 'ALL_PROPERTIES_POPUP'
where id = any(
(
select
interactivity_settings_id
from
data_layers
where
id = any(interactive_layers)
)
);
else
raise exception 'Only admins can import ArcGIS services';
end if;
Expand Down Expand Up @@ -252,4 +267,6 @@ create or replace function table_of_contents_items_is_custom_gl_source(t table_o
end;
$$;

grant execute on function table_of_contents_items_is_custom_gl_source(table_of_contents_items) to anon;
grant execute on function table_of_contents_items_is_custom_gl_source(table_of_contents_items) to anon;

ALTER TYPE interactivity_type ADD VALUE IF NOT EXISTS 'ALL_PROPERTIES_POPUP';
13 changes: 1 addition & 12 deletions packages/client/src/admin/data/DataSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { useMemo } from "react";
import {
Link,
Route,
Expand All @@ -18,13 +18,6 @@ import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import Legend, { LegendItem } from "../../dataLayers/Legend";

const LazyArcGISBrowser = React.lazy(
() =>
import(
/* webpackChunkName: "AdminArcGISBrowser" */ "./arcgis/ArcGISBrowser"
)
);

export default function DataSettings() {
const { path } = useRouteMatch();
const { slug } = useParams<{ slug: string }>();
Expand All @@ -38,7 +31,6 @@ export default function DataSettings() {

const legendState = useMemo<{ items: LegendItem[] }>(() => {
if (mapContext.legends) {
// TODO: this does't really handle WMS or dynamic map services
const visibleLegends: LegendItem[] = [];
for (const id in mapContext.layerStatesByTocStaticId) {
if (mapContext.layerStatesByTocStaticId[id].visible) {
Expand Down Expand Up @@ -133,9 +125,6 @@ export default function DataSettings() {
</div>
</div>
</Route>
<Route exact path={`${path}/add-data/arcgis`}>
<LazyArcGISBrowser />
</Route>
</Switch>
</MapContext.Provider>
</DndProvider>
Expand Down
49 changes: 29 additions & 20 deletions packages/client/src/admin/data/InteractivitySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,36 @@ export default function InteractivitySettings({
},
]
: []),
...(!sublayer
? [
{
label: "Custom Popup",
description:
"Popup windows can be opened and closed to show detailed information.",
value: InteractivityType.Popup,
children: (
<>
<TemplateEditor
type={InteractivityType.Popup}
selectedType={selectedType}
propName={"longTemplate"}
templateValue={longTemplate || undefined}
onSave={sanitizeTemplate}
onChange={(value) => setLongTemplate(value)}
attributeNames={attributeNames}
basemap={basemap}
layers={data.interactivitySetting?.layers as string[]}
onSelectLayers={() => setPickLayersOpen(true)}
/>
</>
),
},
]
: []),
{
label: "Popup",
description:
"Popup windows can be opened and closed to show detailed information.",
value: InteractivityType.Popup,
children: (
<>
<TemplateEditor
type={InteractivityType.Popup}
selectedType={selectedType}
propName={"longTemplate"}
templateValue={longTemplate || undefined}
onSave={sanitizeTemplate}
onChange={(value) => setLongTemplate(value)}
attributeNames={attributeNames}
basemap={basemap}
layers={data.interactivitySetting?.layers as string[]}
onSelectLayers={() => setPickLayersOpen(true)}
/>
</>
),
label: "Popup with all columns",
description: "Popup window which includes all column values.",
value: InteractivityType.AllPropertiesPopup,
},
// {
// label: "Fixed Block",
Expand Down
42 changes: 35 additions & 7 deletions packages/client/src/admin/data/LayerTableOfContentsItemEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { useGlobalErrorHandler } from "../../components/GlobalErrorHandler";
import FeatureLayerPerformanceDetailsModal from "./FeatureLayerPerformanceDetailsModal";
import { ChartBarIcon } from "@heroicons/react/solid";
import ArcGISTiledRasterSettings from "./ArcGISTiledRasterSettings";
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";

interface LayerTableOfContentsItemEditorProps {
itemId: number;
Expand Down Expand Up @@ -775,13 +776,28 @@ export default function LayerTableOfContentsItemEditor(
{item && selectedTab === "interactivity" && (
<div className="flex-1 overflow-y-auto px-4 pb-4">
<div className="mt-5">
{source && layer && (
<InteractivitySettings
id={layer.interactivitySettingsId}
dataSourceId={layer.dataSourceId}
sublayer={layer.sublayer}
/>
)}
{source &&
layer &&
source.type !== DataSourceTypes.ArcgisRasterTiles && (
<InteractivitySettings
id={layer.interactivitySettingsId}
dataSourceId={layer.dataSourceId}
sublayer={layer.sublayer}
/>
)}
{source &&
layer &&
source.type === DataSourceTypes.ArcgisRasterTiles && (
<div className="bg-gray-50 text-sm border p-4 rounded flex items-center space-x-4">
<ExclamationTriangleIcon className="h-8 w-8 text-gray-600" />
<div>
<Trans ns="admin:data">
Popups and other interactivity options are not supported
for tiled ArcGIS sources.
</Trans>
</div>
</div>
)}
</div>
<div className="mt-5">
<MutableRadioGroup
Expand Down Expand Up @@ -888,6 +904,18 @@ export default function LayerTableOfContentsItemEditor(
/>
</div>
)}
{isArcGISCustomSource && (
<div className="bg-gray-50 text-sm border p-4 rounded flex items-center space-x-4 m-4 mt-5">
<ExclamationTriangleIcon className="h-8 w-8 text-gray-600" />
<div className="flex-1">
<Trans ns="admin:data">
Styling is not available for ArcGIS sources. SeaSketch
respects cartographic styling as it is defined in the service
and will change automatically when the service is updated.
</Trans>
</div>
</div>
)}
</div>
)}
</div>
Expand Down
Loading

0 comments on commit 3c7cd77

Please sign in to comment.