Skip to content

Commit

Permalink
some model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Apr 9, 2024
1 parent 32dba4f commit e219f44
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 23 deletions.
6 changes: 4 additions & 2 deletions src/Init/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import Route.Pathfinder as Route

init : Model
init =
{ networks = []
, route = Route.Root
{ network = Nothing

--, route = Route.Root
, selection = []
, dragging = NoDragging
, transform = Transform.init
, history = History.init
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type Hovered
type Dragging id
= NoDragging
| Dragging (Transform.Model id) Coords Coords
| DraggingNode EntityId Coords Coords
| DraggingNode id Coords Coords


type alias Deserializing =
Expand Down
11 changes: 8 additions & 3 deletions src/Model/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import Model.Graph.Transform as Transform
import Model.Pathfinder.History.Entry as Entry
import Model.Pathfinder.Id exposing (Id)
import Model.Pathfinder.Network exposing (Network)
import Route.Pathfinder



--import Route.Pathfinder


type alias Model =
{ networks : List Network
, route : Route.Pathfinder.Route
{ network : Maybe Network

--, route : Route.Pathfinder.Route
, dragging : Dragging Id
, selection : List Id
, transform : Transform.Model Id
, history : History.Model Entry.Model
}
2 changes: 1 addition & 1 deletion src/Model/Pathfinder/History/Entry.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import Model.Pathfinder.Network exposing (Network)


type alias Model =
{ networks : List Network
{ network : Maybe Network
}
17 changes: 16 additions & 1 deletion src/Model/Pathfinder/Tx.elm
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
module Model.Pathfinder.Tx exposing (..)

import Api.Data
import Dict exposing (Dict)
import Model.Pathfinder.Id exposing (Id)
import Model.Pathfinder.Input exposing (Input)
import Model.Pathfinder.Output exposing (Output)


type alias Tx =
type Tx
= Account AccontTx
| Utxo UtxoTx


type alias AccontTx =
{ from : String
, to : String
, value : Api.Data.Values
, id : Id
}


type alias UtxoTx =
{ inputs : Dict Id Input
, outputs : Dict Id Output
, id : Id
}
1 change: 1 addition & 0 deletions src/Route.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Plugin.Model
import Plugin.Route as Plugin
import Route.Graph as Graph
import Route.Pathfinder as Pathfinder
import Theme.Pathfinder exposing (Pathfinder)
import Url exposing (..)
import Url.Builder exposing (..)
import Util.Url.Parser as P exposing (..)
Expand Down
4 changes: 2 additions & 2 deletions src/Update/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ forcePushHistory model =

makeHistoryEntry : Model -> Entry.Model
makeHistoryEntry model =
{ networks = model.networks
{ network = model.network
}


Expand All @@ -142,7 +142,7 @@ undoRedo fun model =
(\( history, entry ) ->
{ model
| history = history
, networks = entry.networks
, network = entry.network
}
)
|> Maybe.withDefault model
Expand Down
15 changes: 13 additions & 2 deletions src/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Model.Dialog as Dialog
import Plugin.View as Plugin exposing (Plugins)
import Route
import Route.Graph
import Route.Pathfinder as Pathfinder
import Util.Css
import Util.View exposing (hovercard)
import View.Dialog as Dialog
Expand Down Expand Up @@ -99,13 +100,23 @@ sidebar plugins vc model =
|> href
]
, FontAwesome.icon FontAwesome.projectDiagram
|> Html.Styled.fromUnstyled
|> List.singleton
|> a
[ model.page == Graph |> Css.View.sidebarIcon vc |> css
, title (Locale.string vc.locale "Graph")
, model.graph.route
|> Route.graphRoute
|> Route.toUrl
|> href
]
, FontAwesome.icon FontAwesome.networkWired
|> Html.Styled.fromUnstyled
|> List.singleton
|> a
[ model.page == Pathfinder |> Css.View.sidebarIcon vc |> css
, title (Locale.string vc.locale "Pathfinder")
, model.pathfinder.route
|> Route.pathfinderRoute
, Route.pathfinderRoute Pathfinder.Root
|> Route.toUrl
|> href
]
Expand Down
101 changes: 90 additions & 11 deletions src/View/Pathfinder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ module View.Pathfinder exposing (view)

import Config.Pathfinder as Pathfinder
import Config.View as View
import Css
import Css.Graph
import Css.Pathfinder as Css
import Html.Styled exposing (..)
import FontAwesome
import Html.Styled as Html exposing (..)
import Html.Styled.Attributes as HA exposing (..)
import Html.Styled.Lazy exposing (..)
import Json.Decode
Expand All @@ -15,6 +17,7 @@ import Model.Pathfinder.Network exposing (Network)
import Msg.Pathfinder exposing (Msg(..))
import Plugin.Model exposing (ModelState)
import Plugin.View as Plugin exposing (Plugins)
import Quicklock exposing (plugin)
import Svg.Styled exposing (..)
import Svg.Styled.Attributes as Svg exposing (..)
import Svg.Styled.Events as Svg exposing (..)
Expand All @@ -40,6 +43,83 @@ graph plugins states vc gc model =
|> Maybe.map (graphSvg plugins states vc gc model)
|> Maybe.withDefault none
]
++ [ titleAndSettings plugins states vc gc model
, graphTools plugins states vc gc model
, propertiesAndSearch plugins states vc gc model
]


boxStyle : List Css.Style
boxStyle =
[]


toolItemStyle : List Css.Style
toolItemStyle =
[ Css.em 2 |> Css.fontSize
, Css.px 5 |> Css.marginRight
, Css.px 5 |> Css.marginLeft
]


titleAndSettingsStyle : List Css.Style
titleAndSettingsStyle =
[ Css.position Css.absolute
, Css.px 10 |> Css.left
, Css.px 10 |> Css.top
]


graphToolsStyle : List Css.Style
graphToolsStyle =
[ Css.position Css.absolute
, Css.pct 50 |> Css.left
, Css.pct 50 |> Css.right
, Css.px 40 |> Css.bottom
, Css.px 200 |> Css.minWidth
, Css.px 1 |> Css.borderWidth
, Css.displayFlex
]


propertiesAndSearchStyle : List Css.Style
propertiesAndSearchStyle =
[ Css.position Css.absolute
, Css.px 10 |> Css.right
, Css.px 10 |> Css.top
]
++ boxStyle


titleAndSettings : Plugins -> ModelState -> View.Config -> Pathfinder.Config -> Model -> Svg Msg
titleAndSettings plugins _ vc gc model =
div [ titleAndSettingsStyle |> HA.css ]
[ h1 [] [ Html.Styled.text "Pathfinder" ]
]


graphTools : Plugins -> ModelState -> View.Config -> Pathfinder.Config -> Model -> Svg Msg
graphTools plugins _ vc gc model =
div
[ graphToolsStyle |> HA.css
]
[ div [ toolItemStyle |> HA.css ] [ FontAwesome.icon FontAwesome.trash |> Html.fromUnstyled ]
, div [ toolItemStyle |> HA.css ] [ FontAwesome.icon FontAwesome.redo |> Html.fromUnstyled ]
, div [ toolItemStyle |> HA.css ] [ FontAwesome.icon FontAwesome.undo |> Html.fromUnstyled ]
, div [ toolItemStyle |> HA.css ] [ FontAwesome.icon FontAwesome.highlighter |> Html.fromUnstyled ]
]


propertiesAndSearch : Plugins -> ModelState -> View.Config -> Pathfinder.Config -> Model -> Svg Msg
propertiesAndSearch plugins _ vc gc model =
div [ propertiesAndSearchStyle |> HA.css ]
[ Html.Styled.text "Pathfinder"
]



--propertyBoxTools : Plugins -> ModelState -> View.Config -> Pathfinder.Config -> Model -> Svg Msg
--propertyBoxTools = div [boxStyle |> HA.css] [Html.Styled.text "Property box tools"]


graphSvg : Plugins -> ModelState -> View.Config -> Pathfinder.Config -> Model -> BBox -> Svg Msg
Expand Down Expand Up @@ -83,16 +163,15 @@ graphSvg plugins _ vc gc model bbox =
[]
)
)
[ Svg.lazy4 networks plugins vc gc model.networks
[ model.network |> Maybe.map (Svg.lazy4 networks plugins vc gc) |> Maybe.withDefault (div [] [])
]


networks : Plugins -> View.Config -> Pathfinder.Config -> List Network -> Svg Msg
networks plugins vc gc =
List.map
(\network ->
( "Pathfinder.network." ++ network.name
, Svg.lazy4 Network.addresses plugins vc gc network.addresses
)
)
>> Keyed.node "g" []
networks : Plugins -> View.Config -> Pathfinder.Config -> Network -> Svg Msg
networks plugins vc gc network =
Keyed.node "g"
[]
[ ( "Pathfinder.network." ++ network.name
, Svg.lazy4 Network.addresses plugins vc gc network.addresses
)
]

0 comments on commit e219f44

Please sign in to comment.