aglinxinyuan commented on code in PR #9063:
URL: https://github.com/apache/texera/pull/9063#discussion_r4418732516
##########
frontend/src/app/workspace/component/result-panel/result-table-frame/result-table-frame.component.ts:
##########
@@ -170,7 +203,8 @@ export class ResultTableFrameComponent implements OnInit,
OnChanges {
.getResultUpdateStream()
.pipe(untilDestroyed(this))
.subscribe(update => {
- if (!this.operatorId) {
+ // an update is about the operator's first port
+ if (!this.operatorId || this.portIndex !== 0) {
Review Comment:
A tab past the first port never refreshes. This drops every result update
when `portIndex !== 0`, and `clearResults()` runs only on workspace teardown,
not on a new run.
- A window pinned mid-run on a Split's second tab keeps its partial rows and
count after the run completes.
- After a re-run it shows the old run's rows until you page. Paging then
mixes in the new run's rows and count.
Asking for the current page again for `portIndex > 0` on that operator's
result updates would cover it (throttled, or at least when a run completes).
##########
frontend/src/app/workspace/component/workflow-editor/pinned-result-window/pinned-result-window.component.ts:
##########
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AfterViewInit,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ EventEmitter,
+ Input,
+ OnDestroy,
+ Output,
+ ViewChild,
+} from "@angular/core";
+import { NgFor, NgIf } from "@angular/common";
+import { NzIconDirective } from "ng-zorro-antd/icon";
+import { WorkflowActionService } from
"../../../service/workflow-graph/model/workflow-action.service";
+import { WorkflowResultService } from
"../../../service/workflow-result/workflow-result.service";
+import { ResultTableFrameComponent } from
"../../result-panel/result-table-frame/result-table-frame.component";
+import { VisualizationFrameContentComponent } from
"../../visualization-panel-content/visualization-frame-content.component";
+import { OperatorResultPreviewComponent } from
"../operator-result-preview/operator-result-preview.component";
+
+/**
+ * An operator's result pinned next to it on the canvas. It shows the whole
result, the way the
+ * result panel would, and stays until it is closed. Dragging its header moves
it away from the
+ * operator; the editor keeps it at that offset when the operator or the
canvas moves.
+ */
+@Component({
+ selector: "texera-pinned-result-window",
+ templateUrl: "./pinned-result-window.component.html",
+ styleUrls: ["./pinned-result-window.component.scss"],
+ imports: [
+ NgIf,
+ NgFor,
+ NzIconDirective,
+ ResultTableFrameComponent,
+ VisualizationFrameContentComponent,
+ OperatorResultPreviewComponent,
+ ],
+})
+export class PinnedResultWindowComponent implements AfterViewInit, OnDestroy {
+ @Input() operatorId = "";
+ @Output() closed = new EventEmitter<void>();
+ @Output() moved = new EventEmitter<{ dx: number; dy: number }>();
+ @ViewChild("body") bodyElement?: ElementRef<HTMLElement>;
+
+ /** The height the window's body leaves for the table, which fills it. */
+ tableHeight?: number;
+ private resizeObserver?: ResizeObserver;
+
+ constructor(
+ private workflowActionService: WorkflowActionService,
+ private workflowResultService: WorkflowResultService,
+ private changeDetectorRef: ChangeDetectorRef
+ ) {}
+
+ ngAfterViewInit(): void {
+ const element = this.bodyElement?.nativeElement;
+ if (!element || typeof ResizeObserver === "undefined") return;
+ // the user resizes the window by its corner, so the body's height is read
as it changes
+ this.resizeObserver = new ResizeObserver(() => {
+ const style = getComputedStyle(element);
+ const height = element.clientHeight - parseFloat(style.paddingTop) -
parseFloat(style.paddingBottom);
+ if (height === this.tableHeight) return;
+ this.tableHeight = height;
+ this.changeDetectorRef.detectChanges();
+ });
+ this.resizeObserver.observe(element);
+ }
+
+ ngOnDestroy(): void {
+ this.resizeObserver?.disconnect();
+ }
+
+ get title(): string {
+ const graph = this.workflowActionService.getTexeraGraph();
+ if (!graph.hasOperator(this.operatorId)) return this.operatorId;
+ const operator = graph.getOperator(this.operatorId);
+ return operator.customDisplayName ?? operator.operatorType;
+ }
+
+ /** The output port whose result is shown. */
+ selectedPort = 0;
Review Comment:
`selectedPort` is never clamped. Say a Python UDF's second output is
removed, or its add is undone, while "Output 2" is selected. The tab bar hides
(`outputPorts.length > 1`), but the table stays on `portIndex = 1`, and the
only way back is to unpin. Clamping it to the last port would fix it.
##########
frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts:
##########
@@ -590,6 +615,171 @@ export class WorkflowEditorComponent implements OnInit,
AfterViewInit, OnDestroy
});
}
+ /**
+ * Shows the hovered operator's result preview beside it; its Pin button
keeps the whole result
+ * there. Off when Layers > Result preview is unchecked, and while the
heat-map overlay is on,
+ * whose own tooltip answers the hover then.
+ */
+ private handleResultPreviewHover(): void {
+ fromJointPaperEvent(this.paper, "element:mouseenter")
+ .pipe(untilDestroyed(this))
+ .subscribe(([elementView, evt]) => {
+ clearTimeout(this.previewHideTimer);
+ clearTimeout(this.previewShowTimer);
+ if (this.wrapper.getHeatmapView() !== null ||
!this.wrapper.isResultPreviewEnabled()) {
+ return;
+ }
+ const operatorId = elementView.model.id.toString();
+ // no preview while a button is held: the pointer is dragging an
operator or a link
+ if (
+ !this.workflowActionService.getTexeraGraph().hasOperator(operatorId)
||
+ isButtonHeld(evt) ||
+ this.pinnedResults.some(pinned => pinned.operatorId === operatorId)
+ ) {
+ return;
+ }
+ // Only a pointer that rests on the operator opens the card, so
passing over one does not.
+ this.previewShowTimer = setTimeout(() => {
+ this.resultPreview = { operatorId,
...this.operatorAnchor(operatorId) };
+ // JointJS paper events fire outside Angular's zone (see
handleHeatmapHover).
+ this.changeDetectorRef.detectChanges();
+ }, RESULT_PREVIEW_DELAY_MS);
+ });
+
+ fromJointPaperEvent(this.paper, "element:mouseleave")
+ .pipe(untilDestroyed(this))
+ .subscribe(() => {
+ clearTimeout(this.previewShowTimer);
+ this.hideResultPreviewSoon();
+ });
+
+ // A click or a drag on the canvas closes the card at once.
+ merge(fromJointPaperEvent(this.paper, "element:pointerdown"),
fromJointPaperEvent(this.paper, "blank:pointerdown"))
+ .pipe(untilDestroyed(this))
+ .subscribe(() => {
+ clearTimeout(this.previewShowTimer);
+ if (this.resultPreview === null) return;
+ this.resultPreview = null;
+ this.changeDetectorRef.detectChanges();
+ });
+
+ // Pinned windows sit beside their operators, so they move when an
operator or the canvas does.
+ merge(
+ fromJointPaperEvent(this.paper, "translate"),
+ fromJointPaperEvent(this.paper, "scale"),
+ fromEvent(this.paper.model as any, "change:position")
+ )
+ .pipe(untilDestroyed(this))
+ .subscribe(() => {
+ if (this.pinnedResults.length > 0)
this.changeDetectorRef.detectChanges();
+ });
+
+ this.workflowActionService
+ .getTexeraGraph()
+ .getOperatorDeleteStream()
+ .pipe(untilDestroyed(this))
+ .subscribe(({ deletedOperatorID }) =>
this.unpinResult(deletedOperatorID));
+ }
+
+ /** Close the card after a moment, so the pointer can cross from the
operator into it. */
+ public hideResultPreviewSoon(): void {
+ clearTimeout(this.previewHideTimer);
+ this.previewHideTimer = setTimeout(() => {
+ this.resultPreview = null;
+ this.changeDetectorRef.detectChanges();
+ }, RESULT_PREVIEW_HIDE_MS);
+ }
+
+ /** The pointer reached the card, so it stays open. */
+ public keepResultPreview(): void {
+ clearTimeout(this.previewHideTimer);
+ }
+
+ public pinResultPreview(): void {
Review Comment:
Nothing in `workflow-editor.component.spec.ts` covers pin, unpin,
unpin-on-delete, or the connector and position math yet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]