Commit dbf9df3d authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Publish build version.

parent 2e13a9e9
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
var key = this.props.jio_key, gadget = this; var key = this.props.jio_key, gadget = this;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
// XXX Conditional simulation menu // XXX Conditional simulation menu
return RSVP.all([ gadget.whoWantToDisplayThisDocumentPage("edit_table", key), gadget.whoWantToDisplayThisDocumentPage("run_simulation", key), gadget.whoWantToDisplayThisDocumentPage("manage_document", key), gadget.whoWantToDisplayThisDocumentPage("station_utilisation_graph", key), gadget.whoWantToDisplayThisDocumentPage("queue_stat_graph", key), gadget.whoWantToDisplayThisDocumentPage("exit_stat", key), gadget.whoWantToDisplayThisDocumentPage("job_gantt", key), gadget.whoWantToDisplayThisDocumentPage("debug_json", key) ]); return RSVP.all([ gadget.whoWantToDisplayThisDocumentPage("edit_table", key), gadget.whoWantToDisplayThisDocumentPage("run_simulation", key), gadget.whoWantToDisplayThisDocumentPage("manage_document", key), gadget.whoWantToDisplayThisDocumentPage("station_utilisation_graph", key), gadget.whoWantToDisplayThisDocumentPage("queue_stat_graph", key), gadget.whoWantToDisplayThisDocumentPage("exit_stat", key), gadget.whoWantToDisplayThisDocumentPage("job_gantt", key), gadget.whoWantToDisplayThisDocumentPage("job_schedule_spreadsheet", key), gadget.whoWantToDisplayThisDocumentPage("debug_json", key) ]);
}).push(function(result_list) { }).push(function(result_list) {
return [ { return [ {
link: result_list[0], link: result_list[0],
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
title: "Job Gantt" title: "Job Gantt"
}, { }, {
link: result_list[7], link: result_list[7],
title: "Job Schedule"
}, {
link: result_list[8],
title: "Debug JSON" title: "Debug JSON"
} ]; } ];
}); });
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Job Schedule</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/moment.js" type="text/javascript"></script>
<script src="document_page_mixin.js" type="text/javascript"></script>
<script src="job_schedule_spreadsheet.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
</body>
</html>
/*global console, rJS, RSVP, initDocumentPageMixin, moment */
/*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, moment) {
"use strict";
function job_schedule_spreadsheet_widget(all_data) {
var now = new Date(), input_data = all_data.input, output_data = all_data.result, spreadsheet_data = [], spreadsheet_header = [ [ "Jobs", "ID", "Project Manager", "Due Date", "Priority", "Entrance Time", "Processing Time", "Station ID", "Step No." ] ], simulation_start_date = new Date(input_data.general.currentDate || now.getTime()), i, j, k, obj, node, component, order, node_id, due_date, entrance_date, duration, schedule, input_job = null, input_order = null;
// XXX why ?
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
// XXX: time unit for later
// or an utility function to map sim time to real time & vice
// versa.
for (i = 0; i < output_data.elementList.length; i += 1) {
obj = output_data.elementList[i];
if (obj._class === "Dream.Job") {
input_job = null;
input_order = null;
// find the input order and order component for this job
for (node_id in input_data.nodes) {
if (input_data.nodes.hasOwnProperty(node_id)) {
node = input_data.nodes[node_id];
if (node.wip) {
for (j = 0; j < node.wip.length; j += 1) {
order = node.wip[j];
if (order.id === obj.id) {
input_job = input_order = order;
}
if (input_job === null) {
for (k = 0; k < order.componentsList.length; k += 1) {
component = order.componentsList[k];
if (component.id === obj.id) {
input_order = order;
input_job = component;
}
}
}
}
}
}
}
due_date = new Date(simulation_start_date.getTime() + input_order.dueDate * 1e3 * 3600);
for (j = 0; j < obj.results.schedule.length; j += 1) {
schedule = obj.results.schedule[j];
entrance_date = new Date(simulation_start_date.getTime() + // XXX: time unit
schedule.entranceTime * 1e3 * 3600);
duration = 0;
// Duration is calculated by difference of entranceTime of this
// step and entranceTime of the next step, or completionTime when
// this is the last step
if (j + 1 === obj.results.schedule.length) {
duration = obj.results.completionTime - schedule.entranceTime;
} else {
duration = obj.results.schedule[j + 1].entranceTime - schedule.entranceTime;
}
spreadsheet_data.push([ // XXX this label is incorrect for design step, during design
// phase we still have an order and not an order component.
input_order.name + "-" + input_job.name, obj.id, input_order.manager, moment(due_date).format("YYYY/MM/DD"), input_order.priority, moment(entrance_date).format("MMM/DD HH:mm"), duration, schedule.stationId, j ]);
}
}
}
if (spreadsheet_data.length > 1) {
// Sort the spreadsheet data to an order convenient for end users
// XXX: search for a default cmp in javascript
spreadsheet_data.sort(function(a, b) {
var result = 0, order_id_a, order_id_b, entrance_a, entrance_b;
order_id_a = a[0].split("-")[0];
order_id_b = b[0].split("-")[0];
if (order_id_a !== order_id_b) {
if (order_id_a > order_id_b) {
result = 1;
} else {
result = -1;
}
} else {
entrance_a = a[4];
entrance_b = b[4];
if (entrance_a > entrance_b) {
result = 1;
} else if (entrance_a < entrance_b) {
result = -1;
} else {
result = 0;
}
}
return result;
});
}
return spreadsheet_header.concat(spreadsheet_data);
}
var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
gadget_klass.ready(function(g) {
g.props = {};
}).ready(function(g) {
return g.getElement().push(function(element) {
g.props.element = element;
});
}).declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key;
return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key,
_attachment: "simulation.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
// XXX Hardcoded result
return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0])[0])));
});
}).declareMethod("startService", function() {
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService();
});
});
})(window, rJS, RSVP, initDocumentPageMixin, moment);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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