-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Default grouping in ui #1864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default grouping in ui #1864
Changes from all commits
26f3e4e
91d2972
1df9de3
9ddadb8
461a6e5
eb8345e
287c149
0a7e227
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| {- | ||
| Alertmanager API | ||
| API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager) | ||
|
|
||
| OpenAPI spec version: 0.0.1 | ||
|
|
||
| NOTE: This file is auto generated by the openapi-generator. | ||
| https://github.com/openapitools/openapi-generator.git | ||
| Do not edit this file manually. | ||
| -} | ||
|
|
||
|
|
||
| module Data.AlertGroup exposing (AlertGroup, decoder, encoder) | ||
|
|
||
| import Data.GettableAlert as GettableAlert exposing (GettableAlert) | ||
| import Data.Receiver as Receiver exposing (Receiver) | ||
| import Dict exposing (Dict) | ||
| import Json.Decode as Decode exposing (Decoder) | ||
| import Json.Decode.Pipeline exposing (optional, required) | ||
| import Json.Encode as Encode | ||
|
|
||
|
|
||
| type alias AlertGroup = | ||
| { labels : Dict String String | ||
| , receiver : Receiver | ||
| , alerts : List GettableAlert | ||
| } | ||
|
|
||
|
|
||
| decoder : Decoder AlertGroup | ||
| decoder = | ||
| Decode.succeed AlertGroup | ||
| |> required "labels" (Decode.dict Decode.string) | ||
| |> required "receiver" Receiver.decoder | ||
| |> required "alerts" (Decode.list GettableAlert.decoder) | ||
|
|
||
|
|
||
| encoder : AlertGroup -> Encode.Value | ||
| encoder model = | ||
| Encode.object | ||
| [ ( "labels", Encode.dict identity Encode.string model.labels ) | ||
| , ( "receiver", Receiver.encoder model.receiver ) | ||
| , ( "alerts", Encode.list GettableAlert.encoder model.alerts ) | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import Url exposing (percentEncode) | |
| type alias Filter = | ||
| { text : Maybe String | ||
| , group : Maybe String | ||
| , customGrouping : Bool | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whenever I look at boolean flags/query strings, I wonder if it would be better to have a concrete setting, like Any thoughts on this? Stay with the boolean flag, or move use a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stuartnelson3 I think the missing parameter should be the default. Because this is how you open it anyways. So |
||
| , receiver : Maybe String | ||
| , showSilenced : Maybe Bool | ||
| , showInhibited : Maybe Bool | ||
|
|
@@ -35,6 +36,7 @@ nullFilter : Filter | |
| nullFilter = | ||
| { text = Nothing | ||
| , group = Nothing | ||
| , customGrouping = False | ||
| , receiver = Nothing | ||
| , showSilenced = Nothing | ||
| , showInhibited = Nothing | ||
|
|
@@ -47,14 +49,15 @@ generateQueryParam name = | |
|
|
||
|
|
||
| generateQueryString : Filter -> String | ||
| generateQueryString { receiver, showSilenced, showInhibited, text, group } = | ||
| generateQueryString { receiver, customGrouping, showSilenced, showInhibited, text, group } = | ||
| let | ||
| parts = | ||
| [ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just ) | ||
| , ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just ) | ||
| , ( "filter", emptyToNothing text ) | ||
| , ( "receiver", emptyToNothing receiver ) | ||
| , ( "group", group ) | ||
| , ( "customGrouping", boolToMaybeString customGrouping ) | ||
| ] | ||
| |> List.filterMap (\( a, b ) -> generateQueryParam a b) | ||
| in | ||
|
|
@@ -96,6 +99,15 @@ generateAPIQueryString { receiver, showSilenced, showInhibited, text, group } = | |
| "" | ||
|
|
||
|
|
||
| boolToMaybeString : Bool -> Maybe String | ||
| boolToMaybeString b = | ||
| if b then | ||
| Just "true" | ||
|
|
||
| else | ||
| Nothing | ||
|
|
||
|
|
||
| boolToString : Bool -> String | ||
| boolToString b = | ||
| if b then | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing the openapi definition!