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