From de285ed64c4b44bdc0d16060c9ea0df3009e480d Mon Sep 17 00:00:00 2001 From: Terrtia Date: Thu, 18 Apr 2019 10:56:00 +0200 Subject: [PATCH] chg: [UI DOC] add dynamic update message + add bootstrap 4 migration message + add update doc (DB) --- OVERVIEW.md | 22 +++++++++++++++++++ var/www/modules/Flask_config.py | 4 ++++ var/www/modules/dashboard/Flask_dashboard.py | 14 +++++++++--- .../modules/dashboard/templates/index.html | 7 +++++- var/www/modules/settings/Flask_settings.py | 7 +++--- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/OVERVIEW.md b/OVERVIEW.md index 02dcbeb9..3e325ceb 100644 --- a/OVERVIEW.md +++ b/OVERVIEW.md @@ -30,6 +30,28 @@ Redis and ARDB overview # Database Map: +## DB0 - Core: + +##### Update keys: +| Key | Value | +| ------ | ------ | +| | | +| ail:version | **current version** | +| | | +| ail:update_**update_version** | **background update name** | +| | **background update name** | +| | **...** | +| | | +| ail:update_date_v1.5 | **update date** | +| | | +| ail:update_error | **update message error** | +| | | +| ail:update_in_progress | **update version in progress** | +| ail:current_background_update | **current update version** | +| | | +| ail:current_background_script | **name of the background script currently executed** | +| ail:current_background_script_stat | **progress in % of the background script** | + ## DB2 - TermFreq: ##### Set: diff --git a/var/www/modules/Flask_config.py b/var/www/modules/Flask_config.py index d16aeaad..fc972c25 100644 --- a/var/www/modules/Flask_config.py +++ b/var/www/modules/Flask_config.py @@ -160,6 +160,10 @@ DiffMaxLineLength = int(cfg.get("Flask", "DiffMaxLineLength"))#Use to display t bootstrap_label = ['primary', 'success', 'danger', 'warning', 'info'] +dict_update_description = {'v1.5':{'nb_background_update': 4, 'update_warning_message': 'An Update is running on the background. Some informations like Tags, screenshot can be', + 'update_warning_message_notice_me': 'missing from the UI.'} + } + UPLOAD_FOLDER = os.path.join(os.environ['AIL_FLASK'], 'submitted') PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], cfg.get("Directories", "pastes")) + '/' diff --git a/var/www/modules/dashboard/Flask_dashboard.py b/var/www/modules/dashboard/Flask_dashboard.py index c4a272fc..3dfa3f53 100644 --- a/var/www/modules/dashboard/Flask_dashboard.py +++ b/var/www/modules/dashboard/Flask_dashboard.py @@ -25,6 +25,7 @@ r_serv_log = Flask_config.r_serv_log r_serv_db = Flask_config.r_serv_db max_dashboard_logs = Flask_config.max_dashboard_logs +dict_update_description = Flask_config.dict_update_description dashboard = Blueprint('dashboard', __name__, template_folder='templates') @@ -165,13 +166,20 @@ def index(): log_select.add(max_dashboard_logs) log_select = list(log_select) log_select.sort() + + # Check if update in progress update_in_progress = False - if r_serv_db.exists('ail:update_v1.5'): - if not r_serv_db.exists('v1.5:onions') or not r_serv_db.exists('v1.5:metadata') or not r_serv_db.exists('v1.5:tags') or not r_serv_db.exists('v1.5:tags_background'): + current_update = r_serv_db.get('ail:current_background_update') + if current_update: + if r_serv_db.scard('ail:update_{}'.format(current_update)) != dict_update_description[current_update]['nb_background_update']: update_in_progress = True + update_warning_message = dict_update_description[current_update]['update_warning_message'] + update_warning_message_notice_me = dict_update_description[current_update]['update_warning_message_notice_me'] return render_template("index.html", default_minute = default_minute, threshold_stucked_module=threshold_stucked_module, - log_select=log_select, selected=max_dashboard_logs, update_in_progress=update_in_progress) + log_select=log_select, selected=max_dashboard_logs, + update_warning_message=update_warning_message, update_in_progress=update_in_progress, + update_warning_message_notice_me=update_warning_message_notice_me) # ========= REGISTRATION ========= app.register_blueprint(dashboard, url_prefix=baseUrl) diff --git a/var/www/modules/dashboard/templates/index.html b/var/www/modules/dashboard/templates/index.html index 4e6d1a21..49f3e59b 100644 --- a/var/www/modules/dashboard/templates/index.html +++ b/var/www/modules/dashboard/templates/index.html @@ -102,11 +102,16 @@ {%if update_in_progress%}
× - Warning! An Update is running on the background. Some informations like Tags, screenshot can be missing from the UI. + Warning! {{update_warning_message}} {{update_warning_message_notice_me}} (Check Update Status)
{%endif%} +
+ × + Bootstrap 4 migration! Some pages are still in bootstrap 3. You can check the migration progress Here. +
+
diff --git a/var/www/modules/settings/Flask_settings.py b/var/www/modules/settings/Flask_settings.py index f81cf397..2d2d2be9 100644 --- a/var/www/modules/settings/Flask_settings.py +++ b/var/www/modules/settings/Flask_settings.py @@ -21,8 +21,7 @@ r_serv_db = Flask_config.r_serv_db max_preview_char = Flask_config.max_preview_char max_preview_modal = Flask_config.max_preview_modal REPO_ORIGIN = Flask_config.REPO_ORIGIN - -dict_update_stat = {'v1.5':{'nb_background_update': 4}} +dict_update_description = Flask_config.dict_update_description settings = Blueprint('settings', __name__, template_folder='templates') @@ -70,7 +69,7 @@ def get_update_metadata(): if dict_update['update_in_progress']: dict_update['update_progression'] = r_serv_db.scard('ail:update_{}'.format(dict_update['update_in_progress'])) - dict_update['update_nb'] = dict_update_stat[dict_update['update_in_progress']]['nb_background_update'] + dict_update['update_nb'] = dict_update_description[dict_update['update_in_progress']]['nb_background_update'] dict_update['update_stat'] = int(dict_update['update_progression']*100/dict_update['update_nb']) dict_update['current_background_script'] = r_serv_db.get('ail:current_background_script') dict_update['current_background_script_stat'] = r_serv_db.get('ail:current_background_script_stat') @@ -107,7 +106,7 @@ def get_background_update_stats_json(): update_stats['background_stats'] = int(update_stats['background_stats']) update_progression = r_serv_db.scard('ail:update_{}'.format(current_update)) - update_nb_scripts = dict_update_stat[current_update]['nb_background_update'] + update_nb_scripts = dict_update_description[current_update]['nb_background_update'] update_stats['update_stat'] = int(update_progression*100/update_nb_scripts) update_stats['update_stat_label'] = '{}/{}'.format(update_progression, update_nb_scripts)