Code refactoring. Serious code refactoring.

This commit is contained in:
Philippe Pittoli 2024-03-13 15:24:20 +01:00
parent 480943d563
commit 19caf90341
25 changed files with 68 additions and 68 deletions

View File

@ -15,7 +15,7 @@
-- | In case the old page is `Zone`, send a request to `dnsmanagerd` to get the zone content again. -- | In case the old page is `Zone`, send a request to `dnsmanagerd` to get the zone content again.
-- | -- |
-- | Once a message is received, it is transfered to the module of the current page; -- | Once a message is received, it is transfered to the module of the current page;
-- | except for the `App.Messages.DNSManagerDaemon.AnswerMessage` `Logged` which is an hint when the -- | except for the `App.Message.DNSManagerDaemon.AnswerMessage` `Logged` which is an hint when the
-- | page has been reloaded, thus having a special treatment. -- | page has been reloaded, thus having a special treatment.
-- | -- |
-- | TODO: -- | TODO:
@ -60,8 +60,8 @@ import Type.Proxy (Proxy(..))
import Effect.Aff.Class (class MonadAff) import Effect.Aff.Class (class MonadAff)
import Data.ArrayBuffer.Types (ArrayBuffer) import Data.ArrayBuffer.Types (ArrayBuffer)
import App.Messages.DNSManagerDaemon as DNSManager import App.Message.DNSManagerDaemon as DNSManager
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
import App.Log as AppLog import App.Log as AppLog
import App.WS as WS import App.WS as WS
@ -80,11 +80,11 @@ import Web.HTML (window) as HTML
import Web.HTML.Window (sessionStorage) as Window import Web.HTML.Window (sessionStorage) as Window
import Web.Storage.Storage as Storage import Web.Storage.Storage as Storage
import App.Email as Email import App.Type.Email as Email
import App.LogMessage (LogMessage(..)) import App.Type.LogMessage (LogMessage(..))
import App.Pages import App.Type.Pages
import CSSClasses as C import CSSClasses as C
type Token = String type Token = String

View File

@ -11,7 +11,7 @@ import Effect.Aff.Class (class MonadAff)
import Halogen as H import Halogen as H
import Halogen.HTML as HH import Halogen.HTML as HH
import App.LogMessage import App.Type.LogMessage
data Output = Void data Output = Void
type Slot = H.Slot Query Output type Slot = H.Slot Query Output

View File

