Sync RR.
This commit is contained in:
parent
f0db34d694
commit
d23699d85a
@ -129,7 +129,10 @@ data Action
|
|||||||
-- Update an already active entry.
|
-- Update an already active entry.
|
||||||
| UpdateLocalForm RRId Update_Local_Form
|
| UpdateLocalForm RRId Update_Local_Form
|
||||||
|
|
||||||
| SyncRR RRId
|
| SyncSRR RRId
|
||||||
|
| SyncMXRR RRId
|
||||||
|
| SyncSRVRR RRId
|
||||||
|
|
||||||
| RemoveRR RRId
|
| RemoveRR RRId
|
||||||
|
|
||||||
| TellSomethingWentWrong RRId String
|
| TellSomethingWentWrong RRId String
|
||||||
@ -423,13 +426,44 @@ handleAction = case _ of
|
|||||||
state <- H.get
|
state <- H.get
|
||||||
H.modify_ _ { _srvrr = (update_port rr_id val state._srvrr) }
|
H.modify_ _ { _srvrr = (update_port rr_id val state._srvrr) }
|
||||||
|
|
||||||
-- TODO: network operations
|
SyncSRR local_rr_id -> do
|
||||||
SyncRR rr_id -> do
|
state <- H.get
|
||||||
H.raise $ Log $ SimpleLog ("TODO: SyncRR: " <> show rr_id)
|
let maybe_local_rr = first (\rr -> rr.id == local_rr_id) state._srr
|
||||||
-- message <- H.liftEffect
|
case maybe_local_rr of
|
||||||
-- $ DNSManager.serialize
|
Nothing -> H.raise $ Log $ SimpleLog $ "Cannot find simple RR id: " <> show local_rr_id
|
||||||
-- $ DNSManager.MkDeleteRR { domain: _current_domain, rrid: rr_id }
|
Just local_rr -> do
|
||||||
-- H.raise $ MessageToSend message
|
let rr = fromLocalSimpleRRRepresentationToResourceRecord local_rr
|
||||||
|
H.raise $ Log $ SimpleLog $ "Sync a simple RR: " <> show local_rr_id
|
||||||
|
message <- H.liftEffect
|
||||||
|
$ DNSManager.serialize
|
||||||
|
$ DNSManager.MkUpdateRR { domain: state._current_domain, rr: rr }
|
||||||
|
H.raise $ MessageToSend message
|
||||||
|
|
||||||
|
SyncMXRR local_rr_id -> do
|
||||||
|
state <- H.get
|
||||||
|
let maybe_local_rr = first (\rr -> rr.id == local_rr_id) state._mxrr
|
||||||
|
case maybe_local_rr of
|
||||||
|
Nothing -> H.raise $ Log $ SimpleLog $ "Cannot find MX RR id: " <> show local_rr_id
|
||||||
|
Just local_rr -> do
|
||||||
|
let rr = fromLocalMXRRRepresentationToResourceRecord local_rr
|
||||||
|
H.raise $ Log $ SimpleLog $ "Sync a MX RR: " <> show local_rr_id
|
||||||
|
message <- H.liftEffect
|
||||||
|
$ DNSManager.serialize
|
||||||
|
$ DNSManager.MkUpdateRR { domain: state._current_domain, rr: rr }
|
||||||
|
H.raise $ MessageToSend message
|
||||||
|
|
||||||
|
SyncSRVRR local_rr_id -> do
|
||||||
|
state <- H.get
|
||||||
|
let maybe_local_rr = first (\rr -> rr.id == local_rr_id) state._srvrr
|
||||||
|
case maybe_local_rr of
|
||||||
|
Nothing -> H.raise $ Log $ SimpleLog $ "Cannot find SRV RR id: " <> show local_rr_id
|
||||||
|
Just local_rr -> do
|
||||||
|
let rr = fromLocalSRVRRepresentationToResourceRecord local_rr
|
||||||
|
H.raise $ Log $ SimpleLog $ "Sync a SRV RR: " <> show local_rr_id
|
||||||
|
message <- H.liftEffect
|
||||||
|
$ DNSManager.serialize
|
||||||
|
$ DNSManager.MkUpdateRR { domain: state._current_domain, rr: rr }
|
||||||
|
H.raise $ MessageToSend message
|
||||||
|
|
||||||
RemoveRR rr_id -> do
|
RemoveRR rr_id -> do
|
||||||
{ _current_domain } <- H.get
|
{ _current_domain } <- H.get
|
||||||
@ -613,7 +647,7 @@ render_records records
|
|||||||
, HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_Domain) rr.domain rr.valid ]
|
, HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_Domain) rr.domain rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_TTL ) rr.ttl rr.valid ]
|
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_TTL ) rr.ttl rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_Value) rr.value rr.valid ]
|
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRR <<< Update_SRR_Value) rr.value rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_change (SyncRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
, HH.td_ [ Bulma.btn_change (SyncSRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -638,7 +672,7 @@ render_mx_records records
|
|||||||
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_TTL) rr.ttl rr.valid ]
|
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_TTL) rr.ttl rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_Priority) rr.priority rr.valid ]
|
, HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_Priority) rr.priority rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_Value) rr.value rr.valid ]
|
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_MXRR <<< Update_MX_Value) rr.value rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_change (SyncRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
, HH.td_ [ Bulma.btn_change (SyncMXRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -665,7 +699,7 @@ render_srv_records records
|
|||||||
, HH.td_ [ Bulma.input_weight ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Weight ) rr.weight rr.valid ]
|
, HH.td_ [ Bulma.input_weight ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Weight ) rr.weight rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_port ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Port ) rr.port rr.valid ]
|
, HH.td_ [ Bulma.input_port ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Port ) rr.port rr.valid ]
|
||||||
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Value ) rr.value rr.valid ]
|
, HH.td_ [ Bulma.input_value ((UpdateLocalForm rr.id) <<< Update_Local_Form_SRVRR <<< Update_SRV_Value ) rr.value rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_change (SyncRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
, HH.td_ [ Bulma.btn_change (SyncSRVRR rr.id) (TellSomethingWentWrong rr.id "cannot update") rr.modified rr.valid ]
|
||||||
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.id) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -955,6 +989,9 @@ fromLocalSRVRRepresentationToResourceRecord form
|
|||||||
, minttl: Nothing
|
, minttl: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
first :: forall a. (a -> Boolean) -> Array a -> Maybe a
|
||||||
|
first condition = A.head <<< (A.filter condition)
|
||||||
|
|
||||||
getNewID :: State -> Int
|
getNewID :: State -> Int
|
||||||
getNewID state = (_ + 1)
|
getNewID state = (_ + 1)
|
||||||
$ Foldable.foldl max 0 [ maxIDrr
|
$ Foldable.foldl max 0 [ maxIDrr
|
||||||
|
Loading…
Reference in New Issue
Block a user