feat: Adds psi to feet of head conversion.
Some checks failed
CI / ubuntu (push) Failing after 7m22s
CI / macOS (debug, 16.2) (push) Has been cancelled
CI / macOS (release, 16.2) (push) Has been cancelled

This commit is contained in:
2025-03-07 16:27:03 -05:00
parent 159031a023
commit a44cc6975d
12 changed files with 312 additions and 3 deletions

View File

@@ -67,6 +67,12 @@ struct HomePage: HTML, Sendable {
svg: .circleGauge,
route: .hydronicSystemPressure(.index)
)
group(
label: "Feet of Head",
description: FeetOfHead.description,
svg: .footprints,
route: .feetOfHead(.index)
)
}
}

View File

@@ -100,6 +100,15 @@ extension ViewController: DependencyKey {
return DehumidifierSizeResult(response: response)
}
case let .feetOfHead(route):
switch route {
case .index:
return request.respond(FeetOfHeadForm(response: nil))
case let .submit(request):
let response = try await request.respond(logger: logger)
return FeetOfHeadResponse(response: response)
}
case let .filterPressureDrop(route):
switch route {
case let .index(mode: mode):

View File

@@ -0,0 +1,70 @@
import Elementary
import ElementaryHTMX
import PsychrometricClient
import Routes
import Styleguide
struct FeetOfHeadForm: HTML, Sendable {
let response: FeetOfHead.Response?
typealias Key = FeetOfHead.Request.FieldKey
var content: some HTML {
FormHeader(label: "Feet of Head", svg: .footprints)
form(
.hx.post(route: .feetOfHead(.index)),
.hx.target("#result")
) {
div(.class("space-y-6")) {
div(.class("grid grid-cols-2 gap-4")) {
LabeledContent(label: "Pressure (psi)") {
Input(id: Key.pressure, placeholder: "Pressure")
.attributes(.type(.number), .min("0.1"), .step("0.1"), .autofocus, .required)
}
LabeledContent(label: "Water Temperature (\(String.fahrenheit))") {
Input(id: Key.waterTemperature, placeholder: "Temperature (optional)")
.attributes(.type(.number), .min("32.0"), .step("0.1"))
}
}
Note {
"""
If water temperature is not supplied, then calculations will be based on 60\(String.fahrenheit) water.
"""
}
div {
SubmitButton(label: "Feet of Head")
}
}
}
div(.id("result")) {
if let response {
FeetOfHeadResponse(response: response)
}
}
}
}
struct FeetOfHeadResponse: HTML, Sendable {
let response: FeetOfHead.Response
var content: some HTML {
ResultContainer(reset: .feetOfHead(.index)) {
ResultBox {
div(.class("grid grid-cols-2")) {
VerticalGroup(label: "Feet of Head", value: "\(double: response.feetOfHead)", valueLabel: "ft.")
VerticalGroup(
label: "Water Density",
value: "\(double: response.density.value)",
valueLabel: response.density.units.rawValue
)
}
}
WarningBox(warnings: response.warnings)
}
}
}