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" ]
|
||||
[ h5 [] [ text "Versions" ]
|
||||
, ul [] (
|
||||
List.map (\version -> li [] [ text (version) ]) app.versions
|
||||
)]
|
||||
, ul []
|
||||
(List.map (\version -> li [] [ text version ]) app.versions)
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -319,8 +319,6 @@ featuresDecoder =
|
|||
]
|
||||
|
||||
|
||||
|
||||
|
||||
versionsDecoder : Decode.Decoder (List String)
|
||||
versionsDecoder =
|
||||
Decode.list (Decode.keyValuePairs Decode.value)
|
||||
|
@ -332,7 +330,6 @@ buildVersions versions =
|
|||
List.concatMap (List.map (\( version, _ ) -> version)) versions
|
||||
|
||||
|
||||
|
||||
appDecoder : Decode.Decoder App
|
||||
appDecoder =
|
||||
Decode.succeed App
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Pages.Top exposing (Model, Msg, Params, page)
|
||||
|
||||
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.Attributes exposing (alt, class, href, src, style, id, for, value)
|
||||
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, for, href, id, src, style, value)
|
||||
import Html.Attributes.Aria exposing (ariaLabel)
|
||||
import Html.Events exposing (onClick, onInput)
|
||||
import Http
|
||||
|
@ -27,6 +27,7 @@ page =
|
|||
}
|
||||
|
||||
|
||||
|
||||
-- INIT
|
||||
|
||||
|
||||
|
@ -53,8 +54,8 @@ type alias Model =
|
|||
, filter_category : Maybe Category
|
||||
, filter_text : Maybe String
|
||||
, status : Status
|
||||
, apps : (List App)
|
||||
, results : (List App)
|
||||
, apps : List App
|
||||
, results : List App
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,7 +83,6 @@ categories =
|
|||
]
|
||||
|
||||
|
||||
|
||||
init : Url Params -> ( Model, Cmd Msg )
|
||||
init { params } =
|
||||
( default_model, loadApps )
|
||||
|
@ -95,8 +95,14 @@ default_image =
|
|||
|
||||
default_model : Model
|
||||
default_model =
|
||||
{ filter_score = Nothing, filter_category = Nothing, filter_text = Nothing,
|
||||
status = Loading, apps = [], results = [] }
|
||||
{ filter_score = Nothing
|
||||
, filter_category = Nothing
|
||||
, filter_text = Nothing
|
||||
, status = Loading
|
||||
, apps = []
|
||||
, results = []
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- UPDATE
|
||||
|
@ -114,41 +120,55 @@ filterAppsScore : List App -> Maybe Int -> List App
|
|||
filterAppsScore apps score =
|
||||
case score of
|
||||
Just s ->
|
||||
List.filter (\app ->
|
||||
List.filter
|
||||
(\app ->
|
||||
app.status >= s
|
||||
) apps
|
||||
)
|
||||
apps
|
||||
|
||||
Nothing ->
|
||||
apps
|
||||
|
||||
|
||||
filterAppsCategory : List App -> Maybe Category -> List App
|
||||
filterAppsCategory apps category =
|
||||
case category of
|
||||
Just c ->
|
||||
if c == All then
|
||||
apps
|
||||
|
||||
else
|
||||
List.filter (\app ->
|
||||
List.filter
|
||||
(\app ->
|
||||
app.category == categories.toString c
|
||||
) apps
|
||||
)
|
||||
apps
|
||||
|
||||
Nothing ->
|
||||
apps
|
||||
|
||||
|
||||
filterAppsText : List App -> Maybe String -> List App
|
||||
filterAppsText apps text =
|
||||
case text of
|
||||
Just "" ->
|
||||
apps
|
||||
|
||||
Just t ->
|
||||
List.filter (\app ->
|
||||
String.contains (String.toLower t) (
|
||||
String.toLower app.name ++ String.toLower (
|
||||
Maybe.withDefault "" app.description
|
||||
List.filter
|
||||
(\app ->
|
||||
String.contains (String.toLower t)
|
||||
(String.toLower app.name
|
||||
++ String.toLower
|
||||
(Maybe.withDefault "" app.description)
|
||||
)
|
||||
)
|
||||
) apps
|
||||
apps
|
||||
|
||||
Nothing ->
|
||||
apps
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
|
@ -157,39 +177,53 @@ update msg model =
|
|||
|
||||
FilterScore filter ->
|
||||
let
|
||||
filter_score = String.toInt filter
|
||||
filter_score =
|
||||
String.toInt filter
|
||||
in
|
||||
( { model
|
||||
| filter_score = filter_score
|
||||
, results = filterAppsScore (
|
||||
filterAppsCategory (
|
||||
filterAppsText model.apps model.filter_text
|
||||
) model.filter_category
|
||||
) (String.toInt filter)
|
||||
}, Cmd.none )
|
||||
, results =
|
||||
filterAppsScore
|
||||
(filterAppsCategory
|
||||
(filterAppsText model.apps model.filter_text)
|
||||
model.filter_category
|
||||
)
|
||||
(String.toInt filter)
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
FilterCategory filter ->
|
||||
let
|
||||
category = categories.fromString filter
|
||||
category =
|
||||
categories.fromString filter
|
||||
in
|
||||
( { model
|
||||
| filter_category = category
|
||||
, results = filterAppsCategory (
|
||||
filterAppsScore (
|
||||
filterAppsText model.apps model.filter_text
|
||||
)model.filter_score
|
||||
) category
|
||||
}, Cmd.none )
|
||||
, results =
|
||||
filterAppsCategory
|
||||
(filterAppsScore
|
||||
(filterAppsText model.apps model.filter_text)
|
||||
model.filter_score
|
||||
)
|
||||
category
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
FilterText filter ->
|
||||
( { model
|
||||
| filter_text = Just filter
|
||||
, results = filterAppsText (
|
||||
filterAppsScore (
|
||||
filterAppsCategory model.apps model.filter_category
|
||||
) model.filter_score
|
||||
) (Just filter)
|
||||
}, Cmd.none )
|
||||
, results =
|
||||
filterAppsText
|
||||
(filterAppsScore
|
||||
(filterAppsCategory model.apps model.filter_category)
|
||||
model.filter_score
|
||||
)
|
||||
(Just filter)
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
GotApps result ->
|
||||
case result of
|
||||
|
@ -197,11 +231,17 @@ update msg model =
|
|||
( { default_model
|
||||
| status = Success
|
||||
, apps = apps
|
||||
, results = apps }, Cmd.none )
|
||||
, results = apps
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
Err _ ->
|
||||
( { default_model
|
||||
| status = Failure}, Cmd.none )
|
||||
| status = Failure
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
|
@ -309,13 +349,11 @@ viewApp app =
|
|||
]
|
||||
|
||||
|
||||
|
||||
viewCategories : ( String, Category ) -> Html Msg
|
||||
viewCategories category =
|
||||
div [ class "category-tile", onClick (FilterCategory (Tuple.first category)) ] [ text (Tuple.first category) ]
|
||||
|
||||
|
||||
|
||||
viewApps : Model -> Html Msg
|
||||
viewApps model =
|
||||
case model.status of
|
||||
|
@ -336,22 +374,22 @@ viewApps model =
|
|||
|
||||
Success ->
|
||||
div [ class "row justify-content-center" ]
|
||||
[ div [ class "col-md-3", id "filter" ] [
|
||||
h2 [ class "app-headings" ] [text "Filter"]
|
||||
, form [] [
|
||||
div [] [
|
||||
h3 [] [text "Categories"]
|
||||
[ div [ class "col-md-3", id "filter" ]
|
||||
[ h2 [ class "app-headings" ] [ text "Filter" ]
|
||||
, form []
|
||||
[ div []
|
||||
[ h3 [] [ text "Categories" ]
|
||||
, div [] (List.map viewCategories categories.list)
|
||||
]
|
||||
, div [] [
|
||||
h3 [] [text "Search"]
|
||||
, div []
|
||||
[ h3 [] [ text "Search" ]
|
||||
, input [ ariaLabel "search", id "text", onInput FilterText ] []
|
||||
]
|
||||
, div [] [
|
||||
h3 [] [text "Status"]
|
||||
, div []
|
||||
[ h3 [] [ text "Status" ]
|
||||
, label [ for "level" ] [ text "At least:" ]
|
||||
, select [ class "search-dropdown", id "level", onInput FilterScore ] [
|
||||
option [ ] [ text "any" ]
|
||||
, select [ class "search-dropdown", id "level", onInput FilterScore ]
|
||||
[ option [] [ text "any" ]
|
||||
, option [ value "5" ] [ text "5 (production)" ]
|
||||
, option [ value "4" ] [ text "4 (beta)" ]
|
||||
, option [ value "3" ] [ text "3 (alpha)" ]
|
||||
|
@ -363,9 +401,9 @@ viewApps model =
|
|||
]
|
||||
, div [ class "col-md-6 offset-md-3" ]
|
||||
[ div [ class "row" ]
|
||||
[ div [ class "col-sm-12" ] [
|
||||
div [] [
|
||||
]
|
||||
[ div [ class "col-sm-12" ]
|
||||
[ div []
|
||||
[]
|
||||
]
|
||||
]
|
||||
, h2 [ class "app-headings" ] [ text "Apps" ]
|
||||
|
@ -382,6 +420,8 @@ viewApps model =
|
|||
, div [ class "col-md-3" ] []
|
||||
]
|
||||
|
||||
|
||||
|
||||
-- HTTP
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue