Skip to content

Commit

Permalink
enhance: node_click, backdrop_click, cleaner js, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Oct 17, 2023
1 parent 57e626b commit d28e13a
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 417 deletions.
17 changes: 15 additions & 2 deletions src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ update msg model =
( { model | time = time, favicon = favicon }
, Cmd.batch
[ updateFavicon
, renderBuildGraph model
, refreshRenderBuildGraph model
]
)

Expand Down Expand Up @@ -2584,7 +2584,7 @@ refreshBuildServices model org repo buildNumber focusFragment =
Cmd.none


{-| refreshBuildGraph : takes model org repo and build number and refreshes the build status
{-| refreshBuildGraph : takes model org repo and build number and refreshes the build graph if necessary
-}
refreshBuildGraph : Model -> Org -> Repo -> BuildNumber -> Cmd Msg
refreshBuildGraph model org repo buildNumber =
Expand All @@ -2595,6 +2595,18 @@ refreshBuildGraph model org repo buildNumber =
Cmd.none


{-| refreshRenderBuildGraph : takes model org repo and build number and refreshes the build graph render if necessary
-}
refreshRenderBuildGraph : Model -> Cmd Msg
refreshRenderBuildGraph model =
case model.page of
Pages.BuildGraph _ _ _ ->
renderBuildGraph model

_ ->
Cmd.none


{-| shouldRefresh : takes build and returns true if a refresh is required
-}
shouldRefresh : BuildModel -> Bool
Expand Down Expand Up @@ -4301,6 +4313,7 @@ loadBuildGraphPage model org repo buildNumber =
Cmd.batch
[ getBuilds m org repo Nothing Nothing Nothing
, getBuild m org repo buildNumber
, getAllBuildSteps m org repo buildNumber Nothing False
, getBuildGraph m org repo buildNumber False
, renderBuildGraph model
]
Expand Down
42 changes: 24 additions & 18 deletions src/elm/Pages/Build/Graph.elm
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ import Visualization.DOT as DOT
)


{-| renderBuildGraphDOT : constant for organizing the layout of build graph nodes
-}
builtInClusterID : Int
builtInClusterID =
2


{-| pipelineClusterID : constant for organizing the layout of build graph nodes
-}
pipelineClusterID : Int
pipelineClusterID =
1


{-| serviceClusterID : constant for organizing the layout of build graph nodes
-}
serviceClusterID : Int
serviceClusterID =
0
-- renderBuildGraph : { a | repo : Vela.RepoModel, velaScheduleAllowlist : List ( Vela.Org, Vela.Repo ), navigationKey : Key, user : RemoteData.WebData Vela.CurrentUser, sourceRepos : RemoteData.WebData (SourceRepositories), page : Page, time : Posix, zone : Zone, shift : Bool, buildMenuOpen : List Int, pipeline : Vela.PipelineModel } -> Cmd msg


renderBuildGraph model =
Expand Down Expand Up @@ -76,13 +59,36 @@ renderBuildGraph model =
Cmd.none


{-| renderBuildGraphDOT : constant for organizing the layout of build graph nodes
-}
builtInClusterID : Int
builtInClusterID =
2


{-| pipelineClusterID : constant for organizing the layout of build graph nodes
-}
pipelineClusterID : Int
pipelineClusterID =
1


{-| serviceClusterID : constant for organizing the layout of build graph nodes
-}
serviceClusterID : Int
serviceClusterID =
0


{-| renderBuildGraphDOT : takes model and build graph, and returns a string representation of a DOT graph using the extended Graph DOT package
<https://graphviz.org/doc/info/lang.html>
<https://package.elm-lang.org/packages/elm-community/graph/latest/Graph.DOT>
-}
renderBuildGraphDOT : BuildModel.PartialModel a -> BuildGraph -> String
renderBuildGraphDOT model buildGraph =
let
-- todo: BUG: single step "step" sleep 10 pipeline when you hover
-- the text changes color???
isNodeFocused : String -> BuildGraphNode -> Bool
isNodeFocused filter n =
n.id
Expand Down
64 changes: 5 additions & 59 deletions src/elm/Pages/Build/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -599,28 +599,22 @@ viewBuildGraph model msgs org repo buildNumber =
, class "d3-build-graph-node-outline-rect"
, class "d3-build-graph-node-step-a"
, class "d3-build-graph-node-step-a-underline"
, class "d3-build-graph-step-connector"
, class "d3-build-graph-edge-path"
, class "-pending"
, class "-running"
, class "-success"
, class "-failure"
, class "-killed"
, class "-canceled"
, class "-skipped"
, class "-hover"
, class "-focus"
, class "-filtered"
]
[]
]

focusedNode =
case model.repo.build.graph.graph of
RemoteData.Success g ->
Dict.get model.repo.build.graph.focusedNode g.nodes

-- dont render anything when the build graph draw command has been dispatched
-- Maybe.withDefault "" <| List.head <| List.filter (\n -> n.id == model.repo.build.graph.focusedNode ) <| Dict.fromList g.nodes
_ ->
Nothing

actions =
div [ class "elm-build-graph-actions" ]
[ ul []
Expand All @@ -629,34 +623,11 @@ viewBuildGraph model msgs org repo buildNumber =
[ FeatherIcons.minimize |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml []
]
]

-- , li []
-- [ button
-- [ class "button"
-- , class "-icon"
-- , id "action-collapse"
-- , Html.Attributes.title "Collapse all stages"
-- , onClick msgs.buildGraphMsgs.collapseAllStages
-- ]
-- [ FeatherIcons.minimize2 |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml []
-- ]
-- ]
-- , li []
-- [ button
-- [ class "button"
-- , class "-icon"
-- , id "action-expand"
-- , Html.Attributes.title "Expand all stages"
-- , onClick msgs.buildGraphMsgs.expandAllStages
-- ]
-- [ FeatherIcons.maximize2 |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml []
-- ]
-- ]
, li []
[ button
[ class "button"
, class "-icon"
, id "action-refresh"
, class "action-refresh"
, Html.Attributes.title "Refresh visualization"
, onClick <| msgs.buildGraphMsgs.refresh org repo buildNumber
]
Expand Down Expand Up @@ -717,31 +688,6 @@ viewBuildGraph model msgs org repo buildNumber =
]
[ FeatherIcons.x |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml [] ]
]

-- todo: cleanup
-- , case focusedNode of
-- Just n ->
-- div [ class "elm-build-graph-focused-node" ]
-- [ span [] [ text <| "focused: " ++ n.name ]
-- , button
-- [ class "button"
-- , class "-icon"
-- , class "elm-build-graph-search-filter-clear"
-- , onClick msgs.buildGraphMsgs.clearFocus
-- ]
-- [ FeatherIcons.x |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml [] ]
-- ]
-- Nothing ->
-- div [ class "elm-build-graph-focused-node" ]
-- [ span [] [ text <| "focused: none" ]
-- , button
-- [ class "button"
-- , class "-icon"
-- , class "elm-build-graph-search-filter-clear"
-- , onClick msgs.buildGraphMsgs.clearFocus
-- ]
-- [ FeatherIcons.x |> FeatherIcons.withSize 20 |> FeatherIcons.withClass "elm-build-graph-actions-button" |> FeatherIcons.toHtml [] ]
-- ]
]
]

Expand Down
Loading

0 comments on commit d28e13a

Please sign in to comment.