-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module Ucm.UcmConnectivity exposing (..) | ||
|
||
import Html exposing (Html, div, h3, p, text) | ||
import Html.Attributes exposing (class) | ||
import Http | ||
import UI | ||
import UI.Icon as Icon | ||
import UI.Tooltip as Tooltip | ||
|
||
|
||
type UcmConnectivity | ||
= Connected | ||
| NotConnected Http.Error | ||
|
||
|
||
view : UcmConnectivity -> Html msg | ||
view ucmConnectivity = | ||
case ucmConnectivity of | ||
Connected -> | ||
UI.nothing | ||
|
||
NotConnected err -> | ||
let | ||
( errorTitle, errorMessage ) = | ||
case err of | ||
Http.Timeout -> | ||
( "UCM Timeout", "The connection to UCM timed out" ) | ||
|
||
Http.NetworkError -> | ||
( "UCM Network error" | ||
, "There was a network error when trying to connect to UCM. Make sure its running." | ||
) | ||
|
||
Http.BadStatus status -> | ||
( "Unexpected response from UCM", "Bad status: " ++ String.fromInt status ) | ||
|
||
Http.BadBody resp -> | ||
( "Unexpected response from UCM: ", resp ) | ||
|
||
Http.BadUrl url -> | ||
( "Malformed URL ", url ) | ||
|
||
tooltipContent = | ||
Tooltip.rich (div [] [ h3 [] [ text errorTitle ], p [] [ text errorMessage ] ]) | ||
|
||
icon = | ||
div | ||
[ class "ucm-connectivity ucm-connectivity_error" ] | ||
[ Icon.view Icon.warn ] | ||
in | ||
Tooltip.tooltip tooltipContent | ||
|> Tooltip.withPosition Tooltip.Above | ||
|> Tooltip.withArrow Tooltip.End | ||
|> Tooltip.view icon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.ucm-connectivity { | ||
position: relative; | ||
width: 1.25rem; | ||
height: 1.25rem; | ||
border-radius: 0.75rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
margin-right: 0.25rem; | ||
} | ||
|
||
.ucm-connectivity_error { | ||
background: var(--u-color_critical_element); | ||
|
||
& .icon { | ||
color: var(--u-color_critical_icon-on-element); | ||
margin-top: -4px; | ||
} | ||
} | ||
|
||
.tooltip-trigger:has(.ucm-connectivity) .tooltip-bubble { | ||
margin-right: -1.75rem; | ||
margin-bottom: -0.65rem; | ||
} | ||
|
||
.tooltip-trigger:has(.ucm-connectivity) .tooltip-bubble p { | ||
margin: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters