Skip to content

Commit

Permalink
Create automatic distribution behavior (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
benn02 authored Apr 18, 2023
1 parent 95d5597 commit f17d69f
Show file tree
Hide file tree
Showing 21 changed files with 1,047 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project does **not** adhere to [Semantic Versioning](https://semver.org
- There is now a display for whether a patient is pregnant.
- The patient status display that visualizes the progression of a patient explains its icons via a tooltip.
- There is now a behavior that answers vehicle requests from other regions.
- There is now a behavior that automatically distributes vehicles to regions.
- The types and optional limits of the distribution can be specified
- The behavior distributes the vehicles in rounds of one vehicle per category for every region every 60 seconds
- There is now a behavior to forward requests to other simulated regions or the trainees.
- There is now a radiogram for missing transfer connections and vehicle requests.
- Radiograms for vehicle requests can also be answered in the user interface, whether they have been accepted or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@ng-bootstrap/ng-bootstrap';
import { MessagesModule } from 'src/app/feature/messages/messages.module';
import { SharedModule } from 'src/app/shared/shared.module';
import { SimulatedRegionOverviewModule } from '../simulated-region-overview/simulated-region-overview.module';
import { TransferPointOverviewModule } from '../transfer-point-overview/transfer-point-overview.module';
import { SimulatedRegionOverviewModule } from '../simulated-region-overview/simulated-region-overview.module';
import { ExerciseMapComponent } from './exercise-map.component';
import { ChooseTransferTargetPopupComponent } from './shared/choose-transfer-target-popup/choose-transfer-target-popup.component';
import { MapImagePopupComponent } from './shared/map-image-popup/map-image-popup.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { RadigoramCardContentMissingTransferConnectionComponent } from './radiog
import { SimulatedRegionOverviewBehaviorProvidePersonnelComponent } from './tabs/behavior-tab/behaviors/provide-personnel/simulated-region-overview-behavior-provide-personnel.component';
import { SimulatedRegionOverviewBehaviorAnswerVehicleRequestsComponent } from './tabs/behavior-tab/behaviors/answer-vehicle-requests/simulated-region-overview-behavior-answer-vehicle-requests.component';
import { RadigoramCardContentResourceRequestComponent } from './radiogram-list/radiogram-card/radigoram-card-content-resource-request/radigoram-card-content-resource-request.component';
import { SimulatedRegionOverviewBehaviorAutomaticallyDistributeVehiclesComponent } from './tabs/behavior-tab/behaviors/automatically-distribute-vehicles/simulated-region-overview-behavior-automatically-distribute-vehicles.component';
import { RequestVehiclesComponent } from './tabs/behavior-tab/behaviors/request-vehicles/simulated-region-overview-behavior-request-vehicles.component';

@NgModule({
Expand Down Expand Up @@ -78,12 +79,13 @@ import { RequestVehiclesComponent } from './tabs/behavior-tab/behaviors/request-
SimulatedRegionOverviewBehaviorProvidePersonnelComponent,
SimulatedRegionOverviewBehaviorAnswerVehicleRequestsComponent,
RadigoramCardContentResourceRequestComponent,
SimulatedRegionOverviewBehaviorAutomaticallyDistributeVehiclesComponent,
RequestVehiclesComponent,
],
imports: [
CommonModule,
FormsModule,
SharedModule,
CommonModule,
NgbNavModule,
NgbCollapseModule,
NgbDropdownModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<ng-container
*ngIf="
automaticallyDistributeVehiclesBehaviorState$
| async as automaticallyDistributeVehiclesBehaviorState
"
>
<h4>Automatische Verteilung von Fahrzeugen</h4>

<h5>Zu Verteilende Fahrzeuge</h5>

<div
ngbDropdown
*ngIf="addableVehicleTypes$ | async as addableVehicleTypes"
placement="bottom-start"
autoClose="outside"
class="d-inline-block overflow-visible text-center m-3"
>
<button
ngbDropdownToggle
type="button"
class="btn btn-outline-primary"
[disabled]="addableVehicleTypes.length === 0"
>
<span class="bi-plus me-1"></span>
Weiteres Fahrzeug verteilen
</button>
<div *ngIf="addableVehicleTypes.length" ngbDropdownMenu>
<button
*ngFor="let addableType of addableVehicleTypes"
ngbDropdownItem
(click)="addVehicle(addableType)"
class="dropdown-item"
>
<span class="bi-plus me-1"></span>
{{ addableType }}
</button>
</div>
</div>

<ng-container *ngIf="distributionLimits$ | async as distributionLimits">
<table class="w-100 table" *ngIf="distributionLimits.length > 0">
<thead>
<tr>
<th style="width: 50%">Fahrzeug</th>
<th style="width: 10%">Limit</th>
<th style="min-width: 60pt"></th>
<th style="width: 10%">Verteilt</th>
<th style="width: 10%"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let vehicleLimit of distributionLimits">
<td>{{ vehicleLimit.vehicleType }}</td>
<td>
<div class="form-check form-switch">
<input
[ngModel]="
vehicleLimit.vehicleAmount !== infinity
"
(ngModelChange)="
$event
? limitedLimitOfVehicle(
vehicleLimit.vehicleType,
automaticallyDistributeVehiclesBehaviorState
.distributedRounds[
vehicleLimit.vehicleType
]
? automaticallyDistributeVehiclesBehaviorState
.distributedRounds[
vehicleLimit.vehicleType
] ?? 1
: 1
)
: unlimitedLimitOfVehicle(
vehicleLimit.vehicleType
)
"
type="checkbox"
role="switch"
class="form-check-input"
title="Limit aktivieren"
/>
</div>
</td>
<td>
<div
*ngIf="vehicleLimit.vehicleAmount !== infinity"
[title]="
'Wie viele Runden ' +
vehicleLimit.vehicleType +
' verteilt werden soll.'
"
class="input-group input-group-sm float-start"
style="max-width: 75pt"
>
<input
#timeInput="ngModel"
[ngModel]="vehicleLimit.vehicleAmount"
(appSaveOnTyping)="
changeLimitOfVehicle(
vehicleLimit.vehicleType,
$event
)
"
[min]="
automaticallyDistributeVehiclesBehaviorState
.distributedRounds[
vehicleLimit.vehicleType
]
? automaticallyDistributeVehiclesBehaviorState
.distributedRounds[
vehicleLimit.vehicleType
] ?? 1
: 1
"
required
step="1"
type="number"
class="form-control form-control-sm d-inline-block no-validation"
data-cy="alarmGroupVehicleDelayInput"
/>
</div>
</td>
<td>
{{
automaticallyDistributeVehiclesBehaviorState
.distributedRounds[vehicleLimit.vehicleType] ??
0
}}
</td>
<td>
<button
type="button"
class="btn btn-outline-danger float-end"
(click)="removeVehicle(vehicleLimit.vehicleType)"
>
<span class="bi-trash"></span>
</button>
</td>
</tr>
</tbody>
</table>
</ng-container>

<h5>Fahrzeuge Erhaltende Bereiche</h5>

<div
*ngIf="addableTransferPoints$ | async | values as addableTransferPoints"
ngbDropdown
placement="bottom-start"
autoClose="outside"
class="d-inline-block overflow-visible text-center m-3"
>
<button
ngbDropdownToggle
type="button"
class="btn btn-outline-primary"
[disabled]="addableTransferPoints.length === 0"
>
<span class="bi-plus me-1"></span>
Ziel hinzufügen
</button>
<div *ngIf="addableTransferPoints.length" ngbDropdownMenu>
<button
*ngFor="
let transferPoint of addableTransferPoints
| orderBy : getTransferPointOrderByValue;
trackBy: 'id' | appTrackByProperty
"
ngbDropdownItem
(click)="addDistributionDestination(transferPoint.id)"
>
<span class="bi-plus me-1"></span>
<app-transfer-point-name
[transferPointId]="transferPoint.id"
></app-transfer-point-name>
</button>
</div>
</div>
<ng-container
*ngIf="distributionDestinations$ | async as distributionDestinations"
>
<table class="w-100 table" *ngIf="distributionDestinations.length > 0">
<thead>
<tr>
<th class="w-50">Ziel</th>
<th class="w-auto"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let destination of distributionDestinations">
<td>{{ destination.name }}</td>

<td>
<button
type="button"
class="btn btn-outline-danger float-end"
(click)="
removeDistributionDestination(destination.id)
"
>
<span class="bi-trash"></span>
</button>
</td>
</tr>
</tbody>
</table>
</ng-container>
</ng-container>
Loading

0 comments on commit f17d69f

Please sign in to comment.