Commit 8f6076d7 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers 🐦

add filter for available rules

parent b513c303
Pipeline #870 passed with stages
in 20 seconds
......@@ -16,6 +16,7 @@ body { padding-top: 70px; }
.agentSide ul:empty{
background-color: #eee;
content: "<li>drag your rules here to build your agent</li>";
border-style: dashed;
}
.agentSide h2{
......
......@@ -36,7 +36,7 @@ function makeRuleItem(list, index, value){
var html = '<li class="list-group-item ' + type + '">';
html = html + '<i class="fa-li fa fa-' + icon + '"></i>';
html = html + value.name;
html = html + '<span class="name">' + value.name + "</span>";
html = html + '<span style="display: none" class="ruleid">' + value.id + '</span>';
html = html + '<button type="button" class="btn btn-info pull-right doc" data-toggle="modal" data-target="#docModal" data-src="http://iggi.fosslab.uk/hanabi/apidocs/' + value.doc + '">Info</button>'
html = html + '</li>';
......@@ -56,6 +56,24 @@ function loadAndDisplay(){
});
}
function filterInit() {
$('#rulesetFilter').on( 'input', function() {
filterRules($(this).val());
});
}
function filterRules(query){
query = query.toLowerCase();
$('#ruleset li').filter( function (index) {
return $(this).children('.name').text().toLowerCase().includes(query);
}).css("display", "block");
$('#ruleset li').filter( function (index) {
return !$(this).children('.name').text().toLowerCase().includes(query);
}).css("display", "none");
}
function updateGraph(json){
var data = [["Your Agent"]];
......@@ -67,6 +85,7 @@ function updateGraph(json){
});
$('#graph').effect('highlight');
chart.load({
columns: data
});
......@@ -97,9 +116,9 @@ function doStuffGraph(){
});
}
$.getJSON("assets/js/blankGraphData.json", updateGraph);
//$.getJSON("assets/js/blankGraphData.json", updateGraph);
}
var chart = null;
$(document).ready(function(){loadAndDisplay();doStuffGraph();});
$(document).ready(function(){loadAndDisplay();doStuffGraph();filterInit();});
......@@ -18,12 +18,19 @@
<div class="col-md-6">
<h2>My Agent</h2>
<ul class="list-inline pull-right">
<li><a href="#" onclick="buildAgent()" class="btn btn-default">Test</a></li>
<li><a href="#" id="testBtn" onclick="buildAgent()" class="btn btn-default"><i class="fa fa-spinner fa-spin fa-fw" style="display: none" aria-hidden="true"></i> Test</a></li>
<li><a href="#" class="btn btn-primary">Submit</a></li>
</ul>
</div>
<div class="col-md-6">
<h2>Available Rules</h2>
<div class="form-group">
<label class="sr-only" for="resetFilter">Filter ruleset</label>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-filter fa-fw" aria-hidden="true"></i></div>
<input class="form-control" id="rulesetFilter">
</div>
</div>
</div>
</div>
<div class="row">
......@@ -63,6 +70,8 @@
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="assets/js/loadAndDisplayRules.js"></script>
<script type="text/javascript">
var testPending = false;
$( function() {
$( "#agent, #ruleset" ).sortable({
connectWith: ".connectedRules"
......@@ -70,6 +79,12 @@
} );
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);
......@@ -80,6 +95,8 @@
$.post("http://hammer.vps.livebytes.co.uk:8000/rule-evaluator-1.0-SNAPSHOT/", model, function(data, textStatus, jqXHR){
console.log("Results", textStatus, data);
updateGraph(data);
testPending = false;
$("#testBtn .fa-spinner").css("display", "none");
});
}
......
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