forked from extern/easydiffusion
added stop and queue clear
This commit is contained in:
parent
330f1577fd
commit
6e877aea02
@ -136,3 +136,19 @@ export const doMakeImage = async (reqBody: ImageRequest) => {
|
|||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const doStopImage = async () => {
|
||||||
|
|
||||||
|
console.log("stopping image");
|
||||||
|
const response = await fetch(`${API_URL}/image/stop`);
|
||||||
|
console.log("stopping image response", response);
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("stopping image data", data);
|
||||||
|
return data;
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// let res = await fetch('/image/stop')
|
||||||
|
// } catch (e) {
|
||||||
|
// console.log(e)
|
||||||
|
// }
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { doStopImage } from "../../../../../api";
|
||||||
|
import { useImageQueue } from "../../../../../stores/imageQueueStore";
|
||||||
|
|
||||||
|
export default function ClearQueue() {
|
||||||
|
|
||||||
|
const hasQueue = useImageQueue((state) => state.hasQueuedImages());
|
||||||
|
const clearQueue = useImageQueue((state) => state.clearQueue);
|
||||||
|
|
||||||
|
const stopAll = async () => {
|
||||||
|
console.log("stopAll");
|
||||||
|
try {
|
||||||
|
clearQueue();
|
||||||
|
const res = await doStopImage();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// / disabled={!hasQueue}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button onClick={() => void stopAll()}>Clear Queue</button>
|
||||||
|
);
|
||||||
|
}
|
@ -6,9 +6,12 @@ import {
|
|||||||
PromptDisplay,
|
PromptDisplay,
|
||||||
} from "./basicCreation.css";
|
} from "./basicCreation.css";
|
||||||
|
|
||||||
|
import MakeButton from "./makeButton";
|
||||||
|
import StopButton from "./stopButton";
|
||||||
|
import ClearQueue from "./clearQueue";
|
||||||
import SeedImage from "./seedImage";
|
import SeedImage from "./seedImage";
|
||||||
import ActiveTags from "./activeTags";
|
import ActiveTags from "./activeTags";
|
||||||
import MakeButton from "./makeButton";
|
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@ -31,9 +34,12 @@ export default function BasicCreation() {
|
|||||||
<textarea value={promptText} onChange={handlePromptChange}></textarea>
|
<textarea value={promptText} onChange={handlePromptChange}></textarea>
|
||||||
</div>
|
</div>
|
||||||
<MakeButton></MakeButton>
|
<MakeButton></MakeButton>
|
||||||
|
<div>
|
||||||
|
<StopButton></StopButton>
|
||||||
|
<ClearQueue></ClearQueue>
|
||||||
|
</div>
|
||||||
|
|
||||||
<SeedImage></SeedImage>
|
<SeedImage></SeedImage>
|
||||||
|
|
||||||
<ActiveTags></ActiveTags>
|
<ActiveTags></ActiveTags>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
useImageFetching
|
useImageFetching
|
||||||
} from "../../../../../stores/imageFetchingStore";
|
} from "../../../../../stores/imageFetchingStore";
|
||||||
|
|
||||||
|
|
||||||
import { useImageDisplay } from "../../../../../stores/imageDisplayStore";
|
import { useImageDisplay } from "../../../../../stores/imageDisplayStore";
|
||||||
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
@ -39,6 +40,8 @@ export default function MakeButton() {
|
|||||||
const isRandomSeed = useImageCreate((state) => state.isRandomSeed());
|
const isRandomSeed = useImageCreate((state) => state.isRandomSeed());
|
||||||
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
||||||
|
|
||||||
|
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
||||||
|
|
||||||
const addNewImage = useImageQueue((state) => state.addNewImage);
|
const addNewImage = useImageQueue((state) => state.addNewImage);
|
||||||
const hasQueue = useImageQueue((state) => state.hasQueuedImages());
|
const hasQueue = useImageQueue((state) => state.hasQueuedImages());
|
||||||
const removeFirstInQueue = useImageQueue((state) => state.removeFirstInQueue);
|
const removeFirstInQueue = useImageQueue((state) => state.removeFirstInQueue);
|
||||||
@ -96,7 +99,9 @@ export default function MakeButton() {
|
|||||||
removeFirstInQueue();
|
removeFirstInQueue();
|
||||||
setStatus(FetchingStates.COMPLETE);
|
setStatus(FetchingStates.COMPLETE);
|
||||||
hackJson(finalJSON, id);
|
hackJson(finalJSON, id);
|
||||||
void dingRef.current?.play();
|
if (isSoundEnabled) {
|
||||||
|
void dingRef.current?.play();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { doStopImage } from "../../../../../api";
|
||||||
|
|
||||||
|
|
||||||
|
export default function StopButton() {
|
||||||
|
|
||||||
|
const stopMake = async () => {
|
||||||
|
try {
|
||||||
|
const res = await doStopImage();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return <button onClick={() => void stopMake()}>Stop</button>;
|
||||||
|
}
|
@ -48,7 +48,7 @@ export default function SystemSettings() {
|
|||||||
state.getValueForRequestKey("use_full_precision")
|
state.getValueForRequestKey("use_full_precision")
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSoundEnabled = true; //useImageCreate((state) => state.isSoundEnabled());
|
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
||||||
|
|
||||||
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
||||||
const toggleUseAutoSave = useImageCreate((state) => state.toggleUseAutoSave);
|
const toggleUseAutoSave = useImageCreate((state) => state.toggleUseAutoSave);
|
||||||
|
@ -317,7 +317,6 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
set(
|
set(
|
||||||
produce((state: ImageCreateState) => {
|
produce((state: ImageCreateState) => {
|
||||||
state.uiOptions.isSoundEnabled = !state.uiOptions.isSoundEnabled;
|
state.uiOptions.isSoundEnabled = !state.uiOptions.isSoundEnabled;
|
||||||
//localStorage.setItem('ui:isSoundEnabled', state.uiOptions.isSoundEnabled);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@ interface ImageQueueState {
|
|||||||
hasQueuedImages: () => boolean;
|
hasQueuedImages: () => boolean;
|
||||||
firstInQueue: () => QueueItem;
|
firstInQueue: () => QueueItem;
|
||||||
removeFirstInQueue: () => void;
|
removeFirstInQueue: () => void;
|
||||||
|
clearQueue: () => void;
|
||||||
clearCachedIds: () => void;
|
clearCachedIds: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +60,14 @@ export const useImageQueue = create<ImageQueueState>((set, get) => ({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearQueue: () => {
|
||||||
|
set(
|
||||||
|
produce((state) => {
|
||||||
|
state.images = [];
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
clearCachedIds: () => {
|
clearCachedIds: () => {
|
||||||
set(
|
set(
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user