Skip to content

Commit 3244ccc

Browse files
authored
chore(image-ui): simplify interface (#7882)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 4f7b6b0 commit 3244ccc

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

core/http/static/image.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async function promptDallE() {
154154
if (json.data && json.data.length > 0) {
155155
json.data.forEach((item, index) => {
156156
const imageContainer = document.createElement("div");
157-
imageContainer.className = "mb-4 bg-[var(--color-bg-primary)]/50 border border-[#1E293B] rounded-lg p-2";
157+
imageContainer.className = "flex flex-col";
158158

159159
// Create image element
160160
const img = document.createElement("img");
@@ -166,23 +166,23 @@ async function promptDallE() {
166166
return; // Skip invalid items
167167
}
168168
img.alt = prompt;
169-
img.className = "w-full h-auto rounded-lg mb-2";
169+
img.className = "w-full h-auto rounded-lg";
170170
imageContainer.appendChild(img);
171171

172-
// Create caption container
172+
// Create caption container (optional, can be collapsed or shown on hover)
173173
const captionDiv = document.createElement("div");
174-
captionDiv.className = "mt-2 p-2 bg-[var(--color-bg-secondary)] rounded-lg";
174+
captionDiv.className = "mt-2 p-2 bg-[var(--color-bg-secondary)] rounded-lg text-xs";
175175

176176
// Prompt caption
177177
const promptCaption = document.createElement("p");
178-
promptCaption.className = "text-xs text-[var(--color-text-primary)] mb-1.5";
178+
promptCaption.className = "text-[var(--color-text-primary)] mb-1.5 break-words";
179179
promptCaption.innerHTML = '<strong>Prompt:</strong> ' + escapeHtml(prompt);
180180
captionDiv.appendChild(promptCaption);
181181

182182
// Negative prompt if provided
183183
if (negativePrompt) {
184184
const negativeCaption = document.createElement("p");
185-
negativeCaption.className = "text-xs text-[var(--color-text-secondary)] mb-1.5";
185+
negativeCaption.className = "text-[var(--color-text-secondary)] mb-1.5 break-words";
186186
negativeCaption.innerHTML = '<strong>Negative Prompt:</strong> ' + escapeHtml(negativePrompt);
187187
captionDiv.appendChild(negativeCaption);
188188
}

core/http/views/text2image.html

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,26 +215,23 @@
215215

216216
<!-- Right Column: Image Preview -->
217217
<div class="flex-grow lg:w-3/4 flex flex-col min-h-0">
218-
<div class="card p-3 flex flex-col flex-1 min-h-0">
219-
<h3 class="text-sm font-semibold text-[var(--color-text-primary)] mb-3 flex-shrink-0">Generated Images</h3>
220-
<div class="relative flex-1 min-h-0 overflow-y-auto">
221-
<!-- Loading Animation -->
222-
<div id="loader" class="hidden absolute inset-0 flex items-center justify-center bg-[var(--color-bg-primary)]/80 rounded-xl z-10">
223-
<div class="text-center">
224-
<svg class="animate-spin h-10 w-10 text-[var(--color-primary)] mx-auto mb-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
225-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
226-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
227-
</svg>
228-
<p class="text-xs text-[var(--color-text-secondary)]">Generating image...</p>
229-
</div>
230-
</div>
231-
<!-- Placeholder when no images -->
232-
<div id="result-placeholder" class="bg-[var(--color-bg-primary)]/50 border border-[#1E293B] rounded-xl p-6 min-h-[400px] flex items-center justify-center flex-shrink-0">
233-
<p class="text-xs text-[var(--color-text-secondary)] italic text-center">Your generated images will appear here</p>
218+
<div class="relative flex-1 min-h-0 overflow-y-auto">
219+
<!-- Loading Animation -->
220+
<div id="loader" class="hidden absolute inset-0 flex items-center justify-center bg-[var(--color-bg-primary)]/80 rounded-xl z-10">
221+
<div class="text-center">
222+
<svg class="animate-spin h-10 w-10 text-[var(--color-primary)] mx-auto mb-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
223+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
224+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
225+
</svg>
226+
<p class="text-xs text-[var(--color-text-secondary)]">Generating image...</p>
234227
</div>
235-
<!-- Results container -->
236-
<div id="result" class="space-y-4 pb-4"></div>
237228
</div>
229+
<!-- Placeholder when no images -->
230+
<div id="result-placeholder" class="min-h-[400px] flex items-center justify-center flex-shrink-0">
231+
<p class="text-xs text-[var(--color-text-secondary)] italic text-center">Your generated images will appear here</p>
232+
</div>
233+
<!-- Results container -->
234+
<div id="result" class="grid grid-cols-1 sm:grid-cols-2 gap-4 pb-4"></div>
238235
</div>
239236
</div>
240237
</div>

0 commit comments

Comments
 (0)