Skip to content

Commit

Permalink
Refactor: created base class to be able to use super type instead of …
Browse files Browse the repository at this point in the history
…any type
  • Loading branch information
MatthijsSmets committed Dec 17, 2024
1 parent 03c7b32 commit fe17719
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/app/shared/interfaces/base-report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface BaseReport {
checked: boolean;
storageId: number;
}
5 changes: 2 additions & 3 deletions src/app/shared/interfaces/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Checkpoint } from './checkpoint';
import { BaseReport } from './base-report';

export interface Report {
export interface Report extends BaseReport {
checkpoints: Checkpoint[];
correlationId: string;
crudStorage: boolean;
Expand All @@ -16,12 +17,10 @@ export interface 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
5 changes: 2 additions & 3 deletions src/app/shared/interfaces/test-list-item.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ReranReport } from './reran-report';
import { BaseReport } from './base-report';

export interface TestListItem {
checked: boolean;
export interface TestListItem extends BaseReport {
name: string;
path: string;
fullPath?: string;
description: string;
storageId: number;
variables?: string;
extractedVariables?: string;
reranReport?: ReranReport | null;
Expand Down
9 changes: 4 additions & 5 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,16 +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);
}
getSelectedReports(reports: BaseReport[]): BaseReport[] {
return reports.filter((report) => report.checked);
}
}

0 comments on commit fe17719

Please sign in to comment.