@ -1,4 +1,4 @@
module App.Messages.AuthenticationDaemon where module App.Message.AuthenticationDaemon where
import Prelude (bind, pure, show, ($)) import Prelude (bind, pure, show, ($))
@ -14,15 +14,15 @@ import Data.UInt (fromInt, toInt, UInt)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.ArrayBuffer.Types (ArrayBuffer) import Data.ArrayBuffer.Types (ArrayBuffer)
import App.Email as Email import App.Type.Email as Email
import App.UserPublic as UserPublic import App.Type.UserPublic as UserPublic
import App.PermissionLevel as PermissionLevel import App.Type.PermissionLevel as PermissionLevel
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Data.Argonaut.Parser as JSONParser import Data.Argonaut.Parser as JSONParser
import Data.Bifunctor (lmap) import Data.Bifunctor (lmap)
import App.IPC as IPC import App.Message.IPC as IPC
{- TODO: {- TODO:
For a few messages, user can be designated by a string (login) or a number (its UID). For a few messages, user can be designated by a string (login) or a number (its UID).

View File

@ -1,4 +1,4 @@
module App.Messages.DNSManagerDaemon where module App.Message.DNSManagerDaemon where
import Prelude (bind, pure, show, ($)) import Prelude (bind, pure, show, ($))
@ -14,16 +14,16 @@ import Data.UInt (fromInt, toInt, UInt)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.ArrayBuffer.Types (ArrayBuffer) import Data.ArrayBuffer.Types (ArrayBuffer)
-- import App.PermissionLevel as PermissionLevel -- import App.Type.PermissionLevel as PermissionLevel
import App.MaintenanceSubject as MaintenanceSubject import App.Type.MaintenanceSubject as MaintenanceSubject
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Data.Argonaut.Parser as JSONParser import Data.Argonaut.Parser as JSONParser
import Data.Bifunctor (lmap) import Data.Bifunctor (lmap)
import App.IPC as IPC import App.Message.IPC as IPC
import App.DNSZone as DNSZone import App.Type.DNSZone as DNSZone
import App.ResourceRecord as ResourceRecord import App.Type.ResourceRecord as ResourceRecord
{- UserID should be in a separate module with a dedicated codec. -} {- UserID should be in a separate module with a dedicated codec. -}
type UserID = Int -- UserID is either a login or an uid number type UserID = Int -- UserID is either a login or an uid number

View File

@ -1,4 +1,4 @@
module App.IPC (toIPC, fromIPC, toTypedIPC, fromTypedIPC) where module App.Message.IPC (toIPC, fromIPC, toTypedIPC, fromTypedIPC) where
{- {-
This file contains raw serialization and deserialization of IPC messages. This file contains raw serialization and deserialization of IPC messages.
@ -10,7 +10,7 @@ module App.IPC (toIPC, fromIPC, toTypedIPC, fromTypedIPC) where
The message type informs what format should be expected. The message type informs what format should be expected.
For example: an authentication attempt, a page request, etc. For example: an authentication attempt, a page request, etc.
Actual message formats can be found in the App.Messages folder. Actual message formats can be found in the App.Message folder.
-} -}
import Prelude (bind, (<$>), discard, ($), (>>>), (+), (-)) import Prelude (bind, (<$>), discard, ($), (>>>), (+), (-))

View File

@ -30,15 +30,15 @@ import Web.HTML (window) as HTML
import Web.HTML.Window (sessionStorage) as Window import Web.HTML.Window (sessionStorage) as Window
import Web.Storage.Storage as Storage import Web.Storage.Storage as Storage
import App.UserPublic (UserPublic) import App.Type.UserPublic (UserPublic)
import Data.ArrayBuffer.Types (ArrayBuffer) import Data.ArrayBuffer.Types (ArrayBuffer)
import App.LogMessage import App.Type.LogMessage
-- import App.IPC as IPC -- import App.IPC as IPC
import App.Email as Email import App.Type.Email as Email
-- import App.Messages.DNSManagerDaemon as DNSManager -- import App.Message.DNSManagerDaemon as DNSManager
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
data Output data Output
= MessageToSend ArrayBuffer = MessageToSend ArrayBuffer

View File

@ -19,8 +19,8 @@ import Web.Event.Event (Event)
import Bulma as Bulma import Bulma as Bulma
import App.LogMessage import App.Type.LogMessage
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
import App.Validation.Login as L import App.Validation.Login as L
import App.Validation.Email as E import App.Validation.Email as E

View File

@ -33,8 +33,8 @@ import App.DisplayErrors (error_to_paragraph_label)
import App.Validation.Label as Validation import App.Validation.Label as Validation
import CSSClasses as C import CSSClasses as C
import App.LogMessage import App.Type.LogMessage
import App.Messages.DNSManagerDaemon as DNSManager import App.Message.DNSManagerDaemon as DNSManager
-- | `App.DomainListInterface` can send messages through websocket interface -- | `App.DomainListInterface` can send messages through websocket interface
-- | connected to dnsmanagerd. See `App.WS`. -- | connected to dnsmanagerd. See `App.WS`.

View File

@ -19,8 +19,8 @@ import Web.Event.Event (Event)
import Bulma as Bulma import Bulma as Bulma
import App.LogMessage import App.Type.LogMessage
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
import App.Validation.Login as L import App.Validation.Login as L
import App.Validation.Token as T import App.Validation.Token as T

View File

@ -20,8 +20,8 @@ import Halogen.HTML.Properties.ARIA as ARIA
import CSSClasses as C import CSSClasses as C
import Bulma as Bulma import Bulma as Bulma
import App.Pages (Page(..)) import App.Type.Pages (Page(..))
import App.LogMessage (LogMessage) import App.Type.LogMessage (LogMessage)
data Output data Output
= Log LogMessage = Log LogMessage
@ -163,8 +163,8 @@ render { logged, active, admin } =
dropdown_element link str = HH.a [HP.classes C.navbar_item, HP.href link] [HH.text str] dropdown_element link str = HH.a [HP.classes C.navbar_item, HP.href link] [HH.text str]
dropdown_separator = HH.hr [HP.classes C.navbar_divider] dropdown_separator = HH.hr [HP.classes C.navbar_divider]
nav_button_strong str action = btn C.is_primary action (HH.strong [] [ HH.text str ]) --nav_button_strong str action = btn C.is_primary action (HH.strong [] [ HH.text str ])
nav_button classes str action = btn classes action (HH.text str) --nav_button classes str action = btn classes action (HH.text str)
nav_link_strong str action = nav_link_strong str action =
HH.a [ HP.classes (C.navbar_item <> C.is_danger <> C.has_background_success_dark) HH.a [ HP.classes (C.navbar_item <> C.is_danger <> C.has_background_success_dark)
@ -189,7 +189,7 @@ render { logged, active, admin } =
"(temporary repo) dnsmanager website" "(temporary repo) dnsmanager website"
] ]
btn c action str --btn c action str
= HH.a [ HP.classes (C.navbar_item <> C.button <> c) -- = HH.a [ HP.classes (C.navbar_item <> C.button <> c)
, HE.onClick (\_ -> action) -- , HE.onClick (\_ -> action)
] [ str ] -- ] [ str ]

View File

@ -18,9 +18,9 @@ import Web.Event.Event (Event)
import Bulma as Bulma import Bulma as Bulma
import App.Email as Email import App.Type.Email as Email
import App.LogMessage import App.Type.LogMessage
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
import App.Validation.Login as L import App.Validation.Login as L
import App.Validation.Email as E import App.Validation.Email as E

View File

@ -15,8 +15,8 @@ import Web.Event.Event (Event)
import Bulma as Bulma import Bulma as Bulma
import App.LogMessage import App.Type.LogMessage
import App.Messages.AuthenticationDaemon as AuthD import App.Message.AuthenticationDaemon as AuthD
data Output data Output
= Log LogMessage = Log LogMessage

View File

@ -43,20 +43,20 @@ import CSSClasses as C
import App.Text.Explanations as Explanations import App.Text.Explanations as Explanations
import App.AcceptedRRTypes (AcceptedRRTypes(..)) import App.Type.AcceptedRRTypes (AcceptedRRTypes(..))
import App.ResourceRecord (ResourceRecord, emptyRR import App.Type.ResourceRecord (ResourceRecord, emptyRR
, show_qualifier, show_qualifier_char , show_qualifier, show_qualifier_char
, show_mechanism_type, show_mechanism, to_mechanism , show_mechanism_type, show_mechanism, to_mechanism
, show_modifier_type, show_modifier, to_modifier , show_modifier_type, show_modifier, to_modifier
, all_qualifiers , all_qualifiers
, mechanism_types, qualifier_types, modifier_types) , mechanism_types, qualifier_types, modifier_types)
import App.ResourceRecord (Mechanism, Modifier, Qualifier(..)) as RR import App.Type.ResourceRecord (Mechanism, Modifier, Qualifier(..)) as RR
import App.DKIM as DKIM import App.Type.DKIM as DKIM
import App.DisplayErrors (error_to_paragraph) import App.DisplayErrors (error_to_paragraph)
import App.LogMessage (LogMessage(..)) import App.Type.LogMessage (LogMessage(..))
import App.Messages.DNSManagerDaemon as DNSManager import App.Message.DNSManagerDaemon as DNSManager
import App.Validation.DNS as Validation import App.Validation.DNS as Validation
type RRId = Int type RRId = Int
@ -827,7 +827,7 @@ render_resources records
then [ Bulma.box_ (C.no_padding_left <> C.no_padding_top <> colors) then [ Bulma.box_ (C.no_padding_left <> C.no_padding_top <> colors)
[title, Bulma.table_ (C.margin_left 3) [] [header, dp rrs]] ] [title, Bulma.table_ (C.margin_left 3) [] [header, dp rrs]] ]
else [] else []
title_col_props = C.is 1 --title_col_props = C.is 1
table_content_w_seps records_ = HH.tbody_ $ table_content_w_seps records_ = HH.tbody_ $
A.groupAllBy (comparing (_.rrtype)) records_ -- [x x y y z] -> [NE[xx], NE[yy], NE[z]] A.groupAllBy (comparing (_.rrtype)) records_ -- [x x y y z] -> [NE[xx], NE[yy], NE[z]]

View File

@ -1,7 +1,7 @@
-- | The application accepts to add a few new entry types in a DNS zone. -- | The application accepts to add a few new entry types in a DNS zone.
-- | Each resource record has a specific form, with dedicated inputs and -- | Each resource record has a specific form, with dedicated inputs and
-- | dedicated validation. -- | dedicated validation.
module App.AcceptedRRTypes where module App.Type.AcceptedRRTypes where
import Prelude import Prelude
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)

View File

@ -1,4 +1,4 @@
module App.DKIM where module App.Type.DKIM where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))

