Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
#29 Nakadi SQL Query tab and server support added (#30)
Browse files Browse the repository at this point in the history
* #29 Nakadi SQL Query tab and server support added

* #29 Nakadi SQL feature flag

* #29 Nakadi SQL feature flag usage

* #29 Make SQL Query the seccond tab

* #29 Adjast tabs height

* #29 Create SQL Query menu item and the routing

* #29 Create SQL Query Form

* #29 Nakadi SQL. Status, Delete, Monitoring

* #29 Nakadi SQL. Create help fix

* #29 Nakadi SQL. #25 Integrate Ace editor

* #29 cleanup

* #29 Hide not supported authz option

* #29 fix SQL create request

* #29 fix. remove admins from autz

* #29 fix. json format for POST

* #29 Hide publishing tab, as it is useless for Query output

* Improve deployment for docker

* Fix Create menu height

* Fix text
  • Loading branch information
SergKam authored Nov 16, 2018
1 parent 0eaf85f commit 39ad08e
Show file tree
Hide file tree
Showing 39 changed files with 1,466 additions and 166 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ SUPPORT_URL=https://hipchat.example.com/chat/room/12345
ALLOW_DELETE_EVENT_TYPE=yes
FORBID_DELETE_URL=https://nakadi-faq.docs.example.com/#how-to-delete-et

NAKADI_SQL_API_URL="http://nakadi-sql.example.com"
QUERY_MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=live&var-$queryId={query}"
SHOW_NAKADI_SQL=no

MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-live"
SLO_MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-slos"
EVENT_TYPE_MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=nakadi-live&var-et={et}"
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ ENV CREDENTIALS_DIR="deploy/OAUTH"
ENV HTTPS_ENABLE=0
ENV NODE_TLS_REJECT_UNAUTHORIZED=0

ENV SHOW_NAKADI_SQL=yes
ENV NAKADI_SQL_API_URL="http://nakadi-sql.example.com"
ENV QUERY_MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=live&var-$queryId={query}"

ENTRYPOINT npm run start:prod
7 changes: 7 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ AUTHORIZE_OPTIONS=myscope
#ANALYTICS_OPTIONS_url="https://nakadi-staging.example.com"
#ANALYTICS_OPTIONS_name="example-team.nakadi-ui.access-log"

# Nakadi SQL Support
# If "yes" shows create SQL Query menu item and the SQL Query tab
# for query output event types
SHOW_NAKADI_SQL=no
NAKADI_SQL_API_URL="http://nakadi-sql.example.com"
QUERY_MONITORING_URL="https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=live&var-$queryId={query}"

# The key used to encode/decode user session.
# Required
COOKIE_SECRET="!!! CHANGE THIS!!! ksdgi98NNliuHHy^fdjy6b!khl_ig6%^#vGdsljhgl Bfdes&8yh3e"
Expand Down
4 changes: 4 additions & 0 deletions client/Config.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ urlNakadiApi : String
urlNakadiApi =
urlBase ++ "api/nakadi/"

urlNakadiSqlApi : String
urlNakadiSqlApi =
urlBase ++ "api/nakadi-sql/"


urlValidationApi : String
urlValidationApi =
Expand Down
10 changes: 6 additions & 4 deletions client/Helpers/AccessEditor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type alias Config =
{ appsInfoUrl : String
, usersInfoUrl : String
, showWrite : Bool
, help: List (Html Msg)
, showAnyToken : Bool
, help : List (Html Msg)
}


