Skip to content

Commit

Permalink
Add checkbox to use cached project metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Sep 5, 2024
1 parent 8883e8e commit 89af843
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ def generate_configs():
"config_generator_service_url",
"http://qwc-config-service:9090").rstrip('/') + '/'

params = {
"tenant": current_handler.tenant,
}
params.update(request.args)
response = requests.post(
urllib.parse.urljoin(
config_generator_url,
"generate_configs?tenant=" + current_handler.tenant))
urllib.parse.urljoin(config_generator_url, "generate_configs"),
params=params
)

return (response.text, response.status_code)

Expand Down
15 changes: 13 additions & 2 deletions src/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@
$('#alerts').find(alertSelector).append(html);
}

var setupAPIRequestButton = function(buttonSelector, url, alertSelector, titleSuccess, titleError) {
var setupAPIRequestButton = function(buttonSelector, url, options, alertSelector, titleSuccess, titleError) {
var button = $(buttonSelector);
button.click(function() {
clearAlert(alertSelector);
button.attr("disabled", true);
$(document.body).css("cursor", 'wait');

let reqUrl = url;
options.forEach(option => {
if ($('#' + option).prop('checked')) {
reqUrl += (reqUrl.includes('?') ? '&' : '?') + option + '=1';
}
});

// call Admin GUI service
$.post(
url,
reqUrl,
{
csrf_token: '{{ csrf_token() }}'
}
Expand Down Expand Up @@ -71,6 +78,7 @@
setupAPIRequestButton(
'#generate_configs',
"{{ url_for('generate_configs') }}",
['use_cached_project_metadata'],
'#alert-generate_configs',
"Service configurations generated:",
"Error while refreshing config cache:"
Expand All @@ -81,6 +89,7 @@
setupAPIRequestButton(
'#update_solr_index',
"{{ url_for('update_solr_index') }}",
[],
'#alert-update_solr_index',
"Solr search index update:",
"Error while updating Solr search index:"
Expand All @@ -101,6 +110,8 @@ <h1>{{ admin_gui_title }}</h1>
<button id="generate_configs" class="btn btn-success">
{{ utils.render_icon('arrow-clockwise') }} {{ i18n('interface.main.generate_configs') }}
</button>
<br>
<label style="padding-top: 0.5em"><input id="use_cached_project_metadata" type="checkbox" /> {{ i18n('interface.main.use_cached_project_metadata') }}</label>
{% endif %}

{% if solr_index_update_enabled %}
Expand Down
5 changes: 3 additions & 2 deletions src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"timeout_error": "Das Generieren der Konfiguration hat zu lange gedauert. Mögliche Gründe:\n- Es besteht ein Netzwerkproblem\n- Das Laden der Capabilities hat zu lange gedauert (zu viele Themen / zu viele Ebenen / langsame ferne Ebenen)\n- Der 'proxy_read_timeout' des `qwc-api-gateway` ist zu tief",
"title": "QWC Admin",
"update_resource_message_error": "Könnte nicht aktualisert werden: {}.",
"update_resource_message_success": "{} wurde aktualisiert."
"update_resource_message_success": "{} wurde aktualisiert.",
"use_cached_project_metadata": "Gecachte Projektmetadaten verwenden falls verfügbar"
},
"permissions": {
"confirm_message_delete": "Berechtigung entfernen?",
Expand Down Expand Up @@ -353,4 +354,4 @@
"user_requests_declined": "Ihre Anträge für folgende Gruppen wurden abgelehnt:"
}
}
}
}
5 changes: 3 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"timeout_error": "The generation of the configuration took too long. Likely causes:\n- There is a network connectivity issue\n- Fetching the Capabilities took too long (too many themes / too many layers / slow remote layers)\n- The 'proxy_read_timeout' of the qwc-api-gateway is too low",
"title": "QWC Admin",
"update_resource_message_error": "Could not update {}.",
"update_resource_message_success": "{} has been updated."
"update_resource_message_success": "{} has been updated.",
"use_cached_project_metadata": "Use cached project metadata if available"
},
"permissions": {
"confirm_message_delete": "Remove permission?",
Expand Down Expand Up @@ -353,4 +354,4 @@
"user_requests_declined": "Your membership requests for the following groups have been declined:"
}
}
}
}
5 changes: 3 additions & 2 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"timeout_error": "La génération de la configuration a pris trop de temps. Causes probables:\n- Il y a un problème de connectivité\n - La récupération des Capabilities a pris trop de temps (trop de thèmes / trop de couches / couches distantes lentes)\n- Le 'proxy_read_timeout' de qwc-api-gateway est trop bas",
"title": "Administration QWC",
"update_resource_message_error": "Impossible de modifier {}.",
"update_resource_message_success": "{} a été modifié."
"update_resource_message_success": "{} a été modifié.",
"use_cached_project_metadata": "Utiliser les métadonnées du projet mises en cache si elles sont disponibles"
},
"permissions": {
"confirm_message_delete": "Voulez-vous supprimer la permission?",
Expand Down Expand Up @@ -353,4 +354,4 @@
"user_requests_declined": "Votre demande pour rejoindre les groupes suivant a été rejetée:"
}
}
}
}
1 change: 1 addition & 0 deletions src/translations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"interface.main.title",
"interface.main.update_resource_message_error",
"interface.main.update_resource_message_success",
"interface.main.use_cached_project_metadata",
"interface.permissions.confirm_message_delete",
"interface.permissions.ph_select_resource",
"interface.permissions.priority",
Expand Down

0 comments on commit 89af843

Please sign in to comment.