Skip to content

[#603][2] Add Operator Panel to the new GUI - #605

Merged
zuozhiw merged 13 commits into
masterfrom
new-gui-operator-panel
Apr 5, 2018
Merged

zuozhiw merged 13 commits into
masterfrom
new-gui-operator-panel

Conversation

@zuozhiw

@zuozhiw zuozhiw commented Mar 28, 2018

Copy link
Copy Markdown
Contributor

This PR adds the Operator Panel to the new GUI. The Operator Panel Component shows the list of operators grouped with their operator group.

This PR also adds OperatorMetadataService. It fetches the operator metadata from the backend. This PR also adds Typescript typing declarations for the interfaces related to operator metadata.

In Angular, Services are singleton instances that provides specific functionaries that are not tightly related to the view. Services are also the primary way for different components to communicate each other. In the new GUI, most of the logic and data are processed in the service. Components only get the data and listen to events from Services.

Service singleton instances are initialized by Angular when the app initializes. And then these service instances are provided to other classes by Angular Dependency Injection https://angular.io/guide/architecture-services

In this PR, OperatorMetadataService's job is to send an HTTP request to the backend API endpoint to fetch the operator metadata and when the HTTP request is done, it passes the metadata to the OperatorPanelComponent through an observable.

The file structure now looks like this (only shows partial structure inside "workspace" folder)

  • workspace (the main workspace application to run workflow plan)
    • component (includes all the angular components, each component corresponds to a section in the UI)
      • operator panel component
      • more components...
    • service
      • operator metadata service
    • types
      • operator schema (type declaration)

The current UI looks like this:
screen shot 2018-03-27 at 4 59 09 pm

Comment thread core/new-gui/src/app/app.component.ts Outdated
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { WorkspaceComponent } from './workspace/component/workspace.component';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why this import?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

// providers: [
// { provide: OperatorMetadataService, useClass: StubOperatorMetadataService }
// ],
// schemas: [ NO_ERRORS_SCHEMA ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file is tool generated. Then, why is this portion commented out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the test case will be added back into a future PR

}

export interface GroupInfo {
groupName: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In case of such definitions, which serve as a protocol with server, please give an example of what is expected from server and explain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's in another mock data file. Comments are added to point to that file.

*
*/
public getOperatorMetadata(): Observable<OperatorMetadata> {
return this.httpClient

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do services have the concept of static variables? Once brought we can initialize it and any call to the function will first check it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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


describe('OperatorMetadataService', () => {

let service: OperatorMetadataService;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be StubOperatorMetadataService?
However, in order to make sure that when server's operator schema changes, the front end's tests fail, we should contact the actual backend and not just mock it.


constructor() { }
constructor(
private operatorMetadataService: OperatorMetadataService,

@avinash0161 avinash0161 Mar 30, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is the service needed in this constructor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's not needed, will be removed later

it('should receive operator metadata from service', () => {
// if the length of our schema list is equal to the length of mock data
// we assume the mock data has been received
expect(component.operatorSchemaList.length).toEqual(MOCK_OPERATOR_SCHEMA_LIST.length);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

F2FQ: What is component here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

component is declared above, and initialized in the beforeEach function, which is called every time before each test

declarations: [ OperatorPanelComponent ]
declarations: [OperatorPanelComponent],
providers: [
{ provide: OperatorMetadataService, useClass: StubOperatorMetadataService }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

F2FQ: so which class are we using operator or stuboperator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OperatorMetadataService is the provided class we try to mock, StubOperatorMetadataService is the actual class used to mock that class.

@@ -0,0 +1,3 @@
<mat-card class="texera-operator-label mat-elevation-z1" [attr.id]="operatorLabelID">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

F2FQ: What is [attr.id]'s brackets mean? Angular Tutorial said it meant input into the child component. But here mat-card is not a child.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[attr.id] is set the DOM element's ID using a variable in the class.
id=something will interpret something as a string
[attr.id]=something will interpret something as a public variable in the component class. It's Angular's syntax.

selector: 'texera-workspace',
templateUrl: './workspace.component.html',
styleUrls: ['./workspace.component.scss']
styleUrls: ['./workspace.component.scss'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be changes in workspace html too where you include operator label and operator panel html tags? Or are you planning to get it reviewed at the last?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

operator panel component is already included in workspace.component.html, operator label component is included inside operator-panel.component.html

@avinash0161 avinash0161 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ignore the questions which start with F2FQ. These are some questions that I have and can be solved with a f2f discussion.

Other than that, please take a look.

@zuozhiw
zuozhiw changed the base branch from new-gui-foundation to master March 31, 2018 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants