Commit 0c65be1a authored by Cédric F.'s avatar Cédric F.

Add some fancy icons

parent 037954a7
Pipeline #13447772 (#) passed with stage
in 2 minutes and 17 seconds
SIL OPEN FONT LICENSE Version 1.1
Copyright (c) 2014 Waybury
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
The MIT License (MIT)
Copyright (c) 2014 Waybury
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
@font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'}
\ No newline at end of file
This diff is collapsed.
......@@ -20,6 +20,7 @@
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/favicon/apple-touch-icon.png">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="assets/open-iconic/font/css/open-iconic-bootstrap.css">
<script src="assets/js/elm.min.js" async defer></script>
......@@ -42,6 +43,12 @@
border-color: #FFF;
}
code {
display: block;
font-size: 50%;
word-break: break-all;
}
.bg-black {
background-color: #000;
}
......@@ -92,8 +99,10 @@
switch (command) {
case 'focus':
const query = document.getElementById('query');
query.focus();
setTimeout(function () { query.select(); }, 50); // delay sightly to allow focus to "stick" before selecting
if (query) {
query.focus();
setTimeout(function () { query.select(); }, 50); // delay sightly to allow focus to "stick" before selecting
}
break;
default:
......
......@@ -2,6 +2,7 @@ module Components.Block exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Http exposing (Error)
import Json.Encode as Encode
import Json.Decode as Decode
......@@ -9,6 +10,7 @@ import Json.Decode.Pipeline as Pipeline
import Time exposing (Time)
import Lib.TimeExtra as TimeExtra
import Lib.JsonRpc as JsonRpc
import Lib.Decred as Decred
type alias Model =
......@@ -65,58 +67,70 @@ type Msg
| GetBlockHashResult (Result Http.Error String)
view : Model -> Html a
view : Model -> Html Msg
view model =
div
[ class "card bg-dark" ]
[ h5 [ class "card-header" ] [ text <| "Block " ++ model.hash ]
, div [ class "card-body" ]
[ p [ class "card-text" ]
[ dl [ class "row" ]
[ dt [ class "col-3 text-right" ] [ text "height" ]
, dd [ class "col-9" ] [ text <| toString model.height ]
, dt [ class "col-3 text-right" ] [ text "time" ]
, dd [ class "col-9" ] [ text <| TimeExtra.toISOString model.time ]
, dt [ class "col-3 text-right" ] [ text "confirmations" ]
, dd [ class "col-9" ] [ text <| toString model.confirmations ]
, dt [ class "col-3 text-right" ] [ text "size" ]
, dd [ class "col-9" ] [ text <| toString model.size ++ " bytes" ]
, dt [ class "col-3 text-right" ] [ text "ticket price" ]
, dd [ class "col-9" ] [ text <| toString model.ticketPrice ++ " DCR" ]
, dt [ class "col-3 text-right" ] [ text "stake transactions" ]
, dd [ class "col-9" ]
((span [ class "mr-2" ] [ text (toString <| List.length model.tickets) ])
:: (List.map
(\tx ->
a
[ href tx, class "badge badge-secondary ml-1" ]
[ text <| shortHash tx ]
)
model.tickets
)
)
, dt [ class "col-3 text-right" ] [ text "normal transactions" ]
, dd [ class "col-9" ]
((span [ class "mr-2" ] [ text (toString <| List.length model.transactions) ])
:: (List.map
(\tx ->
a
[ href tx, class "badge badge-light ml-1" ]
[ text <| shortHash tx ]
)
model.transactions
)
)
]
div [ class "row align-items-center" ]
[ div [ class "col-3 text-right" ]
[ a
[ class "btn btn-secondary"
, href "javascript:void(0)"
, onClick (GetBlock "000000000000006fa9bf10d4a39d0cbc6ef8dc2f2db3e7841fd33b7ad973811a")
]
[ text "<" ]
]
, div [ class "card-footer" ]
[ small [ class "text-muted" ]
[ a
[ target "_blank"
, href <| "https://explorer.dcrdata.org/explorer/block/" ++ model.hash
, div [ class "col-6" ]
[ div
[ class "card bg-dark" ]
[ h5 [ class "card-header" ]
[ span [] [ text <| "Block " ++ model.hash ]
, a
[ class "float-right"
, target "_blank"
, title "Open on dcrdata.org"
, href <| "https://explorer.dcrdata.org/explorer/block/" ++ model.hash
]
[ span [ class "oi oi-external-link" ] [] ]
]
, div [ class "card-body" ]
[ p [ class "card-text" ]
[ dl [ class "row" ]
[ dt [ class "col-3 text-right" ] [ text "height" ]
, dd [ class "col-9" ] [ text <| toString model.height ]
, dt [ class "col-3 text-right" ] [ text "time" ]
, dd [ class "col-9" ] [ text <| TimeExtra.toISOString model.time ]
, dt [ class "col-3 text-right" ] [ text "confirmations" ]
, dd [ class "col-9" ] [ text <| toString model.confirmations ]
, dt [ class "col-3 text-right" ] [ text "size" ]
, dd [ class "col-9" ] [ text <| toString model.size ++ " bytes" ]
, dt [ class "col-3 text-right" ] [ text "ticket price" ]
, dd [ class "col-9" ] [ text <| toString model.ticketPrice ++ " DCR" ]
, dt [ class "col-3 text-right" ] [ text "stake transactions" ]
, dd [ class "col-9" ]
((span [ class "mr-2" ] [ text (toString <| List.length model.tickets) ])
:: (List.map
(\tx ->
a
[ href tx, class "badge badge-secondary ml-1" ]
[ text <| Decred.shortHash tx ]
)
model.tickets
)
)
, dt [ class "col-3 text-right" ] [ text "normal transactions" ]
, dd [ class "col-9" ]
((span [ class "mr-2" ] [ text (toString <| List.length model.transactions) ])
:: (List.map
(\tx ->
a
[ href tx, class "badge badge-light ml-1" ]
[ text <| Decred.shortHash tx ]
)
model.transactions
)
)
]
]
]
[ text "More details at dcrdata.org" ]
]
]
]
......@@ -229,8 +243,3 @@ decodeGetBlock =
decodeGetBlockHash : Decode.Decoder String
decodeGetBlockHash =
Decode.at [ "result" ] Decode.string
shortHash : String -> String
shortHash hash =
String.concat [ String.left 2 hash, "...", String.right 2 hash ]
......@@ -38,11 +38,9 @@ type Msg
view : Model -> Html a
view model =
div [ class "col" ]
[ ul [ class "list-unstyled" ]
[ li [] [ text <| "Blocks: " ++ toString model.blocks ]
, li [] [ text <| "Connections: " ++ toString model.connections ]
]
div [ class "col text-center" ]
[ span [] [ text "Last block: " ]
, a [ href (toString model.blocks) ] [ text <| toString model.blocks ]
]
......
......@@ -9,6 +9,7 @@ import Json.Decode.Pipeline as Pipeline
import Time exposing (Time)
import Lib.TimeExtra as TimeExtra
import Lib.JsonRpc as JsonRpc
import Lib.Decred as Decred
type alias Model =
......@@ -93,6 +94,20 @@ totalSpent model =
List.map .amountIn model.vIn |> List.foldr (+) 0
fee : Model -> Float
fee model =
let
totalOut =
List.map .value model.vOut |> List.foldr (+) 0
in
totalSpent model - totalOut
feePerKb : Model -> Float
feePerKb model =
fee model * 1.0e3 / toFloat model.size
dcrAmount : Float -> String
dcrAmount float =
let
......@@ -129,7 +144,16 @@ view model =
in
div
[ class "card bg-dark" ]
[ h5 [ class "card-header" ] [ text <| "Transaction " ++ model.hash ]
[ h5 [ class "card-header" ]
[ span [] [ text <| "Transaction " ++ model.hash ]
, a
[ class "float-right"
, target "_blank"
, title "Open on dcrdata.org"
, href <| "https://explorer.dcrdata.org/explorer/tx/" ++ model.hash
]
[ span [ class "oi oi-external-link" ] [] ]
]
, div [ class "card-body" ]
[ p [ class "card-text" ]
[ dl [ class "row" ]
......@@ -143,6 +167,12 @@ view model =
, dd [ class "col-9" ] [ text <| toString model.size ++ " bytes" ]
, dt [ class "col-3 text-right" ] [ text "total spent" ]
, dd [ class "col-9" ] [ text <| dcrAmount (totalSpent model) ]
, dt [ class "col-3 text-right" ] [ text "fee" ]
, dd [ class "col-9" ]
[ text <|
dcrAmount (fee model)
++ (" (" ++ (dcrAmount (feePerKb model)) ++ "/kB)")
]
]
]
]
......@@ -162,7 +192,14 @@ view model =
""
)
]
, span [] [ text <| dcrAmount vIn.amountIn ]
, span [ class "float-right" ] [ text <| dcrAmount vIn.amountIn ]
, (case vIn.txId of
Just hash ->
a [ href hash ] [ text <| Decred.shortHash hash ]
Nothing ->
span [] []
)
]
)
model.vIn
......@@ -174,21 +211,13 @@ view model =
(\vOut ->
li [ class "list-group-item bg-success" ]
[ span [ class "badge badge-info" ] [ text vOut.scriptPubKey.type_ ]
, span [] [ text <| dcrAmount vOut.value ]
, span [ class "float-right" ] [ text <| dcrAmount vOut.value ]
, code [ class "mt-2" ] [ text vOut.scriptPubKey.asm ]
]
)
model.vOut
]
]
, div [ class "card-footer" ]
[ small [ class "text-muted" ]
[ a
[ target "_blank"
, href <| "https://explorer.dcrdata.org/explorer/tx/" ++ model.hash
]
[ text "More details at dcrdata.org" ]
]
]
]
......@@ -237,11 +266,29 @@ decodeGetRawTransaction =
|> Pipeline.requiredAt [ "result", "vout" ] (Decode.list decodeVOut)
zeroToNothing : Maybe String -> Decode.Decoder (Maybe String)
zeroToNothing maybe =
let
zero =
"0000000000000000000000000000000000000000000000000000000000000000"
in
Decode.succeed <|
case maybe of
Just string ->
if string == zero then
Nothing
else
maybe
Nothing ->
maybe
decodeVIn : Decode.Decoder VIn
decodeVIn =
Pipeline.decode VIn
-- no txid for coinbase txs
|> Pipeline.optionalAt [ "txid" ] (Decode.maybe Decode.string) Nothing
|> Pipeline.optionalAt [ "txid" ] (Decode.maybe Decode.string |> Decode.andThen zeroToNothing) Nothing
|> Pipeline.optionalAt [ "coinbase" ] (Decode.maybe Decode.string) Nothing
|> Pipeline.requiredAt [ "amountin" ] Decode.float
|> Pipeline.requiredAt [ "blockheight" ] Decode.int
......
module Lib.Decred exposing (..)
shortHash : String -> String
shortHash hash =
String.concat [ String.left 2 hash, "...", String.right 2 hash ]
......@@ -24,21 +24,25 @@ type alias Model =
, transactionModel : TransactionComponent.Model
, query : String
, template : Template
, error : Maybe String
, vimMode : Bool
, debug : Bool
, time : Time
}
initialModel : Model
initialModel =
{ keys = Keys False False False False
{ keys = Keys False False False False False False
, window = Window.Size 0 0
, statusModel = StatusComponent.initialModel
, blockModel = BlockComponent.initialModel
, transactionModel = TransactionComponent.initialModel
, query = ""
, template = Status
, error = Nothing
, vimMode = False
, debug = False
, time = 0
}
......@@ -50,6 +54,7 @@ type Msg
| TransactionMsg TransactionComponent.Msg
| JsMsg String
| Query String
| QueryForce String
| KeyChange Bool Keyboard.KeyCode
| Resize Window.Size
| Tick Time
......@@ -57,7 +62,9 @@ type Msg
type alias Keys =
{ esc : Bool
{ enter : Bool
, esc : Bool
, d : Bool
, i : Bool
, j : Bool
, k : Bool
......
......@@ -83,69 +83,105 @@ update action model =
possibleBlockHash query =
(String.length query == 64 && String.left 8 query == "00000000") || query == genesis
parseBlockHeight string =
String.toInt string |> Result.toMaybe |> Maybe.withDefault -1
possibleBlockHeight query =
parseBlockHeight query /= -1
possibleTransaction query =
String.length query == 64 && String.left 8 query /= "00000000" && query /= genesis
statusModel =
model.statusModel
updatedStatusModel =
{ statusModel | error = Nothing }
updatedModel =
{ model | query = query, statusModel = updatedStatusModel }
updateUrl ( model, cmd ) =
( model
, Cmd.batch [ newUrl model, cmd ]
)
{ model | query = query, error = Nothing }
in
if query == "" then
( { updatedModel | template = Status }, Cmd.none ) |> updateUrl
( { updatedModel | template = Status }
, Cmd.none
)
|> updateUrl
else if possibleTransaction query then
fetchTransaction query updatedModel |> updateUrl
fetchTransaction query updatedModel
else if possibleBlockHash query then
fetchBlockByHash query updatedModel |> updateUrl
else if possibleBlockHeight query then
fetchBlockByHeight (parseBlockHeight query) updatedModel |> updateUrl
fetchBlockByHash query updatedModel
else if possibleAddress query then
fetchAddress query updatedModel |> updateUrl
fetchAddress query updatedModel
else
let
statusModel =
updatedModel.statusModel
( { updatedModel
| template = Status
, error = Just "Not sure what you're looking for :|"
}
, Cmd.none
)
|> updateUrl
QueryForce query ->
let
parseBlockHeight string =
String.toInt string |> Result.toMaybe |> Maybe.withDefault -1
possibleBlockHeight query =
parseBlockHeight query /= -1
updatedStatusModel =
{ statusModel | error = Just "Not sure what you're looking for :|" }
in
( { updatedModel | statusModel = updatedStatusModel }, Cmd.none ) |> updateUrl
updatedModel =
{ model | query = query, error = Nothing }
in
if possibleBlockHeight query then
fetchBlockByHeight (parseBlockHeight query) updatedModel
else
( { updatedModel
| template = Status
, error = Just "Not sure what you're looking for :|"
}
, Cmd.none
)
|> updateUrl
StatusMsg statusMsg ->
let
( updatedModel, cmd ) =
StatusComponent.update statusMsg model.statusModel
in
( { model | template = Status, statusModel = updatedModel }, Cmd.map StatusMsg cmd )
( { model
| template = Status
, statusModel = updatedModel
}
, Cmd.map StatusMsg cmd
)
|> updateUrl
BlockMsg blockMsg ->
let
( updatedModel, cmd ) =
BlockComponent.update blockMsg model.blockModel
query =
case blockMsg of
BlockComponent.GetBlock foo ->
updatedModel.hash
BlockComponent.GetBlockHash foo ->
toString updatedModel.height
_ ->
model.query
in
( { model | template = Block, blockModel = updatedModel }, Cmd.map BlockMsg cmd )
( { model
| template = Block
, query = query
, blockModel = updatedModel
}
, Cmd.map BlockMsg cmd
)
|> updateUrl
TransactionMsg transactionMsg ->
let
( updatedModel, cmd ) =
TransactionComponent.update transactionMsg model.transactionModel
in
( { model | template = Transaction, transactionModel = updatedModel }, Cmd.map TransactionMsg cmd )
( { model
| template = Transaction
, query = updatedModel.hash
, transactionModel = updatedModel
}
, Cmd.map TransactionMsg cmd
)
|> updateUrl
JsMsg _ ->
( model, Cmd.none )
......@@ -168,8 +204,12 @@ update action model =
}
, elmToJs "focus"
)
else
else if updatedModel.query /= model.query then
update (Query updatedModel.query) updatedModel
else if keys.enter then
update (QueryForce updatedModel.query) updatedModel
else
( updatedModel, Cmd.none )
Resize size ->
( { model | window = size }, Cmd.none )
......@@ -182,37 +222,31 @@ fetchAddress address model =
fetchBlockByHash : String -> Model -> ( Model, Cmd Msg )
fetchBlockByHash hash model =
let
( updatedModel, cmd ) =
BlockComponent.update (BlockComponent.GetBlock hash) model.blockModel
in
( { model | blockModel = updatedModel }, Cmd.map BlockMsg cmd )
update (BlockMsg (BlockComponent.GetBlock hash)) model
fetchBlockByHeight : Int -> Model -> ( Model, Cmd Msg )
fetchBlockByHeight height model =
let
( updatedModel, cmd ) =
BlockComponent.update (BlockComponent.GetBlockHash height) model.blockModel
in
( { model | blockModel = updatedModel }, Cmd.map BlockMsg cmd )
update (BlockMsg (BlockComponent.GetBlockHash height)) model
fetchTransaction : String -> Model -> ( Model, Cmd Msg )
fetchTransaction hash model =
let
( updatedModel, cmd ) =
TransactionComponent.update (TransactionComponent.GetRawTransaction hash) model.transactionModel
in
( { model | transactionModel = updatedModel }, Cmd.map TransactionMsg cmd )
update (TransactionMsg (TransactionComponent.GetRawTransaction hash)) model
decodeKeys : Bool -> Keyboard.KeyCode -> Keys -> Keys
decodeKeys bool keyCode keys =
case keyCode of
13 ->
{ keys | enter = bool }
27 ->
{ keys | esc = bool }
68 ->