From 8da5493f8948b793933c8d1f2cd47ff349666145 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 14 Dec 2020 14:17:26 +0300 Subject: [PATCH] reload button --- images/reload.svg | 11 +++++++++++ src/Info.elm | 4 ++++ src/Msg.elm | 1 + src/Update.elm | 10 +++++----- src/View.elm | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 images/reload.svg diff --git a/images/reload.svg b/images/reload.svg new file mode 100644 index 0000000..b9f9e4e --- /dev/null +++ b/images/reload.svg @@ -0,0 +1,11 @@ + + + + Bitmap + Created with Sketch. + + + + + + \ No newline at end of file diff --git a/src/Info.elm b/src/Info.elm index 807d714..b18a036 100644 --- a/src/Info.elm +++ b/src/Info.elm @@ -8,6 +8,7 @@ type alias ModuleDescription = , description : String } + type alias BlueprintDescription = { description : String } @@ -22,10 +23,12 @@ getModuleDescription : String -> String getModuleDescription name = modulesDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault "" + getBlueprintDescription : String -> String getBlueprintDescription name = blueprintsDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault "" + modulesDescription : Dict String ModuleDescription modulesDescription = Dict.fromList @@ -41,6 +44,7 @@ modulesDescription = , ( "facade_url_downloader", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "Adapter module for cURL CLI utility" } ) ] + blueprintsDescription : Dict String BlueprintDescription blueprintsDescription = Dict.fromList diff --git a/src/Msg.elm b/src/Msg.elm index 8cd1da4..aaf349c 100644 --- a/src/Msg.elm +++ b/src/Msg.elm @@ -12,3 +12,4 @@ type Msg | AquamarineEvent Port.ReceiveEvent | RelayChanged String | ToggleInterface String + | Reload diff --git a/src/Update.elm b/src/Update.elm index e3deb89..159f11a 100644 --- a/src/Update.elm +++ b/src/Update.elm @@ -16,6 +16,7 @@ limitations under the License. -} +import AirScripts.GetAll as GetAll import Blueprints.Model exposing (Blueprint) import Browser import Browser.Navigation as Nav @@ -25,6 +26,7 @@ import Model exposing (Model, PeerData, emptyPeerData) import Modules.Model exposing (Module) import Msg exposing (..) import Nodes.Model exposing (Identify) +import Port exposing (sendAir) import Route exposing (getAllCmd) import Service.Model exposing (Service) import Url @@ -66,11 +68,6 @@ update msg model = updatedDict = Dict.union model.discoveredPeers newDict - - emptyPeers = - Dict.toList updatedDict - |> List.filter (\( _, data ) -> List.isEmpty data.identify.external_addresses) - |> List.map Tuple.first in ( { model | discoveredPeers = updatedDict }, getAllCmd model.peerId model.relayId [] ) @@ -107,6 +104,9 @@ update msg model = RelayChanged relayId -> ( { model | relayId = relayId }, Cmd.none ) + Reload -> + ( model, sendAir (GetAll.air model.peerId model.relayId model.knownPeers) ) + updateModel : Model -> String -> Identify -> List Service -> List Module -> List Blueprint -> Model updateModel model peer identify services modules blueprints = diff --git a/src/View.elm b/src/View.elm index 196a690..3629888 100644 --- a/src/View.elm +++ b/src/View.elm @@ -19,6 +19,7 @@ limitations under the License. import Browser exposing (Document, UrlRequest(..)) import Html exposing (Html, a, div, header, img, p, text) import Html.Attributes exposing (attribute, style) +import Html.Events exposing (onClick) import Model exposing (Model, Route(..)) import Msg exposing (..) import Palette exposing (classes) @@ -64,6 +65,19 @@ body model = [ a [ attribute "href" "/nodes", classes "link black" ] [ text "Nodes" ] ] ] + , div [ classes "fl fr" ] + [ a [ attribute "href" "/" ] + [ img + [ classes "mw-100" + , style "height" "20px" + , attribute "src" "/images/reload.svg" + , style "position" "relative" + , style "top" "0.85rem" + , onClick Reload + ] + [] + ] + ] ] ] ]