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

Add UI to restore previous versions of a tracing #3194

Merged
merged 21 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5091391
first working version of tracing version restore
daniel-wer Sep 6, 2018
95f38ec
added types and categorized some update action batches to show better…
daniel-wer Sep 6, 2018
2bc2dcd
Merge branch 'master' of github.com:scalableminds/webknossos into res…
daniel-wer Sep 10, 2018
f0277ed
Merge branch 'master' of github.com:scalableminds/webknossos into res…
daniel-wer Sep 11, 2018
bc317a4
improve batch description, save before opening version restore view
daniel-wer Sep 11, 2018
f8a54f1
rework flow types for ServerUpdateActions
philippotto Sep 11, 2018
a5fbd4f
fix missing null checks
philippotto Sep 11, 2018
4505729
only scroll version list in version history view
philippotto Sep 11, 2018
c440da3
remove obsolete import
philippotto Sep 11, 2018
2bb3f0c
Merge branch 'master' of github.com:scalableminds/webknossos into res…
daniel-wer Sep 12, 2018
cbd75dc
PR feedback #1, show info alert instead of tracing actions
daniel-wer Sep 12, 2018
b5179a9
in updateActionLog, annotate batches with version number (#3203)
fm3 Sep 12, 2018
5536431
PR feedback #2, scroll into view, descriptions for other update actions
daniel-wer Sep 12, 2018
e64b3b7
Merge branch 'master' of github.com:scalableminds/webknossos into res…
daniel-wer Sep 12, 2018
f39f289
adapt changelog and docs
daniel-wer Sep 12, 2018
58e57b1
[docs] point to 'restore older version' from redo/undo, fix typo
daniel-wer Sep 12, 2018
5a064e8
Merge branch 'master' of github.com:scalableminds/webknossos into res…
daniel-wer Sep 17, 2018
3e9c150
make version restore view's position fixed, style fixes, allow showVe…
daniel-wer Sep 17, 2018
4f67ffa
Merge branch 'master' into restore-old-versions
daniel-wer Sep 17, 2018
d2aad3f
Merge branch 'master' into restore-old-versions
daniel-wer Sep 17, 2018
c7187c1
Merge branch 'master' into restore-old-versions
daniel-wer Sep 17, 2018
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
23 changes: 20 additions & 3 deletions app/assets/javascripts/admin/admin_rest_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,11 @@ export function createExplorational(

export async function getTracingForAnnotations(
annotation: APIAnnotationType,
version?: number,
): Promise<HybridServerTracingType> {
const [_skeleton, _volume] = await Promise.all([
getTracingForAnnotationType(annotation, "skeleton"),
getTracingForAnnotationType(annotation, "volume"),
getTracingForAnnotationType(annotation, "skeleton", version),
getTracingForAnnotationType(annotation, "volume", version),
]);

const skeleton = ((_skeleton: any): ?ServerSkeletonTracingType);
Expand All @@ -547,14 +548,18 @@ export async function getTracingForAnnotations(
export async function getTracingForAnnotationType(
annotation: APIAnnotationType,
tracingType: "skeleton" | "volume",
version?: number,
): Promise<?ServerTracingType> {
const tracingId = annotation.tracing[tracingType];
if (!tracingId) {
return null;
}
const possibleVersionString = version != null ? `&version=${version}` : "";
const tracingArrayBuffer = await doWithToken(token =>
Request.receiveArraybuffer(
`${annotation.dataStore.url}/data/tracings/${tracingType}/${tracingId}?token=${token}`,
`${
annotation.dataStore.url
}/data/tracings/${tracingType}/${tracingId}?token=${token}${possibleVersionString}`,
{ headers: { Accept: "application/x-protobuf" } },
),
);
Expand All @@ -565,6 +570,18 @@ export async function getTracingForAnnotationType(
return tracing;
}

export function getUpdateActionLog(
dataStoreUrl: string,
tracingId: string,
tracingType: "skeleton" | "volume",
): Promise<*> {
return doWithToken(token =>
Request.receiveJSON(
`${dataStoreUrl}/data/tracings/${tracingType}/${tracingId}/updateActionLog?token=${token}`,
),
);
}

// ### Datasets
export async function getDatasets(): Promise<Array<APIMaybeUnimportedDatasetType>> {
const datasets = await Request.receiveJSON("/api/datasets");
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ In order to restore the current window, a reload is necessary.`,
"save.leave_page_unfinished":
"WARNING: You have unsaved progress that may be lost when hitting OK. Please click cancel, wait until the progress is saved and the save button displays a checkmark before leaving the page..",
"save.failed": "Failed to save tracing. Retrying.",
"undo.no_undo": "There is no action that could be undone.",
"undo.no_undo":
"There is no action that could be undone. However, if you want to restore an earlier version of this tracing, use the 'Restore Older Version' functionality in the dropdown next to the 'Save' button.",
"undo.no_redo": "There is no action that could be redone.",
"download.wait": "Please wait...",
"download.close_window": "You may close this window after the download has started.",
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/oxalis/api/api_latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,11 @@ class TracingApi {
newTracingType: TracingTypeTracingType,
newAnnotationId: string,
newControlMode: ControlModeType,
version?: number,
) {
Store.dispatch(restartSagaAction());
UrlManager.reset();
await Model.fetch(newTracingType, newAnnotationId, newControlMode, false);
await Model.fetch(newTracingType, newAnnotationId, newControlMode, false, version);
Store.dispatch(discardSaveQueuesAction());
Store.dispatch(wkReadyAction());
UrlManager.updateUnthrottled();
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/oxalis/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ export class OxalisModel {
annotationIdOrDatasetName: string,
controlMode: ControlModeType,
initialFetch: boolean,
version?: number,
) {
const initializationInformation = await initialize(
tracingType,
annotationIdOrDatasetName,
controlMode,
initialFetch,
version,
);
if (initializationInformation) {
// Only executed on initial fetch
Expand Down
13 changes: 13 additions & 0 deletions app/assets/javascripts/oxalis/model/actions/annotation_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type SetAnnotationDescriptionActionType = {
description: string,
};

type SetAnnotationAllowUpdateActionType = {
type: "SET_ANNOTATION_ALLOW_UPDATE",
allowUpdate: boolean,
};

type SetUserBoundingBoxType = {
type: "SET_USER_BOUNDING_BOX",
userBoundingBox: ?BoundingBoxType,
Expand All @@ -32,6 +37,7 @@ export type AnnotationActionTypes =
| SetAnnotationNameActionType
| SetAnnotationPubliceActionType
| SetAnnotationDescriptionActionType
| SetAnnotationAllowUpdateActionType
| SetUserBoundingBoxType;

export const initializeAnnotationAction = (
Expand All @@ -58,6 +64,13 @@ export const setAnnotationDescriptionAction = (
description,
});

export const setAnnotationAllowUpdateAction = (
allowUpdate: boolean,
): SetAnnotationAllowUpdateActionType => ({
type: "SET_ANNOTATION_ALLOW_UPDATE",
allowUpdate,
});

// Strictly speaking this is no annotation action but a tracing action, as the boundingBox is saved with
// the tracing, hence no ANNOTATION in the action type.
export const setUserBoundingBoxAction = (
Expand Down
12 changes: 11 additions & 1 deletion app/assets/javascripts/oxalis/model/actions/ui_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ type SetDropzoneModalVisibilityActionType = {
visible: boolean,
};

export type UiActionType = SetDropzoneModalVisibilityActionType;
type SetVersionRestoreModeActionType = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Mode? Isn't it only visible/invisible? I'd use visibility then, since mode sounds like there would be different "restore modes".

type: "SET_VERSION_RESTORE_MODE_ACTION_TYPE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see that I used the "_TYPE" suffix in the action constant for SET_DROPZONE_MODAL_VISIBILITY_ACTION_TYPE. However, we usually don't use this suffix in action strings. Can you remove that suffix for both actions? :)

active: boolean,
};

export type UiActionType = SetDropzoneModalVisibilityActionType | SetVersionRestoreModeActionType;

export const setDropzoneModalVisibilityAction = (
visible: boolean,
): SetDropzoneModalVisibilityActionType => ({
type: "SET_DROPZONE_MODAL_VISIBILITY_ACTION_TYPE",
visible,
});

export const setVersionRestoreModeAction = (active: boolean): SetVersionRestoreModeActionType => ({
type: "SET_VERSION_RESTORE_MODE_ACTION_TYPE",
active,
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import update from "immutability-helper";
import { updateKey, type StateShape1 } from "oxalis/model/helpers/deep_update";
import { updateKey, updateKey2, type StateShape1 } from "oxalis/model/helpers/deep_update";
import type { OxalisState } from "oxalis/store";
import type { ActionType } from "oxalis/model/actions/actions";
import { convertServerAnnotationToFrontendAnnotation } from "oxalis/model/reducers/reducer_helpers";
Expand Down Expand Up @@ -36,6 +36,11 @@ function AnnotationReducer(state: OxalisState, action: ActionType): OxalisState
});
}

case "SET_ANNOTATION_ALLOW_UPDATE": {
const { allowUpdate } = action;
return updateKey2(state, "tracing", "restrictions", { allowUpdate });
}

case "SET_USER_BOUNDING_BOX": {
const updaterObject = {
userBoundingBox: {
Expand Down
8 changes: 8 additions & 0 deletions app/assets/javascripts/oxalis/model/reducers/ui_reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ function UiReducer(state: OxalisState, action: ActionType): OxalisState {
});
}

case "SET_VERSION_RESTORE_MODE_ACTION_TYPE": {
return update(state, {
uiInformation: {
isVersionRestoreActive: { $set: action.active },
},
});
}

default:
return state;
}
Expand Down
Loading