mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 23:59:45 +02:00
feat: Recipe Timeline Images (#2444)
* refactored recipe image paths/service * added routes for updating/fetching timeline images * make generate * added event image upload and rendering * switched update to patch to preserve timestamp * added tests * tweaked order of requests * always reload events when opening the timeline * re-arranged elements to make them look nicer * delete files when timeline event is deleted
This commit is contained in:
parent
06962cf865
commit
dfe4942451
16 changed files with 355 additions and 92 deletions
|
@ -1,13 +1,14 @@
|
|||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
/* This file was automatically generated from pydantic models by running pydantic2ts.
|
||||
/* Do not modify it by hand - just update the pydantic models and then re-run the script
|
||||
*/
|
||||
/* This file was automatically generated from pydantic models by running pydantic2ts.
|
||||
/* Do not modify it by hand - just update the pydantic models and then re-run the script
|
||||
*/
|
||||
|
||||
export type ExportTypes = "json";
|
||||
export type RegisteredParser = "nlp" | "brute";
|
||||
export type TimelineEventType = "system" | "info" | "comment";
|
||||
export type TimelineEventImage = "has image" | "does not have image";
|
||||
|
||||
export interface AssignCategories {
|
||||
recipes: string[];
|
||||
|
@ -351,31 +352,31 @@ export interface RecipeTagResponse {
|
|||
recipes?: RecipeSummary[];
|
||||
}
|
||||
export interface RecipeTimelineEventCreate {
|
||||
recipeId: string;
|
||||
userId: string;
|
||||
subject: string;
|
||||
eventType: TimelineEventType;
|
||||
eventMessage?: string;
|
||||
image?: string;
|
||||
image?: TimelineEventImage;
|
||||
timestamp?: string;
|
||||
recipeId: string;
|
||||
}
|
||||
export interface RecipeTimelineEventIn {
|
||||
recipeId: string;
|
||||
userId?: string;
|
||||
subject: string;
|
||||
eventType: TimelineEventType;
|
||||
eventMessage?: string;
|
||||
image?: string;
|
||||
image?: TimelineEventImage;
|
||||
timestamp?: string;
|
||||
recipeId: string;
|
||||
}
|
||||
export interface RecipeTimelineEventOut {
|
||||
recipeId: string;
|
||||
userId: string;
|
||||
subject: string;
|
||||
eventType: TimelineEventType;
|
||||
eventMessage?: string;
|
||||
image?: string;
|
||||
image?: TimelineEventImage;
|
||||
timestamp?: string;
|
||||
recipeId: string;
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updateAt: string;
|
||||
|
@ -383,7 +384,7 @@ export interface RecipeTimelineEventOut {
|
|||
export interface RecipeTimelineEventUpdate {
|
||||
subject: string;
|
||||
eventMessage?: string;
|
||||
image?: string;
|
||||
image?: TimelineEventImage;
|
||||
}
|
||||
export interface RecipeToolCreate {
|
||||
name: string;
|
||||
|
@ -400,7 +401,7 @@ export interface RecipeToolResponse {
|
|||
onHand?: boolean;
|
||||
id: string;
|
||||
slug: string;
|
||||
recipes?: Recipe[];
|
||||
recipes?: RecipeSummary[];
|
||||
}
|
||||
export interface RecipeToolSave {
|
||||
name: string;
|
||||
|
|
|
@ -52,6 +52,7 @@ const routes = {
|
|||
|
||||
recipesSlugLastMade: (slug: string) => `${prefix}/recipes/${slug}/last-made`,
|
||||
recipesTimelineEventId: (id: string) => `${prefix}/recipes/timeline/events/${id}`,
|
||||
recipesTimelineEventIdImage: (id: string) => `${prefix}/recipes/timeline/events/${id}/image`,
|
||||
};
|
||||
|
||||
export type RecipeSearchQuery = {
|
||||
|
@ -194,4 +195,12 @@ export class RecipeAPI extends BaseCRUDAPI<CreateRecipe, Recipe, Recipe> {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
async updateTimelineEventImage(eventId: string, fileObject: File) {
|
||||
const formData = new FormData();
|
||||
formData.append("image", fileObject);
|
||||
formData.append("extension", fileObject.name.split(".").pop() ?? "");
|
||||
|
||||
return await this.requests.put<UpdateImageResponse, FormData>(routes.recipesTimelineEventIdImage(eventId), formData);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue