NIFI-13074: Resetting the transform when navigating from the lineage to the event listing (#8678)

* NIFI-13074:
- Resetting the transform when navigating from the lineage to the event listing.

* NIFI-13074:
- Fixing lint issues.

This closes #8678
This commit is contained in:
Matt Gilman 2024-04-22 14:15:46 -04:00 committed by GitHub
parent 2af2a3956e
commit 90506823e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 6 deletions

View File

@ -28,6 +28,7 @@ import {
ContextMenuItemDefinition ContextMenuItemDefinition
} from '../../../../../../ui/common/context-menu/context-menu.component'; } from '../../../../../../ui/common/context-menu/context-menu.component';
import { CdkContextMenuTrigger } from '@angular/cdk/menu'; import { CdkContextMenuTrigger } from '@angular/cdk/menu';
import { ZoomBehavior } from 'd3';
@Component({ @Component({
selector: 'lineage', selector: 'lineage',
@ -93,6 +94,7 @@ export class LineageComponent implements OnInit {
@Input() set reset(reset: EventEmitter<void>) { @Input() set reset(reset: EventEmitter<void>) {
reset.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { reset.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
// clear the current lineage graph
this.nodeLookup.clear(); this.nodeLookup.clear();
this.linkLookup.clear(); this.linkLookup.clear();
@ -108,6 +110,11 @@ export class LineageComponent implements OnInit {
nodes.exit().remove(); nodes.exit().remove();
links.exit().remove(); links.exit().remove();
// reset the transform for the next lineage graph
if (this.svg && this.lineageZoom) {
this.svg.call(this.lineageZoom.transform, d3.zoomIdentity);
}
}); });
} }
@ -226,6 +233,8 @@ export class LineageComponent implements OnInit {
lineageContainerElement: any; lineageContainerElement: any;
lineageContextmenu: ContextMenuDefinitionProvider; lineageContextmenu: ContextMenuDefinitionProvider;
private lineageZoom: ZoomBehavior<any, any> | undefined;
private svg: d3.Selection<any, any, any, any> | undefined;
private nodeLookup: Map<string, any> = new Map<string, any>(); private nodeLookup: Map<string, any> = new Map<string, any>();
private linkLookup: Map<string, any> = new Map<string, any>(); private linkLookup: Map<string, any> = new Map<string, any>();
private previousEventTimestampThreshold = -1; private previousEventTimestampThreshold = -1;
@ -262,7 +271,7 @@ export class LineageComponent implements OnInit {
this.lineageElement = document.getElementById('lineage'); this.lineageElement = document.getElementById('lineage');
// handle zoom behavior // handle zoom behavior
const lineageZoom: any = d3 this.lineageZoom = d3
.zoom() .zoom()
.scaleExtent([0.2, 8]) .scaleExtent([0.2, 8])
.on('zoom', function (event) { .on('zoom', function (event) {
@ -272,15 +281,16 @@ export class LineageComponent implements OnInit {
}); });
// build the birdseye svg // build the birdseye svg
const svg = d3 this.svg = d3
.select(this.lineageElement) .select(this.lineageElement)
.append('svg') .append('svg')
.attr('width', '100%') .attr('width', '100%')
.attr('height', '100%') .attr('height', '100%')
.call(lineageZoom) .call(this.lineageZoom)
.on('dblclick.zoom', null); .on('dblclick.zoom', null);
svg.append('rect') this.svg
.append('rect')
.attr('class', 'lineage') .attr('class', 'lineage')
.attr('width', '100%') .attr('width', '100%')
.attr('height', '100%') .attr('height', '100%')
@ -292,7 +302,8 @@ export class LineageComponent implements OnInit {
event.preventDefault(); event.preventDefault();
}); });
svg.append('defs') this.svg
.append('defs')
.selectAll('marker') .selectAll('marker')
.data(['FLOWFILE', 'FLOWFILE-SELECTED', 'EVENT', 'EVENT-SELECTED']) .data(['FLOWFILE', 'FLOWFILE-SELECTED', 'EVENT', 'EVENT-SELECTED'])
.enter() .enter()
@ -323,7 +334,7 @@ export class LineageComponent implements OnInit {
.attr('d', 'M0,-3 L6,0 L0,3'); .attr('d', 'M0,-3 L6,0 L0,3');
// group everything together // group everything together
this.lineageContainerElement = svg this.lineageContainerElement = this.svg
.append('g') .append('g')
.attr('transform', 'translate(0, 0) scale(1)') .attr('transform', 'translate(0, 0) scale(1)')
.attr('pointer-events', 'all') .attr('pointer-events', 'all')