Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
usage dag put object json value instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
movefasta committed May 21, 2018
1 parent bf33feb commit 906165a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24,675 deletions.
1 change: 1 addition & 0 deletions elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"exposed-modules": [],
"dependencies": {
"BrianHicks/elm-benchmark": "2.0.3 <= v < 3.0.0",
"Microsoft/elm-json-tree-view": "1.0.1 <= v < 2.0.0",
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
"elm-community/json-extra": "2.1.0 <= v < 3.0.0",
"elm-community/string-extra": "1.4.0 <= v < 2.0.0",
Expand Down
14 changes: 14 additions & 0 deletions src/Commands.elm
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,17 @@ headerDecoder =
|> required "Ipfs-Hash" Decode.string
|> hardcoded []

objectEncoder : Object -> Value
objectEncoder object =
Encode.object
[ ("Data", Encode.string object.data)
, ("Links", Encode.list <| List.map linkEncoder object.links)
]

linkEncoder : Link -> Value
linkEncoder link =
Encode.object
[ ("Cid", Encode.object [ ("/", Encode.string link.hash) ])
, ("Name", Encode.string link.name)
, ("Size", Encode.int link.size)
]
3 changes: 2 additions & 1 deletion src/Msgs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Msgs exposing (..)

import Models exposing (Level, Name, Hash, Object, ModifiedObject, Link, Data)
import RemoteData exposing (WebData)
import Json.Encode exposing (Value)


type Msg
Expand All @@ -16,5 +17,5 @@ type Msg
| GetIpfsHash (WebData Hash)
| UpdatePureData (WebData String)
| DagGet Hash
| DagPut String
| DagPut Value
| DagHash String
33 changes: 0 additions & 33 deletions src/Routing.elm

This file was deleted.

3 changes: 2 additions & 1 deletion src/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Style exposing (..)
import Style.Border as Border
import Style.Color as Color
import Style.Font as Font
import Commands exposing (objectEncoder)


view : Model -> Html Msg
Expand Down Expand Up @@ -104,7 +105,7 @@ viewControls model =
<| E.text "get object"
, E.button Button
[ padding 5
, Event.onClick <| Msgs.DagPut <| maybeRemote viewRawDag model.raw_dag
, Event.onClick <| Msgs.DagPut <| objectEncoder <| RemoteData.withDefault {data = "", links = []} model.object
]
<| E.text "set data"
, E.button Button
Expand Down
15 changes: 0 additions & 15 deletions src/elm-package.json

This file was deleted.

Loading

0 comments on commit 906165a

Please sign in to comment.