Skip to content

Commit

Permalink
Copy javascript for editing pipelines back to pipeline app.
Browse files Browse the repository at this point in the history
Part of #751.
I moved it and copied it back, so the annotations would get carried into the container app. The pipeline app will get deleted soon.
  • Loading branch information
donkirkby committed Jan 26, 2019
1 parent 9344701 commit 8d021ef
Show file tree
Hide file tree
Showing 46 changed files with 11,410 additions and 34 deletions.
1 change: 0 additions & 1 deletion kive/container/container.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './tests/canvas.tests';
import './tests/dialog.tests';
import './tests/pipeline_families.tests';
import './tests/pipeline_functions.tests';
import './tests/pipeline_submit.tests';
import './tests/contextmenu.tests';
4 changes: 2 additions & 2 deletions kive/container/tests/canvas.tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CanvasWrapper, MethodNode, CdtNode, RawNode,
OutputNode, OutputZone, Magnet, Connector
} from "@canvas/drydock_objects";
import { CanvasState } from "@canvas/drydock";
} from "@container/canvas/drydock_objects";
import { CanvasState } from "@container/canvas/drydock";
import * as imagediff from 'imagediff';

"use strict";
Expand Down
6 changes: 3 additions & 3 deletions kive/container/tests/contextmenu.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CanvasState } from "@canvas/drydock";
import { CanvasContextMenu } from "@canvas/drydock_contextmenu";
import { RawNode } from "@canvas/drydock_objects";
import { CanvasState } from "@container/canvas/drydock";
import { CanvasContextMenu } from "@container/canvas/drydock_contextmenu";
import { RawNode } from "@container/canvas/drydock_objects";
import * as imagediff from 'imagediff';

