From 8f9d9f53400b7d6a92825897f88302f81945eb2f Mon Sep 17 00:00:00 2001 From: lezhnev Date: Thu, 11 Jan 2024 18:23:54 +0100 Subject: [PATCH] iteration over timeline zoom and pagination --- ui/htmx_controller.go | 12 +++++++++++- ui/web_templates/fragments/pagination.gohtml | 6 +++--- ui/web_templates/fragments/search_form.gohtml | 5 +++++ ui/web_templates/fragments/timeline.gohtml | 15 ++++++++------- ui/web_templates/home.gohtml | 9 ++++++++- ui/web_templates/theme.gohtml | 5 ++--- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/ui/htmx_controller.go b/ui/htmx_controller.go index 4818786..2adc09b 100644 --- a/ui/htmx_controller.go +++ b/ui/htmx_controller.go @@ -275,9 +275,19 @@ func (hc *HtmxController) putResultsPage( PagePrevExists = false } + var fromMilli, toMilli int64 + if from != nil { + fromMilli = from.UnixMilli() + } + if to != nil { + toMilli = to.UnixMilli() + } + PageData := fiber.Map{ // query: - "QueryId": queryId, + "QueryId": queryId, + "FromMilli": fromMilli, + "ToMilli": toMilli, // results: "PageSize": pageSize, "Pages": pages, diff --git a/ui/web_templates/fragments/pagination.gohtml b/ui/web_templates/fragments/pagination.gohtml index 899d556..e1f6f9a 100644 --- a/ui/web_templates/fragments/pagination.gohtml +++ b/ui/web_templates/fragments/pagination.gohtml @@ -16,7 +16,7 @@
  • Previous @@ -29,7 +29,7 @@
  • Next @@ -46,7 +46,7 @@ class="form-select" name="pagesize" id="pagesize" - hx-get="/cmd/page/?queryId={{.QueryId}}&page=0" + hx-get="/cmd/page/?queryId={{.QueryId}}{{if .FromMilli}}&from={{.FromMilli}}{{end}}{{if .ToMilli}}&to={{.ToMilli}}{{end}}" > diff --git a/ui/web_templates/fragments/search_form.gohtml b/ui/web_templates/fragments/search_form.gohtml index 025e3e9..8d58007 100644 --- a/ui/web_templates/fragments/search_form.gohtml +++ b/ui/web_templates/fragments/search_form.gohtml @@ -149,6 +149,11 @@ // pre-process dates before sending: document.body.addEventListener('htmx:configRequest', function (evt) { + if(evt.detail.path != "/cmd/new") { + // only provide the below attribute for the form requests + return + } + if ($("#query_from_input").val()) { evt.detail.parameters['From'] = $("#query_from_input").val() } diff --git a/ui/web_templates/fragments/timeline.gohtml b/ui/web_templates/fragments/timeline.gohtml index fd69710..57fe445 100644 --- a/ui/web_templates/fragments/timeline.gohtml +++ b/ui/web_templates/fragments/timeline.gohtml @@ -1,7 +1,8 @@
    - reset zoom + Mouse wheel to zoom. + Reset Zoom