Commit 48c8a61c authored by Sebastien Robin's avatar Sebastien Robin

add worker count to make the demo more friendly

parent 79a0156c
......@@ -41,7 +41,7 @@ def setModel():
@app.route("/updateModel", methods=["POST", "OPTIONS"])
@crossdomain(origin='*')
def setModel():
def updateModel():
app.logger.debug('updateModel')
data['model'] = request.json
return "ok"
......
......@@ -86,12 +86,22 @@ body {
border-radius: 10px;
}
#total_workers {
position: absolute;
width: 100px;
height: 80px;
border: 2px solid;
margin-top: 80px;
margin-left: 720px;
border-radius: 10px;
}
#total_throughput {
position: absolute;
width: 100px;
height: 80px;
border: 2px solid;
margin-top: 135px;
margin-top: 200px;
margin-left: 720px;
border-radius: 10px;
}
......
......@@ -21,6 +21,10 @@
<ul>
</ul>
</div>
<div id="total_workers">
Workers
<h2>0</h2>
</div>
<div id="total_throughput">
Throughput
<h2></h2>
......
(function($) {
(function($, _) {
"use strict";
jsPlumb.bind("ready", function() {
var graph_data = {}, dream_instance, available_people = {}, people_list,
i, i_length;
i, i_length, updateWorkerCount;
graph_data.throughput = 0;
graph_data.box_list = [
{id: 'window1', title: 'attach1', throughput: 30, target_list: ['window2'], coordinate: {top: 5, left: 5}},
......@@ -28,6 +28,17 @@
$("#not_available ul").append('<li class="ui-state-default">' + people_list[i] + "</li>");
}
updateWorkerCount = function () {
var available_worker_length = 0,
available_worker_values = _.values(available_people);
_.each(available_worker_values, function(value) {
if (value === true) {
available_worker_length += 1;
}
});
$("#total_workers h2").text(available_worker_length.toString());
}
// Make list of people draggable, update list of people depending
// to make them available or not
$("#available li").draggable({appendTo: "body"});
......@@ -36,14 +47,16 @@
drop: function(event, ui) {
available_people[ui.draggable.text()] = true;
dream_instance.setSimulationParameters(available_people);
updateWorkerCount();
}
});
$("#not_available").droppable({
drop: function(event, ui) {
available_people[ui.draggable.text()] = false;
dream_instance.setSimulationParameters(available_people);
updateWorkerCount();
}
});
})
})(jQuery);
\ No newline at end of file
})(jQuery, _);
\ No newline at end of file
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