diff --git a/backend/processor/image.go b/backend/processor/image.go index dc3b108..fdd630f 100644 --- a/backend/processor/image.go +++ b/backend/processor/image.go @@ -40,6 +40,19 @@ func (p *ImageProcessor) setImageToProcess(ctx context.Context, image model.Imag } } +func (p *ImageProcessor) setImageToDone(ctx context.Context, image model.Image) { + err := p.imageModel.UpdateProcess(ctx, image.ID, model.Progress_Complete) + if err != nil { + // TODO: what can we actually do here for the errors? + // We can't stop the work for the others + + p.logger.Error("failed to update image", "err", err) + + // TODO: we can use context here to actually pass some information through + return + } +} + func (p *ImageProcessor) describe(ctx context.Context, image model.Image) { descriptionSubLogger := p.logger.With("describe image", image.ID) @@ -97,6 +110,8 @@ func (p *ImageProcessor) processImage(image model.Image) { wg.Wait() + p.setImageToDone(ctx, image) + // TODO: there is some repeated code here. The ergonomicts of the notifications, // isn't the best. imageNotification = notifications.GetImageNotification(notifications.ImageNotification{ diff --git a/backend/processor/stack.go b/backend/processor/stack.go index afcd392..1e32328 100644 --- a/backend/processor/stack.go +++ b/backend/processor/stack.go @@ -45,6 +45,19 @@ func (p *StackProcessor) setStackToProcess(ctx context.Context, stack model.Stac } } +func (p *StackProcessor) setStackToDone(ctx context.Context, stack model.Stacks) { + err := p.stackModel.UpdateProcess(ctx, stack.ID, model.Progress_Complete) + if err != nil { + // TODO: what can we actually do here for the errors? + // We can't stop the work for the others + + p.logger.Error("failed to update stack", "err", err) + + // TODO: we can use context here to actually pass some information through + return + } +} + func (p *StackProcessor) extractInfo(ctx context.Context, stack model.Stacks) { err := p.stackAgent.CreateList(p.logger, stack.UserID, stack.ID, stack.Name, stack.Description) if err != nil { @@ -87,6 +100,8 @@ func (p *StackProcessor) processImage(stack model.Stacks) { wg.Wait() + p.setStackToDone(ctx, stack) + // TODO: there is some repeated code here. The ergonomicts of the notifications, // isn't the best. stackNotification = notifications.GetStackNotification(notifications.StackNotification{ diff --git a/frontend/src/contexts/SearchImageContext.tsx b/frontend/src/contexts/SearchImageContext.tsx index a4dd6ff..c8e0d83 100644 --- a/frontend/src/contexts/SearchImageContext.tsx +++ b/frontend/src/contexts/SearchImageContext.tsx @@ -10,6 +10,7 @@ import { import { deleteImage, deleteImageFromStack, + deleteStack, deleteStackItem, getUserImages, JustTheImageWhatAreTheseNames, @@ -25,8 +26,11 @@ export type SearchImageStore = { userImages: Accessor; onRefetchImages: () => void; + onDeleteImage: (imageID: string) => void; onDeleteImageFromStack: (stackID: string, imageID: string) => void; + + onDeleteStack: (stackID: string) => void; onDeleteStackItem: (stackID: string, schemaItemID: string) => void; }; @@ -76,6 +80,9 @@ export const SearchImageContextProvider: Component = (props) => { onDeleteImageFromStack: (stackID: string, imageID: string) => { deleteImageFromStack(stackID, imageID).then(refetch); }, + onDeleteStack: (stackID: string) => { + deleteStack(stackID).then(refetch) + }, onDeleteStackItem: (stackID: string, schemaItemID: string) => { deleteStackItem(stackID, schemaItemID).then(refetch); }, diff --git a/frontend/src/pages/stack/index.tsx b/frontend/src/pages/stack/index.tsx index 6aac042..82598a9 100644 --- a/frontend/src/pages/stack/index.tsx +++ b/frontend/src/pages/stack/index.tsx @@ -8,7 +8,7 @@ import { createResource, createSignal, } from "solid-js"; -import { base, deleteStack, getAccessToken } from "../../network"; +import { base, getAccessToken } from "../../network"; import { Dialog } from "@kobalte/core"; const DeleteButton: Component<{ onDelete: () => void }> = (props) => { @@ -107,14 +107,14 @@ export const Stack: Component = () => { const { stackID } = useParams(); const nav = useNavigate(); - const { stacks, onDeleteImageFromStack } = useSearchImageContext(); + const { stacks, onDeleteImageFromStack, onDeleteStack } = useSearchImageContext(); const [accessToken] = createResource(getAccessToken); const stack = () => stacks().find((l) => l.ID === stackID); const handleDeleteStack = async () => { - await deleteStack(stackID) + onDeleteStack(stackID); nav("/"); };