github.com/simpleiot/simpleiot@v0.18.3/frontend/src/Components/NodeRule.elm (about)

     1  module Components.NodeRule exposing (view)
     2  
     3  import Api.Point as Point
     4  import Components.NodeOptions exposing (NodeOptions, oToInputO)
     5  import Element exposing (..)
     6  import Element.Background as Background
     7  import Element.Border as Border
     8  import Element.Font as Font
     9  import UI.Icon as Icon
    10  import UI.NodeInputs as NodeInputs
    11  import UI.Style as Style exposing (colors)
    12  
    13  
    14  view : NodeOptions msg -> Element msg
    15  view o =
    16      let
    17          active =
    18              Point.getBool o.node.points Point.typeActive ""
    19  
    20          descBackgroundColor =
    21              if active then
    22                  Style.colors.blue
    23  
    24              else
    25                  Style.colors.none
    26  
    27          descTextColor =
    28              if active then
    29                  Style.colors.white
    30  
    31              else
    32                  Style.colors.black
    33  
    34          error =
    35              Point.getText o.node.points Point.typeError "0"
    36  
    37          disabled =
    38              Point.getBool o.node.points Point.typeDisabled ""
    39  
    40          titleBackground =
    41              if disabled then
    42                  Style.colors.ltgray
    43  
    44              else if error /= "" then
    45                  Style.colors.red
    46  
    47              else
    48                  Style.colors.none
    49      in
    50      column
    51          [ width fill
    52          , Border.widthEach { top = 2, bottom = 0, left = 0, right = 0 }
    53          , Border.color colors.black
    54          , spacing 6
    55          ]
    56      <|
    57          wrappedRow
    58              [ spacing 10
    59              , paddingEach { top = 0, right = 10, bottom = 0, left = 0 }
    60              , Background.color titleBackground
    61              , width fill
    62              ]
    63              [ Icon.list
    64              , el [ Background.color descBackgroundColor, Font.color descTextColor ] <|
    65                  text <|
    66                      Point.getText o.node.points Point.typeDescription ""
    67              , if Point.getBool o.node.points Point.typeDisabled "" then
    68                  text "(disabled)"
    69  
    70                else
    71                  text ""
    72              ]
    73              :: (if o.expDetail then
    74                      let
    75                          opts =
    76                              oToInputO o 100
    77  
    78                          textInput =
    79                              NodeInputs.nodeTextInput opts "0"
    80  
    81                          checkboxInput =
    82                              NodeInputs.nodeCheckboxInput opts "0"
    83                      in
    84                      [ textInput Point.typeDescription "Description" ""
    85                      , checkboxInput Point.typeDisabled "Disabled"
    86                      , NodeInputs.nodeKeyValueInput opts Point.typeTag "Tags" "Add Tag"
    87                      , el [ Font.color Style.colors.red ] <| text error
    88                      ]
    89  
    90                  else
    91                      []
    92                 )