View File

@ -1,9 +1,9 @@
module App.DNSZone where module App.Type.DNSZone where
import Data.Codec.Argonaut (JsonCodec) import Data.Codec.Argonaut (JsonCodec)
import Data.Codec.Argonaut as CA import Data.Codec.Argonaut as CA
import Data.Codec.Argonaut.Record as CAR import Data.Codec.Argonaut.Record as CAR
import App.ResourceRecord as RR import App.Type.ResourceRecord as RR
type DNSZone type DNSZone
= { domain :: String = { domain :: String

View File

@ -1,6 +1,6 @@
-- | TODO: Email module should include at least some sort of smart -- | TODO: Email module should include at least some sort of smart
-- | constructors, rejecting invalid email addresses. -- | constructors, rejecting invalid email addresses.
module App.Email where module App.Type.Email where
import Prelude import Prelude

View File

@ -1,4 +1,4 @@
module App.LogMessage where module App.Type.LogMessage where
data LogMessage data LogMessage
= SystemLog String = SystemLog String

View File

@ -1,4 +1,4 @@
module App.MaintenanceSubject where module App.Type.MaintenanceSubject where
import Data.Codec.Argonaut as CA import Data.Codec.Argonaut as CA
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))

View File

@ -1,4 +1,4 @@
module App.Pages where module App.Type.Pages where
-- | This list will grow in a near future. -- | This list will grow in a near future.
-- | -- |
-- | TODO: -- | TODO:

