Only display certain views when they are useful.

This commit is contained in:
Danila Fedorin 2019-05-29 19:11:37 -07:00
parent 23ff56ef82
commit b96c16918b

View File

@ -151,13 +151,10 @@ viewCache level (cm, cs) =
viewCacheHierarchy : CacheHierarchy -> Html Msg
viewCacheHierarchy ch =
let
levels = div [ class "cache-levels" ]
levels = div []
<| List.indexedMap viewCache ch
in
div [] <|
[ h2 [] [ text <| "Cache State" ]
, levels
]
levels
viewAccessView : Model -> AccessView -> Html Msg
viewAccessView m av =
@ -170,7 +167,9 @@ viewAccessView m av =
[ primaryButton "Back" AccessViewBack
, primaryButton "Forward" AccessViewForward
]
, h3 [] [ text "Access event log" ]
, viewAccessLog av
, h3 [] [ text "Current cache state" ]
, viewCacheHierarchy <| effectiveCacheHierarchy currentCache av
]
@ -194,23 +193,18 @@ viewAccessLog (aes, ap) =
Up n -> List.indexedMap downEvent aes ++
(List.indexedMap upEvent <| List.drop n aes)
in
div [ ]
[ h3 [] [ text "Simulation events" ]
, div [] events
]
div [] events
viewAccessInput : Model -> Html Msg
viewAccessInput m =
let
accessButton = maybeButton (String.toInt m.accessInput) "Access address" Access
editHierarchyButton = button "Edit hierarchy" (UseHierarchy Nothing)
in
div []
[ h2 [] [ text "Run access simulation" ]
, div [ classList [("alert", True), ("alert-primary", True)] ]
[ text "Please make sure to click \"Use Hierarchy\" to load a hierarchy to simulate."
]
, labeledInput "Access address" m.accessInput ChangeAccessInput
, accessButton
, buttonWrapper [ accessButton, editHierarchyButton ]
]
viewDescription : Html Msg
@ -234,9 +228,13 @@ viewBase : Model -> Html Msg
viewBase m =
let
rawView =
case m.accessView of
case m.hierarchy of
Nothing -> [ viewRawCacheModelHierarchy m.rawHierarchy ]
Just _ -> []
accessInputView =
case (m.hierarchy, m.accessView) of
(Just _, Nothing) -> [ viewAccessInput m ]
_ -> []
cacheView =
case m.accessView of
Nothing ->
@ -244,7 +242,6 @@ viewBase m =
<| Maybe.map (List.singleton << viewCacheHierarchy) <| m.hierarchy
Just _ -> []
accessView = Maybe.withDefault [] <| Maybe.map (List.singleton << viewAccessView m) <| m.accessView
accessInputView = [ viewAccessInput m ]
in
div [ class "container" ]
<| [ viewDescription] ++ rawView ++ cacheView ++ accessView ++ accessInputView
<| [ viewDescription] ++ rawView ++ accessInputView ++ accessView ++ cacheView