diff --git a/monkey_island/cc/admin/ui/js/monkeys-admin.js b/monkey_island/cc/admin/ui/js/monkeys-admin.js index e009b46b7..c58b4f54e 100644 --- a/monkey_island/cc/admin/ui/js/monkeys-admin.js +++ b/monkey_island/cc/admin/ui/js/monkeys-admin.js @@ -77,10 +77,7 @@ function initAdmin() { var options = { layout: { improvedLayout: false - }/*, - physics: { - enabled: true - }*/ + } }; // Using jQuery to get the element does not work with vis.js library @@ -213,7 +210,6 @@ function updateMonkeys() { else { convertScanNodeToMonkey(exiting_scan, new_monkeys[i]); } - updateCounters(); } } @@ -224,6 +220,7 @@ function updateMonkeys() { refreshDrawing(); } createScanned(); + updateCounters(); }); } @@ -803,8 +800,17 @@ function resetDB() { url : '/api?action=reset', type : 'GET', success : function(response, textStatus, jqXhr) { - console.log("DB was successfully reset!"); - location.reload(); + console.log(response); + if (response.status != 'OK') { + BootstrapDialog.show({ + title: "Reset DB", + message: "The following error occured: " + response.reason + }); + } + else { + console.log("DB was successfully reset!"); + location.reload(); + } }, error : function(jqXHR, textStatus, errorThrown) { // log the error to the console diff --git a/monkey_island/cc/main.py b/monkey_island/cc/main.py index 9dfe6a78b..ea4c55b35 100644 --- a/monkey_island/cc/main.py +++ b/monkey_island/cc/main.py @@ -223,11 +223,24 @@ class MonkeyDownload(restful.Resource): class Root(restful.Resource): - def get(self): - return { - 'status': 'OK', - 'mongo': str(mongo.db), - } + def get(self, action=None): + if not action: + action = request.args.get('action') + if not action: + return { + 'status': 'OK', + 'mongo': str(mongo.db), + } + elif action=="reset": + mongo.db.config.drop() + mongo.db.monkey.drop() + mongo.db.telemetry.drop() + return { + 'status': 'OK', + } + else: + return {'status': 'BAD', + 'reason': 'unknown action'} def normalize_obj(obj):