-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#123 delete all button on report listing screen #181
base: master
Are you sure you want to change the base?
Changes from 5 commits
1a4d069
e1183d3
fe78135
540ef0e
705207b
9d38088
9360482
a4c884e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from typing import Any, Dict, List, Tuple, NamedTuple, Optional, AnyStr | ||
|
||
import nbformat | ||
from flask import Blueprint, abort, jsonify, render_template, request, url_for, current_app | ||
from flask import Blueprint, abort, jsonify, render_template, request, url_for, current_app, redirect | ||
from nbformat import NotebookNode | ||
|
||
from notebooker.constants import DEFAULT_RESULT_LIMIT | ||
|
@@ -300,3 +300,23 @@ def delete_report(job_id): | |
except Exception: | ||
error_info = traceback.format_exc() | ||
return jsonify({"status": "error", "error": error_info}), 500 | ||
|
||
|
||
@run_report_bp.route("/delete_all_reports/<path:report_name>", methods=["GET", "POST"]) | ||
def delete_all_reports(report_name): | ||
""" | ||
Deletes all reports associated with a particular report_name from the underlying storage. | ||
Only marks as "status=deleted" so the report is retrievable at a later date. | ||
|
||
:param report_name: The parameter here should be a "/"-delimited string which mirrors the directory structure of \ | ||
the notebook templates. | ||
|
||
:return: A JSON which contains "status" which will either be "ok" or "error". | ||
""" | ||
try: | ||
get_serializer().delete_all_for_report_name(report_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this implemented? |
||
get_all_result_keys(get_serializer(), limit=DEFAULT_RESULT_LIMIT, force_reload=True) | ||
return jsonify({"status": "ok"}), 200 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs some enhancement - exposing the JSON to the end user is a bit too low-level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've set this up to redirect to the front page. |
||
except Exception: | ||
error_info = traceback.format_exc() | ||
return jsonify({"status": "error", "error": error_info}), 500 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,10 +38,13 @@ <h1 class="ui huge centered header">{{ titleised_report_name }} ({{ report_name | |
</div> | ||
{% endif %} | ||
{% if not readonly_mode %} | ||
<div class="three wide column"> | ||
<a class="ui button green" id="runReportButton" href="/run_report/{{ report_name }}"> | ||
<div class="three wide column" style="display: flex;"> | ||
<a class="ui button green" id="runReportButton" href="/run_report/{{ report_name }}" style="margin-right: 40px;"> | ||
Manually run this report | ||
</a> | ||
<button class="ui button red" id="deleteAllReportsButton" data-href="/delete_all_reports/{{ report_name }}"> | ||
Delete all reports | ||
</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we could add a Jest test for this as well please |
||
</div> | ||
{% endif %} | ||
</div> | ||
|
@@ -56,5 +59,14 @@ <h1 class="ui huge centered header">{{ titleised_report_name }} ({{ report_name | |
<div class="ui cancel button">Cancel</div> | ||
</div> | ||
</div> | ||
<script type="application/javascript"> | ||
document.getElementById('deleteAllReportsButton').addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
var confirmed = confirm('Are you sure you wish to delete all reports?'); | ||
if (confirmed) { | ||
window.location.href = this.getAttribute('data-href'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could take a long time - do we want to display a spinner or even a status update to the user? |
||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test please