Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Sep 14, 2024
1 parent 24a6be0 commit a762850
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
12 changes: 6 additions & 6 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ primary_region = 'lhr'

[build]

[http_service]
[[services]]
internal_port = 9999
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
protocol = "tcp"

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[vm]]
memory = '1gb'
Expand Down
28 changes: 20 additions & 8 deletions frontend/src/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ case class JobAttributes(
val error = Var(Option.empty[String])

val updateJob =
id.signal.changes.flatMapSwitch:
case None => EventStream.fromValue(None)
id.signal.flatMapSwitch:
case None => Signal.fromValue(None)
case Some(id) =>
val client =
WebSocket.path(s"/ws/connect/$id").string.build(managed = false)
client.reconnectNow()

client.received
.tapEach(_ => client.sendOne("ping"))
.map(upickle.default.read[Result](_))
.map(Some(_))
Signal
.fromValue(client.reconnectNow())
.combineWith(client.isConnected)
.flatMapSwitch: isConnected =>
println(isConnected)
if isConnected then
client.received
.tapEach(_ => client.sendOne("ping"))
.map(upickle.default.read[Result](_))
.map(Some(_))
.startWith(None)
else Signal.fromValue(None)

val cancelButton =
button(
Expand Down Expand Up @@ -183,7 +190,7 @@ case class JobAttributes(
) --> id
)

val basicLink =
val basicLink =
cls := "text-indigo-500 underline hover:no-underline"

val app =
Expand All @@ -205,6 +212,11 @@ case class JobAttributes(
href := "https://github.com/indoorvivants/scalafmt-genetic-optimiser",
"Github repository"
),
a(
basicLink,
href := "http://twitter.com/velvetbaldmime",
"Author on Twitter"
),
a(
basicLink,
href := "http://twitter.com/velvetbaldmime",
Expand Down

0 comments on commit a762850

Please sign in to comment.