feat(jobs): select image from a Nexus autocomplete
This commit is contained in:
@@ -47,6 +47,7 @@ model/autocompleteLocationItem.ts
|
||||
model/autocompleteResponse.ts
|
||||
model/autocompleteResponseMeta.ts
|
||||
model/autocompleteResponseResultsInner.ts
|
||||
model/availableImages.ts
|
||||
model/award.ts
|
||||
model/backgroundJobTask.ts
|
||||
model/bodyChangePassword.ts
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { AvailableImages } from '../model/availableImages';
|
||||
// @ts-ignore
|
||||
import { BackgroundJobTask } from '../model/backgroundJobTask';
|
||||
// @ts-ignore
|
||||
@@ -646,6 +648,110 @@ export class BackgroundJobsService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Available Images
|
||||
* @endpoint get /api/background-jobs/available-images
|
||||
* @param secureFgpAcc
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getBackgroundJobAvailableImages(
|
||||
secureFgpAcc?: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<AvailableImages>;
|
||||
public getBackgroundJobAvailableImages(
|
||||
secureFgpAcc?: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<AvailableImages>>;
|
||||
public getBackgroundJobAvailableImages(
|
||||
secureFgpAcc?: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<AvailableImages>>;
|
||||
public getBackgroundJobAvailableImages(
|
||||
secureFgpAcc?: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<any> {
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
// authentication (HTTPBearer) required
|
||||
localVarHeaders = this.configuration.addCredentialToHeaders(
|
||||
'HTTPBearer',
|
||||
'Authorization',
|
||||
localVarHeaders,
|
||||
'Bearer ',
|
||||
);
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined =
|
||||
options?.httpHeaderAccept ??
|
||||
this.configuration.selectHeaderAccept(['application/json']);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set(
|
||||
'Accept',
|
||||
localVarHttpHeaderAcceptSelected,
|
||||
);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext =
|
||||
options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (
|
||||
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
|
||||
) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/background-jobs/available-images`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<AvailableImages>(
|
||||
'get',
|
||||
`${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined
|
||||
? { transferCache: localVarTransferCache }
|
||||
: {}),
|
||||
reportProgress: reportProgress,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker Health
|
||||
* @endpoint get /api/background-jobs/docker-health
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface AvailableImages {
|
||||
images: Array<string>;
|
||||
detail?: string;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export interface BackgroundJobTask {
|
||||
name: string;
|
||||
description: string;
|
||||
target_index: string;
|
||||
image: string;
|
||||
image: string | null;
|
||||
command: string | null;
|
||||
env: { [key: string]: string };
|
||||
schedule: string | null;
|
||||
|
||||
@@ -18,6 +18,7 @@ export * from './autocompleteLocationItem';
|
||||
export * from './autocompleteResponse';
|
||||
export * from './autocompleteResponseMeta';
|
||||
export * from './autocompleteResponseResultsInner';
|
||||
export * from './availableImages';
|
||||
export * from './award';
|
||||
export * from './backgroundJobTask';
|
||||
export * from './bodyChangePassword';
|
||||
|
||||
@@ -34,18 +34,26 @@
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Image</mat-label>
|
||||
<textarea
|
||||
<input
|
||||
matInput
|
||||
class="image-input"
|
||||
rows="1"
|
||||
formControlName="image"></textarea>
|
||||
formControlName="image"
|
||||
[matAutocomplete]="imageAuto" />
|
||||
<mat-autocomplete #imageAuto="matAutocomplete">
|
||||
@for (image of filteredImages(); track image) {
|
||||
<mat-option [value]="image">{{ image }}</mat-option>
|
||||
}
|
||||
</mat-autocomplete>
|
||||
<mat-icon
|
||||
matSuffix
|
||||
class="field-info"
|
||||
matTooltip="Vorausgefüllt ist das Standard-Image mit allen Background-Job-Skripten — im Normalfall einfach so lassen. Nur ändern, wenn der Job ein eigenes Docker-Image nutzen soll; eigene Images erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) nicht automatisch."
|
||||
matTooltip="Docker-Image für den Job. Tippen filtert die aus Nexus verfügbaren Images; du kannst auch einen eigenen Wert eingeben. Images aus unserer Registry (docker.nes.uni-due.de) erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch, fremde Images nicht."
|
||||
>info_outline</mat-icon
|
||||
>
|
||||
<mat-hint>Im Normalfall unverändert lassen.</mat-hint>
|
||||
@if (form.controls.image.invalid && form.controls.image.touched) {
|
||||
<mat-error>Bitte ein Image auswählen oder eingeben.</mat-error>
|
||||
}
|
||||
<mat-hint>Aus Nexus wählen oder eigenes Image eingeben.</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import { Component, OnInit, computed, inject, signal } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import {
|
||||
FormControl,
|
||||
FormGroup,
|
||||
ReactiveFormsModule,
|
||||
Validators,
|
||||
} from '@angular/forms';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -23,6 +25,7 @@ const DEFAULT_JOB_IMAGE = 'docker.nes.uni-due.de/inse/background-jobs:latest';
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
MatAutocompleteModule,
|
||||
MatButtonModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
@@ -34,7 +37,7 @@ const DEFAULT_JOB_IMAGE = 'docker.nes.uni-due.de/inse/background-jobs:latest';
|
||||
styleUrl: './task-create-dialog.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class TaskCreateDialogComponent {
|
||||
export class TaskCreateDialogComponent implements OnInit {
|
||||
private readonly dialogRef =
|
||||
inject<
|
||||
MatDialogRef<TaskCreateDialogComponent, BackgroundJobTask | undefined>
|
||||
@@ -43,6 +46,7 @@ export class TaskCreateDialogComponent {
|
||||
|
||||
protected readonly creating = signal(false);
|
||||
protected readonly serverError = signal('');
|
||||
protected readonly images = signal<string[]>([]);
|
||||
|
||||
protected readonly form = new FormGroup({
|
||||
name: new FormControl('', {
|
||||
@@ -52,10 +56,33 @@ export class TaskCreateDialogComponent {
|
||||
description: new FormControl('', { nonNullable: true }),
|
||||
targetIndex: new FormControl('', { nonNullable: true }),
|
||||
command: new FormControl('', { nonNullable: true }),
|
||||
image: new FormControl(DEFAULT_JOB_IMAGE, { nonNullable: true }),
|
||||
image: new FormControl(DEFAULT_JOB_IMAGE, {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
env: new FormControl('', { nonNullable: true }),
|
||||
});
|
||||
|
||||
private readonly imageQuery = toSignal(
|
||||
this.form.controls.image.valueChanges,
|
||||
{
|
||||
initialValue: this.form.controls.image.value,
|
||||
},
|
||||
);
|
||||
|
||||
protected readonly filteredImages = computed(() => {
|
||||
const query = (this.imageQuery() ?? '').toLowerCase().trim();
|
||||
const all = this.images();
|
||||
if (!query) return all;
|
||||
return all.filter((image) => image.toLowerCase().includes(query));
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.backgroundJobsService
|
||||
.getBackgroundJobAvailableImages()
|
||||
.subscribe({ next: (result) => this.images.set(result.images ?? []) });
|
||||
}
|
||||
|
||||
protected submit(): void {
|
||||
this.serverError.set('');
|
||||
const value = this.form.getRawValue();
|
||||
@@ -66,19 +93,23 @@ export class TaskCreateDialogComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const image = value.image.trim();
|
||||
if (!image) {
|
||||
this.form.controls.image.markAsTouched();
|
||||
return;
|
||||
}
|
||||
|
||||
const command = value.command.trim() || null;
|
||||
const env = this.parseEnv(value.env);
|
||||
if (env === undefined) return;
|
||||
|
||||
const image = value.image.trim();
|
||||
|
||||
this.creating.set(true);
|
||||
this.backgroundJobsService
|
||||
.createBackgroundJobTask({
|
||||
name,
|
||||
description: value.description.trim(),
|
||||
target_index: value.targetIndex.trim(),
|
||||
image: !image || image === DEFAULT_JOB_IMAGE ? null : image,
|
||||
image,
|
||||
command,
|
||||
env,
|
||||
})
|
||||
|
||||
@@ -34,18 +34,26 @@
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Image</mat-label>
|
||||
<textarea
|
||||
<input
|
||||
matInput
|
||||
class="image-input"
|
||||
rows="1"
|
||||
formControlName="image"></textarea>
|
||||
formControlName="image"
|
||||
[matAutocomplete]="imageAuto" />
|
||||
<mat-autocomplete #imageAuto="matAutocomplete">
|
||||
@for (image of filteredImages(); track image) {
|
||||
<mat-option [value]="image">{{ image }}</mat-option>
|
||||
}
|
||||
</mat-autocomplete>
|
||||
<mat-icon
|
||||
matSuffix
|
||||
class="field-info"
|
||||
matTooltip="Vorausgefüllt ist das Standard-Image mit allen Background-Job-Skripten — im Normalfall einfach so lassen. Nur ändern, wenn der Job ein eigenes Docker-Image nutzen soll; eigene Images erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) nicht automatisch."
|
||||
matTooltip="Docker-Image für den Job. Tippen filtert die aus Nexus verfügbaren Images; du kannst auch einen eigenen Wert eingeben. Images aus unserer Registry (docker.nes.uni-due.de) erhalten die INSE-Zugangsdaten (Elasticsearch/LLM) automatisch, fremde Images nicht."
|
||||
>info_outline</mat-icon
|
||||
>
|
||||
<mat-hint>Im Normalfall unverändert lassen.</mat-hint>
|
||||
@if (form.controls.image.invalid && form.controls.image.touched) {
|
||||
<mat-error>Bitte ein Image auswählen oder eingeben.</mat-error>
|
||||
}
|
||||
<mat-hint>Aus Nexus wählen oder eigenes Image eingeben.</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import { Component, OnInit, computed, inject, signal } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import {
|
||||
FormControl,
|
||||
FormGroup,
|
||||
ReactiveFormsModule,
|
||||
Validators,
|
||||
} from '@angular/forms';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
@@ -20,8 +22,6 @@ 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;
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export interface TaskEditDialogData {
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
MatAutocompleteModule,
|
||||
MatButtonModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
@@ -42,7 +43,7 @@ export interface TaskEditDialogData {
|
||||
styleUrl: './task-edit-dialog.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class TaskEditDialogComponent {
|
||||
export class TaskEditDialogComponent implements OnInit {
|
||||
private readonly dialogRef =
|
||||
inject<
|
||||
MatDialogRef<TaskEditDialogComponent, BackgroundJobTask | undefined>
|
||||
@@ -52,6 +53,7 @@ export class TaskEditDialogComponent {
|
||||
|
||||
protected readonly saving = signal(false);
|
||||
protected readonly serverError = signal('');
|
||||
protected readonly images = signal<string[]>([]);
|
||||
|
||||
protected readonly form = new FormGroup({
|
||||
name: new FormControl(this.data.task.name, {
|
||||
@@ -67,12 +69,35 @@ export class TaskEditDialogComponent {
|
||||
command: new FormControl(this.data.task.command ?? '', {
|
||||
nonNullable: true,
|
||||
}),
|
||||
image: new FormControl(this.data.task.image, { nonNullable: true }),
|
||||
image: new FormControl(this.data.task.image ?? '', {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
env: new FormControl(this.envToText(this.data.task.env), {
|
||||
nonNullable: true,
|
||||
}),
|
||||
});
|
||||
|
||||
private readonly imageQuery = toSignal(
|
||||
this.form.controls.image.valueChanges,
|
||||
{
|
||||
initialValue: this.form.controls.image.value,
|
||||
},
|
||||
);
|
||||
|
||||
protected readonly filteredImages = computed(() => {
|
||||
const query = (this.imageQuery() ?? '').toLowerCase().trim();
|
||||
const all = this.images();
|
||||
if (!query) return all;
|
||||
return all.filter((image) => image.toLowerCase().includes(query));
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.backgroundJobsService
|
||||
.getBackgroundJobAvailableImages()
|
||||
.subscribe({ next: (result) => this.images.set(result.images ?? []) });
|
||||
}
|
||||
|
||||
protected submit(): void {
|
||||
this.serverError.set('');
|
||||
const value = this.form.getRawValue();
|
||||
@@ -83,18 +108,22 @@ export class TaskEditDialogComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const image = value.image.trim();
|
||||
if (!image) {
|
||||
this.form.controls.image.markAsTouched();
|
||||
return;
|
||||
}
|
||||
|
||||
const env = this.parseEnv(value.env);
|
||||
if (env === undefined) return;
|
||||
|
||||
const image = value.image.trim();
|
||||
|
||||
this.saving.set(true);
|
||||
this.backgroundJobsService
|
||||
.updateBackgroundJobTask(this.data.task.id, {
|
||||
name,
|
||||
description: value.description.trim(),
|
||||
target_index: value.targetIndex.trim(),
|
||||
image: !image || image === DEFAULT_JOB_IMAGE ? null : image,
|
||||
image,
|
||||
command: value.command.trim() || null,
|
||||
env,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user