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

Allow accessing dataset admin view configuration via sharing token #5164

Merged
merged 2 commits into from
Feb 15, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where the listing of users that have open tasks of a project failed. [#5115](https://github.com/scalableminds/webknossos/pull/5115)
- Fixed some scenarios where the Meshes tab could cause errors (e.g., when the UI was used but no segmentation layer was available). [#5142](https://github.com/scalableminds/webknossos/pull/5142)
- Fixed a bug where the user (and telemetry) would get a cryptic error message when trying to register with an email that is already in use. [#5152](https://github.com/scalableminds/webknossos/pull/5152)
- Fixed a bug where default dataset configuration could not be loaded if a dataset was accessed via sharing token [#5164](https://github.com/scalableminds/webknossos/pull/5164)

### Removed
- Support for KNOSSOS cubes data format was removed. Use the [webKnossos cuber](https://github.com/scalableminds/webknossos-cuber) tool to convert existing datasets saved as KNOSSOS cubes. [#5085](https://github.com/scalableminds/webknossos/pull/5085)
Expand Down
9 changes: 6 additions & 3 deletions app/controllers/ConfigurationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.scalableminds.util.accesscontext.GlobalAccessContext
import models.binary.{DataSetDAO, DataSetService}
import models.configuration.{DataSetConfigurationService, UserConfiguration}
import models.user.UserService
import oxalis.security.WkEnv
import oxalis.security.{URLSharing, WkEnv}
import play.api.i18n.Messages
import play.api.libs.json.JsObject
import play.api.libs.json.Json._
Expand Down Expand Up @@ -40,16 +40,19 @@ class ConfigurationController @Inject()(
}
}

def readDataSetViewConfiguration(organizationName: String, dataSetName: String) =
def readDataSetViewConfiguration(organizationName: String, dataSetName: String, sharingToken: Option[String]) =
sil.UserAwareAction.async(validateJson[List[String]]) { implicit request =>
val ctx = URLSharing.fallbackTokenAccessContext(sharingToken)
request.identity.toFox
.flatMap(
user =>
dataSetConfigurationService
.getDataSetViewConfigurationForUserAndDataset(request.body, user, dataSetName, organizationName)(
GlobalAccessContext))
.orElse(
dataSetConfigurationService.getDataSetViewConfigurationForDataset(request.body, dataSetName, organizationName)
dataSetConfigurationService.getDataSetViewConfigurationForDataset(request.body,
dataSetName,
organizationName)(ctx)
)
.getOrElse(Map.empty)
.map(configuration => Ok(toJson(configuration)))
Expand Down
2 changes: 1 addition & 1 deletion conf/webknossos.latest.routes
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ POST /auth/createOrganizationWithAdmin
# Configurations
GET /user/userConfiguration controllers.ConfigurationController.read
PUT /user/userConfiguration controllers.ConfigurationController.update
POST /dataSetConfigurations/:organizationName/:dataSetName controllers.ConfigurationController.readDataSetViewConfiguration(organizationName: String, dataSetName: String)
POST /dataSetConfigurations/:organizationName/:dataSetName controllers.ConfigurationController.readDataSetViewConfiguration(organizationName: String, dataSetName: String, sharingToken: Option[String])
PUT /dataSetConfigurations/:organizationName/:dataSetName controllers.ConfigurationController.updateDataSetViewConfiguration(organizationName: String, dataSetName: String)
GET /dataSetConfigurations/default/:organizationName/:dataSetName controllers.ConfigurationController.readDataSetAdminViewConfiguration(organizationName: String, dataSetName: String)
PUT /dataSetConfigurations/default/:organizationName/:dataSetName controllers.ConfigurationController.updateDataSetAdminViewConfiguration(organizationName: String, dataSetName: String)
Expand Down
4 changes: 3 additions & 1 deletion frontend/javascripts/admin/admin_rest_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,11 @@ export function updateDataset(datasetId: APIDatasetId, dataset: APIDataset): Pro
export async function getDatasetViewConfiguration(
dataset: APIDataset,
displayedVolumeTracings: Array<string>,
sharingToken?: ?string,
): Promise<DatasetConfiguration> {
const sharingTokenSuffix = sharingToken != null ? `?sharingToken=${sharingToken}` : "";
const settings = await Request.sendJSONReceiveJSON(
`/api/dataSetConfigurations/${dataset.owningOrganization}/${dataset.name}`,
`/api/dataSetConfigurations/${dataset.owningOrganization}/${dataset.name}${sharingTokenSuffix}`,
{
data: displayedVolumeTracings,
method: "POST",
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/oxalis/model_initialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export async function initialize(
const initialDatasetSettings = await getDatasetViewConfiguration(
dataset,
displayedVolumeTracings,
getSharingToken(),
);
initializeSettings(initialUserSettings, initialDatasetSettings);

Expand Down