Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 064f9dd

Browse files
BoykoAlexjvalkeal
authored andcommitted
Steam Definitions graph read-only view
- Add flo to stream defs view - Simplify failing test on PhantomJS - Fixes #398
1 parent dd6f15c commit 064f9dd

File tree

9 files changed

+139
-16
lines changed

9 files changed

+139
-16
lines changed

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"ngx-pagination": "^3.0.1",
3838
"rxjs": "^5.4.2",
3939
"sockjs-client": "^1.1.4",
40-
"spring-flo": "git://github.com/spring-projects/spring-flo.git#b584fed1ed201f308bd9a4a6cb9e8f54c824e99d",
40+
"spring-flo": "git://github.com/spring-projects/spring-flo.git#e4782f11e3454ac9925b96f70c043f2dcf6bf42a",
4141
"stompjs": "^2.3.3",
4242
"tixif-ngx-busy": "0.0.5",
4343
"zone.js": "^0.8.14"

ui/src/app/streams/flo/flo.scss

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $btn-default-bg: #607580;
1010
$flo-shape-fill-color: #eeeeee;
1111
$spring-grey: $gray;
1212

13-
#flow-view {
13+
.stream-editor #flow-view {
1414
height:625px;
1515
font-family: inherit;
1616
}
@@ -168,7 +168,7 @@ $spring-grey: $gray;
168168
z-index: 2000;
169169
}
170170

171-
.stream-editor .canvas {
171+
.dataflow-main-container .canvas {
172172
border-color: $btn-default-border;
173173
}
174174

@@ -185,7 +185,7 @@ $spring-grey: $gray;
185185
background-color: $spring-light-grey;
186186
}
187187

188-
.stream-editor .palette-filter {
188+
.dataflow-main-container .palette-filter {
189189
border-color: $btn-default-border;
190190
}
191191

@@ -194,7 +194,7 @@ $spring-grey: $gray;
194194
stroke: $btn-default-border;
195195
}
196196

197-
.stream-editor #sidebar-resizer {
197+
.dataflow-main-container #sidebar-resizer {
198198
background-color: $btn-default-bg;
199199
}
200200

@@ -224,7 +224,7 @@ $spring-grey: $gray;
224224
}
225225

226226
.table .flow-view {
227-
height: 225px;
227+
height: 200px;
228228
}
229229

230230
.undeployed .canvas {
@@ -399,7 +399,21 @@ $spring-grey: $gray;
399399
fill: 'transparent';
400400
}
401401

