2020-10-01 17:11:52 +00:00
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
2022-07-24 21:11:47 +00:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
2020-10-01 17:11:52 +00:00
|
|
|
module Types.Settings where
|
|
|
|
|
2022-07-24 21:11:47 +00:00
|
|
|
import Data.Aeson
|
|
|
|
|
2022-07-24 13:22:32 +00:00
|
|
|
import qualified Data.Text as T
|
2022-07-24 21:11:47 +00:00
|
|
|
import Data.OpenApi (ToSchema)
|
|
|
|
|
|
|
|
import GHC.Generics
|
2022-07-24 13:22:32 +00:00
|
|
|
|
|
|
|
-- internal imports
|
|
|
|
|
2021-06-09 21:45:43 +00:00
|
|
|
import Classes
|
|
|
|
|
2020-10-01 17:11:52 +00:00
|
|
|
data Settings = Settings
|
2021-10-16 15:49:50 +00:00
|
|
|
{ settingsBlockRegistration :: Bool
|
2022-07-24 14:11:37 +00:00
|
|
|
, settingsImprintText :: Maybe T.Text
|
2022-07-24 23:31:16 +00:00
|
|
|
, settingsIdleTime :: Int
|
2020-10-01 17:11:52 +00:00
|
|
|
}
|
2022-07-24 21:11:47 +00:00
|
|
|
deriving (Show, Generic)
|
2020-10-01 17:11:52 +00:00
|
|
|
|
2022-07-24 13:26:55 +00:00
|
|
|
instance DatabaseRepresentation Settings where
|
|
|
|
|
2022-07-24 23:31:16 +00:00
|
|
|
type Representation Settings = (Bool, Maybe T.Text, Int)
|
2020-10-01 17:11:52 +00:00
|
|
|
|
2022-07-24 13:26:55 +00:00
|
|
|
instance ToDatabase Settings where
|
2020-10-01 17:11:52 +00:00
|
|
|
|
2022-07-24 23:31:16 +00:00
|
|
|
toDatabase (Settings reg imprint idleTime) = (reg, imprint, idleTime)
|
2020-10-01 17:11:52 +00:00
|
|
|
|
2021-06-09 21:45:43 +00:00
|
|
|
instance FromDatabase Settings where
|
2020-10-01 17:11:52 +00:00
|
|
|
|
2022-07-24 23:31:16 +00:00
|
|
|
fromDatabase (reg, imprint, idleTime) = Settings reg imprint idleTime
|
2022-07-24 21:11:47 +00:00
|
|
|
|
|
|
|
instance FromJSON Settings
|
|
|
|
|
|
|
|
instance ToJSON Settings
|
|
|
|
|
|
|
|
instance ToSchema Settings
|