elm-format
continuous-integration/drone/pr Build was killed
Details
continuous-integration/drone/pr Build was killed
Details
This commit is contained in:
parent
377c8a7d04
commit
2dec76fbfd
|
@ -272,9 +272,9 @@ viewApp app readme =
|
||||||
]
|
]
|
||||||
, div [ class "card-footer" ]
|
, div [ class "card-footer" ]
|
||||||
[ h5 [] [ text "Versions" ]
|
[ h5 [] [ text "Versions" ]
|
||||||
, ul [] (
|
, ul []
|
||||||
List.map (\version -> li [] [ text (version) ]) app.versions
|
(List.map (\version -> li [] [ text version ]) app.versions)
|
||||||
)]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -319,8 +319,6 @@ featuresDecoder =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
versionsDecoder : Decode.Decoder (List String)
|
versionsDecoder : Decode.Decoder (List String)
|
||||||
versionsDecoder =
|
versionsDecoder =
|
||||||
Decode.list (Decode.keyValuePairs Decode.value)
|
Decode.list (Decode.keyValuePairs Decode.value)
|
||||||
|
@ -332,7 +330,6 @@ buildVersions versions =
|
||||||
List.concatMap (List.map (\( version, _ ) -> version)) versions
|
List.concatMap (List.map (\( version, _ ) -> version)) versions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
appDecoder : Decode.Decoder App
|
appDecoder : Decode.Decoder App
|
||||||
appDecoder =
|
appDecoder =
|
||||||
Decode.succeed App
|
Decode.succeed App
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module Pages.Top exposing (Model, Msg, Params, page)
|
module Pages.Top exposing (Model, Msg, Params, page)
|
||||||
|
|
||||||
import Enum exposing (Enum)
|
import Enum exposing (Enum)
|
||||||
import Html exposing (Html, a, button, div, h2, h3, h5, i, img, li, p, span, text, ul, form, label, select, option, input)
|
import Html exposing (Html, a, button, div, form, h2, h3, h5, i, img, input, label, li, option, p, select, span, text, ul)
|
||||||
import Html.Attributes exposing (alt, class, href, src, style, id, for, value)
|
import Html.Attributes exposing (alt, class, for, href, id, src, style, value)
|
||||||
import Html.Attributes.Aria exposing (ariaLabel)
|
import Html.Attributes.Aria exposing (ariaLabel)
|
||||||
import Html.Events exposing (onClick, onInput)
|
import Html.Events exposing (onClick, onInput)
|
||||||
import Http
|
import Http
|
||||||
|
@ -27,6 +27,7 @@ page =
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- INIT
|
-- INIT
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,8 +54,8 @@ type alias Model =
|
||||||
, filter_category : Maybe Category
|
, filter_category : Maybe Category
|
||||||
, filter_text : Maybe String
|
, filter_text : Maybe String
|
||||||
, status : Status
|
, status : Status
|
||||||
, apps : (List App)
|
, apps : List App
|
||||||
, results : (List App)
|
, results : List App
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,11 +79,10 @@ categories =
|
||||||
[ ( "Apps", Apps )
|
[ ( "Apps", Apps )
|
||||||
, ( "Utilities", Utilities )
|
, ( "Utilities", Utilities )
|
||||||
, ( "Development", Development )
|
, ( "Development", Development )
|
||||||
, ("All", All)
|
, ( "All", All )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init : Url Params -> ( Model, Cmd Msg )
|
init : Url Params -> ( Model, Cmd Msg )
|
||||||
init { params } =
|
init { params } =
|
||||||
( default_model, loadApps )
|
( default_model, loadApps )
|
||||||
|
@ -95,8 +95,14 @@ default_image =
|
||||||
|
|
||||||
default_model : Model
|
default_model : Model
|
||||||
default_model =
|
default_model =
|
||||||
{ filter_score = Nothing, filter_category = Nothing, filter_text = Nothing,
|
{ filter_score = Nothing
|
||||||
status = Loading, apps = [], results = [] }
|
, filter_category = Nothing
|
||||||
|
, filter_text = Nothing
|
||||||
|
, status = Loading
|
||||||
|
, apps = []
|
||||||
|
, results = []
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- UPDATE
|
-- UPDATE
|
||||||
|
@ -114,41 +120,55 @@ filterAppsScore : List App -> Maybe Int -> List App
|
||||||
filterAppsScore apps score =
|
filterAppsScore apps score =
|
||||||
case score of
|
case score of
|
||||||
Just s ->
|
Just s ->
|
||||||
List.filter (\app ->
|
List.filter
|
||||||
|
(\app ->
|
||||||
app.status >= s
|
app.status >= s
|
||||||
) apps
|
)
|
||||||
|
apps
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
apps
|
apps
|
||||||
|
|
||||||
|
|
||||||
filterAppsCategory : List App -> Maybe Category -> List App
|
filterAppsCategory : List App -> Maybe Category -> List App
|
||||||
filterAppsCategory apps category =
|
filterAppsCategory apps category =
|
||||||
case category of
|
case category of
|
||||||
Just c ->
|
Just c ->
|
||||||
if c == All then
|
if c == All then
|
||||||
apps
|
apps
|
||||||
|
|
||||||
else
|
else
|
||||||
List.filter (\app ->
|
List.filter
|
||||||
app.category == categories.toString c
|
(\app ->
|
||||||
) apps
|
app.category == categories.toString c
|
||||||
|
)
|
||||||
|
apps
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
apps
|
apps
|
||||||
|
|
||||||
|
|
||||||
filterAppsText : List App -> Maybe String -> List App
|
filterAppsText : List App -> Maybe String -> List App
|
||||||
filterAppsText apps text =
|
filterAppsText apps text =
|
||||||
case text of
|
case text of
|
||||||
Just "" ->
|
Just "" ->
|
||||||
apps
|
apps
|
||||||
|
|
||||||
Just t ->
|
Just t ->
|
||||||
List.filter (\app ->
|
List.filter
|
||||||
String.contains (String.toLower t) (
|
(\app ->
|
||||||
String.toLower app.name ++ String.toLower (
|
String.contains (String.toLower t)
|
||||||
Maybe.withDefault "" app.description
|
(String.toLower app.name
|
||||||
)
|
++ String.toLower
|
||||||
|
(Maybe.withDefault "" app.description)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) apps
|
apps
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
apps
|
apps
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
case msg of
|
||||||
|
@ -157,51 +177,71 @@ update msg model =
|
||||||
|
|
||||||
FilterScore filter ->
|
FilterScore filter ->
|
||||||
let
|
let
|
||||||
filter_score = String.toInt filter
|
filter_score =
|
||||||
|
String.toInt filter
|
||||||
in
|
in
|
||||||
( { model
|
( { model
|
||||||
| filter_score = filter_score
|
| filter_score = filter_score
|
||||||
, results = filterAppsScore (
|
, results =
|
||||||
filterAppsCategory (
|
filterAppsScore
|
||||||
filterAppsText model.apps model.filter_text
|
(filterAppsCategory
|
||||||
) model.filter_category
|
(filterAppsText model.apps model.filter_text)
|
||||||
) (String.toInt filter)
|
model.filter_category
|
||||||
}, Cmd.none )
|
)
|
||||||
|
(String.toInt filter)
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
FilterCategory filter ->
|
FilterCategory filter ->
|
||||||
let
|
let
|
||||||
category = categories.fromString filter
|
category =
|
||||||
|
categories.fromString filter
|
||||||
in
|
in
|
||||||
( { model
|
( { model
|
||||||
| filter_category = category
|
| filter_category = category
|
||||||
, results = filterAppsCategory (
|
, results =
|
||||||
filterAppsScore (
|
filterAppsCategory
|
||||||
filterAppsText model.apps model.filter_text
|
(filterAppsScore
|
||||||
)model.filter_score
|
(filterAppsText model.apps model.filter_text)
|
||||||
) category
|
model.filter_score
|
||||||
}, Cmd.none )
|
)
|
||||||
|
category
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
FilterText filter ->
|
FilterText filter ->
|
||||||
( { model
|
( { model
|
||||||
| filter_text = Just filter
|
| filter_text = Just filter
|
||||||
, results = filterAppsText (
|
, results =
|
||||||
filterAppsScore (
|
filterAppsText
|
||||||
filterAppsCategory model.apps model.filter_category
|
(filterAppsScore
|
||||||
) model.filter_score
|
(filterAppsCategory model.apps model.filter_category)
|
||||||
) (Just filter)
|
model.filter_score
|
||||||
}, Cmd.none )
|
)
|
||||||
|
(Just filter)
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
GotApps result ->
|
GotApps result ->
|
||||||
case result of
|
case result of
|
||||||
Ok apps ->
|
Ok apps ->
|
||||||
( { default_model
|
( { default_model
|
||||||
| status = Success
|
| status = Success
|
||||||
, apps = apps
|
, apps = apps
|
||||||
, results = apps }, Cmd.none )
|
, results = apps
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
Err _ ->
|
Err _ ->
|
||||||
( { default_model
|
( { default_model
|
||||||
| status = Failure}, Cmd.none )
|
| status = Failure
|
||||||
|
}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
subscriptions : Model -> Sub Msg
|
subscriptions : Model -> Sub Msg
|
||||||
|
@ -304,16 +344,14 @@ viewApp app =
|
||||||
, p [ class "card-description" ] [ text (ellipsis 100 (withDefault "" app.description)) ]
|
, p [ class "card-description" ] [ text (ellipsis 100 (withDefault "" app.description)) ]
|
||||||
]
|
]
|
||||||
, div [ class "footer" ]
|
, div [ class "footer" ]
|
||||||
[ viewStatusBadge app, span [ class "badge app-category" ] [ text app.category ]]
|
[ viewStatusBadge app, span [ class "badge app-category" ] [ text app.category ] ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewCategories : ( String, Category ) -> Html Msg
|
||||||
viewCategories : (String, Category) -> Html Msg
|
|
||||||
viewCategories category =
|
viewCategories category =
|
||||||
div [ class "category-tile", onClick (FilterCategory (Tuple.first category)) ] [text (Tuple.first category)]
|
div [ class "category-tile", onClick (FilterCategory (Tuple.first category)) ] [ text (Tuple.first category) ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
viewApps : Model -> Html Msg
|
viewApps : Model -> Html Msg
|
||||||
|
@ -336,36 +374,36 @@ viewApps model =
|
||||||
|
|
||||||
Success ->
|
Success ->
|
||||||
div [ class "row justify-content-center" ]
|
div [ class "row justify-content-center" ]
|
||||||
[ div [ class "col-md-3", id "filter" ] [
|
[ div [ class "col-md-3", id "filter" ]
|
||||||
h2 [ class "app-headings" ] [text "Filter"]
|
[ h2 [ class "app-headings" ] [ text "Filter" ]
|
||||||
, form [] [
|
, form []
|
||||||
div [] [
|
[ div []
|
||||||
h3 [] [text "Categories"]
|
[ h3 [] [ text "Categories" ]
|
||||||
, div [] (List.map viewCategories categories.list)
|
, div [] (List.map viewCategories categories.list)
|
||||||
]
|
]
|
||||||
, div [] [
|
, div []
|
||||||
h3 [] [text "Search"]
|
[ h3 [] [ text "Search" ]
|
||||||
, input [ ariaLabel "search", id "text", onInput FilterText ] []
|
, input [ ariaLabel "search", id "text", onInput FilterText ] []
|
||||||
]
|
]
|
||||||
, div [] [
|
, div []
|
||||||
h3 [] [text "Status"]
|
[ h3 [] [ text "Status" ]
|
||||||
, label [ for "level" ] [ text "At least:" ]
|
, label [ for "level" ] [ text "At least:" ]
|
||||||
, select [ class "search-dropdown", id "level", onInput FilterScore ] [
|
, select [ class "search-dropdown", id "level", onInput FilterScore ]
|
||||||
option [ ] [ text "any" ]
|
[ option [] [ text "any" ]
|
||||||
, option [ value "5" ] [ text "5 (production)" ]
|
, option [ value "5" ] [ text "5 (production)" ]
|
||||||
, option [ value "4" ] [ text "4 (beta)" ]
|
, option [ value "4" ] [ text "4 (beta)" ]
|
||||||
, option [ value "3" ] [ text "3 (alpha)" ]
|
, option [ value "3" ] [ text "3 (alpha)" ]
|
||||||
, option [ value "2" ] [ text "2 (pre-alpha)" ]
|
, option [ value "2" ] [ text "2 (pre-alpha)" ]
|
||||||
, option [ value "1" ] [ text "1 (work-in-progress)" ]
|
, option [ value "1" ] [ text "1 (work-in-progress)" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
|
||||||
]
|
|
||||||
, div [ class "col-md-6 offset-md-3" ]
|
, div [ class "col-md-6 offset-md-3" ]
|
||||||
[ div [ class "row" ]
|
[ div [ class "row" ]
|
||||||
[ div [ class "col-sm-12" ] [
|
[ div [ class "col-sm-12" ]
|
||||||
div [] [
|
[ div []
|
||||||
]
|
[]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, h2 [ class "app-headings" ] [ text "Apps" ]
|
, h2 [ class "app-headings" ] [ text "Apps" ]
|
||||||
|
@ -379,9 +417,11 @@ viewApps model =
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
, div [class "col-md-3"] []
|
, div [ class "col-md-3" ] []
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- HTTP
|
-- HTTP
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue