[config] gc_frames type instead of separate urls in GargConfig

parent 3b3f5109
......@@ -60,11 +60,6 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo =
, _gc_masteruser
, _gc_secretkey
, _gc_datafilepath
, _gc_frame_write_url
, _gc_frame_calc_url
, _gc_frame_visio_url
, _gc_frame_searx_url
, _gc_frame_istex_url
, _gc_max_docs_parsers
, _gc_max_docs_scrapers
, _gc_js_job_timeout
......@@ -75,7 +70,12 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo =
, _gc_nlp_config = nlpConfig
, _gc_frontend_config = mkFrontendConfig ini
, _gc_database_config = connInfo
, _gc_notifications_config = defaultNotificationsConfig }
, _gc_notifications_config = defaultNotificationsConfig
, _gc_frames = CTypes.FramesConfig { _f_write_url = _gc_frame_write_url
, _f_calc_url = _gc_frame_calc_url
, _f_visio_url = _gc_frame_visio_url
, _f_searx_url = _gc_frame_searx_url
, _f_istex_url = _gc_frame_istex_url } }
mkFrontendConfig :: Ini.GargConfig -> CTypes.FrontendConfig
mkFrontendConfig (Ini.GargConfig { .. }) =
......
......@@ -21,7 +21,10 @@ import Data.Text qualified as Text
import Data.Time.Calendar (Day, toGregorian)
import Data.Time.Format (defaultTimeLocale, formatTime, parseTimeM)
import Data.Tuple.Select (sel1, sel2, sel3)
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.Core (Lang(..))
import Gargantext.Core.Config (GargConfig(..))
import Gargantext.Core.Config.Types (FramesConfig(..))
import Gargantext.Core.NLP (HasNLPServer, nlpServerGet)
import Gargantext.Core.NodeStory.Types ( HasNodeStory )
import Gargantext.Core.Text.Corpus.Query qualified as Query
......@@ -43,12 +46,11 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Database.Query.Tree.Error (HasTreeError)
import Gargantext.Database.Query.Tree.Root (getOrMkRootWithCorpus, MkCorpusUser (MkCorpusUserMaster))
import Gargantext.Prelude hiding (All)
import Gargantext.Core.Config (GargConfig(..))
import Gargantext.Utils.Jobs.Monad (JobHandle, MonadJobStatus(..))
import Network.HTTP.Client
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Prelude qualified
import Gargantext.API.Admin.Types (HasSettings)
langToSearx :: Lang -> Text
langToSearx x = Text.toLower acronym <> "-" <> acronym
......@@ -188,7 +190,7 @@ triggerSearxSearch user cId q l jobHandle = do
-- printDebug "[triggerSearxSearch] l" l
cfg <- view hasConfig
uId <- getUserId user
let surl = _gc_frame_searx_url cfg
let surl = _f_searx_url $ _gc_frames cfg
-- printDebug "[triggerSearxSearch] surl" surl
listId <- getOrMkList cId uId
......
......@@ -21,11 +21,6 @@ module Gargantext.Core.Config (
, gc_backend_name
, gc_datafilepath
, gc_epo_api_url
, gc_frame_calc_url
, gc_frame_istex_url
, gc_frame_searx_url
, gc_frame_visio_url
, gc_frame_write_url
, gc_js_id_timeout
, gc_js_job_timeout
, gc_masteruser
......@@ -40,6 +35,7 @@ module Gargantext.Core.Config (
, gc_database_config
, gc_nlp_config
, gc_notifications_config
, gc_frames
, mkProxyUrl
) where
......@@ -58,38 +54,32 @@ import Toml.Schema
-- stripRight :: Char -> T.Text -> T.Text
-- stripRight c s = if T.last s == c then stripRight c (T.take (T.length s - 1) s) else s
data GargConfig = GargConfig { _gc_backend_name :: !T.Text
, _gc_url :: !T.Text
, _gc_url_backend_api :: !T.Text
data GargConfig = GargConfig { _gc_backend_name :: !T.Text
, _gc_url :: !T.Text
, _gc_url_backend_api :: !T.Text
, _gc_masteruser :: !T.Text
, _gc_secretkey :: !T.Text
, _gc_masteruser :: !T.Text
, _gc_secretkey :: !T.Text
, _gc_datafilepath :: !FilePath
, _gc_datafilepath :: !FilePath
-- , _gc_repofilepath :: !FilePath
, _gc_frame_write_url :: !T.Text
, _gc_frame_calc_url :: !T.Text
, _gc_frame_visio_url :: !T.Text
, _gc_max_docs_parsers :: !Integer
, _gc_max_docs_scrapers :: !Integer
, _gc_frame_searx_url :: !T.Text
, _gc_frame_istex_url :: !T.Text
, _gc_js_job_timeout :: !Integer
, _gc_js_id_timeout :: !Integer
, _gc_max_docs_parsers :: !Integer
, _gc_max_docs_scrapers :: !Integer
, _gc_pubmed_api_key :: !T.Text
, _gc_js_job_timeout :: !Integer
, _gc_js_id_timeout :: !Integer
, _gc_epo_api_url :: !T.Text
, _gc_pubmed_api_key :: !T.Text
, _gc_epo_api_url :: !T.Text
, _gc_frontend_config :: !FrontendConfig
, _gc_mail_config :: !MailConfig
, _gc_database_config :: !PSQL.ConnectInfo
, _gc_nlp_config :: !NLPConfig
, _gc_frontend_config :: !FrontendConfig
, _gc_mail_config :: !MailConfig
, _gc_database_config :: !PSQL.ConnectInfo
, _gc_nlp_config :: !NLPConfig
, _gc_notifications_config :: !NotificationsConfig
, _gc_frames :: !FramesConfig
}
deriving (Generic, Show)
......@@ -103,7 +93,7 @@ instance FromValue GargConfig where
_gc_nlp_config <- reqKey "nlp"
secrets <- reqKey "secrets"
_gc_datafilepath <- reqKeyOf "paths" $ parseTableFromValue $ reqKey "data_filepath"
frames <- reqKeyOf "external" $ parseTableFromValue $ reqKey "frames"
_gc_frames <- reqKeyOf "external" $ parseTableFromValue $ reqKey "frames"
jobs <- reqKey "jobs"
apis <- reqKey "apis"
_gc_notifications_config <- reqKey "notifications"
......@@ -113,11 +103,6 @@ instance FromValue GargConfig where
, _gc_masteruser = _s_master_user secrets
, _gc_secretkey = _s_secret_key secrets
, _gc_datafilepath
, _gc_frame_write_url = _f_write_url frames
, _gc_frame_calc_url = _f_calc_url frames
, _gc_frame_visio_url = _f_visio_url frames
, _gc_frame_searx_url = _f_searx_url frames
, _gc_frame_istex_url = _f_istex_url frames
, _gc_max_docs_parsers = _jc_max_docs_parsers jobs
, _gc_max_docs_scrapers = _jc_max_docs_scrapers jobs
, _gc_js_job_timeout = _jc_js_job_timeout jobs
......@@ -128,7 +113,8 @@ instance FromValue GargConfig where
, _gc_mail_config
, _gc_database_config = unTOMLConnectInfo db_config
, _gc_nlp_config
, _gc_notifications_config }
, _gc_notifications_config
, _gc_frames }
instance ToValue GargConfig where
toValue = defaultTableToValue
instance ToTable GargConfig where
......@@ -137,7 +123,7 @@ instance ToTable GargConfig where
, "secrets" .= secrets
, "paths" .= table [ "data_filepath" .= _gc_datafilepath ]
, "apis" .= apis
, "external" .= table [ "frames" .= frames ]
, "external" .= table [ "frames" .= _gc_frames ]
, "jobs" .= jobs
, "database" .= TOMLConnectInfo _gc_database_config
, "mail" .= _gc_mail_config
......@@ -149,11 +135,6 @@ instance ToTable GargConfig where
, _s_secret_key = _gc_secretkey }
apis = APIsConfig { _ac_pubmed_api_key = _gc_pubmed_api_key
, _ac_epo_api_url = _gc_epo_api_url }
frames = FramesConfig { _f_write_url = _gc_frame_write_url
, _f_calc_url = _gc_frame_calc_url
, _f_visio_url = _gc_frame_visio_url
, _f_searx_url = _gc_frame_searx_url
, _f_istex_url = _gc_frame_istex_url }
jobs = JobsConfig { _jc_max_docs_parsers = _gc_max_docs_parsers
, _jc_max_docs_scrapers = _gc_max_docs_scrapers
, _jc_js_job_timeout = _gc_js_job_timeout
......
......@@ -26,6 +26,12 @@ module Gargantext.Core.Config.Types
, NotificationsConfig(..)
, SecretsConfig(..)
, f_write_url
, f_calc_url
, f_visio_url
, f_searx_url
, f_istex_url
, corsUseOriginsForHosts
, corsAllowedOrigins
, corsAllowedHosts
......@@ -159,6 +165,8 @@ instance ToTable FramesConfig where
, "searx_url" .= _f_searx_url
, "istex_url" .= _f_istex_url ]
makeLenses ''FramesConfig
data FrontendConfig =
FrontendConfig { _fc_url :: !Text
......
......@@ -25,7 +25,7 @@ import Data.Text qualified as T
import Gargantext.API.Admin.Types (settings, _microservicesSettings, HasSettings)
import Gargantext.Core
import Gargantext.Core.Config (GargConfig(..), mkProxyUrl)
import Gargantext.Core.Config.Types (MicroServicesSettings(..))
import Gargantext.Core.Config.Types (FramesConfig(..), MicroServicesSettings(..))
import Gargantext.Core.Types (Name)
import Gargantext.Database.Admin.Types.Hyperdata
import Gargantext.Database.Admin.Types.Hyperdata.Default
......@@ -101,7 +101,7 @@ mkNodeWithParent_ConfigureHyperdata _ _ _ _ = nodeError NotImplYet
internalNotesProxy :: GargConfig -> MicroServicesSettings -> T.Text
internalNotesProxy cfg msSettings
| _msProxyEnabled msSettings = T.pack $ showBaseUrl proxyUrl <> "/notes"
| otherwise = _gc_frame_write_url cfg
| otherwise = _f_write_url $ _gc_frames cfg
where
proxyUrl = mkProxyUrl cfg msSettings
......@@ -123,8 +123,8 @@ mkNodeWithParent_ConfigureHyperdata' nt (Just i) uId name = do
stt <- view settings
u <- case nt of
Notes -> pure $ internalNotesProxy cfg (_microservicesSettings stt)
Calc -> pure $ _gc_frame_calc_url cfg
NodeFrameVisio -> pure $ _gc_frame_visio_url cfg
Calc -> pure $ _f_calc_url $ _gc_frames cfg
NodeFrameVisio -> pure $ _f_visio_url $ _gc_frames cfg
_ -> nodeError NeedsConfiguration
let
s = _gc_secretkey cfg
......
......@@ -38,7 +38,8 @@ import Gargantext.API.Node.ShareURL qualified as Share
import Gargantext.API.Routes.Named.Private
import Gargantext.API.Routes.Named.Share (ShareLink(..))
import Gargantext.API.ThrowAll (throwAllRoutes)
import Gargantext.Core.Config (gc_frame_write_url, mkProxyUrl)
import Gargantext.Core.Config (gc_frames, mkProxyUrl)
import Gargantext.Core.Config.Types (f_write_url)
import Gargantext.Database.Admin.Types.Node (NodeType(..), NodeId (..))
import Gargantext.Database.Prelude (hasConfig)
import Gargantext.Prelude hiding (Handler)
......@@ -274,7 +275,7 @@ proxyPassServer sty env = defaultForwardServer sty id id env
mkProxyDestination :: Env -> ProxyDestination
mkProxyDestination env = fromMaybe (panicTrace "Invalid URI found in the proxied Request.") $ do
baseUrl <- parseBaseUrl (T.unpack $ env ^. hasConfig . gc_frame_write_url)
baseUrl <- parseBaseUrl (T.unpack $ env ^. hasConfig . gc_frames . f_write_url)
pure $ ProxyDestination baseUrl
--
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment