Skip to content

Commit

Permalink
Call triggers/reload with fallback layer name (#8298)
Browse files Browse the repository at this point in the history
* check if histogram is available before reloading its data

* use fallbacklayer name for triggers/request route

* pass tracing id to api reloadbuckets

* add changelog

* address review

---------

Co-authored-by: Philipp Otto <[email protected]>
  • Loading branch information
knollengewaechs and philippotto authored Jan 6, 2025
1 parent e5aecf5 commit 6b4b192
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed some layout issues in the upload view. [#8231](https://github.com/scalableminds/webknossos/pull/8231)
- Fixed `FATAL: role "postgres" does not exist` error message in Docker compose. [#8240](https://github.com/scalableminds/webknossos/pull/8240)
- Fixed the Zarr 3 implementation not accepting BytesCodec without "configuration" key. [#8282](https://github.com/scalableminds/webknossos/pull/8282)
- Fixed that reloading the data of a volume annotation layer did not work properly. [#8298](https://github.com/scalableminds/webknossos/pull/8298)
- Removed the magnification slider for the TIFF export within the download modal if only one magnification is available for the selected layer. [#8297](https://github.com/scalableminds/webknossos/pull/8297)

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,19 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
);
};

getReloadDataButton = (layerName: string) => {
getReloadDataButton = (
layerName: string,
isHistogramAvailable: boolean,
maybeFallbackLayerName: string | null,
) => {
const tooltipText = "Use this when the data on the server changed.";
return (
<FastTooltip title={tooltipText}>
<div onClick={() => this.reloadLayerData(layerName)}>
<div
onClick={() =>
this.reloadLayerData(layerName, isHistogramAvailable, maybeFallbackLayerName)
}
>
<ReloadOutlined className="icon-margin-right" />
Reload data from server
</div>
Expand Down Expand Up @@ -585,6 +593,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
isInEditMode: boolean,
layerName: string,
layerSettings: DatasetLayerConfiguration,
isHistogramAvailable: boolean,
hasLessThanTwoColorLayers: boolean = true,
) => {
const { tracing, dataset, isAdminOrManager } = this.props;
Expand Down Expand Up @@ -645,7 +654,10 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
}
: null,
this.props.dataset.isEditable
? { label: this.getReloadDataButton(layerName), key: "reloadDataButton" }
? {
label: this.getReloadDataButton(layerName, isHistogramAvailable, maybeFallbackLayer),
key: "reloadDataButton",
}
: null,
{
label: this.getFindDataButton(layerName, isDisabled, isColorLayer, maybeVolumeTracing),
Expand Down Expand Up @@ -976,6 +988,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
);

const defaultLayerViewConfig = getDefaultLayerViewConfiguration();
const isHistogramAvailable = isHistogramSupported(elementClass) && isColorLayer;

return (
<div key={layerName} style={style} ref={setNodeRef}>
Expand All @@ -985,6 +998,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
isInEditMode,
layerName,
layerConfiguration,
isHistogramAvailable,
hasLessThanTwoColorLayers,
)}
{isDisabled ? null : (
Expand All @@ -994,9 +1008,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
marginLeft: 10,
}}
>
{isHistogramSupported(elementClass) && layerName != null && isColorLayer
? this.getHistogram(layerName, layerConfiguration)
: null}
{isHistogramAvailable && this.getHistogram(layerName, layerConfiguration)}
<NumberSliderSetting
label={opacityLabel}
min={0}
Expand Down Expand Up @@ -1077,9 +1089,13 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
);
};

reloadLayerData = async (layerName: string): Promise<void> => {
await clearCache(this.props.dataset, layerName);
this.props.reloadHistogram(layerName);
reloadLayerData = async (
layerName: string,
isHistogramAvailable: boolean,
maybeFallbackLayerName: string | null,
): Promise<void> => {
await clearCache(this.props.dataset, maybeFallbackLayerName ?? layerName);
if (isHistogramAvailable) this.props.reloadHistogram(layerName);
await api.data.reloadBuckets(layerName);
Toast.success(`Successfully reloaded data of layer ${layerName}.`);
};
Expand Down

0 comments on commit 6b4b192

Please sign in to comment.