Expand Down Expand Up @@ -395,7 +396,10 @@ accessTable config renderer records =
in
UI.grid header
(List.concat
[ renderSection All emptyString
[ if config.showAnyToken then
renderSection All emptyString
else
[]
, renderSection User "Users:"
, renderSection Service "Services:"
, renderSection Unknown "Unknown types:"
Expand Down Expand Up @@ -496,5 +500,3 @@ hasPermission permissionType record =

Admin ->
record.permission.admin


199 changes: 199 additions & 0 deletions client/Helpers/Ace.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
module Helpers.Ace exposing (..)

{-| A library to use Ace editor with Elm.
# Editor
@docs toHtml
# Ace's Attributes
@docs theme, readOnly, mode, value, highlightActiveLine
@docs showPrintMargin, showCursor, showGutter, tabSize, useSoftTabs, useWrapMode
@docs enableBasicAutocompletion, enableLiveAutocompletion, enableSnippets, extensions
# Ace's Events
@docs onSourceChange
-}

import Html exposing (Attribute, Html)
import Html.Attributes as Attributes
import Html.Events as Events
import Json.Decode as JD
import Json.Encode as JE
import Native.Ace


{-| Attribute to set the theme to Ace.
Ace.toHtml [ Ace.theme "monokai" ] []
-}
theme : String -> Attribute msg
theme val =
Attributes.property "AceTheme" (JE.string val)


{-| Attribute to set editor in readonly.
Ace.toHtml [ Ace.readOnly true ] []
-}
readOnly : Bool -> Attribute msg
readOnly val =
Attributes.property "AceReadOnly" (JE.bool val)


{-| Attribute to set the mode to Ace.
Ace.toHtml [ Ace.mode "lua" ] []
-}
mode : String -> Attribute msg
mode val =
Attributes.property "AceMode" (JE.string val)


{-| Attribute to set initial value or to update current value of Ace.
Ace.toHtml [ Ace.value "-- It's a source!\nlocal x = 1" ] []
-}
value : String -> Attribute msg
value val =
Attributes.property "AceValue" (JE.string val)


{-| Attribute to set whether to show the print margin or not.
Ace.toHtml [ Ace.showPrintMargin false ] []
-}
showPrintMargin : Bool -> Attribute msg
showPrintMargin val =
Attributes.property "AceShowPrintMargin" (JE.bool val)


{-| Attribute to set whether show cursor or not
Ace.toHtml [ Ace.showCursor false ] []
-}
showCursor : Bool -> Attribute msg
showCursor val =
Attributes.property "AceShowCursor" (JE.bool val)


{-| Attribute to set whether to show gutter or not.
Ace.toHtml [ Ace.showGutter false ] []
-}
showGutter : Bool -> Attribute msg
showGutter val =
Attributes.property "AceShowGutter" (JE.bool val)


{-| Attribute to set whether to highlight the active line or not.
Ace.toHtml [ Ace.highlightActiveLine false ] []
-}
highlightActiveLine : Bool -> Attribute msg
highlightActiveLine val =
Attributes.property "AceHighlightActiveLine" (JE.bool val)


{-| Attribute to set the tab size.
Ace.toHtml [ Ace.tabSize 4 ] []
-}
tabSize : Int -> Attribute msg
tabSize val =
Attributes.property "AceTabSize" (JE.int val)


{-| Attribute to set whether to use soft tabs or not.
Ace.toHtml [ Ace.useSoftTabs false ] []
-}
useSoftTabs : Bool -> Attribute msg
useSoftTabs val =
Attributes.property "AceUseSoftTabs" (JE.bool val)


{-| Attribute to set whether to use wrap mode.
Ace.toHtml [ Ace.useWrapMode false ] []
-}
useWrapMode : Bool -> Attribute msg
useWrapMode val =
Attributes.property "AceUseWrapMode" (JE.bool val)


{-| Attribute to set autocompletion option.
Ace.toHtml [ Ace.enableBasicAutocompletion true ] []
-}
enableBasicAutocompletion : Bool -> Attribute msg
enableBasicAutocompletion val =
Attributes.property "AceEnableBasicAutocompletion" (JE.bool val)


{-| Attribute to set live autocompletion option.
Ace.toHtml [ Ace.enableLiveAutocompletion true ] []
-}
enableLiveAutocompletion : Bool -> Attribute msg
enableLiveAutocompletion val =
Attributes.property "AceEnableLiveAutocompletion" (JE.bool val)


{-| Attribute to activate snippets.
Ace.toHtml [ Ace.enableSnippets true ] []
-}
enableSnippets : Bool -> Attribute msg
enableSnippets val =
Attributes.property "AceEnableSnippets" (JE.bool val)


{-| Set list of extensions for ace.
Ace.toHtml [ Ace.extensions [ "language_tools" ] ] []
-}
extensions : List String -> Attribute msg
extensions exts =
Attributes.property "AceExtensions" (List.map JE.string exts |> JE.list)


{-| Values changes listener. It used to get notifications about changes made by user.
Ace.toHtml [ Ace.onSourceChange model.data ] []
-}
onSourceChange : (String -> msg) -> Attribute msg
onSourceChange tagger =
Events.on "AceSourceChange" (JD.map tagger Events.targetValue)


{-| Creates `Html` instance with Ace attached to it.
Ace.toHtml [] []
-}
toHtml : List (Attribute msg) -> List (Html msg) -> Html msg
toHtml =
Native.Ace.toHtml
66 changes: 36 additions & 30 deletions client/Helpers/Forms.elm
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,21 @@ textInput :
-> Locking
-> Html msg
textInput formModel field onInputMsg inputLabel inputPlaceholder hint help isRequired isDisabled =
inputFrame field inputLabel hint help isRequired formModel <|
input
[ onInput (onInputMsg field)
, value (getValue field formModel.values)
, type_ "text"
, validationClass field "dc-input" formModel
, id (inputId formModel.formId field)
, placeholder inputPlaceholder
, tabindex 1
, disabled (isDisabled == Disabled)
]
[]
if isDisabled == Disabled then
none
else
inputFrame field inputLabel hint help isRequired formModel <|
input
[ onInput (onInputMsg field)
, value (getValue field formModel.values)
, type_ "text"
, validationClass field "dc-input" formModel
, id (inputId formModel.formId field)
, placeholder inputPlaceholder
, tabindex 1
, disabled (isDisabled == Disabled)
]
[]


selectInput :
Expand All @@ -119,24 +122,27 @@ selectInput formModel field onInputMsg inputLabel hint help isRequired isDisable
else
(isDisabled == Disabled)
in
inputFrame field inputLabel hint help isRequired formModel <|
select
[ onSelect (onInputMsg field)
, validationClass field "dc-select" formModel
, id (inputId formModel.formId field)
, tabindex 1
, disabled isDisabledOrOne
]
(options
|> List.map
(\optionName ->
option
[ selected (selectedValue == optionName)
, value optionName
]
[ text optionName ]
)
)
if isDisabledOrOne then
none
else
inputFrame field inputLabel hint help isRequired formModel <|
select
[ onSelect (onInputMsg field)
, validationClass field "dc-select" formModel
, id (inputId formModel.formId field)
, tabindex 1
, disabled isDisabledOrOne
]
(options
|> List.map
(\optionName ->
option
[ selected (selectedValue == optionName)
, value optionName
]
[ text optionName ]
)
)


areaInput :
Expand Down
Loading

0 comments on commit 39ad08e

Please sign in to comment.