-
Notifications
You must be signed in to change notification settings - Fork 89
Fixes #29233: Add recent activity table in global parameters details #7352
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
base: branches/rudder/9.2
Are you sure you want to change the base?
Changes from all commits
d84551d
8de8929
3bcfbea
6c07aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| port module GlobalPropertiesRecentActivity exposing (..) | ||
|
|
||
| import Activity.ActivityTable exposing (initTable) | ||
| import Activity.ApiCalls exposing (getActivities, processActivityApiError) | ||
| import Activity.DataTypes exposing (Activity, ActivityMsg(..), BodyParameters, ContextPath(..), string2Search) | ||
| import Browser | ||
| import Dict | ||
| import Html exposing (Html, div) | ||
| import Html.Attributes exposing (class) | ||
| import Rudder.Table exposing (updateData) | ||
| import Time exposing (Zone) | ||
| import TimeZone | ||
|
|
||
|
|
||
| port errorNotification : String -> Cmd msg | ||
|
|
||
|
|
||
| port copy : String -> Cmd msg | ||
|
|
||
|
|
||
| type GlobalPropertyId | ||
| = GlobalPropertyId String | ||
|
|
||
|
|
||
| type alias Model = | ||
| { globalPropertyId : GlobalPropertyId | ||
| , activityTable : Rudder.Table.Model Activity Msg | ||
| , contextPath : ContextPath | ||
| , zone : Zone | ||
| } | ||
|
|
||
|
|
||
| type Msg | ||
| = CallApi (Model -> Cmd Msg) | ||
| | RudderTableMsg (Rudder.Table.Msg Msg) | ||
| | ActivityMessage ActivityMsg | ||
|
|
||
|
|
||
| init : | ||
| { globalPropertyId : String | ||
| , contextPath : String | ||
| , timeZone : String | ||
| } | ||
| -> ( Model, Cmd Msg ) | ||
| init flags = | ||
| let | ||
| initTimeZone = | ||
| Dict.get flags.timeZone TimeZone.zones | ||
| |> Maybe.withDefault (\() -> Time.utc) | ||
|
|
||
| zone = | ||
| initTimeZone () | ||
|
|
||
| initModel : Model | ||
| initModel = | ||
| { globalPropertyId = GlobalPropertyId flags.globalPropertyId | ||
| , activityTable = initTable zone | ||
| , contextPath = ContextPath flags.contextPath | ||
| , zone = zone | ||
| } | ||
|
|
||
| -- full text search on directive id to keep activity related to this directive | ||
| search = | ||
| string2Search flags.globalPropertyId | ||
|
|
||
| bodyParameters : BodyParameters | ||
| bodyParameters = | ||
| { search = search | ||
|
|
||
| -- Keep only directive activity filtering on event log types | ||
| , filterTypes = [ "GlobalParameterAdded", "GlobalParameterDeleted", "GlobalParameterModified" ] | ||
| } | ||
|
|
||
| initActions = | ||
| [ Cmd.map ActivityMessage (getActivities bodyParameters initModel.contextPath) ] | ||
| in | ||
| ( initModel, Cmd.batch initActions ) | ||
|
|
||
|
|
||
|
|
||
| {- Table of the recent activity -} | ||
|
|
||
|
|
||
| table : Model -> Html Msg | ||
| table model = | ||
| div [ class "main-table" ] [ Html.map RudderTableMsg (Rudder.Table.view model.activityTable) ] | ||
|
|
||
|
|
||
| view : Model -> Html Msg | ||
| view model = | ||
| table model | ||
|
|
||
|
|
||
| update : Msg -> Model -> ( Model, Cmd Msg ) | ||
| update msg model = | ||
| case msg of | ||
| CallApi call -> | ||
| ( model, call model ) | ||
|
|
||
| RudderTableMsg m -> | ||
| let | ||
| ( activityTable, tableMsg, _ ) = | ||
| Rudder.Table.update m model.activityTable | ||
| in | ||
| ( { model | activityTable = activityTable }, tableMsg ) | ||
|
|
||
| ActivityMessage a -> | ||
| case a of | ||
| GetActivities res -> | ||
| case res of | ||
| -- Update table data | ||
| Ok ( _, activities ) -> | ||
| let | ||
| updatedTable = | ||
| updateData activities model.activityTable | ||
| in | ||
| ( { model | activityTable = updatedTable }, Cmd.none ) | ||
|
|
||
| Err err -> | ||
| ( model, processActivityApiError "Getting activities list" err errorNotification ) | ||
|
|
||
| CopyToClipboard s -> | ||
| ( model, copy s ) | ||
|
|
||
|
|
||
| subscriptions _ = | ||
| Sub.none | ||
|
|
||
|
|
||
| main = | ||
| Browser.element | ||
| { init = init | ||
| , view = view | ||
| , update = update | ||
| , subscriptions = subscriptions | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,12 +204,18 @@ class ParameterManagement extends SecureDispatchSnippet with Loggable { | |
| "pageLength": 25 | ||
| });""") & | ||
| JsRaw(s""" | ||
| /* Formating function for row details */ | ||
|
|
||
| /* Formating function for row details */ | ||
| function fnFormatDetails(id) { | ||
| const sOut = '<span id="'+id+'" class="parametersDescriptionDetails"/>'; | ||
| return sOut; | ||
| }; | ||
|
|
||
| function fnFormatActivity(id) { | ||
| // FIXME : add some CSS for activity table from elm app | ||
| return '<span><ul class="ms-2"><li><b>Recent activity:</b></li></ul></span><div class="parametersDescriptionDetails"><div id="globalPropertiesRecentActivityApp"></div></div>' | ||
| }; | ||
|
|
||
| ${jsVarNameForId(gridName)}.rows().nodes().to$$().each( function () { | ||
| $$(this).click( function (event) { | ||
| const jTr = $$(this); | ||
|
|
@@ -231,12 +237,45 @@ class ParameterManagement extends SecureDispatchSnippet with Loggable { | |
| color = 'color2'; | ||
| const row = ${jsVarNameForId( | ||
| gridName | ||
| )}.row(this).child(fnFormatDetails(jsid), color + ' parametersDescription details').show(); | ||
| )}.row(this); | ||
|
|
||
| const globalPropertyName = jTr.find('td.name').find('b').html(); | ||
|
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. it would be nice to fetch the name of the property in a more robust way eventually. in the meantime, do you see a cleaner way of fetching the property name @clarktsiory @RaphaelGauthier ?
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. I completely agree that it's not ideal to rely on potentially unstable CSS selectors (such as As for a cleaner way to do that, I don't know any other solution than CSS selectors at this level... |
||
|
|
||
| // row child show is from datatable API | ||
| const children = [fnFormatDetails(jsid)]; | ||
|
|
||
| if (globalPropertyName !== 'rudder') { | ||
| /* Don't show recent activity for rudder global property. | ||
|
|
||
| The 'rudder' global property is created by the system and cannot be modified so it doesn't have any | ||
| activity logged therefore we don't want to add an empty table for this property. | ||
| */ | ||
| children.push(fnFormatActivity(jsid)); | ||
| } | ||
|
|
||
| row.child(children, color + ' parametersDescription details'); | ||
| row.show(); | ||
| $$('#'+jsid).html($$('#description-'+jsid).html()); | ||
|
|
||
|
|
||
| const recentActivityMain = document.getElementById("globalPropertiesRecentActivityApp") | ||
| const initValues = { | ||
| globalPropertyId : globalPropertyName, | ||
| contextPath : contextPath, | ||
| timeZone : localStorage.getItem('timeZone') ?? 'UTC' | ||
| }; | ||
|
|
||
| const app = Elm.GlobalPropertiesRecentActivity.init({node: recentActivityMain, flags: initValues}); | ||
| app.ports.errorNotification.subscribe(function(str) { | ||
| createErrorNotification(str) | ||
| }); | ||
| } | ||
| } | ||
| } ); | ||
| })""") // JsRaw ok, const | ||
| } | ||
| }); | ||
| }) | ||
|
|
||
|
|
||
| """) // JsRaw ok, const | ||
| ) | ||
| } | ||
|
|
||
|
|
||
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.
indeed, i think the CSS should be modified : i think the table should have a border and empty space all around it in order to separate it from the rest
did you have other ideas @P4uline ?
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.
it's acceptable that you modify it in another PR, that's a kind of iterative fix/improvement you can do in alpha