From a5593d66ea541dfbcd2597f81dcbc51965c51cfc Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 11 Jul 2018 23:38:14 +0200 Subject: Manage alerts --- ishtar_common/static/js/ishtar.js | 32 ++++++++++++++ ishtar_common/templates/base.html | 1 + ishtar_common/templates/blocks/DataTables.html | 20 +++++++-- .../ishtar/blocks/base_shortcut_menu.html | 4 +- ishtar_common/templates/ishtar/wizard/search.html | 8 ++++ ishtar_common/urls.py | 6 ++- ishtar_common/utils.py | 3 +- ishtar_common/views.py | 50 ++++++++++++++++++++++ ishtar_common/views_item.py | 17 ++++++-- ishtar_common/wizards.py | 22 ++++++++-- 10 files changed, 149 insertions(+), 14 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index a71450fab..60840bcf8 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -38,7 +38,10 @@ function manage_async_link(event){ function get_next_table_id(){} function get_previous_table_id(){} +var datatable_submit_search = function() {}; + var shortcut_url = ''; +var alert_url = ''; var datatables_i18n; var current_modal; @@ -222,6 +225,7 @@ function load_shortcut_menu(opened){ cache: false, success:function(html){ init_shortcut_menu(html); + load_alerts(); if(opened){ $("#dropdown-toggle-shortcut-menu").click(); } @@ -232,6 +236,34 @@ function load_shortcut_menu(opened){ }); } +var load_alerts = function(){ + if (!alert_url) return; + $('.modal-progress').modal('show'); + $.ajax({ + url: alert_url, + cache: false, + success:function(json){ + $('.modal-progress').modal('hide'); + var html = ""; + for (idx in json["alerts"]){ + var b = json["alerts"][idx]; + var url = "/bookmark/" + b["query_id"] + "/" ; + html += ''; + html += b["label"]; + html += ' '; + html += b["number"]; + html += ''; + html += ' '; + } + $("#alert-list").html(html); + }, + error:function(XMLHttpRequest, textStatus, errorThrows){ + close_wait(); + }, + dataType: 'json' + }); +} + function dynamic_load(url, target){ $.ajax({ url: url, diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index 40e30706c..72c6a9b65 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -30,6 +30,7 @@ {{EXTRA_JS|safe}} +{% endif %} {% comment %}