implemented reset DB from UI

This commit is contained in:
itsikkes 2016-07-24 16:27:56 +03:00
parent 97cf9031c4
commit 4ed667d805
2 changed files with 31 additions and 12 deletions

View File

@ -77,10 +77,7 @@ function initAdmin() {
var options = { var options = {
layout: { layout: {
improvedLayout: false improvedLayout: false
}/*, }
physics: {
enabled: true
}*/
}; };
// Using jQuery to get the element does not work with vis.js library // Using jQuery to get the element does not work with vis.js library
@ -213,7 +210,6 @@ function updateMonkeys() {
else { else {
convertScanNodeToMonkey(exiting_scan, new_monkeys[i]); convertScanNodeToMonkey(exiting_scan, new_monkeys[i]);
} }
updateCounters();
} }
} }
@ -224,6 +220,7 @@ function updateMonkeys() {
refreshDrawing(); refreshDrawing();
} }
createScanned(); createScanned();
updateCounters();
}); });
} }
@ -803,8 +800,17 @@ function resetDB() {
url : '/api?action=reset', url : '/api?action=reset',
type : 'GET', type : 'GET',
success : function(response, textStatus, jqXhr) { success : function(response, textStatus, jqXhr) {
console.log("DB was successfully reset!"); console.log(response);
location.reload(); 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) { error : function(jqXHR, textStatus, errorThrown) {
// log the error to the console // log the error to the console

View File

@ -223,11 +223,24 @@ class MonkeyDownload(restful.Resource):
class Root(restful.Resource): class Root(restful.Resource):
def get(self): def get(self, action=None):
return { if not action:
'status': 'OK', action = request.args.get('action')
'mongo': str(mongo.db), 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): def normalize_obj(obj):