View File

@ -1,4 +1,4 @@
module App.PermissionLevel where module App.Type.PermissionLevel where
import Data.Codec.Argonaut as CA import Data.Codec.Argonaut as CA
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))

View File

@ -1,4 +1,4 @@
module App.ResourceRecord where module App.Type.ResourceRecord where
import Prelude ((<>), map, bind, pure) import Prelude ((<>), map, bind, pure)
@ -8,7 +8,7 @@ import Data.Codec.Argonaut (JsonCodec)
import Data.Codec.Argonaut as CA import Data.Codec.Argonaut as CA
import Data.Codec.Argonaut.Record as CAR import Data.Codec.Argonaut.Record as CAR
import App.DKIM as DKIM import App.Type.DKIM as DKIM
type ResourceRecord type ResourceRecord
= { rrtype :: String = { rrtype :: String

View File

@ -1,4 +1,4 @@
module App.UserPublic where module App.Type.UserPublic where
import Data.Maybe (Maybe) import Data.Maybe (Maybe)

View File

@ -1,6 +1,6 @@
module App.Validation.DNS where module App.Validation.DNS where
import Prelude (apply, between, bind, map, pure, ($), (-), (<), (<>), (<$>)) import Prelude (apply, between, bind, map, pure, ($), (-), (<), (<>))
import Control.Alt ((<|>)) import Control.Alt ((<|>))
import Data.Array as A import Data.Array as A
@ -10,8 +10,8 @@ import Data.String.CodeUnits as CU
import Data.String as S import Data.String as S
import Data.Validation.Semigroup (V, invalid, toEither) import Data.Validation.Semigroup (V, invalid, toEither)
import App.ResourceRecord (ResourceRecord, emptyRR, Mechanism, Modifier, Qualifier) import App.Type.ResourceRecord (ResourceRecord, emptyRR, Mechanism, Modifier)
import App.ResourceRecord (MechanismType(..), ModifierType(..)) as RR import App.Type.ResourceRecord (MechanismType(..), ModifierType(..)) as RR
import GenericParser.SomeParsers as SomeParsers import GenericParser.SomeParsers as SomeParsers
import GenericParser.Parser as G import GenericParser.Parser as G
import GenericParser.DomainParser.Common (DomainError) as DomainParser import GenericParser.DomainParser.Common (DomainError) as DomainParser
@ -19,7 +19,7 @@ import GenericParser.DomainParser (sub_eof) as DomainParser
import GenericParser.IPAddress as IPAddress import GenericParser.IPAddress as IPAddress
import GenericParser.RFC5234 as RFC5234 import GenericParser.RFC5234 as RFC5234
import App.DKIM as DKIM import App.Type.DKIM as DKIM
-- | **History:** -- | **History:**
-- | The module once used dedicated types for each type of RR. -- | The module once used dedicated types for each type of RR.

View File

@ -32,7 +32,7 @@ import Web.Socket.Event.MessageEvent as WSME
import Web.Socket.ReadyState (ReadyState(Connecting, Open, Closing, Closed)) import Web.Socket.ReadyState (ReadyState(Connecting, Open, Closing, Closed))
import Web.Socket.WebSocket as WS import Web.Socket.WebSocket as WS
import App.LogMessage import App.Type.LogMessage
keepalive = 30000.0 :: Number keepalive = 30000.0 :: Number