Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Oct 7, 2021
1 parent 1b0de67 commit f9c5d8a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
Expand Up @@ -112,18 +112,18 @@ type alias ComponentCompliance =
{ component : String
, compliance : Float
, complianceDetails : ComplianceDetails
, nodes : List NodeCompliance
, nodes : List NodeCompliance
}
type alias ValueCompliance =
{ value : String
, reports : List Report

}

type alias Report = { status : String, message : Maybe String}

type alias NodeCompliance =
{ nodeId : NodeId
{ nodeId : NodeId
, name : String
, values : List ValueCompliance
}

Expand Down
Expand Up @@ -128,7 +128,8 @@ decodeReport =
decodeNodeCompliance : Decoder NodeCompliance
decodeNodeCompliance =
succeed NodeCompliance
|> required "id" (D.map NodeId D.string)
|> required "id" (D.map NodeId D.string)
|> required "name" D.string
|> required "values" (D.list decodeValueCompliance)

decodeComplianceDetails : Decoder ComplianceDetails
Expand Down
Expand Up @@ -7,16 +7,12 @@ import Html.Events exposing (onClick)
import List.Extra
import List
import String
import ViewUtilsCompliance exposing (buildComplianceBar, getAllComplianceValues)
import ViewUtilsCompliance exposing (buildComplianceBar, getAllComplianceValues, getRuleCompliance)
import ViewUtilsRules exposing (..)
--
-- This file contains all methods to display the Rules table
--

getRuleCompliance : Model -> RuleId -> Maybe RuleCompliance
getRuleCompliance model rId =
List.Extra.find (\c -> c.ruleId == rId) model.rulesCompliance

getSortFunction : Model -> Rule -> Rule -> Order
getSortFunction model r1 r2 =
let
Expand Down
Expand Up @@ -10,7 +10,7 @@ import Maybe.Extra
import String exposing ( fromFloat)
import NaturalOrdering exposing (compareOn)
import ApiCalls exposing (..)
import ViewUtilsCompliance exposing (buildComplianceBar)
import ViewUtilsCompliance exposing (buildComplianceBar, getRuleCompliance)

--
-- This file contains all methods to display the details of the selected rule.
Expand Down Expand Up @@ -395,7 +395,6 @@ tabContent model details =

buildIncludeList : Bool -> RuleTarget -> Html Msg
buildIncludeList includeBool ruleTarget =

let
groupsList = getAllElems model.groupsTree

Expand All @@ -422,6 +421,24 @@ tabContent model details =
]
in
rowIncludeGroup

buildNodesTable : RuleId -> List (Html Msg)
buildNodesTable rId =
let
ruleCompliance = getRuleCompliance model rId
nodesList = case ruleCompliance of
Nothing -> [tr[][td[class "empty"][text "Cannot find nodes compliance"]]]
Just rc -> rc.directives
|> List.concatMap (\d -> d.components
|> List.concatMap (\c -> c.nodes
|> List.map (\n -> tr[]
[ td[][text n.name]
, td[][] -- Here goes the compliance bar
])
)
)
in
nodesList
in

if not details.ui.editGroups then
Expand All @@ -446,8 +463,7 @@ tabContent model details =
, th [class "sorting" ][text "Compliance"]
]
]
, tbody[]
[tr[][]]
, tbody[](buildNodesTable details.rule.id)
]
]
]
Expand Down
Expand Up @@ -9,6 +9,10 @@ import List
import String exposing (fromFloat)
import ApiCalls exposing (..)

getRuleCompliance : Model -> RuleId -> Maybe RuleCompliance
getRuleCompliance model rId =
List.Extra.find (\c -> c.ruleId == rId) model.rulesCompliance

getCompliance : Float -> String -> Html msg
getCompliance val t =
if val > 0 then
Expand Down

0 comments on commit f9c5d8a

Please sign in to comment.