forked from citrusframework/citrus-simulator
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): scenario actions detail view
- Loading branch information
Showing
8 changed files
with
186 additions
and
4 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
.../main/webapp/app/entities/scenario-execution/detail/scenario-actions-table.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div class="table-responsive table-entities" id="entities" *ngIf="sortedActions && sortedActions.length > 0; else noParameters"> | ||
<table class="table table-striped" aria-describedby="page-heading"> | ||
<thead> | ||
<tr jhiSort [(predicate)]="predicate" [(ascending)]="ascending" (sortChange)="sortActions()"> | ||
<th scope="col" jhiSortBy="actionId"> | ||
<div class="d-flex"> | ||
<span jhiTranslate="global.field.id">ID</span> | ||
<fa-icon class="p-1" icon="sort"></fa-icon> | ||
</div> | ||
</th> | ||
<th scope="col" jhiSortBy="name"> | ||
<div class="d-flex"> | ||
<span jhiTranslate="citrusSimulatorApp.scenarioAction.name">Name</span> | ||
<fa-icon class="p-1" icon="sort"></fa-icon> | ||
</div> | ||
</th> | ||
<th scope="col" jhiSortBy="startDate"> | ||
<div class="d-flex"> | ||
<span jhiTranslate="citrusSimulatorApp.scenarioAction.startDate">Start Date</span> | ||
<fa-icon class="p-1" icon="sort"></fa-icon> | ||
</div> | ||
</th> | ||
<th scope="col" jhiSortBy="endDate"> | ||
<div class="d-flex"> | ||
<span jhiTranslate="citrusSimulatorApp.scenarioAction.endDate">End Date</span> | ||
<fa-icon class="p-1" icon="sort"></fa-icon> | ||
</div> | ||
</th> | ||
<th scope="col"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let scenarioAction of sortedActions; trackBy: trackId" data-cy="entityTable"> | ||
<td> | ||
<a [routerLink]="['/scenario-action', scenarioAction.actionId, 'view']">{{ scenarioAction.actionId }}</a> | ||
</td> | ||
<td>{{ scenarioAction.name }}</td> | ||
<td>{{ scenarioAction.startDate | formatMediumDatetime }}</td> | ||
<td>{{ scenarioAction.endDate | formatMediumDatetime }}</td> | ||
<td class="text-end"> | ||
<div class="btn-group"> | ||
<a [routerLink]="['/scenario-action', scenarioAction.actionId, 'view']"> | ||
<button type="submit" class="btn btn-info btn-sm" data-cy="entityDetailsButton"> | ||
<fa-icon icon="eye"></fa-icon> | ||
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> | ||
</button> | ||
</a> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<ng-template #noParameters> | ||
<div class="alert alert-warning" id="no-result"> | ||
<span jhiTranslate="citrusSimulatorApp.scenarioAction.home.notFound">No Scenario Actions found</span> | ||
</div> | ||
</ng-template> |
67 changes: 67 additions & 0 deletions
67
...in/webapp/app/entities/scenario-execution/detail/scenario-actions-table.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
import * as operators from 'app/core/util/operators'; | ||
|
||
import { IScenarioAction } from 'app/entities/scenario-action/scenario-action.model'; | ||
|
||
import { ScenarioActionsTableComponent } from './scenario-actions-table.component'; | ||
|
||
import SpyInstance = jest.SpyInstance; | ||
|
||
describe('Message Table Component', () => { | ||
let sortSpy: SpyInstance; | ||
|
||
let fixture: ComponentFixture<ScenarioActionsTableComponent>; | ||
let component: ScenarioActionsTableComponent; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule.withRoutes([{ path: 'message', component: ScenarioActionsTableComponent }]), | ||
HttpClientTestingModule, | ||
ScenarioActionsTableComponent, | ||
], | ||
providers: [], | ||
}) | ||
.overrideTemplate(ScenarioActionsTableComponent, '') | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ScenarioActionsTableComponent); | ||
component = fixture.componentInstance; | ||
|
||
sortSpy = jest.spyOn(operators, 'sort'); | ||
sortSpy.mockClear(); | ||
}); | ||
|
||
describe('ngOnInit', () => { | ||
it('sorts actions', () => { | ||
expectSortBeingCalled(() => component.ngOnInit()); | ||
}); | ||
}); | ||
|
||
describe('set actions', () => { | ||
it('sets the action list and calls sort', () => { | ||
const actions = [{ actionId: 1234 }] as IScenarioAction[]; | ||
|
||
component.actions = actions; | ||
|
||
expect(component.sortedActions).toEqual(actions); | ||
expect(sortSpy).toHaveBeenCalledWith(actions, 'actionId', true); | ||
}); | ||
}); | ||
|
||
it('sorts actions', () => { | ||
expectSortBeingCalled(() => component.sortActions()); | ||
}); | ||
|
||
const expectSortBeingCalled = (whenFunction: () => void): void => { | ||
const actions = [{ actionId: 1234 }] as IScenarioAction[]; | ||
component.sortedActions = actions; | ||
|
||
whenFunction(); | ||
|
||
expect(sortSpy).toHaveBeenCalledWith(actions, 'actionId', true); | ||
}; | ||
}); |
46 changes: 46 additions & 0 deletions
46
...rc/main/webapp/app/entities/scenario-execution/detail/scenario-actions-table.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
import { sort } from 'app/core/util/operators'; | ||
|
||
import SharedModule from 'app/shared/shared.module'; | ||
import { DurationPipe, FormatMediumDatePipe } from 'app/shared/date'; | ||
import FormatMediumDatetimePipe from 'app/shared/date/format-medium-datetime.pipe'; | ||
import SortDirective from 'app/shared/sort/sort.directive'; | ||
import SortByDirective from 'app/shared/sort/sort-by.directive'; | ||
|
||
import { IScenarioAction } from 'app/entities/scenario-action/scenario-action.model'; | ||
import { ScenarioActionService } from 'app/entities/scenario-action/service/scenario-action.service'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'app-scenario-actions-table', | ||
templateUrl: './scenario-actions-table.component.html', | ||
imports: [RouterModule, SharedModule, DurationPipe, FormatMediumDatetimePipe, FormatMediumDatePipe, SortDirective, SortByDirective], | ||
}) | ||
export class ScenarioActionsTableComponent implements OnInit { | ||
@Input() | ||
ascending = true; | ||
|
||
@Input() | ||
predicate = 'actionId'; | ||
|
||
sortedActions: IScenarioAction[] | null = null; | ||
|
||
constructor(protected scenarioActionService: ScenarioActionService) {} | ||
|
||
ngOnInit(): void { | ||
this.sortActions(); | ||
} | ||
|
||
@Input() set actions(actions: IScenarioAction[] | null) { | ||
this.sortedActions = actions ? actions.slice() : []; | ||
this.sortActions(); | ||
} | ||
|
||
trackId = (_index: number, item: IScenarioAction): number => this.scenarioActionService.getScenarioActionIdentifier(item); | ||
|
||
sortActions(): void { | ||
sort(this.sortedActions, this.predicate, this.ascending); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters