Skip to content

Commit

Permalink
chore: remove all but last selected report when show multiple is disa…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
MatthijsSmets committed Jan 15, 2024
1 parent 2b649f8 commit 9e35059
Showing 1 changed file with 47 additions and 20 deletions.
67 changes: 47 additions & 20 deletions src/app/debug/debug-tree/debug-tree.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core';
import {

Check failure on line 1 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `⏎··AfterViewInit,⏎··Component,⏎··EventEmitter,⏎··Input,⏎··OnDestroy,⏎··Output,⏎··ViewChild,⏎` with `·AfterViewInit,·Component,·EventEmitter,·Input,·OnDestroy,·Output,·ViewChild·`

Check failure on line 1 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `⏎··AfterViewInit,⏎··Component,⏎··EventEmitter,⏎··Input,⏎··OnDestroy,⏎··Output,⏎··ViewChild,⏎` with `·AfterViewInit,·Component,·EventEmitter,·Input,·OnDestroy,·Output,·ViewChild·`
AfterViewInit,
Component,
EventEmitter,
Input,
OnDestroy,
Output,
ViewChild,
} from '@angular/core';
import { Report } from '../../shared/interfaces/report';
import { jqxTreeComponent } from 'jqwidgets-ng/jqxtree';
import { HelperService } from '../../shared/services/helper.service';
Expand Down Expand Up @@ -49,11 +57,15 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
}

subscribeToSettingsServiceObservables(): void {
this.showMultipleAtATimeSubscription = this.settingsService.showMultipleAtATimeObservable.subscribe(
(value: boolean) => {
this.showMultipleAtATime = value;
}
);
this.showMultipleAtATimeSubscription =

Check failure on line 60 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `⏎·····`

Check failure on line 60 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `⏎·····`
this.settingsService.showMultipleAtATimeObservable.subscribe(
(value: boolean) => {

Check failure on line 62 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 62 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
this.showMultipleAtATime = value;

Check failure on line 63 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 63 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
if (!this.showMultipleAtATime) {

Check failure on line 64 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 64 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
this.removeAllReportsButOne();

Check failure on line 65 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 65 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
}

Check failure on line 66 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `··········` with `········`

Check failure on line 66 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `··········` with `········`
}

Check failure on line 67 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 67 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
);

Check failure on line 68 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`

Check failure on line 68 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
}

ngAfterViewInit(): void {
Expand All @@ -75,7 +87,11 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
this.getTreeReports().forEach((report) => {
if (report.value.storageName === currentView.storageName) {
this.httpService
.getUnmatchedCheckpoints(report.value.storageName, report.value.storageId, currentView.name)
.getUnmatchedCheckpoints(

Check failure on line 90 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `⏎············report.value.storageName,⏎············report.value.storageId,⏎············currentView.name⏎··········` with `report.value.storageName,·report.value.storageId,·currentView.name`

Check failure on line 90 in src/app/debug/debug-tree/debug-tree.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Replace `⏎············report.value.storageName,⏎············report.value.storageId,⏎············currentView.name⏎··········` with `report.value.storageName,·report.value.storageId,·currentView.name`
report.value.storageName,
report.value.storageId,
currentView.name
)
.subscribe((unmatched: any) => {
const selectedReport: any = this.treeReference.getSelectedItem();
this.prepareNextSelect(unmatched, selectedReport);
Expand Down Expand Up @@ -105,8 +121,13 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
}
}

recursivelyFindParentThatWontBeDeleted(selectedReport: any, unmatched: any[]) {
const parent: any = this.treeReference.getItems().find((item: any) => item.id === selectedReport.parentId);
recursivelyFindParentThatWontBeDeleted(
selectedReport: any,
unmatched: any[]
) {
const parent: any = this.treeReference
.getItems()
.find((item: any) => item.id === selectedReport.parentId);
if (parent && !unmatched.includes(parent.value.uid)) {
this.treeReference.selectItem(parent);
} else {
Expand All @@ -118,13 +139,6 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
this.treeReference.width('100%');
}

toggleShowAmount(): void {
this.showMultipleAtATime = !this.showMultipleAtATime;
if (!this.showMultipleAtATime) {
this.removeAllReportsButOne();
}
}

removeAllReportsButOne(): void {
if (this.lastReport) {
this.addReportToTree(this.lastReport);
Expand All @@ -141,7 +155,11 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
this.treeReference.addTo(tree, null);
this.treeReference.selectItem(
// @ts-ignore
this.treeReference.getItems()[this.treeReference.getItems().findIndex((item: any) => item.id == tree.items[0].id)]
this.treeReference.getItems()[
this.treeReference
.getItems()
.findIndex((item: any) => item.id == tree.items[0].id)
]
);
this.hideOrShowCheckpointsBasedOnView(this.currentView);
}
Expand All @@ -151,14 +169,18 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
}

removeReport(report: any): void {
let parentItem: any = this.findParentNode(this.treeReference.getItems().find((item: any) => item.value == report));
let parentItem: any = this.findParentNode(
this.treeReference.getItems().find((item: any) => item.value == report)
);
let root = parentItem.element.parentNode;
this.treeReference.removeItem(parentItem);
parentItem.element.remove();

let latestAddedReport = root.lastChild;
if (latestAddedReport) {
this.treeReference.selectItem(latestAddedReport.querySelectorAll('li')[0]);
this.treeReference.selectItem(
latestAddedReport.querySelectorAll('li')[0]
);
}
}

Expand Down Expand Up @@ -188,7 +210,12 @@ export class DebugTreeComponent implements AfterViewInit, OnDestroy {
this.getTreeReports().forEach((report) => {
queryString += 'id=' + report.value.storageId + '&';
});
this.helperService.download(queryString, this.currentView.storageName, exportBinary, exportXML);
this.helperService.download(
queryString,
this.currentView.storageName,
exportBinary,
exportXML
);
}

changeSearchTerm(event: KeyboardEvent): void {
Expand Down

0 comments on commit 9e35059

Please sign in to comment.