Skip to content

Commit

Permalink
Merge pull request #1192 from aneoconsulting/chore/update-components-…
Browse files Browse the repository at this point in the history
…for-inspection

chore: update components for inspection
  • Loading branch information
ngruelaneo authored Aug 2, 2024
2 parents e0f855f + 0ab2cb8 commit 1ff0ff7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 57 deletions.
4 changes: 2 additions & 2 deletions src/app/components/inspection-header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('InspectionHeaderComponent', () => {
expect(component.id).toEqual(id);
});

it('should not change "id" if a undefined value is provided', () => {
component.id = undefined;
it('should not change "id" if a null value is provided', () => {
component.id = null;
expect(component.id).toEqual(id);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/inspection-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class InspectionHeaderComponent {

private _id = '';

@Input({ required: true }) set id(entry: string | undefined) {
@Input({ required: true }) set id(entry: string | null) {
if (entry) {
this._id = entry;
}
Expand Down
19 changes: 10 additions & 9 deletions src/app/components/show-page.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<app-page-header [sharableURL]="sharableURL">
<ng-content></ng-content>
<span>{{ id }}</span>
<button mat-icon-button [cdkCopyToClipboard]="id ?? ''" (cdkCopyToClipboardCopied)="onCopiedTaskId()">
<mat-icon aria-hidden="true" fontIcon="content_copy" />
</button>
</app-page-header>
<app-inspection-header [id]="id" [status]="status" [sharableURL]="sharableURL">
<ng-content title select="[title]" />
</app-inspection-header>

<app-show-actions [actionsButton]="actionsButton" (refresh)="onRefresh()" />
<app-inspection-toolbar (refresh)="onRefresh()">
<ng-content select="[actions]" actions />
<ng-content select="[bonus-actions]" bonus-actions />
</app-inspection-toolbar>

<app-show-card [data]="data" [statuses]="statuses" />
<app-inspection-card [data]="data" [statuses]="statuses" [fields]="fields" [optionsFields]="optionsFields"/>

<app-inspection-list-grid [arrays]="arrays" [data]="data">
11 changes: 0 additions & 11 deletions src/app/components/show-page.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { TestBed } from '@angular/core/testing';
import { DataRaw } from '@app/types/data';
import { NotificationService } from '@services/notification.service';
import { ShowPageComponent } from './show-page.component';

describe('ShowPageComponent', () => {
let component: ShowPageComponent<DataRaw>;

const mockNotificationService = {
success: jest.fn()
};

beforeEach(() => {
component = TestBed.configureTestingModule({
providers: [
ShowPageComponent,
{provide: NotificationService, useValue: mockNotificationService}
]
}).inject(ShowPageComponent);
});
Expand All @@ -23,11 +17,6 @@ describe('ShowPageComponent', () => {
expect(component).toBeTruthy();
});

it('should call a notification success on copy', () => {
component.onCopiedTaskId();
expect(mockNotificationService.success).toHaveBeenCalledWith('Task ID copied to clipboard');
});

it('should emit on refresh', () => {
const refreshSpy = jest.spyOn(component.refresh, 'emit');
component.onRefresh();
Expand Down
45 changes: 19 additions & 26 deletions src/app/components/show-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ClipboardModule } from '@angular/cdk/clipboard';
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { TaskOptions } from '@app/tasks/types';
import { Field } from '@app/types/column.type';
import { ShowActionButton } from '@app/types/components/show';
import { DataRaw } from '@app/types/data';
import { NotificationService } from '@services/notification.service';
import { PageHeaderComponent } from './page-header.component';
import { InspectionCardComponent } from './inspection/inspection-card.component';
import { InspectionListGridComponent } from './inspection/inspection-list-grid.component';
import { InspectionHeaderComponent } from './inspection-header.component';
import { InspectionToolbarComponent } from './inspection-toolbar.component';
import { ShowActionsComponent } from './show-actions.component';
import { ShowCardComponent } from './show-card.component';

Expand All @@ -20,33 +19,27 @@ span {
}
`],
standalone: true,
providers: [
NotificationService,
MatSnackBar
],
imports: [
PageHeaderComponent,
ShowCardComponent,
ShowActionsComponent,
CommonModule,
MatIconModule,
ClipboardModule,
MatButtonModule
]
InspectionCardComponent,
InspectionHeaderComponent,
InspectionListGridComponent,
InspectionToolbarComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ShowPageComponent<T extends DataRaw>{
export class ShowPageComponent<T extends DataRaw, O extends TaskOptions | null = null>{
@Input({ required: true }) id: string | null = null;
@Input({required: true }) data: T | null;
@Input() statuses: Record<number, string> = [];
@Input() sharableURL: string | null = null;
@Input({ required: true }) actionsButton: ShowActionButton[];
@Input({ required: false }) actionsButton: ShowActionButton[];
@Output() refresh = new EventEmitter<never>();

#notificationService = inject(NotificationService);

onCopiedTaskId() {
this.#notificationService.success('Task ID copied to clipboard');
}
@Input({ required: false }) arrays: Field<T>[];
@Input({ required: false }) status: string | undefined;
@Input({ required: false }) fields: Field<T>[];
@Input({ required: false }) optionsFields: Field<O>[];

onRefresh() {
this.refresh.emit();
Expand Down
3 changes: 2 additions & 1 deletion src/app/partitions/show.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import { PartitionRaw } from './types';
TableStorageService,
NotificationService,
MatSnackBar,
FiltersService
FiltersService,
PartitionsInspectionService,
],
imports: [
ShowPageComponent,
Expand Down
6 changes: 3 additions & 3 deletions src/app/sessions/services/sessions-filters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SessionsFiltersService implements FiltersServiceOptionsInterface<Se
[SessionRawEnumField.SESSION_RAW_ENUM_FIELD_WORKER_SUBMISSION]: $localize`Worker Submission`,
};

readonly optionsField: Record<SessionTaskOptionEnumField, string> = {
readonly optionsFields: Record<SessionTaskOptionEnumField, string> = {
[SessionTaskOptionEnumField.TASK_OPTION_ENUM_FIELD_UNSPECIFIED]: $localize`Unspecified`,
[SessionTaskOptionEnumField.TASK_OPTION_ENUM_FIELD_MAX_DURATION]: $localize`Max Duration`,
[SessionTaskOptionEnumField.TASK_OPTION_ENUM_FIELD_MAX_RETRIES]: $localize`Max Retries`,
Expand Down Expand Up @@ -171,7 +171,7 @@ export class SessionsFiltersService implements FiltersServiceOptionsInterface<Se
case 'root':
return this.rootField[filterField as SessionRawEnumField];
case 'options':
return this.optionsField[filterField as SessionTaskOptionEnumField];
return this.optionsFields[filterField as SessionTaskOptionEnumField];
default:
throw new Error(`Unknown filter type: ${filterFor} ${filterField}`);
}
Expand All @@ -189,7 +189,7 @@ export class SessionsFiltersService implements FiltersServiceOptionsInterface<Se
return { for: 'root', index: index };
}

const optionsValues = Object.values(this.optionsField);
const optionsValues = Object.values(this.optionsFields);
index = optionsValues.findIndex(value => value.toLowerCase() === filterField.toLowerCase());
return { for: 'options', index: index };
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/tasks/services/tasks-filters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TasksFiltersService implements FiltersServiceOptionsInterface<TaskS
[TaskSummaryEnumField.TASK_SUMMARY_ENUM_FIELD_PAYLOAD_ID]: $localize`Payload ID`,
};

readonly optionsField: Record<TaskOptionEnumField, string> = {
readonly optionsFields: Record<TaskOptionEnumField, string> = {
[TaskOptionEnumField.TASK_OPTION_ENUM_FIELD_UNSPECIFIED]: $localize`Unspecified`,
[TaskOptionEnumField.TASK_OPTION_ENUM_FIELD_MAX_DURATION]: $localize`Max Duration`,
[TaskOptionEnumField.TASK_OPTION_ENUM_FIELD_MAX_RETRIES]: $localize`Max Retries`,
Expand Down Expand Up @@ -211,7 +211,7 @@ export class TasksFiltersService implements FiltersServiceOptionsInterface<TaskS
case 'root':
return this.rootField[filterField as TaskSummaryEnumField];
case 'options':
return this.optionsField[filterField as TaskOptionEnumField];
return this.optionsFields[filterField as TaskOptionEnumField];
default:
throw new Error(`Unknown filter type: ${filterFor} ${filterField}`);
}
Expand All @@ -229,7 +229,7 @@ export class TasksFiltersService implements FiltersServiceOptionsInterface<TaskS
return { for: 'root', index: index };
}

const optionsValues = Object.values(this.optionsField);
const optionsValues = Object.values(this.optionsFields);
index = optionsValues.findIndex(value => value.toLowerCase() === filterField.toLowerCase());
return { for: 'options', index: index };
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/types/services/filtersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface FiltersServiceInterface<F extends FiltersEnums, O extends Filte
}

export interface FiltersServiceOptionsInterface<F extends FiltersEnums, O extends NonNullable<FiltersOptionsEnums>> extends FiltersServiceInterface<F, O> {
readonly optionsField: Record<O, string>;
readonly optionsFields: Record<O, string>;
}

export interface FiltersServiceStatusesInterface {
Expand Down

1 comment on commit 1ff0ff7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 99%
99.79% (4411/4420) 100% (846/846) 99.58% (1186/1191)

JUnit

Tests Skipped Failures Errors Time
1644 0 💤 0 ❌ 0 🔥 1m 17s ⏱️
Files coverage (99%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files99.7910099.5899.8 
applications100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
applications/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
applications/services100100100100 
   applications-filters.service.ts100100100100 
   applications-grpc.service.ts100100100100 
   applications-index.service.ts100100100100 
components99.6510098.8199.61 
   actions-toolbar-group.component.ts100100100100 
   actions-toolbar.component.ts100100100100 
   auto-complete.component.html100100100100 
   auto-complete.component.ts100100100100 
   auto-refresh-button.component.html100100100100 
   auto-refresh-button.component.ts100100100100 
   auto-refresh-dialog.component.html100100100100 
   auto-refresh-dialog.component.ts100100100100 
   columns-button.component.ts951008094.7342
   columns-modify-dialog.component.html100100100100 
   columns-modify-dialog.component.ts100100100100 
   count-tasks-by-status.component.ts100100100100 
   icon-picker-dialog.component.html100100100100 
   icon-picker-dialog.component.ts100100100100 
   inspect-list.component.html100100100100 
   inspect-list.component.ts100100100100 
   inspection-header.component.html100100100100 
   inspection-header.component.ts100100100100 
   inspection-toolbar.component.html100100100100 
   inspection-toolbar.component.ts100100100100 
   manage-custom-dialog.component.html100100100100 
   manage-custom-dialog.component.ts100100100100 
   page-header.component.html100100100100 
   page-header.component.ts100100100100 
   page-section-header.component.ts100100100100 
   page-section.component.ts100100100100 
   refresh-button.component.ts92.31007591.6632
   share-url.component.ts100100100100 
   show-action-area.component.html100100100100 
   show-action-area.component.ts100100100100 
   show-actions.component.html100100100100 
   show-actions.component.ts100100100100 
   show-card-content.component.html100100100100 
   show-card-content.component.ts100100100100 
   show-card.component.html100100100100 
   show-card.component.ts100100100100 
   show-page.component.html100100100100 
   show-page.component.ts100100100100 
   spinner.component.ts100100100100 
   table-actions-toolbar.component.html100100100100 
   table-actions-toolbar.component.ts100100100100 
   table-container.component.ts100100100100 
   table-dashboard-actions-toolbar.component.html100100100100 
   table-dashboard-actions-toolbar.component.ts100100100100 
   table-index-actions-toolbar.component.html100100100100 
   table-index-actions-toolbar.component.ts100100100100 
   view-tasks-by-status.component.ts100100100100 
components/filters100100100100 
   filters-chips.component.html100100100100 
   filters-chips.component.ts100100100100 
   filters-dialog-and.component.html100100100100 
   filters-dialog-and.component.ts100100100100 
   filters-dialog-filter-field.component.html100100100100 
   filters-dialog-filter-field.component.ts100100100100 
   filters-dialog-input.component.html100100100100 
   filters-dialog-input.component.ts100100100100 
   filters-dialog-or.component.html100100100100 
   filters-dialog-or.component.ts100100100100 
   filters-dialog.component.html100100100100 
   filters-dialog.component.ts100100100100 
   filters-toolbar.component.html100100100100 
   filters-toolbar.component.ts100100100100 
components/inspection100100100100 
   field-content.component.html100100100100 
   field-content.component.ts100100100100 
   inspection-card.component.html100100100100 
   inspection-card.component.ts100100100100 
   inspection-list-grid.component.html100100100100 
   inspection-list-grid.component.ts100100100100 
   inspection-object.component.html100100100100 
   inspection-object.component.ts100100100100 
   inspection.component.html100100100100 
   inspection.component.ts100100100100 
components/navigation100100100100 
   add-external-service-dialog.component.html100100100100 
   add-external-service-dialog.component.ts100100100100 
   change-language-button.component.html100100100100 
   change-language-button.component.ts100100100100 
   edit-external-service-dialog.component.html100100100100 
   edit-external-service-dialog.component.ts100100100100 
   external-services.component.html100100100100 
   external-services.component.ts100100100100 
   form-external-service.component.html100100100100 
   form-external-service.component.ts100100100100 
   manage-external-services-dialog.component.html100100100100 
   manage-external-services-dialog.component.ts100100100100 
   navigation.component.html100100100100 
   navigation.component.ts100100100100 
   theme-selector.component.html100100100100 
   theme-selector.component.ts100100100100 
components/statuses100100100100 
   add-statuses-group-dialog.component.ts100100100100 
   edit-status-group-dialog.component.ts100100100100 
   form-statuses-group.component.html100100100100 
   form-statuses-group.component.ts100100100100 
   manage-groups-dialog.component.html100100100100 
   manage-groups-dialog.component.ts100100100100 
components/table100100100100 
   table-actions.component.html100100100100 
   table-actions.component.ts100100100100 
   table-cell.component.html100100100100 
   table-cell.component.ts100100100100 
   table-column-header.component.html100100100100 
   table-column-header.component.ts100100100100 
   table-empty-data.component.ts100100100100 
   table-inspect-object-dialog.component.html100100100100 
   table-inspect-object-dialog.component.ts100100100100 
   table-inspect-object.component.html100100100100 
   table-inspect-object.component.ts100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
dashboard100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
dashboard/components100100100100 
   add-line-dialog.component.html100100100100 
   add-line-dialog.component.ts100100100100 
   edit-name-line-dialog.component.html100100100100 
   edit-name-line-dialog.component.ts100100100100 
   reorganize-lines-dialog.component.html100100100100 
   reorganize-lines-dialog.component.ts100100100100 
   split-lines-dialog.component.ts100100100100 
   statuses-group-card.component.html100100100100 
   statuses-group-card.component.ts100100100100 
dashboard/components/lines100100100100 
   applications-line.component.html100100100100 
   applications-line.component.ts100100100100 
   partitions-line.component.html100100100100 
   partitions-line.component.ts100100100100 
   results-line.component.html100100100100 
   results-line.component.ts100100100100 
   sessions-line.component.html100100100100 
   sessions-line.component.ts100100100100 
   task-by-status-line.component.html100100100100 
   task-by-status-line.component.ts100100100100 
   tasks-line.component.html100100100100 
   tasks-line.component.ts100100100100 
dashboard/services100100100100 
   dashboard-index.service.ts100100100100 
   dashboard-storage.service.ts100100100100 
healthcheck100100100100 
   healthcheck.component.html100100100100 
   healthcheck.component.ts100100100100 
healthcheck/services100100100100 
   healthcheck-grpc.service.ts100100100100 
partitions100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.ts100100100100 
partitions/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
partitions/services100100100100 
   partitions-filters.service.ts100100100100 
   partitions-grpc.service.ts100100100100 
   partitions-index.service.ts100100100100 
   partitions-inspection.service.ts100100100100 
pipes100100100100 
   duration.pipe.ts100100100100 
   empty-cell.pipe.ts100100100100 
   pretty.pipe.ts100100100100 
profile100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   types.ts100100100100 
results100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.ts100100100100 
results/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
results/services100100100100 
   results-filters.service.ts100100100100 
   results-grpc.service.ts100100100100 
   results-index.service.ts100100100100 
   results-inspection.service.ts100100100100 
   results-statuses.service.ts100100100100 
services100100100100 
   auto-refresh.service.ts100100100100 
   cache.service.ts100100100100 
   default-config.service.ts100100100100 
   environment.service.ts100100100100 
   filters.service.ts100100100100 
   grpc-build-request.service.ts100100100100 
   grpc-sort-field.service.ts100100100100 
   icons.service.ts100100100100 
   navigation.service.ts100100100100 
   notification.service.ts100100100100 
   query-params.service.ts100100100100 
   share-url.service.ts100100100100 
   storage.service.ts100100100100 
   table-storage.service.ts100100100100 
   table-url.service.ts100100100100 
   table.service.ts100100100100 
   tasks-by-status.service.ts100100100100 
   user-grpc.service.ts100100100100 
   user.service.ts100100100100 
   utils.service.ts100100100100 
   versions-grpc.service.ts100100100100 
   versions.service.ts100100100100 
sessions100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.ts100100100100 
sessions/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
sessions/services100100100100 
   sessions-filters.service.ts100100100100 
   sessions-grpc.service.ts100100100100 
   sessions-index.service.ts100100100100 
   sessions-inspection.service.ts100100100100 
   sessions-statuses.service.ts100100100100 
tasks100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.ts100100100100 
tasks/components100100100100 
   manage-view-in-logs-dialog.component.html100100100100 
   manage-view-in-logs-dialog.component.ts100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
tasks/services100100100100 
   tasks-filters.service.ts100100100100 
   tasks-grpc.service.ts100100100100 
   tasks-index.service.ts100100100100 
   tasks-inspection.service.ts100100100100 
   tasks-statuses.service.ts100100100100 
tokens100100100100 
   filters.token.ts100100100100 
types100100100100 
   navigation.ts100100100100 
types/components98.0110097.4198.16 
   dashboard-line-table.ts100100100100 
   index.ts99.1510097.29100 
   show.ts85.7110089.4785.7159–63, 110
   table.ts100100100100 
types/services100100100100 
   grpcService.ts100100100100 
   inspectionService.ts100100100100 

Please sign in to comment.