describe("Drydock context menu", function() {
Expand Down
40 changes: 21 additions & 19 deletions kive/container/tests/dialog.tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MethodDialog, Dialog, InputDialog, OutputDialog } from "@pipeline/pipeline_dialogs";
import { MethodNode, CdtNode, OutputNode } from "@canvas/drydock_objects";
import { REDRAW_INTERVAL, CanvasState } from "@canvas/drydock";
import { MethodDialog, Dialog, InputDialog, OutputDialog } from "@container/pipeline_dialogs";
import {MethodNode, CdtNode, OutputNode} from "@container/canvas/drydock_objects";
import { REDRAW_INTERVAL, CanvasState } from "@container/canvas/drydock";
import * as imagediff from 'imagediff';
import {RawNode} from "@container/canvas/drydock_objects";

jasmine.getFixtures().fixturesPath = '/templates/pipeline';
jasmine.getStyleFixtures().fixturesPath = '/static/pipeline';
Expand Down Expand Up @@ -752,6 +753,7 @@ describe("InputDialog fixture", function() {
let expected_canvas;
let expected_ctx;
let expected_input;
let expected_raw_input;

beforeAll(function() {
jasmine.addMatchers(imagediff.jasmine);
Expand All @@ -773,6 +775,7 @@ describe("InputDialog fixture", function() {
expected_canvas = imagediff.createCanvas(canvas.width, canvas.height);
expected_ctx = expected_canvas.getContext('2d');
expected_input = new CdtNode(99, 125, 30, '');
expected_raw_input = new RawNode(125, 30, '');
});

it('should initialize properly', function() {
Expand All @@ -798,28 +801,24 @@ describe("InputDialog fixture", function() {
expect(dlg_pos.top).toBeCloseTo(92, 1);
});

it('should show a CDTNode preview when a CDT is selected', function(done) {
it('should show a CDTNode preview when a CDT is selected', function() {
expected_input.draw(expected_ctx);

dlg.activator.click();
$select_cdt.append($('<option>').val(23));
$select_cdt.val(23).change();

(expect(canvas) as any).toImageDiffEqual(expected_canvas);
done();
});

it('should show a RawNode preview when no CDT is selected', function(done) {
it('should show a RawNode preview when no CDT is selected', function() {
expected_raw_input.draw(expected_ctx);

dlg.activator.click();
$select_cdt.append($('<option>').val('foo'));
$select_cdt.val('foo').change();

let raw_node = new Image();
raw_node.src = "/test_assets/pipeline/rawnode.png";
raw_node.onload = function() {
(expect(canvas) as any).toImageDiffEqual(raw_node);
done();
};
(expect(canvas) as any).toImageDiffEqual(expected_canvas);
});

it('should not submit when required fields are empty', function() {
Expand Down Expand Up @@ -872,6 +871,8 @@ describe("OutputDialog fixture", function() {
let $output_name;
let $error;
let canvas;
let expected_canvas;
let expected_ctx;

beforeAll(function() {
jasmine.addMatchers(imagediff.jasmine);
Expand All @@ -889,6 +890,8 @@ describe("OutputDialog fixture", function() {
$output_name = $('#id_output_name');
$error = $('#id_output_error');
canvas = <HTMLCanvasElement> $('canvas')[0];
expected_canvas = imagediff.createCanvas(canvas.width, canvas.height);
expected_ctx = expected_canvas.getContext('2d');
});

it('should initialize properly', function() {
Expand All @@ -914,14 +917,13 @@ describe("OutputDialog fixture", function() {
expect(dlg_pos.top).toBeCloseTo(92, 1);
});

it('should show an OutputNode preview', function(done) {
it('should show an OutputNode preview', function() {
let expectedNode = new OutputNode(125, 30, '');
expectedNode.draw(expected_ctx);

dlg.activator.click();
let outputnode = new Image();
outputnode.src = "/test_assets/pipeline/outputnode.png";
outputnode.onload = function() {
(expect(canvas) as any).toImageDiffEqual(outputnode);
done();
};

(expect(canvas) as any).toImageDiffEqual(expected_canvas);
});

it('should not submit when required fields are empty', function() {
Expand Down
8 changes: 4 additions & 4 deletions kive/container/tests/pipeline_functions.tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CanvasWrapper } from "@canvas/drydock_objects";
import { CanvasState } from "@canvas/drydock";
import { Pipeline } from "@pipeline/io/pipeline_load";
import { serializePipeline } from "@pipeline/io/serializer";
import { CanvasWrapper } from "@container/canvas/drydock_objects";
import { CanvasState } from "@container/canvas/drydock";
import { Pipeline } from "@container/io/pipeline_load";
import { serializePipeline } from "@container/io/serializer";
import * as imagediff from 'imagediff';

describe("Pipeline functions", function() {
Expand Down
6 changes: 3 additions & 3 deletions kive/container/tests/pipeline_submit.tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CanvasState } from "@canvas/drydock";
import { buildPipelineSubmit } from "@pipeline/io/pipeline_submit";
import { RawNode, MethodNode, OutputNode, Connector } from "@canvas/drydock_objects";
import { CanvasState } from "@container/canvas/drydock";
import { buildPipelineSubmit } from "@container/io/pipeline_submit";
import { RawNode, MethodNode, OutputNode, Connector } from "@container/canvas/drydock_objects";
import * as imagediff from 'imagediff';

(window as any).$ = (window as any).jQuery = $;
Expand Down
6 changes: 6 additions & 0 deletions kive/pipeline/pipeline.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './tests/canvas.tests';
import './tests/dialog.tests';
import './tests/pipeline_families.tests';
import './tests/pipeline_functions.tests';
import './tests/pipeline_submit.tests';
import './tests/contextmenu.tests';
22 changes: 22 additions & 0 deletions kive/pipeline/static/pipeline/canvas/ShapeTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export interface Point {
x: number;
y: number;
}
export interface Circle extends Point {
r: number;
}
export interface Ellipse extends Point {
rx: number;
ry: number;
}
export interface Rectangle extends Point {
height: number;
width: number;
r?: number;
stroke?: boolean;
}
export interface TextParams extends Point {
dir: number;
style: string;
text: string;
}
Loading

0 comments on commit 8d021ef

Please sign in to comment.