Repository navigation
[#603][3] Integrate JointJS to the new GUI - #606
Conversation
…ator-view-element.service.ts is applied to the operators, add new comments to the services
…w test to test whether the number of inPort and outPort created matches the metadata
| * for the delte button. | ||
| */ | ||
| public readonly deleteButtonSVG = | ||
| `<svg class="delete-button" fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"> |
There was a problem hiding this comment.
F2F: What do these and above numbers mean? I mean how to interpret them?
There was a problem hiding this comment.
viewBox and xmlns is unnecessary (will be deleted). viewBox is basically "min-width, min-height, width, height", which is redundant with height and width attribute. Fill specifies the color of delete button, which doesn't do anything here
Only Height and Width are required for this svg. Height and width basically specify the dimension of the delete button on operators.
| operatorType: string, operatorID: string, xPosition: number, yPosition: number | ||
| ): joint.dia.Element { | ||
|
|
||
| const operatorSchema = this.operators.find(op => op.operatorType === operatorType); |
There was a problem hiding this comment.
how do we know that the call in contructor has completed and this.operators is not empty.
There was a problem hiding this comment.
Currently, we uses a timeout in workflow-editor.component.ts
which is about the time where the service constructor is completed. This code will be
deleted later when drag and drop is implemented. Currently we need the time out because
there are 2 operators created as soon as ngAfterViewInit is called.
There was a problem hiding this comment.
ok. so am I correct in saying that we assume that when drag and drop is used, the user will take some time to do that, and till then the operatorMetadataService.getOperatorMetadata() will finish and bring in the metadata? And if it hasn't finished and the user does something, the action will throw an error.
I realize that might not happen because if the service doesn't succeed in bringing the metadata, there will be nothing for the user to drag and drop. Is that correct?
There was a problem hiding this comment.
However, still we might have a to-do item which we can take up later, to do something like blurring out the screen and showing a loading sign till some initialization is taking place. At that time, we don't allow users to do anything
There was a problem hiding this comment.
@avinash0161 we don't need that (at least for now). The operator panel won't show operators initially because the data hasn't arrived yet. And as you said, users have nothing to drag at this point of time.
But yeah, it is nice to have a initial loading animation if the loading takes long time. I think for what we are doing now, the loading animation might just flash because the data arrives very fast.
| type: 'devs.TexeraModel', | ||
| markup: | ||
| `<g class="element-node"> | ||
| <rect class="body" stroke-width="2" stroke="blue" rx="5px" ry="5px"></rect> |
There was a problem hiding this comment.
Is this just to add a custom delete button to the operator's jointjs model and other properties of the model are being set in getJointjsOperatorElement()? If so, please mention that in the comment
There was a problem hiding this comment.
Yes, setupCustomJointjsModel() basically creates an empty rectangle with delete button on the top-right hand corner. Other properties such as styles and texts are set in the getJointJsOperatorElement(). I will modify the comments ASAP.
…calls more specifically explained
| styleUrls: ['./workflow-editor.component.scss'] | ||
| }) | ||
| export class WorkflowEditorComponent implements OnInit { | ||
| export class WorkflowEditorComponent implements AfterViewInit { |
There was a problem hiding this comment.
Why does this implement AfterViewInit instead of OnInit()
There was a problem hiding this comment.
We implement AfterViewInit instead of OnInit because we want to override the AfterViewInit method here. We use ngAfterViewInit in this component because we want to display JointJS element on the UI after the component view is fully initialized.
There was a problem hiding this comment.
In Angular's component lifecycle, afterViewInit() is called after onInit().
onInit is called after the data of the class are initialized, for example, if this component class needs any inputs from its parent component.
afterViewInit, as its name suggests, is called after the view (the DOM elements) are initialized. We bind JointJS paper to an DOM element, and we need to wait after the view is initialized.
| workflow-editor works! | ||
| </p> | ||
| <div class="texera-workspace-workflow-editor-body texera-workflow-component-body" [attr.id]="WORKFLOW_EDITOR_JOINTJS_WRAPPER_ID"> | ||
| <div class ="texera-workspace-workflow-jointjs" [attr.id]="WORKFLOW_EDITOR_JOINTJS_ID"> |
There was a problem hiding this comment.
Can you please remind me how is the attr.id input used? Is this just a normal id being allotted to the tag?
There was a problem hiding this comment.
[attr.id] is basically the same thing with doing the same thing as:
<div #id="WORKFLOW_EDITOR_JOINTJS_WRAPPER_ID"></div>
we uses attr.id because we want to use the variable defined in the workflow-editor.component.ts. Since resizing will also need the ID of the paper, we decided that it is better to defined the ID in the TS file to improve the structure of the code base.
| // add some dummy operators and links to show that JointJS works | ||
| this.graph.addCell( | ||
| this.jointUIService.getJointjsOperatorElement( | ||
| 'ScanSource', |
There was a problem hiding this comment.
Why are these operators being added? Is it just for this PR?
There was a problem hiding this comment.
This is just for this PR and will be deleted in the future. These operators show that the custom element defined is successfully registered and being utilized by JointJS
| */ | ||
| private getWrapperElementSize(): {width: number, height: number} { | ||
| return { | ||
| width: $('#' + this.WORKFLOW_EDITOR_JOINTJS_WRAPPER_ID).width(), |
There was a problem hiding this comment.
I suppose this will give the size of div. But isn't the size of div 0 if there isn't anything inside it? If yes, then how are we using it in createJoinJSPaper to set the size?
There was a problem hiding this comment.
since the wrapper has the style texera-workflow-component-body, which is defined in `workspace.component.scss', the size of the div will be the entire area of the workflow-editor at the center of the browser.
Since all the sub components wrapper use the class texera-workflow-component-body. We defined it in `workspace.component.scss' to avoid redundancy.
|
|
||
| import { OperatorMetadataService } from '../service/operator-metadata/operator-metadata.service'; | ||
| import { JointUIService } from '../service/joint-ui/joint-ui.service'; | ||
| import { StubOperatorMetadataService } from '../service/operator-metadata/stub-operator-metadata.service'; |
There was a problem hiding this comment.
Wasn't this imported in the previous PR? because I remember seeing stuboperatormetadatservice being used
There was a problem hiding this comment.
stuboperatormetadatservice is used another file. This is imported here because in line 15 of this file, we added a line to use it to conveniently test things.
There was a problem hiding this comment.
JointUIService needs to be important to the parent (in this case, workspace.component.ts file) for workflow-editor.component.ts to use.
As for the StubOperatorMetadataService, it is only used when we try to test the new-gui without opening the java backend server. Instead of fetching backend metadata, we would use the mock metadata defined in service/operator-metadata/mock-operator-metadata.data.ts
| expect(outPortCount3).toEqual(0); | ||
|
|
||
| }); | ||
|
|
There was a problem hiding this comment.
Should there also be a test to test that linking of two elements works?
There was a problem hiding this comment.
Since JointJS are managing all the links, there's no point of testing the correctness of JointJS. We trust the library is implemented correctly.
avinash0161
left a comment
There was a problem hiding this comment.
Added a few more comments. Please take a look. Other than that, we are fine.
This PR integrates JointJS to the codebase. JointJS is a Javascript Library we use to draw the workflow graph.
JointJS tutorial: https://resources.jointjs.com/tutorial
JointJS API: https://resources.jointjs.com/docs/jointjs/v2.0/joint.html
This PR adds the component WorkflowEditor, which is the main canvas to let user edit the workflow. JointJS is attached to the DOM element of this component. The JointJS paper is created with many custom options in this Component.
This PR also adds a service
JointUIServiceThe job of this service to provide JointJS Element (which contains all attributes and data for JointJS to create an Operator element) and JointJS link to other modules.The current UI looks like this. The JointJS data model isn't fully integrated into our own data model yet, this PR only includes the UI part. The operators and links are temporary to show that JointJS works.
New Frontend PR status:
[1]: PR #604 creates the app using Angular CLI, which sets up the project with basic templates. The basic components are created.
[2]: PR #605 adds the left side operator panel, which shows the operators and the groups. It adds OperatorMetadataService, which fetches metadata from the backend.
[3]: PR #606 integrates JointJS to the app. JointJS is used to display the operators and the links. This PR integrates JointJS in the View level.