Skip to content

Commit

Permalink
Release/0.2.1-5 (#109)
Browse files Browse the repository at this point in the history
* Panel update style

* Polygon bugs

* Bump

* Undo & redo & reset on Image

* Bump to new MST vers

* #102

* Fix bug with zoom

* Fix bug with incorrect start / end

* Time and image

* Polygon bugs

* Time traveller prepare new logic

* Build 0.2.1-5

* Fix multi labeling
  • Loading branch information
shevchenkonik authored Oct 29, 2019
1 parent 8740635 commit 2d52988
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 407 deletions.
10 changes: 5 additions & 5 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"main.css": "/static/css/main.ca4d6399.css",
"main.js": "/static/js/main.b5ddacd9.js",
"main.js.map": "/static/js/main.b5ddacd9.js.map",
"main.css": "/static/css/main.ae336099.css",
"main.js": "/static/js/main.10833e21.js",
"main.js.map": "/static/js/main.10833e21.js.map",
"static/media/config.xml": "/static/media/config.1890026d.xml",
"static/css/main.ca4d6399.css.map": "/static/css/main.ca4d6399.css.map",
"static/css/main.ae336099.css.map": "/static/css/main.ae336099.css.map",
"index.html": "/index.html",
"precache-manifest.bbf29cc0590c9f5ed8edf29c73dce7a4.js": "/precache-manifest.bbf29cc0590c9f5ed8edf29c73dce7a4.js",
"precache-manifest.a131d1729d95bfbae20b0e22e7cffac6.js": "/precache-manifest.a131d1729d95bfbae20b0e22e7cffac6.js",
"service-worker.js": "/service-worker.js"
}
4 changes: 2 additions & 2 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Roboto Mono" rel="stylesheet"/><link href="//fonts.googleapis.com/css?family=Dosis:500&text=LabelStudio" rel="stylesheet"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="stylesheet" href="/styles/main.css"><title>Label Studio</title><link href="/static/css/main.ca4d6399.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="header"><a id="logo" href="/"><img src="./images/ls_logo.png" alt="label studio logo"> <span style="font-size:1.2em">Label Studio</span></a><ul id="nav" style="display:flex;align-items:center"><a style="margin-right:1em;text-decoration:underline" href="https://labelstud.io/guide">Guide</a> <a class="github-button" href="https://github.com/heartexlabs/label-studio" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star heartexlabs/label-studio on GitHub"><img src="./images/GitHub-Mark-64px.png" height="25"/></a></ul></div><div id="label-studio"></div><footer class="footer">Made by <a target="_blank" href="https://heartex.net">Heartex</a> in San Francisco<br/><br/><img src="./images/3nowhite.svg" height="80"/></footer><script>setTimeout(() => {
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Roboto Mono" rel="stylesheet"/><link href="//fonts.googleapis.com/css?family=Dosis:500&text=LabelStudio" rel="stylesheet"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="stylesheet" href="/styles/main.css"><title>Label Studio</title><link href="/static/css/main.ae336099.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="header"><a id="logo" href="/"><img src="./images/ls_logo.png" alt="label studio logo"> <span style="font-size:1.2em">Label Studio</span></a><ul id="nav" style="display:flex;align-items:center"><a style="margin-right:1em;text-decoration:underline" href="https://labelstud.io/guide">Guide</a> <a class="github-button" href="https://github.com/heartexlabs/label-studio" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star heartexlabs/label-studio on GitHub"><img src="./images/GitHub-Mark-64px.png" height="25"/></a></ul></div><div id="label-studio"></div><footer class="footer">Made by <a target="_blank" href="https://heartex.net">Heartex</a> in San Francisco<br/><br/><img src="./images/3nowhite.svg" height="80"/></footer><script>setTimeout(() => {
var ls = new LabelStudio("label-studio", {
config: `
<View>
Expand Down Expand Up @@ -37,4 +37,4 @@
}
}
});
}, 2000);</script><script src="/static/js/main.b5ddacd9.js"></script></body></html>
}, 2000);</script><script src="/static/js/main.10833e21.js"></script></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ self.__precacheManifest = [
"url": "/static/media/config.be40f192.xml"
},
{
"revision": "b5ddacd94d11a4c88ddb",
"url": "/static/css/main.ca4d6399.css"
"revision": "10833e215ea38553448e",
"url": "/static/css/main.ae336099.css"
},
{
"revision": "5bb63d8f59b769afa2951085535974c9",
Expand All @@ -28,8 +28,8 @@ self.__precacheManifest = [
"url": "/static/media/config.2a6054fe.xml"
},
{
"revision": "b5ddacd94d11a4c88ddb",
"url": "/static/js/main.b5ddacd9.js"
"revision": "10833e215ea38553448e",
"url": "/static/js/main.10833e21.js"
},
{
"revision": "f4626f44ab6f63bfc683408a117236b7",
Expand All @@ -52,7 +52,7 @@ self.__precacheManifest = [
"url": "/static/media/config.1890026d.xml"
},
{
"revision": "1de38c3f2c31b4441d36af033bd835a9",
"revision": "1bce8d3350dfa9a19e0e41bb2f10be22",
"url": "/index.html"
}
];
2 changes: 1 addition & 1 deletion build/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");

importScripts(
"/precache-manifest.bbf29cc0590c9f5ed8edf29c73dce7a4.js"
"/precache-manifest.a131d1729d95bfbae20b0e22e7cffac6.js"
);

workbox.clientsClaim();
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/css/main.ae336099.css.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/static/css/main.ca4d6399.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.10833e21.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/static/js/main.b5ddacd9.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "label-studio",
"version": "0.2.1-4",
"version": "0.2.1-5",
"description": "Label Studio is a multi-domain data labeling tool with standardized output format",
"homepage": "https://labelstud.io",
"author": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"konva": "^4.0.13",
"mobx": "^5.8.0",
"mobx-react": "^5.4.3",
"mobx-state-tree": "^3.10.0",
"mobx-state-tree": "^3.14.1",
"nanoid": "^2.0.3",
"node-sass": "^4.12.0",
"react": "^16.10.2",
Expand Down
1 change: 1 addition & 0 deletions src/components/App/App.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

.menu {
width: 320px;
min-width: 320px;
display: flex;
flex-flow: column;

Expand Down
30 changes: 25 additions & 5 deletions src/components/ImageView/ImageView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from "react";
import { observer } from "mobx-react";
import { getParent } from "mobx-state-tree";
import { Stage, Layer, Rect, Group, Line } from "react-konva";

import Tree from "../../core/Tree";
Expand Down Expand Up @@ -42,6 +43,7 @@ export default observer(
*/
handleMouseUp = e => {
const { item } = this.props;
// getParent(item, 4)[0].history.freeze();

if (item.mode === "drawing") {
/**
Expand All @@ -51,14 +53,13 @@ export default observer(

const as = item.detachActiveShape();

console.log(as);

if (as.width > 3 && as.height > 3) item.addShape(as);
}
};

handleMouseMove = e => {
const { item } = this.props;
getParent(item, 4)[0].history.freeze();
if (item.mode === "drawing") {
const x = (e.evt.offsetX - item.zoomPosX) / item.zoomScale;
const y = (e.evt.offsetY - item.zoomPosY) / item.zoomScale;
Expand All @@ -73,6 +74,7 @@ export default observer(

handleStageMouseDown = e => {
const { item } = this.props;
getParent(item, 4)[0].history.freeze();

if (item.controlButtonType === "PolygonLabelsModel") {
return;
Expand Down Expand Up @@ -111,8 +113,26 @@ export default observer(
* Handle to zoom
*/
handleZoom = e => {
/**
* Disable if user doesn't use ctrl
*/
if (e.evt && !e.evt.ctrlKey) {
return;
} else if (e.evt && e.evt.ctrlKey) {
/**
* Disable scrolling page
*/
e.evt.preventDefault();
}

const { item } = this.props;

/**
* Freeze Time Traveller
* TODO: currently work with [0] completion
*/
getParent(item, 4)[0].history.freeze();

const stage = item.stageRef;
const scaleBy = parseFloat(item.zoomby);
const oldScale = stage.scaleX();
Expand Down Expand Up @@ -294,12 +314,12 @@ export default observer(
onMouseDown={this.handleStageMouseDown}
onMouseMove={this.handleMouseMove}
onMouseUp={this.handleMouseUp}
onWheel={item.zoom === true ? this.handleZoom : () => {}}
onWheel={item.zoom ? this.handleZoom : () => {}}
>
{item.grid && item.sizeUpdated && this.renderGrid()}
<Layer>
{item.shapes.map(s => {
return Tree.renderItem(s);
{item.shapes.map(shape => {
return Tree.renderItem(shape);
})}
{item.activeShape && Tree.renderItem(item.activeShape)}

Expand Down
48 changes: 26 additions & 22 deletions src/core/TimeTraveller.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { types, resolvePath, getEnv, onSnapshot, getSnapshot, applySnapshot } from "mobx-state-tree";

/**
* Time Traveller
*/
const TimeTraveller = types
.model("TimeTraveller", {
history: types.array(types.frozen()),
undoIdx: -1,
targetPath: "",
skipNextUndoState: types.optional(types.boolean, false),

createdIdx: 1,

Expand All @@ -24,25 +28,27 @@ const TimeTraveller = types
.actions(self => {
let targetStore;
let snapshotDisposer;
let skipNextUndoState = false;

return {
freeze() {
self.isFrozen = true;
skipNextUndoState = true;
self.skipNextUndoState = true;
self.frozenIdx = self.undoIdx;
},

addUndoState(ss) {
if (skipNextUndoState) {
// skip recording if this state was caused by undo / redo
skipNextUndoState = false;
addUndoState(recorder) {
if (self.skipNextUndoState) {
/**
* Skip recording if this state was caused by undo / redo
*/
self.skipNextUndoState = false;

return;
}

self.history.splice(self.undoIdx + 1);
self.history.push(ss);
self.undoIdx = self.history.length - 1;
self.history.splice(self.undoIdx);
self.history.push(recorder);
self.undoIdx = self.history.length;
},

afterCreate() {
Expand All @@ -58,7 +64,7 @@ const TimeTraveller = types
snapshotDisposer = onSnapshot(targetStore, snapshot => this.addUndoState(snapshot));
// record an initial state if no known
if (self.history.length === 0) {
this.addUndoState(getSnapshot(targetStore));
self.addUndoState(getSnapshot(targetStore));
}

self.createdIdx = self.undoIdx;
Expand All @@ -69,29 +75,27 @@ const TimeTraveller = types
},

undo() {
if (self.isFrozen && self.frozenIdx <= self.undoIdx) return;
if (self.isFrozen && self.frozenIdx < self.undoIdx) return;

let newIdx = self.undoIdx - 1;

self.undoIdx--;
skipNextUndoState = true;
applySnapshot(targetStore, self.history[self.undoIdx]);
self.set(newIdx);
},

redo() {
self.undoIdx++;
skipNextUndoState = true;
applySnapshot(targetStore, self.history[self.undoIdx]);
let newIdx = self.undoIdx + 1;

self.set(newIdx);
},

set(idx) {
self.undoIdx = idx;
skipNextUndoState = true;
applySnapshot(targetStore, self.history[self.undoIdx]);
self.skipNextUndoState = true;
applySnapshot(targetStore, self.history[idx]);
},

reset() {
self.undoIdx = 1;
skipNextUndoState = true;
applySnapshot(targetStore, self.history[self.undoIdx]);
self.set(self.createdIdx);
},
};
});
Expand Down
43 changes: 36 additions & 7 deletions src/interfaces/control/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,44 @@ const Model = types

labels.finishCurrentObject();

labels.shouldBeUnselected && labels.unselectAll();
/**
* Multiple
*/
if (!labels.shouldBeUnselected) {
self.markSelected(!self.selected);
}

if (labels.shouldBeUnselected && !selectedLabel) {
self.selected = !self.selected;
/**
* Single
*/
if (labels.shouldBeUnselected) {
/**
* Current not selected
*/
if (!selectedLabel) {
/**
* Unselect all labels
*/
labels.unselectAll();
/**
* Select current label
*/
self.markSelected(!self.selected);
} else {
/**
* Unselect all labels
*/
labels.unselectAll();
}
}
},

markSelected(val) {
self.selected = val;
/**
*
* @param {boolean} value
*/
markSelected(value) {
self.selected = value;
},

onHotKey() {
Expand All @@ -90,7 +119,7 @@ const LabelModel = types.compose(

const HtxLabelView = inject("store")(
observer(({ item, store }) => {
const bg = {
const labelStyle = {
backgroundColor: item.selected ? item.background : "#e8e8e8",
color: item.selected ? item.selectedcolor : "#333333",
cursor: "pointer",
Expand All @@ -103,7 +132,7 @@ const HtxLabelView = inject("store")(
item.toggleSelected();
return false;
}}
style={bg}
style={labelStyle}
size={item.size}
>
{item._value}
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/mixins/Regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const RegionsMixin = types

unselectRegion() {
const completion = self.completion;

if (completion.relationMode) {
completion.stopRelationMode();
}
Expand All @@ -38,11 +39,18 @@ const RegionsMixin = types
}
},

/**
* Remove region
*/
deleteRegion() {
self.unselectRegion();

self.completion.relationStore.deleteNodeRelation(self);

if (self.type === "polygonregion") {
self.destroyRegion();
}

self.completion.regionStore.deleteRegion(self);

self.completion.deleteRegion(self);
Expand Down
Loading

0 comments on commit 2d52988

Please sign in to comment.