1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-19 10:37:01 +00:00

ui: Easy renames and refactors

This commit is contained in:
James Hillyerd
2018-11-18 18:52:14 -08:00
parent 0ed0cd2d64
commit 5be2b57a12
11 changed files with 150 additions and 164 deletions

View File

@@ -7,7 +7,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Http exposing (Error)
import HttpUtil
import Sparkline exposing (DataSet, Point, Size, sparkline)
import Sparkline as Spark
import Svg.Attributes as SvgAttrib
import Time exposing (Posix)
@@ -40,8 +40,8 @@ type alias Metric =
{ label : String
, value : Int
, formatter : Int -> String
, graph : DataSet -> Html Msg
, history : DataSet
, graph : Spark.DataSet -> Html Msg
, history : Spark.DataSet
, minutes : Int
}
@@ -67,7 +67,7 @@ init =
}
initDataSet : DataSet
initDataSet : Spark.DataSet
initDataSet =
List.range 0 59
|> List.map (\x -> ( toFloat x, 0 ))
@@ -92,17 +92,17 @@ subscriptions model =
type Msg
= NewMetrics (Result Http.Error Metrics)
= MetricsReceived (Result Http.Error Metrics)
| Tick Posix
update : Session -> Msg -> Model -> ( Model, Cmd Msg, Session.Msg )
update session msg model =
case msg of
NewMetrics (Ok metrics) ->
MetricsReceived (Ok metrics) ->
( updateMetrics metrics model, Cmd.none, Session.none )
NewMetrics (Err err) ->
MetricsReceived (Err err) ->
( model, Cmd.none, Session.SetFlash (HttpUtil.errorString err) )
Tick time ->
@@ -209,7 +209,7 @@ getMetrics : Cmd Msg
getMetrics =
Http.get
{ url = "/debug/vars"
, expect = Http.expectJson NewMetrics Metrics.decoder
, expect = Http.expectJson MetricsReceived Metrics.decoder
}
@@ -283,7 +283,7 @@ graphNull =
div [] []
graphSize : Size
graphSize : Spark.Size
graphSize =
{ width = 180
, height = 16
@@ -292,25 +292,25 @@ graphSize =
}
areaStyle : Sparkline.Param a -> Sparkline.Param a
areaStyle : Spark.Param a -> Spark.Param a
areaStyle =
Sparkline.Style
Spark.Style
[ SvgAttrib.fill "rgba(50,100,255,0.3)"
, SvgAttrib.stroke "rgba(50,100,255,1.0)"
, SvgAttrib.strokeWidth "1.0"
]
barStyle : Sparkline.Param a -> Sparkline.Param a
barStyle : Spark.Param a -> Spark.Param a
barStyle =
Sparkline.Style
Spark.Style
[ SvgAttrib.fill "rgba(50,200,50,0.7)"
]
zeroStyle : Sparkline.Param a -> Sparkline.Param a
zeroStyle : Spark.Param a -> Spark.Param a
zeroStyle =
Sparkline.Style
Spark.Style
[ SvgAttrib.stroke "rgba(0,0,0,0.2)"
, SvgAttrib.strokeWidth "1.0"
]
@@ -318,7 +318,7 @@ zeroStyle =
{-| Bar graph to be used with updateRemoteTotal metrics (change instead of absolute values).
-}
graphChange : DataSet -> Html a
graphChange : Spark.DataSet -> Html a
graphChange data =
let
-- Used with Domain to stop sparkline forgetting about zero; continue scrolling graph.
@@ -330,16 +330,16 @@ graphChange data =
Just point ->
Tuple.first point
in
sparkline graphSize
[ Sparkline.Bar 2.5 data |> barStyle
, Sparkline.ZeroLine |> zeroStyle
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
Spark.sparkline graphSize
[ Spark.Bar 2.5 data |> barStyle
, Spark.ZeroLine |> zeroStyle
, Spark.Domain [ ( x, 0 ), ( x, 1 ) ]
]
{-| Zero based area graph, for charting absolute values relative to 0.
-}
graphZero : DataSet -> Html a
graphZero : Spark.DataSet -> Html a
graphZero data =
let
-- Used with Domain to stop sparkline forgetting about zero; continue scrolling graph.
@@ -351,10 +351,10 @@ graphZero data =
Just point ->
Tuple.first point
in
sparkline graphSize
[ Sparkline.Area data |> areaStyle
, Sparkline.ZeroLine |> zeroStyle
, Sparkline.Domain [ ( x, 0 ), ( x, 1 ) ]
Spark.sparkline graphSize
[ Spark.Area data |> areaStyle
, Spark.ZeroLine |> zeroStyle
, Spark.Domain [ ( x, 0 ), ( x, 1 ) ]
]