Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add buttons in selected feature table in STAC API Explorer to de… #4678

Merged
merged 1 commit into from
Dec 24, 2024
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
5 changes: 5 additions & 0 deletions .changeset/serious-jokes-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"geohub": patch
---

fix: add buttons in selected feature table in STAC API Explorer to deselect a feature or all features.
47 changes: 42 additions & 5 deletions sites/geohub/src/components/util/stac/StacApiExplorer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
clean,
DatePicker,
FieldControl,
initTooltipTippy,
Notification,
type RasterAlgorithm,
type RasterTileMetadata,
Expand Down Expand Up @@ -52,6 +53,8 @@
const NOTIFICATION_MESSAGE_TIME = 5000;
const MAX_ZOOM = 8;

const tooltipTippy = initTooltipTippy();

let config: UserConfig = $page.data.config;

export let stacId: string;
Expand Down Expand Up @@ -466,6 +469,18 @@
}
};

const removeClickedFeature = (feature?: MapGeoJSONFeature) => {
if (feature) {
map.setFeatureState(feature, { click: false });
clickedFeatures = [...clickedFeatures.filter((f) => f !== feature)];
} else {
for (const feature of clickedFeatures) {
map.setFeatureState(feature, { click: false });
}
clickedFeatures = [];
}
};

const handleSelectedAssets = async () => {
selectedProduct = '';
assetSelectionDone = !assetSelectionDone;
Expand Down Expand Up @@ -939,29 +954,51 @@
<ShowDetails bind:show={showDetails} />
</div>
{#if showDetails}
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
<table class="table is-narrow is-hoverable is-fullwidth">
<thead>
<tr>
<th>No.</th>
<th>Datetime</th>
{#if stacInstance.hasCloudCoverProp}
<th>Cloud cover (%)</th>
{/if}
<th>
<button
class="delete-button"
on:click={() => {
removeClickedFeature();
}}
use:tooltipTippy={{ content: 'Clear all selected features' }}
>
<span class="material-symbols-outlined"> clear_all </span>
</button>
</th>
</tr>
</thead>
<tbody>
{#each clickedFeatures as feature, index}
<tr>
<th>{index + 1}</th>
<th
<td>{index + 1}</td>
<td
><Time
timestamp={feature.properties.datetime}
format="HH:mm, MM/DD/YYYY"
/></th
/></td
>
{#if stacInstance.hasCloudCoverProp}
<th>{feature.properties[stacInstance.cloudCoverPropName].toFixed(2)}%</th>
<td>{feature.properties[stacInstance.cloudCoverPropName].toFixed(2)}%</td>
{/if}
<td>
<button
class="delete-button"
on:click={() => {
removeClickedFeature(feature);
}}
use:tooltipTippy={{ content: `Deselect No. ${index + 1} feature` }}
>
<span class="material-symbols-outlined"> remove_selection </span>
</button>
</td>
</tr>
{/each}
</tbody>
Expand Down
Loading