Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate and render thumbnail #341

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/api/custom/getAnalogueModelImageById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import axios from 'axios';
import { OpenAPI } from '../generated';

export const getAnalogueModelImage = async (
analogueModelId: string,
imageId: string,
): Promise<string> => {
const token = OpenAPI.TOKEN; // replace with your bearer token
const base = OpenAPI.BASE;

const response = await axios.get(
`/api/analogue-models/${analogueModelId}/images/${imageId}`,
{
headers: { Authorization: `Bearer ${token}` },
responseType: 'blob', // response type of blob to handle images
baseURL: base,
},
);

// create an object URL for the image blob and return it
return URL.createObjectURL(response.data);
};
19 changes: 7 additions & 12 deletions src/api/custom/getImageById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ export const getVariogramImage = async (imageId: string): Promise<string> => {
const token = OpenAPI.TOKEN; // replace with your bearer token
const base = OpenAPI.BASE;

try {
const response = await axios.get(`/api/images/variogram/${imageId}`, {
headers: { Authorization: `Bearer ${token}` },
responseType: 'blob', // response type of blob to handle images
baseURL: base,
});
const response = await axios.get(`/api/images/variogram/${imageId}`, {
headers: { Authorization: `Bearer ${token}` },
responseType: 'blob', // response type of blob to handle images
baseURL: base,
});

// create an object URL for the image blob and return it
return URL.createObjectURL(response.data);
} catch (error) {
console.error(`Error fetching image: ${error}`);
throw error; // re-throw the error so it can be handled by the caller
}
// create an object URL for the image blob and return it
return URL.createObjectURL(response.data);
};
10 changes: 10 additions & 0 deletions src/api/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type { AddParameterDto } from './models/AddParameterDto';
export type { AddStatigraphicGroupForm } from './models/AddStatigraphicGroupForm';
export type { AddStratigraphicGroupCommandResponse } from './models/AddStratigraphicGroupCommandResponse';
export type { AnalogueModelDetail } from './models/AnalogueModelDetail';
export type { AnalogueModelImageDto } from './models/AnalogueModelImageDto';
export type { AnalogueModelList } from './models/AnalogueModelList';
export { AnalogueModelSourceType } from './models/AnalogueModelSourceType';
export type { ComputeCaseComputeMethodDto } from './models/ComputeCaseComputeMethodDto';
Expand Down Expand Up @@ -59,13 +60,18 @@ export type { EstimateVariogramCommandResponse } from './models/EstimateVariogra
export type { EstimateVariogramDto } from './models/EstimateVariogramDto';
export type { FieldDto } from './models/FieldDto';
export type { File } from './models/File';
export { FileType } from './models/FileType';
export type { GenerateThumbnailCommand } from './models/GenerateThumbnailCommand';
export type { GenerateThumbnailCommandResponse } from './models/GenerateThumbnailCommandResponse';
export type { GenerateThumbnailDto } from './models/GenerateThumbnailDto';
export type { GeologicalGroupDto } from './models/GeologicalGroupDto';
export type { GeologicalStandardDto } from './models/GeologicalStandardDto';
export type { GetAnalogueModelListQueryResponse } from './models/GetAnalogueModelListQueryResponse';
export type { GetAnalogueModelQueryResponse } from './models/GetAnalogueModelQueryResponse';
export type { GetCurrentJobStatusCommandResponse } from './models/GetCurrentJobStatusCommandResponse';
export type { GetCurrentJobStatusDto } from './models/GetCurrentJobStatusDto';
export type { GetCurrentJobStatusListCommand } from './models/GetCurrentJobStatusListCommand';
export type { GetImageMetadataCommandResponse } from './models/GetImageMetadataCommandResponse';
export type { GetJobDetailQueryResponse } from './models/GetJobDetailQueryResponse';
export type { GetJobListQueryResponse } from './models/GetJobListQueryResponse';
export type { GetObjectResultsByModelIdQueryResponse } from './models/GetObjectResultsByModelIdQueryResponse';
Expand All @@ -78,6 +84,7 @@ export type { GetUploadListQueryResponse } from './models/GetUploadListQueryResp
export type { GetVariogramResultsByModelIdQueryResponse } from './models/GetVariogramResultsByModelIdQueryResponse';
export type { GetVariogramResultsDto } from './models/GetVariogramResultsDto';
export type { GetVariogramResultsVariogramResultFileDto } from './models/GetVariogramResultsVariogramResultFileDto';
export type { ImageMetadataDto } from './models/ImageMetadataDto';
export type { JobDetail } from './models/JobDetail';
export type { JobList } from './models/JobList';
export type { JobListUploadsDto } from './models/JobListUploadsDto';
Expand Down Expand Up @@ -119,6 +126,7 @@ export type { RadixJobDto } from './models/RadixJobDto';
export type { StratColumnDto } from './models/StratColumnDto';
export type { StratigraphicGroupDto } from './models/StratigraphicGroupDto';
export type { StratUnitDto } from './models/StratUnitDto';
export type { ThumbnailBoundingBoxDto } from './models/ThumbnailBoundingBoxDto';
export type { UpdateAnalogueModelAreaCommandForm } from './models/UpdateAnalogueModelAreaCommandForm';
export type { UpdateAnalogueModelCommandBody } from './models/UpdateAnalogueModelCommandBody';
export type { UpdateAnalogueModelCommandResponse } from './models/UpdateAnalogueModelCommandResponse';
Expand All @@ -131,6 +139,7 @@ export type { UpdateJobStatusDto } from './models/UpdateJobStatusDto';
export type { UpdateObjectEstimationStatusCommand } from './models/UpdateObjectEstimationStatusCommand';
export type { UpdateObjectEstimationStatusCommandResponse } from './models/UpdateObjectEstimationStatusCommandResponse';
export type { UpdateObjectEstimationStatusDto } from './models/UpdateObjectEstimationStatusDto';
export type { UpdateThumbnailGenStatusCommand } from './models/UpdateThumbnailGenStatusCommand';
export type { UpdateVariogramEstimationStatusCommand } from './models/UpdateVariogramEstimationStatusCommand';
export type { UploadAnalogueModelCommandResponse } from './models/UploadAnalogueModelCommandResponse';
export type { UploadAnalogueModelDto } from './models/UploadAnalogueModelDto';
Expand All @@ -142,6 +151,7 @@ export type { UploadList } from './models/UploadList';
export { UploadStatus } from './models/UploadStatus';

