Skip to content

Commit

Permalink
Merge branch 'master' into allow-dragscroll-in-tree-compoenents
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBuessemeyer authored Nov 4, 2024
2 parents da374ad + 43dd861 commit fbdf34d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Admins can now see and cancel all jobs. The owner of the job is shown in the job list. [#8112](https://github.com/scalableminds/webknossos/pull/8112)
- Migrated nightly screenshot tests from CircleCI to GitHub actions. [#8134](https://github.com/scalableminds/webknossos/pull/8134)
- Migrated nightly screenshot tests for wk.org from CircleCI to GitHub actions. [#8135](https://github.com/scalableminds/webknossos/pull/8135)
- Thumbnails for datasets now use the selected mapping from the view configuration if available. [#8157](https://github.com/scalableminds/webknossos/pull/8157)

### Fixed
- Fixed a bug during dataset upload in case the configured `datastore.baseFolder` is an absolute path. [#8098](https://github.com/scalableminds/webknossos/pull/8098) [#8103](https://github.com/scalableminds/webknossos/pull/8103)
Expand Down
14 changes: 6 additions & 8 deletions DEV_INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ arch -x86_64 /bin/zsh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install git, node.js, postgres, sbt, gfind, gsed, draco
brew install openjdk draco openssl git node postgresql sbt findutils coreutils gnu-sed redis yarn c-blosc brotli wget
brew install openjdk draco openssl git node postgresql sbt findutils coreutils gnu-sed redis c-blosc brotli wget

# Set env variables for openjdk and openssl
# You probably want to add these lines manually to avoid conflicts in your zshrc
Expand Down Expand Up @@ -84,12 +84,8 @@ source ~/.bashrc
nvm install 18
nvm use 18

# Adding repositories for yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt update
sudo apt install -y git postgresql postgresql-client unzip zip yarn redis-server build-essential libblosc1 libbrotli1 libdraco-dev cmake
sudo apt install -y git postgresql postgresql-client unzip zip redis-server build-essential libblosc1 libbrotli1 libdraco-dev cmake

# Install sdkman, java, scala and sbt
curl -s "https://get.sdkman.io" | bash
Expand Down Expand Up @@ -132,8 +128,10 @@ On older Ubuntu distributions: Please make sure to have the correct versions of
### node.js & yarn

* Install node from [http://nodejs.org/download/](http://nodejs.org/download/)
* node version **16 to 18 is required**
* Install yarn package manager: `npm install -g yarn`
* node version **18 is required**
* Use `corepack` to install `yarn`
* `corepack enable`&& `yarn install`


## Run locally

Expand Down
49 changes: 32 additions & 17 deletions app/models/dataset/ThumbnailService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import models.configuration.DatasetConfigurationService
import net.liftweb.common.Full
import play.api.http.Status.NOT_FOUND
import play.api.i18n.{Messages, MessagesProvider}
import play.api.libs.json.JsArray
import play.api.libs.json.{JsArray, JsObject}
import utils.ObjectId
import utils.sql.{SimpleSQLDAO, SqlClient}

Expand Down Expand Up @@ -74,39 +74,41 @@ class ThumbnailService @Inject()(datasetService: DatasetService,
viewConfiguration <- datasetConfigurationService.getDatasetViewConfigurationForDataset(List.empty,
datasetName,
organizationId)(ctx)
(mag1BoundingBox, mag, intensityRangeOpt, colorSettingsOpt) = selectParameters(viewConfiguration,
usableDataSource,
layerName,
layer,
width,
height)
(mag1BoundingBox, mag, intensityRangeOpt, colorSettingsOpt, mapping) = selectParameters(viewConfiguration,
usableDataSource,
layerName,
layer,
width,
height,
mappingName)
client <- datasetService.clientFor(dataset)
image <- client.getDataLayerThumbnail(organizationId,
dataset,
layerName,
mag1BoundingBox,
mag,
mappingName,
mapping,
intensityRangeOpt,
colorSettingsOpt)
_ <- thumbnailDAO.upsertThumbnail(dataset._id,
layerName,
width,
height,
mappingName,
mapping,
image,
jpegMimeType,
mag,
mag1BoundingBox)
} yield image

private def selectParameters(
viewConfiguration: DatasetViewConfiguration,
usableDataSource: GenericDataSource[DataLayerLike],
layerName: String,
layer: DataLayerLike,
targetMagWidth: Int,
targetMagHeigt: Int): (BoundingBox, Vec3Int, Option[(Double, Double)], Option[ThumbnailColorSettings]) = {
private def selectParameters(viewConfiguration: DatasetViewConfiguration,
usableDataSource: GenericDataSource[DataLayerLike],
layerName: String,
layer: DataLayerLike,
targetMagWidth: Int,
targetMagHeigt: Int,
mappingName: Option[String])
: (BoundingBox, Vec3Int, Option[(Double, Double)], Option[ThumbnailColorSettings], Option[String]) = {
val configuredCenterOpt =
viewConfiguration.get("position").flatMap(jsValue => JsonHelper.jsResultToOpt(jsValue.validate[Vec3Int]))
val centerOpt =
Expand All @@ -124,7 +126,13 @@ class ThumbnailService @Inject()(datasetService: DatasetService,
val x = center.x - mag1Width / 2
val y = center.y - mag1Height / 2
val z = center.z
(BoundingBox(Vec3Int(x, y, z), mag1Width, mag1Height, 1), mag, intensityRangeOpt, colorSettingsOpt)

val mappingNameResult = mappingName.orElse(readMappingName(viewConfiguration, layerName))
(BoundingBox(Vec3Int(x, y, z), mag1Width, mag1Height, 1),
mag,
intensityRangeOpt,
colorSettingsOpt,
mappingNameResult)
}

private def readIntensityRange(viewConfiguration: DatasetViewConfiguration,
Expand All @@ -147,6 +155,13 @@ class ThumbnailService @Inject()(datasetService: DatasetService,
b <- colorArray(2).validate[Int].asOpt
} yield ThumbnailColorSettings(Color(r / 255d, g / 255d, b / 255d, 0), isInverted)

private def readMappingName(viewConfiguration: DatasetViewConfiguration, layerName: String): Option[String] =
for {
layersJsValue <- viewConfiguration.get("layers")
mapping <- (layersJsValue \ layerName \ "mapping").validate[JsObject].asOpt
mappingName <- mapping("name").validate[String].asOpt
} yield mappingName

private def magForZoom(dataLayer: DataLayerLike, zoom: Double): Vec3Int =
dataLayer.resolutions.minBy(r => Math.abs(r.maxDim - zoom))

Expand Down

0 comments on commit fbdf34d

Please sign in to comment.