Fix clients table

This commit is contained in:
Smaug123
2022-11-12 20:34:01 +00:00
parent 0accc01126
commit 9f91cae1e1
2 changed files with 39 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
namespace RaftFable
open System
open System.Collections.Generic
open System.Security.Cryptography
open Fable.Core.JS
@@ -62,9 +63,9 @@ module App =
(fun () ->
match response with
| RegisterClientResponse.Success client ->
if clients.TryAdd (client, HashSet ()) then
()
else
try
clients.Add (client, HashSet ())
with :? ArgumentException ->
failwith "got a response a second time - need to handle this in the UI"
| RegisterClientResponse.NotLeader hint -> failwith "asked a non-leader, have to handle it"
)

View File

@@ -284,47 +284,48 @@ module Ui =
| None -> leaderIdBox.innerText <- sprintf "%i: not a leader" userPrefs.LeaderUnderConsideration
| Some leaderState ->
let knownStoredIndices =
leaderState.MatchIndex
|> Seq.mapi (fun target index ->
let target = target * 1<ServerId>
let knownStoredIndices =
leaderState.MatchIndex
|> Seq.mapi (fun target index ->
let target = target * 1<ServerId>
if target = userPrefs.LeaderUnderConsideration then
"(self)"
else
sprintf "%i" index
)
|> Seq.toList
|> fun l -> "Log index known to be stored on each node" :: l
|> List.map (fun text ->
let node = document.createElement "div"
node.innerText <- text
Some node
)
if target = userPrefs.LeaderUnderConsideration then
"(self)"
else
sprintf "%i" index
)
|> Seq.toList
|> fun l -> "Log index known to be stored on each node" :: l
|> List.map (fun text ->
let node = document.createElement "div"
node.innerText <- text
Some node
)
Table.createRow document knownStoredIndices ui.LeaderStateTable |> ignore
Table.createRow document knownStoredIndices ui.LeaderStateTable |> ignore
let nextToSend =
leaderState.ToSend
|> Seq.mapi (fun target index ->
let target = target * 1<ServerId>
let nextToSend =
leaderState.ToSend
|> Seq.mapi (fun target index ->
let target = target * 1<ServerId>
if target = userPrefs.LeaderUnderConsideration then
"(self)"
else
sprintf "%i" index
)
|> Seq.toList
|> fun l -> "Will try next to send this index" :: l
|> List.map (fun text ->
let node = document.createElement "div"
node.innerText <- text
Some node
)
if target = userPrefs.LeaderUnderConsideration then
"(self)"
else
sprintf "%i" index
)
|> Seq.toList
|> fun l -> "Will try next to send this index" :: l
|> List.map (fun text ->
let node = document.createElement "div"
node.innerText <- text
Some node
)
Table.createRow document nextToSend ui.LeaderStateTable |> ignore
Table.createRow document nextToSend ui.LeaderStateTable |> ignore
Table.createHeaderRow document [ "Client ID" ; "Successful requests" ] ui.ClientsList
// Clients
for KeyValue (clientId, committed) in state.Clients do
let clientNode =
@@ -339,8 +340,6 @@ module Ui =
node.innerText <- text
node
printfn "hi!"
Table.createRow document [ Some clientNode ; Some messagesNode ] ui.ClientsList
|> ignore