export { AnalogueModelComputeCasesService } from './services/AnalogueModelComputeCasesService';
export { AnalogueModelImagesService } from './services/AnalogueModelImagesService';
export { AnalogueModelMetadataService } from './services/AnalogueModelMetadataService';
export { AnalogueModelParametersService } from './services/AnalogueModelParametersService';
export { AnalogueModelsService } from './services/AnalogueModelsService';
Expand Down
2 changes: 2 additions & 0 deletions src/api/generated/models/AnalogueModelDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* tslint:disable */
/* eslint-disable */

import type { AnalogueModelImageDto } from './AnalogueModelImageDto';
import type { AnalogueModelSourceType } from './AnalogueModelSourceType';
import type { GeologicalGroupDto } from './GeologicalGroupDto';
import type { JobStatus } from './JobStatus';
Expand Down Expand Up @@ -31,5 +32,6 @@ export type AnalogueModelDetail = {
geologicalGroups: Array<GeologicalGroupDto>;
outcrops: Array<OutcropDto>;
processingStatus: JobStatus;
analogueModelImage?: AnalogueModelImageDto;
};

13 changes: 13 additions & 0 deletions src/api/generated/models/AnalogueModelImageDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { FileType } from './FileType';

export type AnalogueModelImageDto = {
analogueModelImageId: string;
fileName: string;
type: FileType;
};

10 changes: 10 additions & 0 deletions src/api/generated/models/FileType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export enum FileType {
JPG = 'JPG',
PNG = 'PNG',
CSV = 'CSV',
}
9 changes: 9 additions & 0 deletions src/api/generated/models/GenerateThumbnailCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type GenerateThumbnailCommand = {
modelId: string;
};

15 changes: 15 additions & 0 deletions src/api/generated/models/GenerateThumbnailCommandResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { GenerateThumbnailDto } from './GenerateThumbnailDto';

export type GenerateThumbnailCommandResponse = {
success?: boolean;
count?: number | null;
message?: string | null;
validationErrors?: Array<string> | null;
data: GenerateThumbnailDto;
};

15 changes: 15 additions & 0 deletions src/api/generated/models/GenerateThumbnailDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { JobStatus } from './JobStatus';
import type { JobType } from './JobType';

export type GenerateThumbnailDto = {
jobId: string;
name: string;
jobStatus: JobStatus;
jobType: JobType;
};

15 changes: 15 additions & 0 deletions src/api/generated/models/GetImageMetadataCommandResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { ImageMetadataDto } from './ImageMetadataDto';

export type GetImageMetadataCommandResponse = {
success?: boolean;
count?: number | null;
message?: string | null;
validationErrors?: Array<string> | null;
data: ImageMetadataDto;
};

13 changes: 13 additions & 0 deletions src/api/generated/models/ImageMetadataDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { ThumbnailBoundingBoxDto } from './ThumbnailBoundingBoxDto';

export type ImageMetadataDto = {
modelName: string;
boundingBox: ThumbnailBoundingBoxDto;
colorLegend: Record<string, string>;
};

1 change: 1 addition & 0 deletions src/api/generated/models/JobType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export enum JobType {
NRRESQML = 'Nrresqml',
NRCHANNEL = 'Nrchannel',
NRVARIOGRAM = 'Nrvariogram',
NRTHUMBNAIL_GEN = 'NrthumbnailGen',
}
12 changes: 12 additions & 0 deletions src/api/generated/models/ThumbnailBoundingBoxDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type ThumbnailBoundingBoxDto = {
x0: number;
y0: number;
x1: number;
y1: number;
};