402-
.stream-editor .zoom-canvas-input {
402+
table.zoom-canvas-control {
403+
tr {
404+
border: 0px;
405+
}
406+
tr:last-child {
407+
border: 0px;
408+
}
409+
td {
410+
border: 0px;
411+
padding: 0px;
412+
}
413+
}
414+
415+
416+
.dataflow-main-container .zoom-canvas-input {
403417
border: 0px;
404418
padding: 0px;
405419
font-size: 11px;

ui/src/app/streams/flo/render.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,16 @@ export class RenderService implements Flo.Renderer {
316316
const link = <dia.Link> cell;
317317
if (changedPropertyPath === 'props/isTapLink') {
318318
const isTapLink = link.attr('props/isTapLink');
319-
const linkView = paper.findViewByModel(link);
320-
console.log('Adjusting link class isTapLink? ' + isTapLink);
321-
// TODO: Check if need to switch bacl to _.each(...)
322-
if (isTapLink) {
319+
const linkView = paper ? paper.findViewByModel(link) : undefined;
320+
if (linkView) {
321+
// TODO: Check if need to switch bacl to _.each(...)
322+
if (isTapLink) {
323323
linkView.el.querySelectorAll('.connection, .marker-source, .marker-target')
324324
.forEach(connection => joint.V(connection).addClass('tapped-output-from-app'));
325-
} else {
325+
} else {
326326
linkView.el.querySelectorAll('.connection, .marker-source, .marker-target')
327327
.forEach(connection => joint.V(connection).removeClass('tapped-output-from-app'));
328+
}
328329
}
329330
}
330331
console.log('link being refreshed');

ui/src/app/streams/stream-definitions/stream-definitions.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
</td>
7777
</tr>
7878
<tr *ngIf="item.isExpanded">
79-
<td colspan="4">
80-
<div>This is in under development. We would love to hear feedback on the other available tabs/views.</div>
81-
<td>
79+
<td colspan="5">
80+
<app-stream-graph-view [dsl]="item.dslText"></app-stream-graph-view>
81+
</td>
8282
</tr>
8383
</ng-template>
8484
</tbody>

ui/src/app/streams/stream-definitions/stream-definitions.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {StreamDefinition} from '../model/stream-definition';
1919
import { RolesDirective } from '../../auth/directives/roles.directive';
2020
import { MockAuthService } from '../../tests/mocks/auth';
2121
import { AuthService } from '../../auth/auth.service';
22+
import { StreamGraphViewComponent } from '../stream-graph-view/stream-graph-view.component';
23+
import { FloModule } from 'spring-flo';
2224

2325
/**
2426
* Test {@link StreamDefinitionsComponent}.
@@ -40,6 +42,7 @@ describe('StreamDefinitionsComponent', () => {
4042
declarations: [
4143
KeyValuePipe,
4244
RolesDirective,
45+
StreamGraphViewComponent,
4346
StreamDefinitionsComponent,
4447
],
4548
imports: [
@@ -48,6 +51,7 @@ describe('StreamDefinitionsComponent', () => {
4851
ModalModule.forRoot(),
4952
PopoverModule.forRoot(),
5053
FormsModule,
54+
FloModule,
5155
ReactiveFormsModule,
5256
RouterTestingModule.withRoutes([])
5357
],
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div id="stream-graph-view-container">
2+
<flo-editor (floApi)="setEditorContext($event)" [metamodel]="metamodelService" [renderer]="renderService"
3+
[dsl]="dsl" [paperPadding]="5" >
4+
</flo-editor>
5+
</div>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2+
import { StreamGraphViewComponent } from '../stream-graph-view/stream-graph-view.component';
3+
import { FloModule } from 'spring-flo';
4+
import { MockMetamodelService } from '../flo/mocks/mock-metamodel.service';
5+
import { MetamodelService } from '../flo/metamodel.service';
6+
import { RenderService } from '../flo/render.service';
7+
8+
/**
9+
* Test {@link StreamGraphViewComponent}.
10+
*
11+
* @author Alex Boyko
12+
*/
13+
describe('StreamGraphViewComponent', () => {
14+
let component: StreamGraphViewComponent;
15+
let fixture: ComponentFixture<StreamGraphViewComponent>;
16+
const metamodelService = new MockMetamodelService();
17+
const renderService = new RenderService(metamodelService);
18+
19+
beforeEach(async(() => {
20+
TestBed.configureTestingModule({
21+
declarations: [
22+
StreamGraphViewComponent
23+
],
24+
imports: [
25+
FloModule
26+
],
27+
providers: [
28+
{ provide: MetamodelService, useValue: metamodelService },
29+
{ provide: RenderService, useValue: renderService }
30+
]
31+
})
32+
.compileComponents();
33+
}));
34+
35+
beforeEach(() => {
36+
fixture = TestBed.createComponent(StreamGraphViewComponent);
37+
component = fixture.componentInstance;
38+
});
39+
40+
it('should be created', () => {
41+
fixture.detectChanges();
42+
expect(component).toBeTruthy();
43+
expect(component.dsl).toBeUndefined();
44+
expect(component.flo).toBeDefined();
45+
});
46+
47+
it('check empty read-only view', () => {
48+
fixture.detectChanges();
49+
expect(component.flo.noPalette).toBeTruthy();
50+
expect(component.flo.readOnlyCanvas).toBeTruthy();
51+
expect(component.flo.getGraph().getCells().length).toEqual(0);
52+
});
53+
54+
it('check stream in the view', (done) => {
55+
component.dsl = 'http';
56+
fixture.detectChanges();
57+
let subscription = component.flo.textToGraphConversionSubject.subscribe(() => {
58+
subscription.unsubscribe();
59+
expect(component.flo.getGraph().getElements().length).toEqual(1);
60+
done();
61+
});
62+
});
63+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component, ViewEncapsulation, Input } from '@angular/core';
2+
import { Flo } from 'spring-flo';
3+
import { MetamodelService } from '../flo/metamodel.service';
4+
import { RenderService } from '../flo/render.service';
5+
6+
@Component({
7+
selector: 'app-stream-graph-view',
8+
templateUrl: './stream-graph-view.component.html',
9+
styleUrls: [ '../flo/flo.scss' ],
10+
encapsulation: ViewEncapsulation.None
11+
})
12+
export class StreamGraphViewComponent {
13+
14+
@Input()
15+
dsl: string;
16+
17+
private editorContext: Flo.EditorContext;
18+
19+
constructor(
20+
public metamodelService: MetamodelService,
21+
public renderService: RenderService
22+
) {}
23+
24+
setEditorContext(editorContext: Flo.EditorContext) {
25+
this.editorContext = editorContext;
26+
this.editorContext.noPalette = true;
27+
this.editorContext.readOnlyCanvas = true;
28+
}
29+
30+
get flo(): Flo.EditorContext {
31+
return this.editorContext;
32+
}
33+
34+
}

ui/src/app/streams/streams.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { TooltipModule } from 'ngx-bootstrap';
2323
import { NodeComponent } from './flo/node/node.component';
2424
import { DecorationComponent } from './flo/decoration/decoration.component';
2525
import { HandleComponent } from './flo/handle/handle.component';
26+
import { StreamGraphViewComponent } from './stream-graph-view/stream-graph-view.component';
2627

2728
@NgModule({
2829
imports: [
@@ -48,7 +49,8 @@ import { HandleComponent } from './flo/handle/handle.component';
4849
PropertiesDialogComponent,
4950
NodeComponent,
5051
DecorationComponent,
51-
HandleComponent
52+
HandleComponent,
53+
StreamGraphViewComponent
5254
],
5355
entryComponents: [
5456
StreamCreateDialogComponent,

0 commit comments

Comments
 (0)