Commit 99015b1c authored by Piers Williams's avatar Piers Williams

Added reovery feature

parent 0a2fc8ca
Pipeline #879 passed with stages
in 20 seconds
......@@ -34,7 +34,7 @@ function makeRuleItem(list, index, value){
random, info, lightbulb-o, recycle, times, trash, arrow-right
*/
var html = '<li class="list-group-item clearfix ' + type + '">';
var html = '<li class="list-group-item clearfix ' + type + '" id="rule' + value.id + '">';
html = html + '<i class="fa-fw fa fa-' + icon + '"></i>';
html = html + '<span class="name">' + value.name + "</span>";
html = html + '<span style="display: none" class="ruleid">' + value.id + '</span>';
......@@ -133,9 +133,32 @@ function updateTable(){
tableRows[0].cells[index + 1].innerHTML = value.score;
tableRows[1].cells[index + 1].innerHTML = value.moves;
tableRows[2].cells[index + 1].innerHTML = value.lives;
tableRows[3].cells[index + 1].innerHTML = '<button class="btn btn-success" onclick=recoverModel(' + index + ')>Recover</btn>'
});
}
function recoverModel(index){
// Clear the list on the left
var rulesCurrent = $("#agent li");
var availableRules = $("#ruleset");
//empty the list and put them back where they belong
$.each(rulesCurrent, function(index, value){
availableRules.append(value);
});
// get the model
var model = models[index].split(",");
for(var location = 0; location < model.length; location++){
console.log(model[location]);
var rule = $("#rule" + model[location]);
console.log("FOUND", rule);
$("#agent").append(rule);
}
}
function doStuffGraph(){
if(chart == null){
chart = c3.generate({
......@@ -162,8 +185,39 @@ function doStuffGraph(){
}
}
function buildAgent() {
if (testPending) {
return;
}
testPending = true;
$("#testBtn .fa-spinner").css("display", "inline");
var ruleList = [];
$("#agent .list-group-item .ruleid").each(function(x, i) {
ruleList.push(i.innerHTML);
});
var model = ruleList.join(",");
models.unshift(model);
if(models.length > 4){
models.pop();
}
console.log("MODELS", models);
$.post("http://hammer.vps.livebytes.co.uk:8000/rule-evaluator-1.0-SNAPSHOT/", model, function(data, textStatus, jqXHR){
console.log("Results", textStatus, data);
updateData(data);
updateGraph();
updateTable();
testPending = false;
$("#testBtn .fa-spinner").css("display", "none");
});
}
var chart = null;
var allData = [];
var tableData = [];
var models = [];
$(document).ready(function(){loadAndDisplay();doStuffGraph();filterInit();});
......@@ -72,7 +72,12 @@
<td>0</td>
<td>0</td>
</tr>
<tr>
<th></th>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
......@@ -123,30 +128,6 @@
}).disableSelection();
} );
function buildAgent() {
if (testPending) {
return;
}
testPending = true;
$("#testBtn .fa-spinner").css("display", "inline");
var ruleList = [];
$("#agent .list-group-item .ruleid").each(function(x, i) {
ruleList.push(i.innerHTML);
});
var model = ruleList.join(",");
$.post("http://hammer.vps.livebytes.co.uk:8000/rule-evaluator-1.0-SNAPSHOT/", model, function(data, textStatus, jqXHR){
console.log("Results", textStatus, data);
updateData(data);
updateGraph();
updateTable();
testPending = false;
$("#testBtn .fa-spinner").css("display", "none");
});
}
</script>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment