Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaadF committed Apr 2, 2023
1 parent 68c311d commit 39f1582
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type TabMenu
| Nodes
| Groups
| TechnicalLogs
| Rules


type alias Tag =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ViewUtils exposing (..)
view : Model -> Html Msg
view model =
let
rulesList = getListRules model.rulesTree
allMissingCategoriesId = List.map .id (getAllMissingCats model.rulesTree)
ruleTreeElem : Rule -> Html Msg
ruleTreeElem item =
Expand Down Expand Up @@ -130,7 +131,7 @@ view model =
] [ text "Changes" ]
]
]
, tbody [] (buildRulesTable model)
, tbody [] (buildRulesTable model rulesList)
]
]
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module ViewCategoryDetails exposing (..)

import DataTypes exposing (..)
import Html exposing (Html, button, div, i, span, text, h1, h4, ul, li, input, a, p, form, label, textarea, select, option, table, thead, tbody, tr, th, td, small)
import Html.Attributes exposing (id, class, type_, placeholder, value, for, href, colspan, rowspan, style, selected, disabled, attribute)
import Debug exposing (log)
import Html exposing (Html, button, div, i, span, text, h1, ul, li, input, a, p, form, label, textarea, select, table, thead, tbody, tr, th)
import Html.Attributes exposing (id, class, type_, placeholder, value, for, colspan, rowspan, style)
import Html.Events exposing (onClick, onInput, onSubmit)
import List.Extra
import List
import Maybe.Extra
import String exposing ( fromFloat)
import NaturalOrdering exposing (compareOn)
import String
import ApiCalls exposing (..)
import ViewRulesTable exposing (buildRulesTable)
import ViewTabContent exposing (buildListCategories)
import ViewUtils exposing (btnSave)
import ViewUtils exposing (btnSave, getListRules, sortTable, thClass)


--
Expand All @@ -23,10 +23,22 @@ editionTemplateCat model details =
let
originCat = details.originCategory
category = details.category

-- missing categories logic
allMissingCategories = List.filter (\sub -> sub.id == missingCategoryId) (getSubElems model.rulesTree)
listOfCat = List.concatMap getAllCats (allMissingCategories)
listCatIdMissing = List.map (\r -> r.id) (listOfCat)

writeRights = model.ui.hasWriteRights && (not (category.id == missingCategoryId) && not (List.member category.id listCatIdMissing))

-- Logic to get all rule above a category, it take the sub categories rules too
categoryInfos = List.filter (\c -> c.id == details.category.id) (getAllCats model.rulesTree)
rulesList =
-- Category ID must be unique, so the list contains an unique element
case (List.head categoryInfos) of
Just c -> getListRules c
Nothing -> []

categoryTitle =
case originCat of
Nothing -> span[style "opacity" "0.4"][text "New category"]
Expand Down Expand Up @@ -68,6 +80,46 @@ editionTemplateCat model details =
)
]
]
categoryFormMode =
if(details.tab == Information) then
div[class "row"]
[ categoryForm
, div [class "col-xs-12 col-sm-6 col-lg-5"][] -- <== Right column
]
else
div [class "main-table"]
[
--div [class "table-header"]
-- [ input [type_ "text", placeholder "Filter", class "input-sm form-control", value model.ui.ruleFilters.tableFilters.filter
-- , onInput (\s -> UpdateDirectiveFilters {directiveFilters | tableFilters = {tableFilters | filter = s}} )][]
-- , button [class "btn btn-default", onCustomClick (RefreshComplianceTable rule.id)][i [class "fa fa-refresh"][]]
-- ]
div [class "table-container"]
[ table [ class "no-footer dataTable"]
[ thead []
[ tr [class "head"]
[ th [ class (thClass model.ui.ruleFilters.tableFilters Name) , rowspan 1, colspan 1
, onClick (UpdateRuleFilters (sortTable model.ui.ruleFilters Name))
] [ text "Name" ]
, th [ class (thClass model.ui.ruleFilters.tableFilters Parent) , rowspan 1, colspan 1
, onClick (UpdateRuleFilters (sortTable model.ui.ruleFilters Parent))
] [ text "Category" ]
, th [ class (thClass model.ui.ruleFilters.tableFilters Status) , rowspan 1, colspan 1
, onClick (UpdateRuleFilters (sortTable model.ui.ruleFilters Status))
] [ text "Status" ]
, th [ class (thClass model.ui.ruleFilters.tableFilters Compliance) , rowspan 1, colspan 1
, onClick (UpdateRuleFilters (sortTable model.ui.ruleFilters Compliance))
] [ text "Compliance" ]
, th [ class (thClass model.ui.ruleFilters.tableFilters RuleChanges) , rowspan 1, colspan 1
, onClick (UpdateRuleFilters (sortTable model.ui.ruleFilters RuleChanges))
] [ text "Changes" ]
]
]
, tbody [] (buildRulesTable model (log "rulesList" rulesList))
]
]
]


in
div [class "main-container"]
Expand Down Expand Up @@ -97,15 +149,17 @@ editionTemplateCat model details =
]
, div [class "main-navbar" ]
[ ul[class "ui-tabs-nav "]
[ li[class "ui-tabs-tab ui-tabs-active"]
[ a[][ text "Information" ]
[ li[class ("ui-tabs-tab" ++ (if details.tab == Information then " ui-tabs-active" else ""))]
[ a[onClick (UpdateCategoryForm {details | tab = Information})][ text "Information" ]
]
, li[class ("ui-tabs-tab" ++ (if details.tab == Rules then " ui-tabs-active" else ""))]
[ a[onClick (UpdateCategoryForm {details | tab = Rules})][ text "Rules" ]
]

]

]
, div [class "main-details"]
[ div[class "row"]
[ categoryForm
, div [class "col-xs-12 col-sm-6 col-lg-5"][] -- <== Right column
]
[ categoryFormMode
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ getSortFunction model r1 r2 =
EQ -> EQ
GT -> LT

buildRulesTable : Model -> List(Html Msg)
buildRulesTable model =
buildRulesTable : Model -> List Rule -> List(Html Msg)
buildRulesTable model rules =
let
rulesList = getListRules model.rulesTree
rulesList = rules
sortedRulesList = rulesList
|> List.filter (\r -> filterSearch model.ui.ruleFilters.treeFilters.filter (searchFieldRules r model))
|> List.filter (\r -> filterTags r.tags model.ui.ruleFilters.treeFilters.tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Dict
import Dict.Extra
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput, onSubmit)
import Html.Events exposing (onClick, onInput)
import List.Extra
import List
import Maybe.Extra
Expand Down Expand Up @@ -225,6 +225,7 @@ tabContent model details =
Nodes -> nodesTab model details
Groups -> groupsTab model details
TechnicalLogs -> ViewRepairedReports.showTab model details
Rules -> div [] []

directivesTab: Model -> RuleDetails -> Html Msg
directivesTab model details =
Expand Down

0 comments on commit 39f1582

Please sign in to comment.