From cbacebbcd5dbac943ff999146585a0db4de78a12 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sat, 4 Sep 2021 21:43:43 +0200 Subject: [PATCH] update URL with search query in unified mode see #295 --- .../annotation_browse_select_mode.html | 24 +++++++++++++++++-- src/web.go | 6 ++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/html/templates/modules/annotation_browse_select_mode.html b/html/templates/modules/annotation_browse_select_mode.html index bc7f995f..133460b6 100644 --- a/html/templates/modules/annotation_browse_select_mode.html +++ b/html/templates/modules/annotation_browse_select_mode.html @@ -165,10 +165,23 @@ {{ end }} var url = '{{ .apiBaseUrl }}/v1/validations/unannotated'; - if(browseAnnotationsOnlyMode) - url = '{{ .apiBaseUrl }}/v1/annotations'; + let searchOption = ''; + if(browseAnnotationsOnlyMode) { + url = '{{ .apiBaseUrl }}/v1/annotations'; + searchOption = 'rework'; + } var query = $("#annotationQuery").val(); + + let fullUrl = new URL(window.location); + fullUrl.searchParams.set('query', query); + fullUrl.searchParams.set('search_option', searchOption); + if(searchOption === '') + fullUrl.searchParams.delete('search_option'); + else if(searchOption === 'rework') + fullUrl.searchParams.set('search_option', searchOption); + window.history.pushState({}, null, fullUrl); + $.ajax({ url: url, dataType: 'json', @@ -345,6 +358,13 @@ imageMonkeyApi.setToken(getCookie("imagemonkey")); + {{ if ne .query "" }} + $("#annotationQuery").val({{ .query }}); + {{ if eq .searchOption "rework" }} + $("#annotationsOnlyCheckbox").checkbox("set checked"); + {{ end }} + populateImageGrid(); + {{ end }} var staticQueryAttributes = {{ .queryAttributes }}; var availableLabels = staticQueryAttributes; diff --git a/src/web.go b/src/web.go index 05c55e00..9be69ddc 100644 --- a/src/web.go +++ b/src/web.go @@ -564,7 +564,9 @@ func main() { } view := commons.GetParamFromUrlParams(c, "view", "default") - + query := commons.GetParamFromUrlParams(c, "query", "") + searchOption := commons.GetParamFromUrlParams(c, "search_option", "default") + c.HTML(http.StatusOK, "annotate.html", gin.H{ "title": "Annotate", "activeMenuNr": 4, @@ -579,6 +581,8 @@ func main() { "annotationMode": mode, "annotationView": view, "onlyOnce": onlyOnce, + "query": query, + "searchOption": searchOption, "sentryDsn": localSentryDsn, "showSkipAnnotationButtons": showSkipAnnotationButtons, "queryAttributes": parser.GetStaticQueryAttributes(parser.AnnotationView),