diff --git a/webapp/src/app/modules/jobs/jobs.component.html b/webapp/src/app/modules/jobs/jobs.component.html
index 4909b602..f1863d32 100644
--- a/webapp/src/app/modules/jobs/jobs.component.html
+++ b/webapp/src/app/modules/jobs/jobs.component.html
@@ -58,9 +58,21 @@
-
{{ row.name }}
-
{{ row.description }}
-
{{ row.target_index }}
+
+
+ {{ row.name }}
+ {{ row.description }}
+ {{ row.target_index }}
+
diff --git a/webapp/src/app/modules/jobs/jobs.component.scss b/webapp/src/app/modules/jobs/jobs.component.scss
index ca8c94e5..137b4f24 100644
--- a/webapp/src/app/modules/jobs/jobs.component.scss
+++ b/webapp/src/app/modules/jobs/jobs.component.scss
@@ -95,10 +95,50 @@ mat-paginator {
}
.task-name-cell {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 6px;
+ min-width: 220px;
+}
+
+.task-name-text {
display: flex;
flex-direction: column;
gap: 2px;
- min-width: 220px;
+}
+
+.edit-name-action {
+ flex: 0 0 auto;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 22px;
+ height: 22px;
+ padding: 0;
+ border: none;
+ background: none;
+ cursor: pointer;
+ color: #64748b;
+ opacity: 0;
+ transition: opacity 0.15s ease;
+
+ .mat-icon {
+ font-size: 18px;
+ width: 18px;
+ height: 18px;
+ line-height: 18px;
+ }
+}
+
+.task-name-cell:hover .edit-name-action,
+.edit-name-action:focus-visible {
+ opacity: 1;
+}
+
+.edit-name-action[disabled] {
+ cursor: not-allowed;
+ color: #cbd5e1;
}
.task-description {
diff --git a/webapp/src/app/modules/jobs/jobs.component.ts b/webapp/src/app/modules/jobs/jobs.component.ts
index 9a97abfb..0d0bd51b 100644
--- a/webapp/src/app/modules/jobs/jobs.component.ts
+++ b/webapp/src/app/modules/jobs/jobs.component.ts
@@ -42,6 +42,10 @@ import {
JobLogsDialogData,
} from './job-logs-dialog/job-logs-dialog.component';
import { TaskCreateDialogComponent } from './task-create-dialog/task-create-dialog.component';
+import {
+ TaskEditDialogComponent,
+ TaskEditDialogData,
+} from './task-edit-dialog/task-edit-dialog.component';
@Component({
selector: 'app-jobs',
@@ -279,6 +283,31 @@ export class JobsComponent implements OnInit {
});
}
+ protected openEditDialog(task: BackgroundJobTask): void {
+ if (['running', 'stopping'].includes(task.status)) return;
+
+ const dialogRef = this.dialog.open<
+ TaskEditDialogComponent,
+ TaskEditDialogData,
+ BackgroundJobTask | undefined
+ >(TaskEditDialogComponent, {
+ width: '560px',
+ maxWidth: 'calc(100vw - 32px)',
+ data: { task },
+ });
+
+ dialogRef.afterClosed().subscribe((updatedTask) => {
+ if (!updatedTask) return;
+
+ this.updateTask(updatedTask.id, () => updatedTask);
+ this.snackBar.open(`„${updatedTask.name}“ wurde gespeichert.`, 'OK', {
+ duration: 3000,
+ horizontalPosition: 'center',
+ verticalPosition: 'bottom',
+ });
+ });
+ }
+
protected openScheduleDialog(task: BackgroundJobTask): void {
const dialogRef = this.dialog.open<
TaskScheduleDialogComponent,
diff --git a/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.html b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.html
new file mode 100644
index 00000000..8f7d8b18
--- /dev/null
+++ b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.html
@@ -0,0 +1,91 @@
+
Job bearbeiten
+
+
+ {{ data.task.name }}
+
+
+
+ @if (serverError()) {
+ {{ serverError() }}
+ }
+
+
+
+
+
+
diff --git a/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.scss b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.scss
new file mode 100644
index 00000000..d02bdb7e
--- /dev/null
+++ b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.scss
@@ -0,0 +1,29 @@
+.edit-name {
+ margin: 0 0 16px;
+ font-weight: 600;
+ color: var(--sg-text, #101a3d);
+}
+
+.edit-form {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ min-width: 400px;
+}
+
+.field-info {
+ color: #94a3b8;
+ cursor: help;
+}
+
+.server-error {
+ margin: 8px 0 0;
+ color: #b3261e;
+ font-size: 14px;
+}
+
+@media (max-width: 640px) {
+ .edit-form {
+ min-width: 0;
+ }
+}
diff --git a/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.ts b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.ts
new file mode 100644
index 00000000..782cd05d
--- /dev/null
+++ b/webapp/src/app/modules/jobs/task-edit-dialog/task-edit-dialog.component.ts
@@ -0,0 +1,126 @@
+import { CommonModule } from '@angular/common';
+import { Component, inject, signal } from '@angular/core';
+import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
+import { MatButtonModule } from '@angular/material/button';
+import {
+ MAT_DIALOG_DATA,
+ MatDialogModule,
+ MatDialogRef,
+} from '@angular/material/dialog';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatIconModule } from '@angular/material/icon';
+import { MatInputModule } from '@angular/material/input';
+import { MatTooltipModule } from '@angular/material/tooltip';
+import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
+
+const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
+
+const DEFAULT_JOB_IMAGE = 'docker.nes.uni-due.de/inse/background-jobs:latest';
+
+export interface TaskEditDialogData {
+ task: BackgroundJobTask;
+}
+
+@Component({
+ selector: 'app-task-edit-dialog',
+ imports: [
+ CommonModule,
+ ReactiveFormsModule,
+ MatButtonModule,
+ MatDialogModule,
+ MatFormFieldModule,
+ MatIconModule,
+ MatInputModule,
+ MatTooltipModule,
+ ],
+ templateUrl: './task-edit-dialog.component.html',
+ styleUrl: './task-edit-dialog.component.scss',
+ standalone: true,
+})
+export class TaskEditDialogComponent {
+ private readonly dialogRef =
+ inject<
+ MatDialogRef
+ >(MatDialogRef);
+ private readonly backgroundJobsService = inject(BackgroundJobsService);
+ protected readonly data = inject(MAT_DIALOG_DATA);
+
+ protected readonly saving = signal(false);
+ protected readonly serverError = signal('');
+
+ protected readonly form = new FormGroup({
+ description: new FormControl(this.data.task.description, {
+ nonNullable: true,
+ }),
+ targetIndex: new FormControl(this.data.task.target_index, {
+ nonNullable: true,
+ }),
+ command: new FormControl(this.data.task.command ?? '', {
+ nonNullable: true,
+ }),
+ image: new FormControl(this.data.task.image, { nonNullable: true }),
+ env: new FormControl(this.envToText(this.data.task.env), {
+ nonNullable: true,
+ }),
+ });
+
+ protected submit(): void {
+ this.serverError.set('');
+ const value = this.form.getRawValue();
+
+ const env = this.parseEnv(value.env);
+ if (env === undefined) return;
+
+ // The default image is stored as null so the job keeps following the
+ // backend-configured image if it ever changes.
+ const image = value.image.trim();
+
+ this.saving.set(true);
+ this.backgroundJobsService
+ .updateBackgroundJobTask(this.data.task.id, {
+ description: value.description.trim(),
+ target_index: value.targetIndex.trim(),
+ image: !image || image === DEFAULT_JOB_IMAGE ? null : image,
+ command: value.command.trim() || null,
+ env,
+ })
+ .subscribe({
+ next: (task) => this.dialogRef.close(task),
+ error: (error) => {
+ this.saving.set(false);
+ const detail = error?.error?.detail;
+ this.serverError.set(
+ typeof detail === 'string'
+ ? detail
+ : 'Der Job konnte nicht gespeichert werden.',
+ );
+ },
+ });
+ }
+
+ protected close(): void {
+ this.dialogRef.close();
+ }
+
+ private envToText(env: { [key: string]: string }): string {
+ return Object.entries(env)
+ .map(([key, value]) => `${key}=${value}`)
+ .join('\n');
+ }
+
+ private parseEnv(text: string): { [key: string]: string } | undefined {
+ const env: { [key: string]: string } = {};
+ for (const line of text.split('\n')) {
+ const trimmed = line.trim();
+ if (!trimmed) continue;
+ if (!ENV_LINE_PATTERN.test(trimmed)) {
+ this.form.controls.env.setErrors({ invalidEnv: true });
+ this.form.controls.env.markAsTouched();
+ return undefined;
+ }
+ const separatorIndex = trimmed.indexOf('=');
+ env[trimmed.slice(0, separatorIndex)] = trimmed.slice(separatorIndex + 1);
+ }
+ return env;
+ }
+}