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

     1  module Components.NodeFile exposing (view)
     2  
     3  import Api.Point as Point
     4  import Components.NodeOptions exposing (NodeOptions, oToInputO)
     5  import Element exposing (..)
     6  import Element.Border as Border
     7  import UI.Form as Form
     8  import UI.Icon as Icon
     9  import UI.NodeInputs as NodeInputs
    10  import UI.Style as Style exposing (colors)
    11  
    12  
    13  view : NodeOptions msg -> Element msg
    14  view o =
    15      let
    16          desc =
    17              Point.getText o.node.points Point.typeDescription ""
    18  
    19          name =
    20              Point.getText o.node.points Point.typeName ""
    21      in
    22      column
    23          [ width fill
    24          , Border.widthEach { top = 2, bottom = 0, left = 0, right = 0 }
    25          , Border.color Style.colors.black
    26          , spacing 6
    27          ]
    28      <|
    29          wrappedRow [ spacing 10 ]
    30              [ Icon.file
    31              , text <|
    32                  desc
    33                      ++ " ("
    34                      ++ name
    35                      ++ ")"
    36              ]
    37              :: (if o.expDetail then
    38                      let
    39                          labelWidth =
    40                              150
    41  
    42                          opts =
    43                              oToInputO o labelWidth
    44  
    45                          textInput =
    46                              NodeInputs.nodeTextInput opts "0"
    47  
    48                          checkbox =
    49                              NodeInputs.nodeCheckboxInput opts "0"
    50  
    51                          binary =
    52                              Point.getBool o.node.points Point.typeBinary "0"
    53  
    54                          size =
    55                              Point.getValue o.node.points Point.typeSize "0"
    56  
    57                          data =
    58                              Point.getText o.node.points Point.typeData "0"
    59  
    60                          hash =
    61                              Point.getText o.node.points Point.typeHash "0"
    62                      in
    63                      [ textInput Point.typeDescription "Description" ""
    64                      , checkbox "binary" "Binary"
    65                      , text <| " "
    66                      , text <| "     File name: " ++ name
    67                      , text <| "     File size: " ++ String.fromFloat size ++ " bytes"
    68                      , text <| "     File md5: " ++ hash
    69                      , text <| "     Stored data len: " ++ String.fromInt (String.length data) ++ " bytes"
    70                      , Form.buttonRow
    71                          [ Form.button
    72                              { label = "Upload new file"
    73                              , color = colors.blue
    74                              , onPress = o.onUploadFile binary
    75                              }
    76                          ]
    77                      , NodeInputs.nodeKeyValueInput opts Point.typeTag "Tags" "Add Tag"
    78                      ]
    79  
    80                  else
    81                      []
    82                 )