mirror of
https://github.com/samsonjs/immich.git
synced 2026-03-25 09:15:56 +00:00
refactor(server): send job command (#2777)
* refactor: send job command * chore: open api
This commit is contained in:
parent
f04e47803c
commit
fde410e2ac
12 changed files with 34 additions and 29 deletions
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/doc/JobApi.md
generated
BIN
mobile/openapi/doc/JobApi.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api/job_api.dart
generated
BIN
mobile/openapi/lib/api/job_api.dart
generated
Binary file not shown.
BIN
mobile/openapi/test/job_api_test.dart
generated
BIN
mobile/openapi/test/job_api_test.dart
generated
Binary file not shown.
|
|
@ -2387,12 +2387,12 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/jobs/{jobId}": {
|
||||
"/jobs/{id}": {
|
||||
"put": {
|
||||
"operationId": "sendJobCommand",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "jobId",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ export class JobIdDto {
|
|||
@IsNotEmpty()
|
||||
@IsEnum(QueueName)
|
||||
@ApiProperty({ type: String, enum: QueueName, enumName: 'JobName' })
|
||||
jobId!: QueueName;
|
||||
id!: QueueName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,22 +23,28 @@ export class JobService {
|
|||
this.configCore = new SystemConfigCore(configRepository);
|
||||
}
|
||||
|
||||
handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<void> {
|
||||
async handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
this.logger.debug(`Handling command: queue=${queueName},force=${dto.force}`);
|
||||
|
||||
switch (dto.command) {
|
||||
case JobCommand.START:
|
||||
return this.start(queueName, dto);
|
||||
await this.start(queueName, dto);
|
||||
break;
|
||||
|
||||
case JobCommand.PAUSE:
|
||||
return this.jobRepository.pause(queueName);
|
||||
await this.jobRepository.pause(queueName);
|
||||
break;
|
||||
|
||||
case JobCommand.RESUME:
|
||||
return this.jobRepository.resume(queueName);
|
||||
await this.jobRepository.resume(queueName);
|
||||
break;
|
||||
|
||||
case JobCommand.EMPTY:
|
||||
return this.jobRepository.empty(queueName);
|
||||
await this.jobRepository.empty(queueName);
|
||||
break;
|
||||
}
|
||||
|
||||
return this.getJobStatus(queueName);
|
||||
}
|
||||
|
||||
async getJobStatus(queueName: QueueName): Promise<JobStatusDto> {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { MemoryLaneResponseDto } from '@app/domain/asset/response-dto/memory-lan
|
|||
export class AssetController {
|
||||
constructor(private service: AssetService) {}
|
||||
|
||||
@Get('/map-marker')
|
||||
@Get('map-marker')
|
||||
getMapMarkers(@GetAuthUser() authUser: AuthUserDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
|
||||
return this.service.getMapMarkers(authUser, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import { UUIDParamDto } from './dto/uuid-param.dto';
|
|||
@Authenticated()
|
||||
@UseValidation()
|
||||
export class AuthController {
|
||||
constructor(private readonly service: AuthService) {}
|
||||
constructor(private service: AuthService) {}
|
||||
|
||||
@PublicRoute()
|
||||
@Post('login')
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@ export class JobController {
|
|||
return this.service.getAllJobsStatus();
|
||||
}
|
||||
|
||||
@Put('/:jobId')
|
||||
async sendJobCommand(@Param() { jobId }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
await this.service.handleCommand(jobId, dto);
|
||||
return this.service.getJobStatus(jobId);
|
||||
@Put(':id')
|
||||
sendJobCommand(@Param() { id }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
return this.service.handleCommand(id, dto);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
web/src/api/open-api/api.ts
generated
28
web/src/api/open-api/api.ts
generated
|
|
@ -8053,18 +8053,18 @@ export const JobApiAxiosParamCreator = function (configuration?: Configuration)
|
|||
},
|
||||
/**
|
||||
*
|
||||
* @param {JobName} jobId
|
||||
* @param {JobName} id
|
||||
* @param {JobCommandDto} jobCommandDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
sendJobCommand: async (jobId: JobName, jobCommandDto: JobCommandDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'jobId' is not null or undefined
|
||||
assertParamExists('sendJobCommand', 'jobId', jobId)
|
||||
sendJobCommand: async (id: JobName, jobCommandDto: JobCommandDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'id' is not null or undefined
|
||||
assertParamExists('sendJobCommand', 'id', id)
|
||||
// verify required parameter 'jobCommandDto' is not null or undefined
|
||||
assertParamExists('sendJobCommand', 'jobCommandDto', jobCommandDto)
|
||||
const localVarPath = `/jobs/{jobId}`
|
||||
.replace(`{${"jobId"}}`, encodeURIComponent(String(jobId)));
|
||||
const localVarPath = `/jobs/{id}`
|
||||
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
|
|
@ -8120,13 +8120,13 @@ export const JobApiFp = function(configuration?: Configuration) {
|
|||
},
|
||||
/**
|
||||
*
|
||||
* @param {JobName} jobId
|
||||
* @param {JobName} id
|
||||
* @param {JobCommandDto} jobCommandDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async sendJobCommand(jobId: JobName, jobCommandDto: JobCommandDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<JobStatusDto>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.sendJobCommand(jobId, jobCommandDto, options);
|
||||
async sendJobCommand(id: JobName, jobCommandDto: JobCommandDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<JobStatusDto>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.sendJobCommand(id, jobCommandDto, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
}
|
||||
|
|
@ -8149,13 +8149,13 @@ export const JobApiFactory = function (configuration?: Configuration, basePath?:
|
|||
},
|
||||
/**
|
||||
*
|
||||
* @param {JobName} jobId
|
||||
* @param {JobName} id
|
||||
* @param {JobCommandDto} jobCommandDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
sendJobCommand(jobId: JobName, jobCommandDto: JobCommandDto, options?: any): AxiosPromise<JobStatusDto> {
|
||||
return localVarFp.sendJobCommand(jobId, jobCommandDto, options).then((request) => request(axios, basePath));
|
||||
sendJobCommand(id: JobName, jobCommandDto: JobCommandDto, options?: any): AxiosPromise<JobStatusDto> {
|
||||
return localVarFp.sendJobCommand(id, jobCommandDto, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
@ -8171,7 +8171,7 @@ export interface JobApiSendJobCommandRequest {
|
|||
* @type {JobName}
|
||||
* @memberof JobApiSendJobCommand
|
||||
*/
|
||||
readonly jobId: JobName
|
||||
readonly id: JobName
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -8206,7 +8206,7 @@ export class JobApi extends BaseAPI {
|
|||
* @memberof JobApi
|
||||
*/
|
||||
public sendJobCommand(requestParameters: JobApiSendJobCommandRequest, options?: AxiosRequestConfig) {
|
||||
return JobApiFp(this.configuration).sendJobCommand(requestParameters.jobId, requestParameters.jobCommandDto, options).then((request) => request(this.axios, this.basePath));
|
||||
return JobApiFp(this.configuration).sendJobCommand(requestParameters.id, requestParameters.jobCommandDto, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@
|
|||
const title = jobDetails[jobId]?.title;
|
||||
|
||||
try {
|
||||
const { data } = await api.jobApi.sendJobCommand({ jobId, jobCommandDto: jobCommand });
|
||||
const { data } = await api.jobApi.sendJobCommand({ id: jobId, jobCommandDto: jobCommand });
|
||||
jobs[jobId] = data;
|
||||
|
||||
switch (jobCommand.command) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue