Skip to content

Commit

Permalink
update URL with search query in unified mode
Browse files Browse the repository at this point in the history
see #295
  • Loading branch information
Bernhard B committed Sep 4, 2021
1 parent 66c6851 commit cbacebb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 22 additions & 2 deletions html/templates/modules/annotation_browse_select_mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit cbacebb

Please sign in to comment.