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

Implement shift spreadsheet

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