fix: various inbox and ui tweaks

This commit is contained in:
Jonas Juselius
2023-12-13 14:57:09 +01:00
parent c41df1d67d
commit 95b227adf3
3 changed files with 31 additions and 19 deletions

View File

@@ -162,32 +162,37 @@ let inboxDialog
| MessageType.Progress ->
let j = decodeProgressMessage item.content
let jobName =
html $"""<span style="max-width: 20px; text-overflow: ellipsis">{j.name}</span>"""
html $"""
<span title="{j.name}" style="display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis">
{j.name}
</span>"""
let eta =
if j.eta > 0 then
html $"completion in {(TimeSpan.FromSeconds j.eta).Minutes} min."
if j.eta > 60 then
html $"Completion in {(TimeSpan.FromSeconds j.eta).Minutes} min"
elif j.eta > 0 then
html $"Completion in {j.eta} s"
else
html $"is running."
html $"Running"
let progress =
if j.progress < 0 then
Lit.nothing
else
html $"""
{j.progress}%% <sp-progress-bar progress="{j.progress}"></sp-progress-bar>
<sp-progress-bar side-label label=" " progress="{j.progress}"></sp-progress-bar>
"""
html $"""
<div style="display: flex; justify-content: space-between">
<span>Job '{jobName}' {eta}.</span>
<div style="display: flex; align-items: center; font-weight: bold">Job '{jobName}': {eta}.</div>
<span>{progress}</span>
</div>"""
| MessageType.Drifters ->
let j = decodeJobMessage item.content
match j.status with
| JobStatus.Completed -> $"Job '{j.name}' finished."
| JobStatus.Failed -> $"Job '{j.name}' with jobid {j.job} failed."
| JobStatus.Waiting -> $"Job '{j.name}' has been queued."
| JobStatus.Running -> $"Job '{j.name}' has started with jobid {j.job}"
| JobStatus.Completed -> $"Job '{j.name}': Done."
| JobStatus.Failed -> $"Job '{j.name}': Job id {j.job} failed."
| JobStatus.Waiting -> $"Job '{j.name}': Queued."
| JobStatus.Running -> $"Job '{j.name}': Started with jobid {j.job}"
| _ -> "Something went wrong..."
|> unread item.unread
| _ -> unread item.unread item.content
@@ -203,10 +208,10 @@ let inboxDialog
<sp-table-cell @click={Ev(chooseItem item)}>
{message}
</sp-table-cell>
<sp-table-cell @click={Ev(chooseItem item)} style="max-width: 100px">
<sp-table-cell @click={Ev(chooseItem item)} style="max-width: 100px; align-items: center; display: flex">
{unread item.unread (inboxMessageTypeToString item.type')}
</sp-table-cell>
<sp-table-cell @click={Ev(chooseItem item)} style="max-width: 120px">
<sp-table-cell @click={Ev(chooseItem item)} style="max-width: 120px; align-items: center; display: flex">
{unread item.unread (item.created.ToString "dd/MM/yyyy")}
</sp-table-cell>
"""
@@ -261,7 +266,7 @@ let inboxDialog
<sp-action-group horizontal>
{readSelectedButton}
{deleteSelectedButton}
{if true then sendMessageButton else Lit.nothing}
{if false then sendMessageButton else Lit.nothing}
</sp-action-group>
</div>
</sp-dialog>

View File

@@ -288,8 +288,11 @@ let addAquacultureHoverInteraction map dispatch : unit =
let feature = ev.selected[0]
let geom = feature.getGeometry()
let coord = geom.getExtent() |> Extent.extent.getCenter
let species =
feature.get("arter") :?> string
|> fun s -> if s.Length > 80 then $"{s.Substring(0, 80)}..." else s
elem?heading <- feature.get("lokalitet")
elem?subheading <- feature.get("arter")
elem?subheading <- species
desc.innerText <- feature.get("innehaver") :?> string
popup.setPosition(Some coord)
)
@@ -1162,6 +1165,7 @@ let update cmd (model: Model) =
{ model with identity = identity }, Cmd.none
| SetUnread n ->
let n' = if n = abs(model.inboxUnread) then -model.inboxUnread else n
console.log $"unread: {n'}"
{ model with inboxUnread = n' }, Cmd.none
| SelectPlume id ->
console.log $"Selected plume: {id}"
@@ -1172,7 +1176,7 @@ let update cmd (model: Model) =
let aquaculturePopup =
html $"""
<sp-card id="aquaculture-popup" heading="Undefined" subheading="Undefined">
<div slot="description">...</div>
<div slot="footer">...</div>
</sp-card>
"""
@@ -1460,6 +1464,7 @@ let initModel () =
Cmd.OfAsync.perform getIdentity () SetIdentity
Cmd.OfAsync.perform archive () SetArchive
Cmd.OfAsync.perform atmoApi.Wind.GetBarbSigns () SetArrows
Cmd.ofMsg (AddInfoLayer InfoLayer.Lokaliteter)
]
let plotPage dispatch model =
@@ -1699,12 +1704,12 @@ let MapApp () =
unread = true
type' =
match count with
| n when n > 0 && n < 5 -> MessageType.Progress
| n when n < 5 -> MessageType.Progress
| _ -> MessageType.Drifters
created = DateTime.Now
content =
match count with
| n when n > 0 && n < 5 ->
| n when n < 5 ->
Encode.Auto.toString {
aid = aid
job = 0

View File

@@ -41,10 +41,12 @@ let private handleIncoming model msg =
let handleHubMsg model msg =
match msg with
| Incoming incoming -> handleIncoming model incoming
| Incoming incoming ->
// console.debug("[SignalR] Incoming from Atlantis server")
handleIncoming model incoming
| Outgoing action ->
console.debug("[SignalR] Invoke Atlantis server")
model, Cmd.SignalR.perform model.hub action (Incoming >> HubMsg)
| RegisterHub hub ->
console.debug("[SignalR] Connected to the SignalR hub.")
{ model with hub = Some hub }, Cmd.none
{ model with hub = Some hub }, Cmd.none