manual bulk execution

This commit is contained in:
Patrick Haßel 2023-06-19 09:46:00 +02:00
parent 7738927be4
commit 390c44b7ef
5 changed files with 29 additions and 1 deletions

View File

@ -62,6 +62,10 @@ export class BulkService implements ISearchService {
this.api.getReturnItem("bulk/delete/" + bulk.id, _ => _, next); this.api.getReturnItem("bulk/delete/" + bulk.id, _ => _, next);
} }
run(bulk: Bulk, next?: () => void): void {
this.api.getReturnItem("bulk/run/" + bulk.id, _ => _, next);
}
setEntry(entry: BulkEntry, key: string, value: any, next: (result: BulkEntry) => void = NO_OP): void { setEntry(entry: BulkEntry, key: string, value: any, next: (result: BulkEntry) => void = NO_OP): void {
this.api.putReturnItem("BulkEntry/" + entry.id + "/set/" + key, value, next); this.api.putReturnItem("BulkEntry/" + entry.id + "/set/" + key, value, next);
} }

View File

@ -15,6 +15,10 @@
{{bulk.name}} {{bulk.name}}
</td> </td>
<td class="run" (click)="run(bulk)">
<fa-icon title="Ausführen" [icon]="faPlay"></fa-icon>
</td>
<td class="delete" (click)="delete(bulk)"> <td class="delete" (click)="delete(bulk)">
<fa-icon title="Löschen" [icon]="faTimes"></fa-icon> <fa-icon title="Löschen" [icon]="faTimes"></fa-icon>
</td> </td>

View File

@ -1,7 +1,7 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {BulkService} from "../../../api/bulk/BulkService"; import {BulkService} from "../../../api/bulk/BulkService";
import {Bulk} from "../../../api/bulk/Bulk"; import {Bulk} from "../../../api/bulk/Bulk";
import {faCheckCircle, faCircle, faTimesCircle} from "@fortawesome/free-regular-svg-icons"; import {faCheckCircle, faCircle, faPlayCircle, faTimesCircle} from "@fortawesome/free-regular-svg-icons";
@Component({ @Component({
selector: 'app-bulk-list', selector: 'app-bulk-list',
@ -16,6 +16,8 @@ export class BulkListComponent implements OnInit {
readonly faTimes = faTimesCircle; readonly faTimes = faTimesCircle;
readonly faPlay = faPlayCircle;
readonly Bulk = Bulk; readonly Bulk = Bulk;
bulks: Bulk[] = []; bulks: Bulk[] = [];
@ -52,6 +54,12 @@ export class BulkListComponent implements OnInit {
this.bulkService.create(bulk => this.addOrReplace(bulk)); this.bulkService.create(bulk => this.addOrReplace(bulk));
} }
run(bulk: Bulk): void {
if (confirm("Zeitplan \"" + bulk.name + "\" wirklich ausführen?")) {
this.bulkService.run(bulk);
}
}
delete(bulk: Bulk): void { delete(bulk: Bulk): void {
if (confirm("Zeitplan \"" + bulk.name + "\" wirklich löschen?")) { if (confirm("Zeitplan \"" + bulk.name + "\" wirklich löschen?")) {
this.bulkService.delete(bulk, () => this.remove(bulk)); this.bulkService.delete(bulk, () => this.remove(bulk));

View File

@ -32,6 +32,11 @@ public class BulkController implements ISearchController {
bulkWriter.delete(id); bulkWriter.delete(id);
} }
@GetMapping("run/{id}")
public void run(@PathVariable final long id) {
bulkWriter.run(id);
}
@PostMapping("set/{id}/name") @PostMapping("set/{id}/name")
public BulkDto name(@PathVariable final long id, @RequestBody final String name) { public BulkDto name(@PathVariable final long id, @RequestBody final String name) {
return bulkWriter.set(id, bulk -> bulk.setName(name)); return bulkWriter.set(id, bulk -> bulk.setName(name));

View File

@ -19,6 +19,8 @@ public class BulkWriter {
private final BulkMapper bulkMapper; private final BulkMapper bulkMapper;
private final BulkExecutor bulkExecutor;
public Bulk create(final BulkCreateDto dto) { public Bulk create(final BulkCreateDto dto) {
final Bulk bulk = bulkRepository.save(new Bulk(dto)); final Bulk bulk = bulkRepository.save(new Bulk(dto));
log.info("Bulk created: {}", bulk); log.info("Bulk created: {}", bulk);
@ -31,6 +33,11 @@ public class BulkWriter {
log.info("Bulk deleted: {}", bulk); log.info("Bulk deleted: {}", bulk);
} }
public void run(final long id) {
final Bulk bulk = bulkReader.getById(id);
bulkExecutor.execute(bulk);
}
public BulkDto set(final long id, final Consumer<Bulk> consumer) { public BulkDto set(final long id, final Consumer<Bulk> consumer) {
final Bulk bulk = bulkReader.getById(id); final Bulk bulk = bulkReader.getById(id);
consumer.accept(bulk); consumer.accept(bulk);