Skip to content

Commit

Permalink
get rid of jsRoutes, start to refactor to fetch actual tracing from t…
Browse files Browse the repository at this point in the history
…he datastore (#1759)
  • Loading branch information
daniel-wer committed Aug 9, 2017
1 parent 3a15730 commit 5f52820
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DashboardTaskListView extends Marionette.CompositeView {
this.prototype.template = _.template(`\
<h3>Tasks</h3>
<% if (isAdminView) { %>
<a href="<%- jsRoutes.controllers.AnnotationIOController.userDownload(id).url %>"
<a href="/api/users/<%- id %>/annotations/download"
class="btn btn-primary"
title="download all finished tracings">
<i class="fa fa-download"></i>download
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DatasetListItemView extends Marionette.CompositeView {
<span class="label label-default"><%- layer.category %> - <%- layer.elementClass %></span>
<% }) %>
<td class="nowrap">
<form action="<%- jsRoutes.controllers.AnnotationController.createExplorational().url %>" method="POST">
<form action="/annotations/createExplorational" method="POST">
<input type="hidden" name="dataSetName" value="<%- name %>" />
<input type="hidden" name="contentType" id="contentTypeInput" />
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,33 @@ class ExplorativeTracingListItemView extends Marionette.View {
<td><%- dataSetName %></td>
<td class="nowrap">
<% if (stats && (contentType == "skeletonTracing")) { %>
<% if (stats && (content.typ == "skeletonTracing")) { %>
<span title="Trees"><i class="fa fa-sitemap"></i><%- stats.numberOfTrees %>&nbsp;</span><br />
<span title="Nodes"><i class="fa fa-bull"></i><%- stats.numberOfNodes %>&nbsp;</span><br />
<span title="Edges"><i class="fa fa-arrows-h"></i><%- stats.numberOfEdges %></span>
<% } %>
</td>
<td><%- contentType + " - " + typ %></td>
<td><%- content.typ + " - " + typ %></td>
<td><%- created %></td>
<td class="nowrap">
<% if (typ == "Explorational"){ %>
<% if (!state.isFinished) {%>
<a href="<%- jsRoutes.controllers.AnnotationController.trace(typ, id).url %>">
<a href="/annotations/<%- typ %>/<%- id %>">
<i class="fa fa-random"></i>
<strong>trace</strong>
</a><br />
<a href="<%- jsRoutes.controllers.AnnotationIOController.download(typ, id).url %>">
<a href="/download">
<i class="fa fa-download"></i>
download
</a><br />
<a href="<%- jsRoutes.controllers.AnnotationController.finish(typ, id).url %>"
<a href="/annotations/<%- typ %>/<%- id %>/finish"
id="finish-tracing">
<i class="fa fa-archive"></i>
archive
</a><br />
<% } else {%>
<a href="<%- jsRoutes.controllers.AnnotationController.reopen(typ, id).url %>"
<a href="/annotations/<%- typ %>/<%- id %>/reopen"
id="reopen-tracing">
<i class="fa fa-folder-open"></i>
reopen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExplorativeTracingListView extends Marionette.CompositeView {
<h3>Explorative Annotations</h3>
<% if (!isAdminView) {%>
<div>
<form action="<%- jsRoutes.controllers.AnnotationIOController.upload().url %>"
<form action="/admin/nml/upload"
method="POST"
enctype="multipart/form-data"
id="upload-and-explore-form"
Expand Down Expand Up @@ -161,15 +161,12 @@ class ExplorativeTracingListView extends Marionette.CompositeView {
}

const unarchivedAnnoationIds = this.collection.pluck("id");
Request.sendJSONReceiveJSON(
jsRoutes.controllers.AnnotationController.finishAll("Explorational").url,
{
method: "POST",
data: {
annotations: unarchivedAnnoationIds,
},
Request.sendJSONReceiveJSON("/annotations/Explorational/finish", {
method: "POST",
data: {
annotations: unarchivedAnnoationIds,
},
).then(data => {
}).then(data => {
Toast.message(data.messages);
this.collection.reset();
this.render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SpotlightDatasetView extends Marionette.View {
</div>
</div>
<form action="<%- jsRoutes.controllers.AnnotationController.createExplorational().url %>" method="POST">
<form action="/annotations/createExplorational" method="POST">
<input type="hidden" name="dataSetName" value="<%- name %>" />
<input type="hidden" name="contentType" id="contentTypeInput" />
</form>
Expand Down
2 changes: 0 additions & 2 deletions app/assets/javascripts/flow/custom-libdefs/jsRoutes.js

This file was deleted.

16 changes: 8 additions & 8 deletions app/assets/javascripts/oxalis/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ export class OxalisModel {
infoUrl = `/annotations/${tracingType}/${tracingId}/info`;
}

const tracing: ServerTracing<*> = await Request.receiveJSON(infoUrl);
const annotation: ServerTracing<*> = await Request.receiveJSON(infoUrl);
const dataset = await Request.receiveJSON(`/api/datasets/${annotation.dataSetName}`);

let error;
const dataset = tracing.content.dataSet;
if (tracing.error) {
({ error } = tracing);
if (annotation.error) {
({ error } = annotation);
} else if (!dataset) {
error = "Selected dataset doesn't exist";
} else if (!dataset.dataLayers) {
} else if (!dataset.dataSource.dataLayers) {
if (dataset.name) {
error = `Please, double check if you have the dataset '${dataset.name}' imported.`;
} else {
Expand All @@ -160,7 +160,7 @@ export class OxalisModel {
throw this.HANDLED_ERROR;
}

if (!tracing.restrictions.allowAccess) {
if (!annotation.restrictions.allowAccess) {
error = "You are not allowed to access this tracing";
throw this.HANDLED_ERROR;
}
Expand All @@ -174,12 +174,12 @@ export class OxalisModel {
}

ErrorHandling.assertExtendContext({
task: tracing.id,
task: annotation.id,
dataSet: dataset.name,
});

Store.dispatch(setDatasetAction(dataset));
Store.dispatch(setTaskAction(tracing.task));
Store.dispatch(setTaskAction(annotation.task));

// Only initialize the model once.
// There is no need to reinstantiate the binaries if the dataset didn't change.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class MergeModalView extends PureComponent {
<Form.Item label="NML">
<Upload
name="nmlFile"
action={jsRoutes.controllers.AnnotationIOController.upload().url}
action={"/admin/nml/upload"}
headers={{ authorization: "authorization-text" }}
onChange={this.handleChangeNML}
value={this.state.selectedNML}
Expand Down
1 change: 0 additions & 1 deletion app/views/pageSkeleton.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
data-airbrake-project-id=@play.api.Play.current.configuration.getString("airbrake.projectID")
data-airbrake-project-key=@play.api.Play.current.configuration.getString("airbrake.projectKey")
data-airbrake-environment-name=@play.api.Play.current.configuration.getString("airbrake.environment")></script>
<script type="text/javascript" src="@routes.Assets.at("javascripts/routes.js")?nocache=@(webknossos.BuildInfo.commitHash)"></script>
<script type="text/javascript" src="@routes.Assets.at("bundle/manifest.js")?nocache=@(webknossos.BuildInfo.commitHash)"></script>
<script type="text/javascript" src="@routes.Assets.at("bundle/vendor.js")?nocache=@(webknossos.BuildInfo.commitHash)"></script>
<script type="text/javascript" src="@routes.Assets.at("bundle/main.js")?nocache=@(webknossos.BuildInfo.commitHash)"></script>
Expand Down

0 comments on commit 5f52820

Please sign in to comment.