15 changes: 15 additions & 0 deletions src/api/generated/models/UpdateThumbnailGenStatusCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { RadixJobDto } from './RadixJobDto';

export type UpdateThumbnailGenStatusCommand = {
name: string;
started?: string | null;
ended?: string | null;
status: string;
jobStatuses?: Array<RadixJobDto> | null;
};

62 changes: 62 additions & 0 deletions src/api/generated/services/AnalogueModelImagesService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { File } from '../models/File';
import type { GetImageMetadataCommandResponse } from '../models/GetImageMetadataCommandResponse';

import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';

export class AnalogueModelImagesService {

/**
* @param analogueModelId
* @param imageId
* @returns File Success
* @throws ApiError
*/
public static getApiAnalogueModelsImages(
analogueModelId: string,
imageId: string,
): CancelablePromise<File> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/analogue-models/{analogueModelId}/images/{imageId}',
path: {
'analogueModelId': analogueModelId,
'imageId': imageId,
},
errors: {
403: `Forbidden`,
404: `Not Found`,
},
});
}

/**
* @param analogueModelId
* @param imageId
* @returns GetImageMetadataCommandResponse Success
* @throws ApiError
*/
public static getApiAnalogueModelsImagesMetadata(
analogueModelId: string,
imageId: string,
): CancelablePromise<GetImageMetadataCommandResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/analogue-models/{analogueModelId}/images/{imageId}/metadata',
path: {
'analogueModelId': analogueModelId,
'imageId': imageId,
},
errors: {
403: `Forbidden`,
404: `Not Found`,
},
});
}

}
23 changes: 23 additions & 0 deletions src/api/generated/services/JobsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import type { EstimateObjectCommand } from '../models/EstimateObjectCommand';
import type { EstimateObjectCommandResponse } from '../models/EstimateObjectCommandResponse';
import type { EstimateVariogramCommand } from '../models/EstimateVariogramCommand';
import type { EstimateVariogramCommandResponse } from '../models/EstimateVariogramCommandResponse';
import type { GenerateThumbnailCommand } from '../models/GenerateThumbnailCommand';
import type { GenerateThumbnailCommandResponse } from '../models/GenerateThumbnailCommandResponse';
import type { GetCurrentJobStatusCommandResponse } from '../models/GetCurrentJobStatusCommandResponse';
import type { GetCurrentJobStatusListCommand } from '../models/GetCurrentJobStatusListCommand';
import type { GetJobDetailQueryResponse } from '../models/GetJobDetailQueryResponse';
Expand Down Expand Up @@ -156,4 +158,25 @@ export class JobsService {
});
}

/**
* Generate thumbnail for processed analogue model.
* @param requestBody
* @returns GenerateThumbnailCommandResponse Accepted
* @throws ApiError
*/
public static postApiJobsComputeThumbnailGen(
requestBody?: GenerateThumbnailCommand,
): CancelablePromise<GenerateThumbnailCommandResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/jobs/compute/thumbnail-gen',
body: requestBody,
mediaType: 'application/json-patch+json',
errors: {
400: `Bad Request`,
403: `Forbidden`,
},
});
}

}
21 changes: 21 additions & 0 deletions src/api/generated/services/WebhooksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { UpdateJobStatusCommand } from '../models/UpdateJobStatusCommand';
import type { UpdateJobStatusCommandResponse } from '../models/UpdateJobStatusCommandResponse';
import type { UpdateObjectEstimationStatusCommand } from '../models/UpdateObjectEstimationStatusCommand';
import type { UpdateObjectEstimationStatusCommandResponse } from '../models/UpdateObjectEstimationStatusCommandResponse';
import type { UpdateThumbnailGenStatusCommand } from '../models/UpdateThumbnailGenStatusCommand';
import type { UpdateVariogramEstimationStatusCommand } from '../models/UpdateVariogramEstimationStatusCommand';

import type { CancelablePromise } from '../core/CancelablePromise';
Expand Down Expand Up @@ -35,6 +36,26 @@ export class WebhooksService {
});
}

/**
* @param requestBody
* @returns UpdateThumbnailGenStatusCommand Success
* @throws ApiError
*/
public static postApiWebhooksThumbnailGenStatus(
requestBody?: UpdateThumbnailGenStatusCommand,
): CancelablePromise<UpdateThumbnailGenStatusCommand> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/webhooks/thumbnail-gen/status',
body: requestBody,
mediaType: 'application/json-patch+json',
errors: {
400: `Bad Request`,
404: `Not Found`,
},
});
}

/**
* @param requestBody
* @returns UpdateObjectEstimationStatusCommandResponse Success
Expand Down
Loading