rvv041 #82

Merged
pitmutt merged 30 commits from rvv041 into milestone2 2024-06-07 20:03:06 +00:00
Showing only changes of commit a33ae3b595 - Show all commits

View file

@ -162,6 +162,7 @@ data DisplayType
| TxDisplay | TxDisplay
| SyncDisplay | SyncDisplay
| SendDisplay | SendDisplay
| AdrBookEntryDisplay
| BlankDisplay | BlankDisplay
data Tick data Tick
@ -194,6 +195,9 @@ data State = State
, _abaddresses :: !(L.List Name (Entity AddressBook)) , _abaddresses :: !(L.List Name (Entity AddressBook))
, _abForm :: !(Form AdrBookEntry () Name) , _abForm :: !(Form AdrBookEntry () Name)
, _abCurAdrs :: !T.Text , _abCurAdrs :: !T.Text
, _abTxt :: !T.Text
, _showConfirm :: Bool
, _confirmResult :: Maybe Bool
} }
makeLenses ''State makeLenses ''State
@ -411,7 +415,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
(renderForm (st ^. abForm) <=> (renderForm (st ^. abForm) <=>
C.hCenter C.hCenter
(hBox [capCommand "" " Delete", capCommand3 "" "<Esc>" " Cancel"])) (hBox [capCommand "" " Delete", capCommand3 "" "<Esc>" " Cancel"]))
--
splashDialog :: State -> Widget Name splashDialog :: State -> Widget Name
splashDialog st = splashDialog st =
@ -547,6 +551,14 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
(strWrapWith (strWrapWith
(WrapSettings False True NoFill FillAfterFirst) (WrapSettings False True NoFill FillAfterFirst)
(st ^. msg))) (st ^. msg)))
AdrBookEntryDisplay ->
withBorderStyle unicodeBold $
D.renderDialog
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60)
(padAll 1 $
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
(st ^. abTxt))
BlankDisplay -> emptyWidget BlankDisplay -> emptyWidget
mkInputForm :: DialogInput -> Form DialogInput e Name mkInputForm :: DialogInput -> Form DialogInput e Name
@ -749,6 +761,7 @@ appEvent (BT.AppEvent t) = do
TxDisplay -> return () TxDisplay -> return ()
SyncDisplay -> return () SyncDisplay -> return ()
SendDisplay -> BT.modify $ set msg m SendDisplay -> BT.modify $ set msg m
AdrBookEntryDisplay -> return ()
BlankDisplay -> return () BlankDisplay -> return ()
TickVal v -> do TickVal v -> do
case s ^. displayBox of case s ^. displayBox of
@ -757,6 +770,7 @@ appEvent (BT.AppEvent t) = do
PhraseDisplay -> return () PhraseDisplay -> return ()
TxDisplay -> return () TxDisplay -> return ()
SendDisplay -> return () SendDisplay -> return ()
AdrBookEntryDisplay -> return ()
SyncDisplay -> do SyncDisplay -> do
if s ^. barValue == 1.0 if s ^. barValue == 1.0
then do then do
@ -880,6 +894,7 @@ appEvent (BT.VtyEvent e) = do
TxDisplay -> BT.modify $ set displayBox BlankDisplay TxDisplay -> BT.modify $ set displayBox BlankDisplay
SendDisplay -> BT.modify $ set displayBox BlankDisplay SendDisplay -> BT.modify $ set displayBox BlankDisplay
SyncDisplay -> BT.modify $ set displayBox BlankDisplay SyncDisplay -> BT.modify $ set displayBox BlankDisplay
AdrBookEntryDisplay -> BT.modify $ set displayBox BlankDisplay
BlankDisplay -> do BlankDisplay -> do
case s ^. dialogBox of case s ^. dialogBox of
WName -> do WName -> do
@ -1084,6 +1099,18 @@ appEvent (BT.VtyEvent e) = do
V.EvKey (V.KChar 'n') [] -> do V.EvKey (V.KChar 'n') [] -> do
BT.modify $ set abForm $ mkNewABForm (AdrBookEntry "" "") BT.modify $ set abForm $ mkNewABForm (AdrBookEntry "" "")
BT.modify $ set dialogBox AdrBookForm BT.modify $ set dialogBox AdrBookForm
-- Show AddressBook entry data
V.EvKey V.KEnter [] -> do
case L.listSelectedElement $ s ^. abaddresses of
Just (_, a) -> do
BT.modify $ set abTxt $ T.pack $
" Descr: " ++
T.unpack (addressBookDescrip (entityVal a)) ++
"\n Address: " ++
T.unpack (addressBookAddress (entityVal a))
BT.modify $ set displayBox AdrBookEntryDisplay
_ -> do
BT.modify $ set dialogBox Blank
-- Process any other event -- Process any other event
ev -> BT.zoom abaddresses $ L.handleListEvent ev ev -> BT.zoom abaddresses $ L.handleListEvent ev
-- Process new address book entry -- Process new address book entry
@ -1106,8 +1133,8 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set msg ("New AddressBook entry created!!\n" ++ T.unpack (fs ^.address)) BT.modify $ set msg ("New AddressBook entry created!!\n" ++ T.unpack (fs ^.address))
BT.modify $ set displayBox MsgDisplay BT.modify $ set displayBox MsgDisplay
-- case end -- case end
ab <- liftIO $ refreshAddressBook s s' <- liftIO $ refreshAddressBook s
BT.put ab BT.put s'
BT.modify $ set dialogBox AdrBook BT.modify $ set dialogBox AdrBook
else do else do
BT.modify $ set msg "Invalid or missing data!!: " BT.modify $ set msg "Invalid or missing data!!: "
@ -1134,7 +1161,6 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set msg ("AddressBook entry modified!!\n" ++ T.unpack (fs ^.address)) BT.modify $ set msg ("AddressBook entry modified!!\n" ++ T.unpack (fs ^.address))
BT.modify $ set displayBox MsgDisplay BT.modify $ set displayBox MsgDisplay
-- case end -- case end
-- BT.modify $ set dialogBox AdrBook
s' <- liftIO $ refreshAddressBook s s' <- liftIO $ refreshAddressBook s
BT.put s' BT.put s'
BT.modify $ set dialogBox AdrBook BT.modify $ set dialogBox AdrBook
@ -1149,7 +1175,7 @@ appEvent (BT.VtyEvent e) = do
setFieldValid setFieldValid
(isRecipientValid (fs ^. address)) (isRecipientValid (fs ^. address))
AddressField AddressField
-- Process new address book entry -- Process delete AddresBook entry
AdrBookDelForm -> do AdrBookDelForm -> do
case e of case e of
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
@ -1306,6 +1332,9 @@ runZenithCLI config = do
(L.list ABList (Vec.fromList abookList) 1) (L.list ABList (Vec.fromList abookList) 1)
(mkNewABForm (AdrBookEntry "" "")) (mkNewABForm (AdrBookEntry "" ""))
" " " "
""
False
Nothing
Left e -> print $ Left e -> print $
"No Zebra node available on port " <> "No Zebra node available on port " <>
show port <> ". Check your configuration." show port <> ". Check your configuration."