Skip to content

Commit 2b9f2ac

Browse files
committed
Update TextToImage.mjs
1 parent ee5e2f8 commit 2b9f2ac

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

AiServer/wwwroot/mjs/components/TextToImage.mjs

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ref, computed, onMounted, inject, watch, nextTick } from "vue"
2-
import { useClient } from "@servicestack/vue"
3-
import { createErrorStatus } from "@servicestack/client"
2+
import { useClient, useFormatters } from "@servicestack/vue"
3+
import { createErrorStatus, fromXsdDuration } from "@servicestack/client"
44
import { TextToImage, ActiveMediaModels } from "../dtos.mjs"
55
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, toArtifacts } from "../utils.mjs"
66
import { ArtifactGallery, ArtifactDownloads } from "./Artifacts.mjs"
@@ -28,22 +28,10 @@ export default {
2828
<div class="col-span-6 sm:col-span-2">
2929
<SelectInput id="model" v-model="request.model" :entries="activeModels" label="Active Models" required />
3030
</div>
31-
<div class="col-span-6 sm:col-span-4">
31+
<div class="col-span-6 sm:col-span-3">
3232
<TextInput id="negativePrompt" v-model="request.negativePrompt" required placeholder="Negative Prompt" />
3333
</div>
3434
<div class="col-span-6 sm:col-span-1">
35-
<TextInput type="number" id="width" v-model="request.width" min="0" required />
36-
</div>
37-
<div class="col-span-6 sm:col-span-1">
38-
<TextInput type="number" id="height" v-model="request.height" min="0" required />
39-
</div>
40-
<div class="col-span-6 sm:col-span-1">
41-
<TextInput type="number" id="batchSize" label="Image Count" v-model="request.batchSize" min="0" required />
42-
</div>
43-
<div class="col-span-6 sm:col-span-1">
44-
<TextInput type="number" id="seed" v-model="request.seed" min="0" />
45-
</div>
46-
<div class="col-span-6 sm:col-span-2">
4735
<TextInput id="tag" v-model="request.tag" placeholder="Tag" />
4836
</div>
4937
</div>
@@ -64,6 +52,22 @@ export default {
6452
</button>
6553
</div>
6654
</div>
55+
56+
<div class="mt-4 grid grid-cols-6 gap-4">
57+
<div class="col-span-6 sm:col-span-1">
58+
<TextInput type="number" id="width" v-model="request.width" min="0" required />
59+
</div>
60+
<div class="col-span-6 sm:col-span-1">
61+
<TextInput type="number" id="height" v-model="request.height" min="0" required />
62+
</div>
63+
<div class="col-span-6 sm:col-span-1">
64+
<TextInput type="number" id="batchSize" label="Image Count" v-model="request.batchSize" min="0" required />
65+
</div>
66+
<div class="col-span-6 sm:col-span-1">
67+
<TextInput type="number" id="seed" v-model="request.seed" min="0" />
68+
</div>
69+
</div>
70+
6771
</fieldset>
6872
</div>
6973
</div>
@@ -89,10 +93,15 @@ export default {
8993
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path fill="currentColor" d="M12 12h2v12h-2zm6 0h2v12h-2z"></path><path fill="currentColor" d="M4 6v2h2v20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8h2V6zm4 22V8h16v20zm4-26h8v2h-8z"></path></svg>
9094
</div>
9195
</div>
92-
<div v-if="result.request.model" class="float-right">
93-
<span class="inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-blue-700 ring-1 ring-inset ring-blue-700/10">
96+
<div v-if="result.request.model" class="float-right">
97+
<span class="inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-blue-700 ring-1 ring-inset ring-blue-700/10"
98+
:title="'Image Model ' + result.request.model">
9499
{{activeModels.find(x => x.key == result.request.model)?.value || result.request.model}}
95100
</span>
101+
<span v-if="result.response.duration" class="ml-2 inline-flex items-center rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10"
102+
:title="'Executed in ' + formatDuration(result.response.duration)">
103+
{{formatDuration(result.response.duration)}}
104+
</span>
96105
</div>
97106
98107
<ArtifactGallery :results="toArtifacts(result)">
@@ -282,6 +291,17 @@ export default {
282291
}
283292
}
284293
}
294+
295+
function formatDuration(xsdDuration) {
296+
const seconds = fromXsdDuration(xsdDuration)
297+
const wholeSeconds = Math.floor(seconds);
298+
const milliseconds = Math.round((seconds - wholeSeconds) * 1000);
299+
const duration = {
300+
seconds: wholeSeconds,
301+
milliseconds: milliseconds
302+
};
303+
return new Intl.DurationFormat("en", { style:"narrow" }).format(duration)
304+
}
285305

286306
watch(() => routes.id, updated)
287307
watch(() => [
@@ -332,6 +352,7 @@ export default {
332352
getThreadResults,
333353
saveHistoryItem,
334354
removeHistoryItem,
355+
formatDuration,
335356
}
336357
}
337358
}

0 commit comments

Comments
 (0)