aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-11-11 13:44:46 +0300
committerBonfaceKilz2022-11-11 15:01:04 +0300
commitfe3414198289526d1ec9816cf56ba1b916cae8d6 (patch)
tree0647ade70e2f519603d0f4a31fd687ddae6fa3d1 /wqflask
parent43272386e182df16e5da761e0c36238ff921e5ca (diff)
downloadgenenetwork2-fe3414198289526d1ec9816cf56ba1b916cae8d6.tar.gz
Notify user when they modify probeset data
* wqflask/wqflask/metadata_edits.py (update_probeset): Flash a success messages when user updates something. Otherwise flash a warning message * wqflask/wqflask/templates/edit_probeset.html: Display flash messages.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py9
-rw-r--r--wqflask/wqflask/templates/edit_probeset.html31
2 files changed, 40 insertions, 0 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index 0840d4dd..383316e4 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -447,6 +447,15 @@ def update_probeset(name: str):
json_data=json.dumps(diff_data),
),
)
+ edited_values = {k: v for (k, v) in diff_data['Probeset'].items() if k not in {"id_", "timestamp", "author"}}
+ changes = []
+ for k in edited_values.keys():
+ changes.append(f"<b><span data-message-id='{k}'></span></b>")
+ message = f"You successfully updated the following entries \
+ at {diff_data['timestamp']}: {', '.join(changes)}"
+ flash(f"You successfully edited: {message}", "success")
+ else:
+ flash("No edits were made!", "warning")
return redirect(
f"/datasets/traits/{name}"
f"?resource-id={request.args.get('resource-id')}"
diff --git a/wqflask/wqflask/templates/edit_probeset.html b/wqflask/wqflask/templates/edit_probeset.html
index 60973da2..c5ef992e 100644
--- a/wqflask/wqflask/templates/edit_probeset.html
+++ b/wqflask/wqflask/templates/edit_probeset.html
@@ -3,6 +3,31 @@
{% block content %}
<!-- Start of body -->
<div class="container">
+ {% with messages = get_flashed_messages(category_filter=["warning"]) %}
+ {% if messages %}
+ {% for message in messages %}
+ <div class="alert alert-warning alert-dismissible" role="alert">
+ <button class="close" type="button" data-dismiss="alert" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ {{ message }}
+ </div>
+ {% endfor %}
+ {% endif %}
+ {% endwith %}
+
+ {% with messages = get_flashed_messages(category_filter=["success"]) %}
+ {% if messages %}
+ {% for message in messages %}
+ <div class="alert alert-success alert-dismissible" role="alert">
+ <button class="close" type="button" data-dismiss="alert" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ {{ message|safe }}
+ </div>
+ {% endfor %}
+ {% endif %}
+ {% endwith %}
<div class="page-header text-left">
<h1>Probeset Editing Form: {{ probeset.name }}</h1>
<small><a href="{{url_for('metadata_edit.show_history', name=name)}}" target="_blank">[View History]</a></small>
@@ -188,6 +213,12 @@
{% block js %}
<script>
gn_server_url = "{{ gn_server_url }}";
+ spans = document.querySelectorAll("[data-message-id]")
+ spans.forEach((span) => {
+ span.innerHTML = $("[for='" + span.getAttribute("data-message-id") + "']").text();
+ });
+ $("[data-message-id]").lead
+
function MarkAsChanged(){
$(this).addClass("changed");
}