From 7c9490b8cd7000c57fe3274cfeefc6a9882f2be1 Mon Sep 17 00:00:00 2001 From: Dominik Chrastecky Date: Wed, 27 Mar 2024 21:47:34 +0100 Subject: [PATCH 1/2] Fix default width --- src/app/types/db/generation-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/types/db/generation-options.ts b/src/app/types/db/generation-options.ts index 130e28b..bd31cee 100644 --- a/src/app/types/db/generation-options.ts +++ b/src/app/types/db/generation-options.ts @@ -41,7 +41,7 @@ export const DefaultGenerationOptions: GenerationOptions = { cfgScale: 5, denoisingStrength: 0.75, height: 512, - width: 52, + width: 512, steps: 25, model: 'AlbedoBase XL (SDXL)', karras: true, From 1916c4b556dcac939b05c0d24b093d42b98177d1 Mon Sep 17 00:00:00 2001 From: Rikudou_Sage Date: Wed, 27 Mar 2024 22:57:23 +0100 Subject: [PATCH 2/2] Feat: Add slider with value (#19) --- .../slider-with-value.component.html | 4 ++ .../slider-with-value.component.scss | 9 +++ .../slider-with-value.component.ts | 64 +++++++++++++++++++ .../generate-image.component.html | 32 +++++----- .../generate-image.component.ts | 4 +- 5 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 src/app/components/slider-with-value/slider-with-value.component.html create mode 100644 src/app/components/slider-with-value/slider-with-value.component.scss create mode 100644 src/app/components/slider-with-value/slider-with-value.component.ts diff --git a/src/app/components/slider-with-value/slider-with-value.component.html b/src/app/components/slider-with-value/slider-with-value.component.html new file mode 100644 index 0000000..c64cde9 --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/src/app/components/slider-with-value/slider-with-value.component.scss b/src/app/components/slider-with-value/slider-with-value.component.scss new file mode 100644 index 0000000..7eb920f --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.scss @@ -0,0 +1,9 @@ +div > input { + &:first-child { + flex: 85% 1 1; + margin-right: 1vw; + } + &:last-child { + flex: 15% 1 1; + } +} diff --git a/src/app/components/slider-with-value/slider-with-value.component.ts b/src/app/components/slider-with-value/slider-with-value.component.ts new file mode 100644 index 0000000..bbc9a6b --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.ts @@ -0,0 +1,64 @@ +import {Component, effect, input, signal, WritableSignal} from '@angular/core'; +import {ControlValueAccessor, NG_VALUE_ACCESSOR, ReactiveFormsModule} from "@angular/forms"; +import {OnChange, OnTouched} from "../../types/value-accessor"; + +@Component({ + selector: 'app-slider-with-value', + standalone: true, + imports: [ + ReactiveFormsModule + ], + templateUrl: './slider-with-value.component.html', + styleUrl: './slider-with-value.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + multi: true, + useExisting: SliderWithValueComponent, + }, + ] +}) +export class SliderWithValueComponent implements ControlValueAccessor { + protected readonly Number = Number; + + private onChange: WritableSignal | null> = signal(null); + private onTouched: WritableSignal = signal(null); + + public inputId = input(); + public required = input(false); + public min = input(null); + public max = input(null); + public step = input(null); + + public disabled = signal(false); + + public value = signal(0); + + constructor() { + effect(() => { + if (this.onChange() === null) { + return; + } + (this.onChange()!)(this.value()); + if (this.onTouched() !== null) { + (this.onTouched()!)(); + } + }); + } + + public registerOnChange(fn: OnChange): void { + this.onChange.set(fn); + } + + public registerOnTouched(fn: OnTouched): void { + this.onTouched.set(fn); + } + + public setDisabledState(isDisabled: boolean): void { + this.disabled.set(isDisabled); + } + + public writeValue(obj: number): void { + this.value.set(obj); + } +} diff --git a/src/app/pages/generate-image/generate-image.component.html b/src/app/pages/generate-image/generate-image.component.html index 1eee10c..797610e 100644 --- a/src/app/pages/generate-image/generate-image.component.html +++ b/src/app/pages/generate-image/generate-image.component.html @@ -147,9 +147,9 @@ @if (form.value.faceFixers?.length) {
- - + + +
}
@@ -186,28 +186,26 @@
- - + + +
- - + + +
- - + + +
- - + + +
diff --git a/src/app/pages/generate-image/generate-image.component.ts b/src/app/pages/generate-image/generate-image.component.ts index 42b3df3..41d9891 100644 --- a/src/app/pages/generate-image/generate-image.component.ts +++ b/src/app/pages/generate-image/generate-image.component.ts @@ -62,6 +62,7 @@ import {getFaceFixers, getGenericPostProcessors, getUpscalers} from "../../helpe import _ from 'lodash'; import {BaselineModel} from "../../types/sd-repo/baseline-model"; import {AutoGrowDirective} from "../../directives/auto-grow.directive"; +import {SliderWithValueComponent} from "../../components/slider-with-value/slider-with-value.component"; interface Result { width: number; @@ -103,7 +104,8 @@ interface Result { LoraTextRowComponent, IsFaceFixerPipe, IsUpscalerPipe, - AutoGrowDirective + AutoGrowDirective, + SliderWithValueComponent ], templateUrl: './generate-image.component.html', styleUrl: './generate-image.component.scss'