Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #835

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { DebugComponent } from './debug/debug.component';
import { Router, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { Tab } from './shared/interfaces/tab';
import { ReportData } from './shared/interfaces/report-data';
import { HelperService } from './shared/services/helper.service';
import { ToastComponent } from './shared/components/toast/toast.component';
import { ReportComponent } from './report/report.component';
import { CloseTab } from './shared/interfaces/close-tab';
Expand Down Expand Up @@ -48,7 +47,6 @@ export class AppComponent implements OnInit, OnDestroy {
private settingsService: SettingsService,
private tabService: TabService,
private router: Router,
private helperService: HelperService,
private location: Location,
private httpService: HttpService,
private errorHandler: ErrorHandling,
Expand Down Expand Up @@ -112,7 +110,7 @@ export class AppComponent implements OnInit, OnDestroy {
}

openNewCompareTab(data: CompareData): void {
const tabId = this.helperService.createCompareTabId(data.originalReport, data.runResultReport);
const tabId = this.tabService.createCompareTabId(data.originalReport, data.runResultReport);
const tabIndex: number = this.tabs.findIndex((tab: Tab): boolean => tab.id == tabId);
if (tabIndex == -1) {
data.id = tabId;
Expand Down
3 changes: 1 addition & 2 deletions src/app/compare/compare-tree/compare-tree.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { Report } from '../../shared/interfaces/report';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TitleCasePipe } from '@angular/common';

import { ReportHierarchyTransformer } from '../../shared/classes/report-hierarchy-transformer';
import { ReportUtil } from '../../shared/util/report-util';
Expand All @@ -26,7 +25,7 @@ export type TreeSide = (typeof treeSideConst)[number];
templateUrl: './compare-tree.component.html',
styleUrls: ['./compare-tree.component.css'],
standalone: true,
imports: [ReactiveFormsModule, TitleCasePipe, FormsModule, NgSimpleFileTreeModule],
imports: [ReactiveFormsModule, FormsModule, NgSimpleFileTreeModule],
})
export class CompareTreeComponent {
@Output() compareEvent: EventEmitter<void> = new EventEmitter<void>();
Expand Down
16 changes: 1 addition & 15 deletions src/app/debug/debug-tree/debug-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import {
NgSimpleFileTree,
NgSimpleFileTreeModule,
} from 'ng-simple-file-tree';
import {
NgbDropdown,
NgbDropdownButtonItem,
NgbDropdownItem,
NgbDropdownMenu,
NgbDropdownToggle,
} from '@ng-bootstrap/ng-bootstrap';
import { ReportHierarchyTransformer } from '../../shared/classes/report-hierarchy-transformer';
import { SimpleFileTreeUtil } from '../../shared/util/simple-file-tree-util';
import { View } from '../../shared/interfaces/view';
Expand All @@ -29,14 +22,7 @@ import { RefreshCondition } from '../../shared/interfaces/refresh-condition';
templateUrl: './debug-tree.component.html',
styleUrls: ['./debug-tree.component.css'],
standalone: true,
imports: [
NgbDropdown,
NgbDropdownToggle,
NgbDropdownMenu,
NgbDropdownButtonItem,
NgbDropdownItem,
NgSimpleFileTreeModule,
],
imports: [NgSimpleFileTreeModule],
})
export class DebugTreeComponent implements OnDestroy {
@ViewChild('tree') tree!: NgSimpleFileTree;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { FilterService } from './filter.service';
import { Subscription, catchError } from 'rxjs';
import { catchError, Subscription } from 'rxjs';
import { animate, style, transition, trigger } from '@angular/animations';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { FormsModule } from '@angular/forms';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SettingsService } from '../../../shared/services/settings.service';
import { catchError, Subscription } from 'rxjs';
import { ToastService } from '../../../shared/services/toast.service';
import { UploadParams } from 'src/app/shared/interfaces/upload-params';
import { ToastComponent } from '../../../shared/components/toast/toast.component';
import { ErrorHandling } from 'src/app/shared/classes/error-handling.service';
import { OptionsSettings } from '../../../shared/interfaces/options-settings';
import { Transformation } from '../../../shared/interfaces/transformation';
Expand All @@ -18,7 +17,7 @@ import { CopyTooltipDirective } from '../../../shared/directives/copy-tooltip.di
templateUrl: './table-settings-modal.component.html',
styleUrls: ['./table-settings-modal.component.css'],
standalone: true,
imports: [ReactiveFormsModule, ToastComponent, CopyTooltipDirective],
imports: [ReactiveFormsModule, CopyTooltipDirective],
})
export class TableSettingsModalComponent implements OnDestroy {
@ViewChild('modal') modal!: ElementRef;
Expand Down
3 changes: 1 addition & 2 deletions src/app/debug/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,7 @@ export class TableComponent implements OnInit, OnDestroy {
const originalReport = this.transformCompareToReport(data[selectedReports[0]]);
const runResultReport = this.transformCompareToReport(data[selectedReports[1]]);

const id: string = this.helperService.createCompareTabId(originalReport, runResultReport);

const id: string = this.tabService.createCompareTabId(originalReport, runResultReport);
this.tabService.openNewCompareTab({
id: id,
originalReport: originalReport,
Expand Down
4 changes: 0 additions & 4 deletions src/app/report/edit-display/edit-display.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { EditorComponent } from '../../editor/editor.component';
import { Report } from '../../shared/interfaces/report';
import { MetadataTableComponent } from '../../shared/components/metadata-table/metadata-table.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgClass, NgStyle, TitleCasePipe } from '@angular/common';
import { BooleanToStringPipe } from '../../shared/pipes/boolean-to-string.pipe';
import { catchError } from 'rxjs';
import { ClipboardModule } from '@angular/cdk/clipboard';
Expand Down Expand Up @@ -54,14 +53,11 @@ import { Router } from '@angular/router';
EditorComponent,
MetadataTableComponent,
BooleanToStringPipe,
NgStyle,
ClipboardModule,
EditFormComponent,
TitleCasePipe,
DifferenceModalComponent,
ToggleButtonComponent,
MatTooltipModule,
NgClass,
EncodingButtonComponent,
FormsModule,
ReportAlertMessageComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class EncodingButtonComponent implements OnChanges {

constructor(private toastService: ToastService) {}

ngOnChanges(changes: SimpleChanges) {
ngOnChanges() {
this.showEncodingButton = ReportUtil.isCheckPoint(this.selectedNode) && this.selectedNode.encoding === 'Base64';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnChanges } from '@angular/core';
import { Component, Input } from '@angular/core';
import { ClipboardModule } from '@angular/cdk/clipboard';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CopyTooltipDirective } from '../../directives/copy-tooltip.directive';
Expand Down
7 changes: 7 additions & 0 deletions src/app/shared/interfaces/base-report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface BaseReport {
checked: boolean;
storageId: number;
path: string;
name: string;
description: string;
}
8 changes: 2 additions & 6 deletions src/app/shared/interfaces/report.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import { Checkpoint } from './checkpoint';
import { BaseReport } from './base-report';

export interface Report {
export interface Report extends BaseReport {
checkpoints: Checkpoint[];
correlationId: string;
crudStorage: boolean;
description: string;
endTime: number;
estimatedMemoryUsage: number;
fullPath: string;
inputCheckpoint: Checkpoint;
name: string;
numberOfCheckpoints: number;
originalEndpointOrAbortpointForCurrentLevel?: Checkpoint;
originalReport: Report;
path: string;
reportFilterMatching: boolean;
startTime: number;
storageId: number;
stub: number;
stubStrategy: string;
transformation: string;
variableCsv: string;
checked: boolean;
storageName: string;
variablesAsMap: any; // Map<String, String>
xml: string; // Custom for the xml representation of the report
Expand Down
8 changes: 2 additions & 6 deletions src/app/shared/interfaces/test-list-item.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { ReranReport } from './reran-report';
import { BaseReport } from './base-report';

export interface TestListItem {
checked: boolean;
name: string;
path: string;
export interface TestListItem extends BaseReport {
fullPath?: string;
description: string;
storageId: number;
variables?: string;
extractedVariables?: string;
reranReport?: ReranReport | null;
Expand Down
12 changes: 4 additions & 8 deletions src/app/shared/services/helper.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Report } from '../interfaces/report';
import { BaseReport } from '../interfaces/base-report';

@Injectable({
providedIn: 'root',
Expand All @@ -9,19 +9,15 @@ export class HelperService {
window.open(`api/report/download/${storage}/${exportBinary}/${exportXML}?${queryString.slice(0, -1)}`);
}

getSelectedIds(reports: any[]): number[] {
getSelectedIds(reports: BaseReport[]): number[] {
let copiedIds: number[] = [];
for (const report of this.getSelectedReports(reports)) {
copiedIds.push(report.storageId);
}
return copiedIds;
}

getSelectedReports(reports: Report[]): Report[] {
return reports.filter((report: Report) => report.checked);
}

createCompareTabId(originalReport: Report, runResultReport: Report): string {
return `${originalReport.storageId}-${runResultReport.storageId}`;
getSelectedReports(reports: BaseReport[]): BaseReport[] {
return reports.filter((report) => report.checked);
}
}
3 changes: 1 addition & 2 deletions src/app/shared/services/http.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { map, Observable, tap } from 'rxjs';
import { ToastService } from './toast.service';
import { map, Observable } from 'rxjs';
import { View } from '../interfaces/view';
import { OptionsSettings } from '../interfaces/options-settings';
import { Report } from '../interfaces/report';
Expand Down
5 changes: 5 additions & 0 deletions src/app/shared/services/tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Observable, ReplaySubject, Subject } from 'rxjs';
import { ReportData } from '../interfaces/report-data';
import { CompareData } from '../../compare/compare-data';
import { CloseTab } from '../interfaces/close-tab';
import { Report } from '../interfaces/report';

@Injectable({
providedIn: 'root',
Expand All @@ -29,6 +30,10 @@ export class TabService {
this.activeCompareTabs.set(value.id, value);
}

createCompareTabId(originalReport: Report, runResultReport: Report): string {
return `${originalReport.storageId}-${runResultReport.storageId}`;
}

closeTab(value: CompareData | ReportData): void {
let closeTab: CloseTab;
if (this.isCompareData(value)) {
Expand Down
12 changes: 0 additions & 12 deletions src/app/shared/util/update-report-util.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, EventEmitter, Output, ViewChild } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { UntypedFormControl, UntypedFormGroup, ReactiveFormsModule } from '@angular/forms';
import { ReactiveFormsModule, UntypedFormControl, UntypedFormGroup } from '@angular/forms';

@Component({
selector: 'app-test-settings-modal',
Expand Down
8 changes: 1 addition & 7 deletions src/app/test/test-table/test-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { catchError } from 'rxjs';
import { HttpService } from '../../shared/services/http.service';
import { ErrorHandling } from '../../shared/classes/error-handling.service';
import { TabService } from '../../shared/services/tab.service';
import { HelperService } from '../../shared/services/helper.service';
import { Report } from '../../shared/interfaces/report';
import { ReportData } from '../../shared/interfaces/report-data';
import { View } from '../../shared/interfaces/view';
Expand All @@ -31,8 +30,6 @@ import {
MatRowDef,
MatTable,
} from '@angular/material/table';
import { MatSortHeader } from '@angular/material/sort';
import { TableCellShortenerPipe } from '../../shared/pipes/table-cell-shortener.pipe';

@Component({
selector: 'app-test-table',
Expand All @@ -44,8 +41,6 @@ import { TableCellShortenerPipe } from '../../shared/pipes/table-cell-shortener.
MatCell,
MatCellDef,
MatHeaderCell,
MatSortHeader,
TableCellShortenerPipe,
MatHeaderCellDef,
MatHeaderRow,
MatHeaderRowDef,
Expand All @@ -68,7 +63,6 @@ export class TestTableComponent implements OnChanges {
private httpService: HttpService,
private errorHandler: ErrorHandling,
private tabService: TabService,
private helperService: HelperService,
private testReportsService: TestReportsService,
private toastService: ToastService,
) {}
Expand Down Expand Up @@ -151,7 +145,7 @@ export class TestTableComponent implements OnChanges {

compareReports(report: TestListItem): void {
if (report.reranReport) {
const tabId: string = this.helperService.createCompareTabId(
const tabId: string = this.tabService.createCompareTabId(
report.reranReport.originalReport,
report.reranReport.runResultReport,
);
Expand Down
Loading