Commit 26731163 authored by Jérome Perrin's avatar Jérome Perrin

Implement shift spreadsheet

parent 7ee95995
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
<div class="twelve columns"> <div class="twelve columns">
<div id="main"></div> <div id="main"></div>
<div id="wip_spreadsheet"></div> <div id="wip_spreadsheet" style="display: none;"></div>
<div id="shift_spreadsheet"></div> <div id="shift_spreadsheet" style="display: none;"></div>
</div> </div>
</div> </div>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<div id="result_zone"> <div id="result_zone">
<div>Result List</div> <div>Result List</div>
<ul id="result_list"></ul></div> <ul id="result_list"></ul></div>
<div id="graph_zone"> <!-- station_utilisation_graph --> <div id="graph_zone">
<div>Stations Utilization</div> <div>Stations Utilization</div>
<div id="graph"></div> <div id="graph"></div>
</div> </div>
......
...@@ -74,6 +74,9 @@ ...@@ -74,6 +74,9 @@
if (configuration['Dream-Configuration'].gui.wip_spreadsheet){ if (configuration['Dream-Configuration'].gui.wip_spreadsheet){
$("#wip_spreadsheet").show(); $("#wip_spreadsheet").show();
} }
if (configuration['Dream-Configuration'].gui.shift_spreadsheet){
$("#shift_spreadsheet").show();
}
if (configuration['Dream-Configuration'].gui.debug_json){ if (configuration['Dream-Configuration'].gui.debug_json){
$("#debug_json").show(); $("#debug_json").show();
} }
...@@ -86,6 +89,12 @@ ...@@ -86,6 +89,12 @@
spreadsheet.handsontable('populateFromArray', 0, 0, wip_spreadsheet_data); spreadsheet.handsontable('populateFromArray', 0, 0, wip_spreadsheet_data);
spreadsheet.find('.htCore').width(spreadsheet.width()); spreadsheet.find('.htCore').width(spreadsheet.width());
} }
var shift_spreadsheet_data = data.shift_spreadsheet;
if (shift_spreadsheet_data !== undefined) {
var spreadsheet = $('#shift_spreadsheet');
spreadsheet.handsontable('populateFromArray', 0, 0, shift_spreadsheet_data);
spreadsheet.find('.htCore').width(spreadsheet.width());
}
var preference = data.preference !== undefined ? var preference = data.preference !== undefined ?
data.preference : {}; data.preference : {};
...@@ -172,7 +181,6 @@ ...@@ -172,7 +181,6 @@
} else { } else {
$("#result_zone").hide(); $("#result_zone").hide();
$("#graph_zone").hide(); $("#graph_zone").hide();
$("#shift_spreadsheet").hide();
$("#job_schedule_spreadsheet").hide(); $("#job_schedule_spreadsheet").hide();
$("#job_gantt").hide(); $("#job_gantt").hide();
$("#json_result").effect('shake', 50).val(data['error']); $("#json_result").effect('shake', 50).val(data['error']);
......
...@@ -133,24 +133,25 @@ ...@@ -133,24 +133,25 @@
} }
}); });
wip_spreadsheet.find('.htCore').width(wip_spreadsheet.width()); wip_spreadsheet.find('.htCore').width(wip_spreadsheet.width());
if (0) {
var shift_spreadsheet = $('#shift_spreadsheet'); var shift_spreadsheet = $('#shift_spreadsheet');
var data = [ var data = [
[ [
"Monday", "Day",
"Tuesday", "Machines", // XXX more generic name ?
"...", "Start",
] "End"
]; ]
shift_spreadsheet.handsontable({ ];
data: data, shift_spreadsheet.handsontable({
minSpareRows: 1, data: data,
afterChange: function () { minSpareRows: 1,
priv.onDataChange(); afterChange: function () {
} priv.onDataChange();
}); }
shift_spreadsheet.find('.htCore').width(shift_spreadsheet.width()); });
} shift_spreadsheet.find('.htCore').width(shift_spreadsheet.width());
}; };
priv.updateElementCoordinate = function (node_id, coordinate) { priv.updateElementCoordinate = function (node_id, coordinate) {
...@@ -320,6 +321,10 @@ ...@@ -320,6 +321,10 @@
if (wip_spreadsheet.length > 0) { if (wip_spreadsheet.length > 0) {
data['wip_spreadsheet'] = wip_spreadsheet.handsontable('getData'); data['wip_spreadsheet'] = wip_spreadsheet.handsontable('getData');
} }
var shift_spreadsheet = $('#shift_spreadsheet');
if (shift_spreadsheet.length > 0) {
data['shift_spreadsheet'] = shift_spreadsheet.handsontable('getData');
}
return data; return data;
}; };
......
...@@ -4,12 +4,12 @@ import time ...@@ -4,12 +4,12 @@ import time
import random import random
import operator import operator
from dream.simulation.GUI.Default import Simulation as DefaultSimulation from dream.simulation.GUI.Shifts import Simulation as ShiftsSimulation
from dream.simulation.GUI.Default import schema from dream.simulation.GUI.Default import schema
class Simulation(DefaultSimulation): class Simulation(ShiftsSimulation):
def getConfigurationDict(self): def getConfigurationDict(self):
conf = DefaultSimulation.getConfigurationDict(self) conf = ShiftsSimulation.getConfigurationDict(self)
conf['Dream-LineClearance'] = { conf['Dream-LineClearance'] = {
"_class": "Dream.LineClearance", "_class": "Dream.LineClearance",
"name": "Clearance", "name": "Clearance",
......
...@@ -260,7 +260,8 @@ class Simulation(object): ...@@ -260,7 +260,8 @@ class Simulation(object):
"""Run one scenario. """Run one scenario.
To be reused by subclasses. To be reused by subclasses.
""" """
return json.loads(simulate_line_json(input_data=json.dumps(data))) return json.loads(simulate_line_json(
input_data=json.dumps(self._preprocess(data))))
def _preprocess(self, data): def _preprocess(self, data):
"""Preprocess the data, for instance reading spreadsheet. """Preprocess the data, for instance reading spreadsheet.
......
...@@ -8,11 +8,6 @@ from dream.simulation.GUI.Default import Simulation as DefaultSimulation ...@@ -8,11 +8,6 @@ from dream.simulation.GUI.Default import Simulation as DefaultSimulation
class Simulation(DefaultSimulation): class Simulation(DefaultSimulation):
def getConfigurationDict(self):
conf = DefaultSimulation.getConfigurationDict(self)
conf["Dream-Configuration"]["gui"]["shift_spreadsheet"] = 1
return conf
def _preprocess(self, data): def _preprocess(self, data):
"""Preprocess data, reading shift spreadsheet""" """Preprocess data, reading shift spreadsheet"""
# TODO # TODO
......
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