diff --git a/webapp/titanembeds/static/js/admin_index.js b/webapp/titanembeds/static/js/admin_index.js new file mode 100644 index 0000000..1a1f11c --- /dev/null +++ b/webapp/titanembeds/static/js/admin_index.js @@ -0,0 +1,30 @@ +/* global $ */ +/* global Materialize */ + +(function () { + function cleanup_database() { + var funct = $.ajax({ + method: "DELETE", + url: "/api/cleanup-db", + }); + return funct.promise(); + } + + $(function(){ + $("#db_cleanup_btn").click(run_cleanup_db); + }); + + function run_cleanup_db() { + $("#db_cleanup_btn").attr("disabled",true); + Materialize.toast('Please wait for the cleanup database task to finish...', 10000); + var cleanupdb = cleanup_database(); + cleanupdb.done(function () { + $("#db_cleanup_btn").attr("disabled",false); + Materialize.toast('Successfully cleaned up the database!', 10000); + }); + cleanupdb.fail(function () { + $("#db_cleanup_btn").attr("disabled",false); + Materialize.toast('Database cleanup failiure.', 10000); + }); + } +})(); \ No newline at end of file diff --git a/webapp/titanembeds/templates/admin_index.html.j2 b/webapp/titanembeds/templates/admin_index.html.j2 index 60a7ce1..2785249 100644 --- a/webapp/titanembeds/templates/admin_index.html.j2 +++ b/webapp/titanembeds/templates/admin_index.html.j2 @@ -22,10 +22,13 @@
Clean up the database
- SoonTM +Clears the keyval caches and purges the old messages. (Hit once, and wait a minute)
+ Run DB Cleanup Task