Skip to content

Commit

Permalink
feat(simulator-ui): scenario execution filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Nov 16, 2023
1 parent 3d5f85e commit 3303611
Show file tree
Hide file tree
Showing 37 changed files with 547 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h2 data-cy="messageHeaderDetailsHeading">
</dd>
</dl>

<button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<button type="button" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<td class="text-end">
<div class="btn-group">
<button
type="submit"
type="button"
[routerLink]="['/message-header', messageHeader.headerId, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class MessageHeaderTableComponent implements OnInit {

ngOnInit(): void {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-ignore: string-property identifier
this.messageHeaders?.sort((a: IMessageHeader, b: IMessageHeader) => (a[this.predicate] as number) - b[this.predicate]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 id="page-heading" data-cy="MessageHeaderHeading">

<app-alert></app-alert>

<app-filter [filters]="filters"></app-filter>
<app-filter [filters]="displayFilters"></app-filter>

<div class="alert alert-warning" id="no-result" *ngIf="messageHeaders?.length === 0">
<span jhiTranslate="citrusSimulatorApp.messageHeader.home.notFound">No Message Headers found</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { combineLatest, Observable, switchMap, tap } from 'rxjs';
import { ASC, DESC, SORT, DEFAULT_SORT_DATA } from 'app/config/navigation.constants';
import { ITEMS_PER_PAGE, PAGE_HEADER, TOTAL_COUNT_RESPONSE_HEADER } from 'app/config/pagination.constants';
import SharedModule from 'app/shared/shared.module';
import { formatDateTimeFilterOptions } from 'app/shared/date/format-date-time-filter-options';
import { FilterComponent, FilterOptions, IFilterOptions, IFilterOption } from 'app/shared/filter';
import { ItemCountComponent } from 'app/shared/pagination';

Expand All @@ -29,12 +30,14 @@ export class MessageHeaderComponent implements OnInit {
predicate = 'headerId';
ascending = true;

filters: IFilterOptions = new FilterOptions();
displayFilters: IFilterOptions = new FilterOptions();

itemsPerPage = ITEMS_PER_PAGE;
totalItems = 0;
page = 1;

private filters: IFilterOptions = new FilterOptions();

constructor(
private ngZone: NgZone,
protected messageHeaderService: MessageHeaderService,
Expand Down Expand Up @@ -81,6 +84,7 @@ export class MessageHeaderComponent implements OnInit {
this.predicate = sort[0];
this.ascending = sort[1] === ASC;
this.filters.initializeFromParams(params);
this.displayFilters = formatDateTimeFilterOptions(this.filters);
}

protected onResponseSuccess(response: EntityArrayResponseType): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3 data-cy="messageDetailsHeading"><span jhiTranslate="citrusSimulatorApp.messa

<app-message-header-table [messageHeaders]="message.headers ?? []" [fullDetails]="false" predicate="name"></app-message-header-table>

<button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<button type="button" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 id="page-heading" data-cy="MessageHeading">

<app-alert></app-alert>

<app-filter [filters]="filters"></app-filter>
<app-filter [filters]="displayFilters"></app-filter>

<div class="alert alert-warning" id="no-result" *ngIf="messages?.length === 0">
<span jhiTranslate="citrusSimulatorApp.message.home.notFound">No Messages found</span>
Expand Down Expand Up @@ -87,7 +87,7 @@ <h2 id="page-heading" data-cy="MessageHeading">
<td class="text-end">
<div class="btn-group">
<button
type="submit"
type="button"
[routerLink]="['/message-header']"
[queryParams]="{ 'filter[messageId.in]': message.messageId }"
class="btn btn-info btn-sm"
Expand All @@ -102,7 +102,7 @@ <h2 id="page-heading" data-cy="MessageHeading">
>
</button>
<button
type="submit"
type="button"
[routerLink]="['/message', message.messageId, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { FormsModule } from '@angular/forms';

import { ITEMS_PER_PAGE, PAGE_HEADER, TOTAL_COUNT_RESPONSE_HEADER } from 'app/config/pagination.constants';
import { ASC, DESC, SORT, DEFAULT_SORT_DATA } from 'app/config/navigation.constants';
import { formatDateTimeFilterOptions } from 'app/shared/date/format-date-time-filter-options';
import { FilterComponent, FilterOptions, IFilterOptions, IFilterOption } from 'app/shared/filter';

import { EntityArrayResponseType, MessageService } from '../service/message.service';
import { IMessage } from '../message.model';

Expand All @@ -38,12 +40,15 @@ export class MessageComponent implements OnInit {

predicate = 'messageId';
ascending = true;
filters: IFilterOptions = new FilterOptions();

displayFilters: IFilterOptions = new FilterOptions();

itemsPerPage = ITEMS_PER_PAGE;
totalItems = 0;
page = 1;

private filters: IFilterOptions = new FilterOptions();

constructor(
private ngZone: NgZone,
protected messageService: MessageService,
Expand Down Expand Up @@ -89,6 +94,7 @@ export class MessageComponent implements OnInit {
this.predicate = sort[0];
this.ascending = sort[1] === ASC;
this.filters.initializeFromParams(params);
this.displayFilters = formatDateTimeFilterOptions(this.filters);
}

protected onResponseSuccess(response: EntityArrayResponseType): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 id="page-heading" data-cy="ScenarioActionHeading">

<app-alert></app-alert>

<app-filter [filters]="filters"></app-filter>
<app-filter [filters]="displayFilters"></app-filter>

<div class="alert alert-warning" id="no-result" *ngIf="scenarioActions?.length === 0">
<span jhiTranslate="citrusSimulatorApp.scenarioAction.home.notFound">No Scenario Actions found</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FormsModule } from '@angular/forms';

import { ITEMS_PER_PAGE, PAGE_HEADER, TOTAL_COUNT_RESPONSE_HEADER } from 'app/config/pagination.constants';
import { ASC, DESC, SORT, DEFAULT_SORT_DATA } from 'app/config/navigation.constants';
import { formatDateTimeFilterOptions } from 'app/shared/date/format-date-time-filter-options';
import { FilterComponent, FilterOptions, IFilterOptions, IFilterOption } from 'app/shared/filter';
import { EntityArrayResponseType, ScenarioActionService } from '../service/scenario-action.service';
import { IScenarioAction } from '../scenario-action.model';
Expand Down Expand Up @@ -38,12 +39,15 @@ export class ScenarioActionComponent implements OnInit {

predicate = 'actionId';
ascending = true;
filters: IFilterOptions = new FilterOptions();

displayFilters: IFilterOptions = new FilterOptions();

itemsPerPage = ITEMS_PER_PAGE;
totalItems = 0;
page = 1;

private filters: IFilterOptions = new FilterOptions();

constructor(
private ngZone: NgZone,
protected scenarioActionService: ScenarioActionService,
Expand Down Expand Up @@ -89,6 +93,7 @@ export class ScenarioActionComponent implements OnInit {
this.predicate = sort[0];
this.ascending = sort[1] === ASC;
this.filters.initializeFromParams(params);
this.displayFilters = formatDateTimeFilterOptions(this.filters);
}

protected onResponseSuccess(response: EntityArrayResponseType): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ export class ScenarioActionService {
return scenarioActionCollection;
}

protected convertDateFromClient<T extends IScenarioAction | NewScenarioAction>(scenarioAction: T): RestOf<T> {
return {
...scenarioAction,
startDate: scenarioAction.startDate?.toJSON() ?? null,
endDate: scenarioAction.endDate?.toJSON() ?? null,
};
}

protected convertDateFromServer(restScenarioAction: RestScenarioAction): IScenarioAction {
return {
...restScenarioAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h2 data-cy="scenarioExecutionDetailsHeading">
</dd>
</dl>

<button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<button type="button" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<h2 id="page-heading" data-cy="ScenarioExecutionHeading">
<h2 id="page-heading" data-cy="ScenarioExecutionHeading" *ngIf="!hideTitle">
<span jhiTranslate="citrusSimulatorApp.scenarioExecution.home.title">Scenario Executions</span>

<div class="d-flex justify-content-end">
Expand All @@ -14,7 +14,7 @@ <h2 id="page-heading" data-cy="ScenarioExecutionHeading">

<app-alert></app-alert>

<app-filter [filters]="filters"></app-filter>
<app-filter [filters]="displayFilters"></app-filter>

<div class="alert alert-warning" id="no-result" *ngIf="scenarioExecutions?.length === 0">
<span jhiTranslate="citrusSimulatorApp.scenarioExecution.home.notFound">No Scenario Executions found</span>
Expand Down Expand Up @@ -80,7 +80,7 @@ <h2 id="page-heading" data-cy="ScenarioExecutionHeading">
<td class="text-end">
<div class="btn-group">
<button
type="submit"
type="button"
[routerLink]="['/scenario-action']"
[queryParams]="{ 'filter[scenarioExecutionId.in]': scenarioExecution.executionId }"
class="btn btn-info btn-sm"
Expand All @@ -95,7 +95,7 @@ <h2 id="page-heading" data-cy="ScenarioExecutionHeading">
>
</button>
<button
type="submit"
type="button"
[routerLink]="['/message']"
[queryParams]="{ 'filter[scenarioExecutionId.in]': scenarioExecution.executionId }"
class="btn btn-info btn-sm"
Expand All @@ -110,7 +110,7 @@ <h2 id="page-heading" data-cy="ScenarioExecutionHeading">
>
</button>
<button
type="submit"
type="button"
[routerLink]="['/scenario-parameter']"
[queryParams]="{ 'filter[scenarioExecutionId.in]': scenarioExecution.executionId }"
class="btn btn-info btn-sm"
Expand All @@ -125,7 +125,7 @@ <h2 id="page-heading" data-cy="ScenarioExecutionHeading">
>
</button>
<button
type="submit"
type="button"
[routerLink]="['/scenario-execution', scenarioExecution.executionId, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, NgZone, OnInit } from '@angular/core';
import { Component, Input, NgZone, OnInit } from '@angular/core';
import { HttpHeaders } from '@angular/common/http';
import { ActivatedRoute, Data, ParamMap, Router, RouterModule } from '@angular/router';
import { combineLatest, Observable, switchMap, tap } from 'rxjs';
Expand All @@ -11,7 +11,9 @@ import { FormsModule } from '@angular/forms';

import { ITEMS_PER_PAGE, PAGE_HEADER, TOTAL_COUNT_RESPONSE_HEADER } from 'app/config/pagination.constants';
import { ASC, DESC, SORT, DEFAULT_SORT_DATA } from 'app/config/navigation.constants';
import { formatDateTimeFilterOptions } from 'app/shared/date/format-date-time-filter-options';
import { FilterComponent, FilterOptions, IFilterOptions, IFilterOption } from 'app/shared/filter';

import { EntityArrayResponseType, ScenarioExecutionService } from '../service/scenario-execution.service';
import { IScenarioExecution, IScenarioExecutionStatus } from '../scenario-execution.model';

Expand All @@ -33,17 +35,22 @@ import { IScenarioExecution, IScenarioExecutionStatus } from '../scenario-execut
],
})
export class ScenarioExecutionComponent implements OnInit {
@Input() hideTitle = false;

scenarioExecutions?: IScenarioExecution[];
isLoading = false;

predicate = 'executionId';
ascending = true;
filters: IFilterOptions = new FilterOptions();

displayFilters: IFilterOptions = new FilterOptions();

itemsPerPage = ITEMS_PER_PAGE;
totalItems = 0;
page = 1;

private filters: IFilterOptions = new FilterOptions();

constructor(
private ngZone: NgZone,
protected scenarioExecutionService: ScenarioExecutionService,
Expand Down Expand Up @@ -89,6 +96,7 @@ export class ScenarioExecutionComponent implements OnInit {
this.predicate = sort[0];
this.ascending = sort[1] === ASC;
this.filters.initializeFromParams(params);
this.displayFilters = formatDateTimeFilterOptions(this.filters);
}

protected onResponseSuccess(response: EntityArrayResponseType): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
scenarioExecutionStatusFromName,
scenarioExecutionStatusFromId,
STATUS_UNKNOWN,
STATUS_RUNNING,
STATUS_SUCCESS,
STATUS_FAILED,
} from './scenario-execution.model';

describe('ScenarioExecutionStatus', () => {
describe('scenarioExecutionStatusFromName', () => {
it('should return the correct status for a valid name', () => {
expect(scenarioExecutionStatusFromName('RUNNING')).toEqual(STATUS_RUNNING);
expect(scenarioExecutionStatusFromName('SUCCESS')).toEqual(STATUS_SUCCESS);
expect(scenarioExecutionStatusFromName('FAILED')).toEqual(STATUS_FAILED);
expect(scenarioExecutionStatusFromName('UNKNOWN')).toEqual(STATUS_UNKNOWN);
});

it('should return STATUS_UNKNOWN for an invalid name', () => {
expect(scenarioExecutionStatusFromName('invalid')).toEqual(STATUS_UNKNOWN);
});
});

describe('scenarioExecutionStatusFromId', () => {
it('should return the correct status for a valid id', () => {
expect(scenarioExecutionStatusFromId(1)).toEqual(STATUS_RUNNING);
expect(scenarioExecutionStatusFromId(2)).toEqual(STATUS_SUCCESS);
expect(scenarioExecutionStatusFromId(3)).toEqual(STATUS_FAILED);
expect(scenarioExecutionStatusFromId(0)).toEqual(STATUS_UNKNOWN);
});

it('should return STATUS_UNKNOWN for an invalid id', () => {
expect(scenarioExecutionStatusFromId(99)).toEqual(STATUS_UNKNOWN);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,23 @@ export const STATUS_UNKNOWN: IScenarioExecutionStatus = { id: 0, name: 'UNKNOWN'
export const STATUS_RUNNING: IScenarioExecutionStatus = { id: 1, name: 'RUNNING' };
export const STATUS_SUCCESS: IScenarioExecutionStatus = { id: 2, name: 'SUCCESS' };
export const STATUS_FAILED: IScenarioExecutionStatus = { id: 3, name: 'FAILED' };

export const scenarioExecutionStatusFromName = (name: string): IScenarioExecutionStatus => {
for (const status of [STATUS_UNKNOWN, STATUS_RUNNING, STATUS_SUCCESS, STATUS_FAILED]) {
if (status.name === name) {
return status;
}
}

return STATUS_UNKNOWN;
};

export const scenarioExecutionStatusFromId = (id: number): IScenarioExecutionStatus => {
for (const status of [STATUS_UNKNOWN, STATUS_RUNNING, STATUS_SUCCESS, STATUS_FAILED]) {
if (status.id === id) {
return status;
}
}

return STATUS_UNKNOWN;
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 data-cy="scenarioParameterDetailsHeading">
</dd>
</dl>

<button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<button type="button" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Back</span>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 id="page-heading" data-cy="ScenarioParameterHeading">

<app-alert></app-alert>

<app-filter [filters]="filters"></app-filter>
<app-filter [filters]="displayFilters"></app-filter>

<div class="alert alert-warning" id="no-result" *ngIf="scenarioParameters?.length === 0">
<span jhiTranslate="citrusSimulatorApp.scenarioParameter.home.notFound">No Scenario Parameters found</span>
Expand Down Expand Up @@ -89,7 +89,7 @@ <h2 id="page-heading" data-cy="ScenarioParameterHeading">
<td class="text-end">
<div class="btn-group">
<button
type="submit"
type="button"
[routerLink]="['/scenario-parameter', scenarioParameter.parameterId, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
Expand Down
Loading

0 comments on commit 3303611

Please sign in to comment.