mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
implementing download for bulk_download events
This commit is contained in:
parent
9db7e073a3
commit
8d9c566656
@ -426,6 +426,8 @@
|
||||
"downloadSelection": "Download Selection",
|
||||
"preparingDownload": "Preparing Download",
|
||||
"preparingDownloadFailed": "Problem Preparing Download",
|
||||
"bulkDownloadStarting": "Beginning Download",
|
||||
"bulkDownloadFailed": "Problem Preparing Download",
|
||||
"problemDeletingImages": "Problem Deleting Images",
|
||||
"problemDeletingImagesDesc": "One or more images could not be deleted"
|
||||
},
|
||||
|
@ -48,6 +48,8 @@ import { addInitialImageSelectedListener } from './listeners/initialImageSelecte
|
||||
import { addModelSelectedListener } from './listeners/modelSelected';
|
||||
import { addModelsLoadedListener } from './listeners/modelsLoaded';
|
||||
import { addDynamicPromptsListener } from './listeners/promptChanged';
|
||||
import { addBulkDownloadCompleteEventListener } from './listeners/socketio/socketBulkDownloadComplete';
|
||||
import { addBulkDownloadFailedEventListener } from './listeners/socketio/socketBulkDownloadFailed';
|
||||
import { addSocketConnectedEventListener as addSocketConnectedListener } from './listeners/socketio/socketConnected';
|
||||
import { addSocketDisconnectedEventListener as addSocketDisconnectedListener } from './listeners/socketio/socketDisconnected';
|
||||
import { addGeneratorProgressEventListener as addGeneratorProgressListener } from './listeners/socketio/socketGeneratorProgress';
|
||||
@ -137,6 +139,8 @@ addModelLoadEventListener();
|
||||
addSessionRetrievalErrorEventListener();
|
||||
addInvocationRetrievalErrorEventListener();
|
||||
addSocketQueueItemStatusChangedEventListener();
|
||||
addBulkDownloadCompleteEventListener();
|
||||
addBulkDownloadFailedEventListener();
|
||||
|
||||
// ControlNet
|
||||
addControlNetImageProcessedListener();
|
||||
|
@ -0,0 +1,41 @@
|
||||
import { logger } from 'app/logging/logger';
|
||||
import { addToast } from 'features/system/store/systemSlice';
|
||||
import { t } from 'i18next';
|
||||
import { socketBulkDownloadCompleted } from 'services/events/actions';
|
||||
|
||||
import { startAppListening } from '../..';
|
||||
|
||||
const log = logger('socketio');
|
||||
|
||||
export const addBulkDownloadCompleteEventListener = () => {
|
||||
startAppListening({
|
||||
actionCreator: socketBulkDownloadCompleted,
|
||||
effect: async (action, { dispatch }) => {
|
||||
log.debug(action.payload, 'Bulk download complete');
|
||||
|
||||
const bulk_download_item_name = action.payload.data.bulk_download_item_name;
|
||||
|
||||
const url = `/api/v1/images/download/${bulk_download_item_name}`;
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = bulk_download_item_name;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
dispatch(
|
||||
addToast({
|
||||
title: t('gallery.bulkDownloadStarting'),
|
||||
status: 'success',
|
||||
...(action.payload
|
||||
? {
|
||||
description: bulk_download_item_name,
|
||||
duration: null,
|
||||
isClosable: true,
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
import { logger } from 'app/logging/logger';
|
||||
import { addToast } from 'features/system/store/systemSlice';
|
||||
import { t } from 'i18next';
|
||||
import { socketBulkDownloadFailed } from 'services/events/actions';
|
||||
|
||||
import { startAppListening } from '../..';
|
||||
|
||||
const log = logger('socketio');
|
||||
|
||||
export const addBulkDownloadFailedEventListener = () => {
|
||||
startAppListening({
|
||||
actionCreator: socketBulkDownloadFailed,
|
||||
effect: async (action, { dispatch }) => {
|
||||
log.debug(action.payload, 'Bulk download error');
|
||||
|
||||
|
||||
dispatch(
|
||||
addToast({
|
||||
title: t('gallery.bulkDownloadFailed'),
|
||||
status: 'error',
|
||||
...(action.payload
|
||||
? {
|
||||
description: action.payload.data.error,
|
||||
duration: null,
|
||||
isClosable: true,
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
};
|
@ -156,7 +156,7 @@ export type InvocationRetrievalErrorEvent = {
|
||||
*
|
||||
* @example socket.on('queue_item_status_changed', (data: QueueItemStatusChangedEvent) => { ... }
|
||||
*/
|
||||
export type QueueItemStatusChangedEvent = {
|
||||
export type QueueItemStatusChangedEvent = {
|
||||
queue_id: string;
|
||||
queue_item: {
|
||||
queue_id: string;
|
||||
@ -191,7 +191,7 @@ export type QueueItemStatusChangedEvent = {
|
||||
failed: number;
|
||||
canceled: number;
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type ClientEmitSubscribeQueue = {
|
||||
@ -205,6 +205,7 @@ export type ClientEmitUnsubscribeQueue = {
|
||||
export type BulkDownloadStartedEvent = {
|
||||
bulk_download_id: string;
|
||||
bulk_download_item_id: string;
|
||||
bulk_download_item_name: string;
|
||||
};
|
||||
|
||||
export type BulkDownloadCompletedEvent = {
|
||||
@ -216,8 +217,9 @@ export type BulkDownloadCompletedEvent = {
|
||||
export type BulkDownloadFailedEvent = {
|
||||
bulk_download_id: string;
|
||||
bulk_download_item_id: string;
|
||||
bulk_download_item_name: string;
|
||||
error: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type ClientEmitSubscribeBulkDownload = {
|
||||
bulk_download_id: string;
|
||||
|
Loading…
Reference in New Issue
Block a user