implemented reset DB from UI
This commit is contained in:
parent
97cf9031c4
commit
4ed667d805
|
@ -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(response);
|
||||||
|
if (response.status != 'OK') {
|
||||||
|
BootstrapDialog.show({
|
||||||
|
title: "Reset DB",
|
||||||
|
message: "The following error occured: " + response.reason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
console.log("DB was successfully reset!");
|
console.log("DB was successfully reset!");
|
||||||
location.reload();
|
location.reload();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error : function(jqXHR, textStatus, errorThrown) {
|
error : function(jqXHR, textStatus, errorThrown) {
|
||||||
// log the error to the console
|
// log the error to the console
|
||||||
|
|
|
@ -223,11 +223,24 @@ class MonkeyDownload(restful.Resource):
|
||||||
|
|
||||||
|
|
||||||
class Root(restful.Resource):
|
class Root(restful.Resource):
|
||||||
def get(self):
|
def get(self, action=None):
|
||||||
|
if not action:
|
||||||
|
action = request.args.get('action')
|
||||||
|
if not action:
|
||||||
return {
|
return {
|
||||||
'status': 'OK',
|
'status': 'OK',
|
||||||
'mongo': str(mongo.db),
|
'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):
|
||||||
|
|
Loading…
Reference in New Issue