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

     1  module Components.NodeSignalGenerator 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 Round
     9  import UI.Icon as Icon
    10  import UI.NodeInputs as NodeInputs
    11  import UI.Style as Style
    12  import UI.ViewIf exposing (viewIf)
    13  
    14  
    15  view : NodeOptions msg -> Element msg
    16  view o =
    17      let
    18          value =
    19              Point.getValue o.node.points Point.typeValue ""
    20  
    21          valueText =
    22              String.fromFloat (Round.roundNum 2 value)
    23  
    24          disabled =
    25              Point.getBool o.node.points Point.typeDisabled ""
    26  
    27          summaryBackground =
    28              if disabled then
    29                  Style.colors.ltgray
    30  
    31              else
    32                  Style.colors.none
    33      in
    34      column
    35          [ width fill
    36          , Border.widthEach { top = 2, bottom = 0, left = 0, right = 0 }
    37          , Border.color Style.colors.black
    38          , spacing 6
    39          ]
    40      <|
    41          wrappedRow [ spacing 10, Background.color summaryBackground ]
    42              [ Icon.activity
    43              , text <|
    44                  Point.getText o.node.points Point.typeDescription ""
    45              , el [ paddingXY 7 0 ] <|
    46                  text <|
    47                      valueText
    48                          ++ " "
    49                          ++ Point.getText o.node.points Point.typeUnits ""
    50              , viewIf disabled <| text "(disabled)"
    51              ]
    52              :: (if o.expDetail then
    53                      let
    54                          labelWidth =
    55                              150
    56  
    57                          opts =
    58                              oToInputO o labelWidth
    59  
    60                          textInput =
    61                              NodeInputs.nodeTextInput opts "0"
    62  
    63                          numberInput =
    64                              NodeInputs.nodeNumberInput opts "0"
    65  
    66                          optionInput =
    67                              NodeInputs.nodeOptionInput opts "0"
    68  
    69                          checkboxInput =
    70                              NodeInputs.nodeCheckboxInput opts "0"
    71  
    72                          signalType =
    73                              Point.getText o.node.points Point.typeSignalType ""
    74                      in
    75                      [ textInput Point.typeDescription "Description" ""
    76                      , checkboxInput Point.typeDisabled "Disabled"
    77                      , textInput Point.typeUnits "Units" ""
    78                      , optionInput Point.typeSignalType
    79                          "Signal type"
    80                          [ ( Point.valueSine, "Sine" )
    81                          , ( Point.valueSquare, "Square" )
    82                          , ( Point.valueTriangle, "Triangle" )
    83                          , ( Point.valueRandomWalk, "Random Walk" )
    84                          ]
    85                      , numberInput Point.typeMinValue "Min. Value"
    86                      , numberInput Point.typeMaxValue "Max. Value"
    87                      , numberInput Point.typeInitialValue "Initial Value"
    88                      , numberInput Point.typeRoundTo "Round To"
    89                      , numberInput Point.typeSampleRate "Sample Rate (Hz)"
    90                      , NodeInputs.nodeCheckboxInput opts
    91                          Point.keyParent
    92                          Point.typeDestination
    93                          "Sync parent node"
    94                      , NodeInputs.nodeCheckboxInput opts
    95                          Point.keyHighRate
    96                          Point.typeDestination
    97                          "High rate data"
    98                      , NodeInputs.nodeTextInput opts
    99                          Point.keyPointType
   100                          Point.typeDestination
   101                          "Point type"
   102                          ""
   103                      , NodeInputs.nodeTextInput opts
   104                          Point.keyPointKey
   105                          Point.typeDestination
   106                          "Point key"
   107                          ""
   108                      , numberInput Point.typeBatchPeriod "Batch Period (ms)"
   109                      , viewIf
   110                          (signalType
   111                              == Point.valueSine
   112                              || signalType
   113                              == Point.valueSquare
   114                              || signalType
   115                              == Point.valueTriangle
   116                          )
   117                        <|
   118                          numberInput Point.typeFrequency "Frequency (Hz)"
   119                      , viewIf (signalType == Point.valueRandomWalk) <|
   120                          numberInput Point.typeMinIncrement "Min. Increment"
   121                      , viewIf (signalType == Point.valueRandomWalk) <|
   122                          numberInput Point.typeMaxIncrement "Max. Increment"
   123                      , NodeInputs.nodeKeyValueInput opts Point.typeTag "Tags" "Add Tag"
   124                      ]
   125  
   126                  else
   127                      []
   128                 )