Create Silence from filter Bar (#1911)

* Create Silence from filters

Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>

* Get rid of unnecessary things

Signed-off-by: m-masataka <m.mizukoshi.wakuwaku@gmail.com>
This commit is contained in:
masataka 2019-06-06 02:01:56 +09:00 committed by Andrey Kuzmin
parent b783cf8e60
commit e33edd6f13
3 changed files with 26 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@ module Utils.Filter exposing
( Filter
, MatchOperator(..)
, Matcher
, convertFilterMatcher
, generateAPIQueryString
, generateQueryParam
, generateQueryString
@ -231,6 +232,14 @@ stringifyMatcher { key, op, value } =
++ "\""
convertFilterMatcher : Matcher -> Data.Matcher.Matcher
convertFilterMatcher { key, op, value } =
{ name = key
, value = value
, isRegex = op == RegexMatch
}
filter : Parser (List Matcher)
filter =
Parser.succeed identity

View File

@ -1,12 +1,13 @@
module Views.FilterBar.Views exposing (view)
import Html exposing (Attribute, Html, button, div, i, input, small, span, text)
import Html.Attributes exposing (class, disabled, id, style, value)
import Html exposing (Attribute, Html, a, button, div, i, input, small, span, text)
import Html.Attributes exposing (class, disabled, href, id, style, value)
import Html.Events exposing (keyCode, on, onClick, onInput)
import Utils.Filter exposing (Matcher)
import Utils.Filter exposing (Matcher, convertFilterMatcher)
import Utils.Keyboard exposing (keys, onKeyDown, onKeyUp)
import Utils.List
import Views.FilterBar.Types exposing (Model, Msg(..))
import Views.SilenceForm.Parsing exposing (newSilenceFromMatchers)
keys :
@ -101,6 +102,10 @@ view { matchers, matcherText, backspacePressed } =
isDisabled =
maybeMatcher == Nothing
dataMatchers =
matchers
|> List.map convertFilterMatcher
in
div
[ class "row no-gutters align-items-start" ]
@ -122,6 +127,13 @@ view { matchers, matcherText, backspacePressed } =
, span
[ class "input-group-btn" ]
[ button [ class "btn btn-primary", disabled isDisabled, onClickAttr ] [ text "+" ] ]
, a
[ class "btn btn-outline-info border-0"
, href (newSilenceFromMatchers dataMatchers)
]
[ i [ class "fa fa-bell-slash-o mr-2" ] []
, text "Silence"
]
]
, small [ class "form-text text-muted" ]
[ text "Custom matcher, e.g."