Commit 406521d3 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] read instance + fix warnings

parent 00786471
module Gargantext.AsyncTasks where module Gargantext.AsyncTasks where
import Data.Argonaut (decodeJson, class EncodeJson, encodeJson, (:=), (~>), (.:)) import Data.Argonaut (decodeJson)
import Data.Argonaut.Parser (jsonParser) import Data.Argonaut.Parser (jsonParser)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
......
...@@ -34,7 +34,7 @@ import Gargantext.Utils.Reactix as R2 ...@@ -34,7 +34,7 @@ import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, post, delete, put) import Gargantext.Sessions (Session, sessionId, post, delete, put)
import Gargantext.Types (NodeType(..), OrderBy(..), TabType, TabPostQuery(..), AffTableResult, NodeID) import Gargantext.Types (NodeType(..), OrderBy(..), TabType, TabPostQuery(..), AffTableResult)
------------------------------------------------------------------------ ------------------------------------------------------------------------
data Category = Trash | UnRead | Checked | Topic | Favorite data Category = Trash | UnRead | Checked | Topic | Favorite
......
module Gargantext.Components.Forest.Tree.Node.Action where module Gargantext.Components.Forest.Tree.Node.Action where
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Prelude (class Eq, class Show, class Read, Unit) import Gargantext.Prelude (class Show, Unit)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), glyphiconNodeAction) import Gargantext.Components.Forest.Tree.Node (NodeAction(..), glyphiconNodeAction)
......
...@@ -2,7 +2,6 @@ module Gargantext.Components.Forest.Tree.Node.Tools.FTree where ...@@ -2,7 +2,6 @@ module Gargantext.Components.Forest.Tree.Node.Tools.FTree where
import Data.Argonaut (class DecodeJson, decodeJson, (.:)) import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Types as GT import Gargantext.Types as GT
import Prelude hiding (div) import Prelude hiding (div)
......
module Gargantext.Types where module Gargantext.Types where
import Prelude
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
...@@ -11,9 +10,10 @@ import Data.Generic.Rep.Show (genericShow) ...@@ -11,9 +10,10 @@ import Data.Generic.Rep.Show (genericShow)
import Data.Int (toNumber) import Data.Int (toNumber)
import Data.Maybe (Maybe(..), maybe, fromMaybe) import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Prelude (class Read, read)
import Prelude
import Prim.Row (class Union) import Prim.Row (class Union)
import URI.Query (Query) import URI.Query (Query)
import Gargantext.Prelude (class Read, read)
type ID = Int type ID = Int
type Name = String type Name = String
...@@ -508,25 +508,28 @@ data AsyncTaskStatus = Running ...@@ -508,25 +508,28 @@ data AsyncTaskStatus = Running
| Finished | Finished
| Killed | Killed
derive instance genericAsyncTaskStatus :: Generic AsyncTaskStatus _ derive instance genericAsyncTaskStatus :: Generic AsyncTaskStatus _
instance showAsyncTaskStatus :: Show AsyncTaskStatus where instance showAsyncTaskStatus :: Show AsyncTaskStatus where
show = genericShow show = genericShow
derive instance eqAsyncTaskStatus :: Eq AsyncTaskStatus derive instance eqAsyncTaskStatus :: Eq AsyncTaskStatus
instance encodeJsonAsyncTaskStatus :: EncodeJson AsyncTaskStatus where instance encodeJsonAsyncTaskStatus :: EncodeJson AsyncTaskStatus where
encodeJson s = encodeJson $ show s encodeJson s = encodeJson $ show s
instance decodeJsonAsyncTaskStatus :: DecodeJson AsyncTaskStatus where instance decodeJsonAsyncTaskStatus :: DecodeJson AsyncTaskStatus where
decodeJson json = do decodeJson json = do
obj <- decodeJson json obj <- decodeJson json
pure $ readAsyncTaskStatus obj pure $ fromMaybe Running $ read obj
readAsyncTaskStatus :: String -> AsyncTaskStatus instance readAsyncTaskStatus :: Read AsyncTaskStatus where
readAsyncTaskStatus "IsFailure" = Failed read "IsFailure" = Just Failed
readAsyncTaskStatus "IsFinished" = Finished read "IsFinished" = Just Finished
readAsyncTaskStatus "IsKilled" = Killed read "IsKilled" = Just Killed
readAsyncTaskStatus "IsPending" = Pending read "IsPending" = Just Pending
readAsyncTaskStatus "IsReceived" = Received read "IsReceived" = Just Received
readAsyncTaskStatus "IsRunning" = Running read "IsRunning" = Just Running
readAsyncTaskStatus "IsStarted" = Started read "IsStarted" = Just Started
readAsyncTaskStatus _ = Running read _ = Nothing
newtype AsyncTask = newtype AsyncTask =
AsyncTask { id :: AsyncTaskID AsyncTask { id :: AsyncTaskID
......
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