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

GUI: new widget to download demandPlanningOutput.xls

parent 2ff9cce1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Download Excel Spreadsheet</title>
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewDownloadExcelSpreadsheet.js" type="text/javascript"></script>
</head>
<body>
<a class="download_link ui-btn ui-btn-inline ui-icon-action ui-btn-icon-right">Download</a>
</body>
</html>
/*global rJS, RSVP, jQuery, initGadgetMixin */
/*jslint nomen: true, unparam: true */
(function (window, rJS, RSVP, $, initGadgetMixin) {
"use strict";
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
})
.push(function (simulation_json) {
var result = JSON.parse(simulation_json)[0].result,
download_link = gadget.props.element.querySelector(
".download_link"
);
download_link.download = "demandPlannerOutput.xls";
download_link.href = "data:application/excel;base64,"
+ result['demandPlannerOutput.xls'];
});
})
.declareMethod("startService", function () {
return new RSVP.Queue()
.push(function () {
// Infinite wait, until cancelled
return (new RSVP.defer()).promise;
});
});
}(window, rJS, RSVP, jQuery, initGadgetMixin));
...@@ -114,6 +114,15 @@ ...@@ -114,6 +114,15 @@
.gui.station_utilisation_graph); .gui.station_utilisation_graph);
} }
}, },
"download_excel_spreadsheet": {
"gadget": "Output_viewDownloadExcelSpreadsheet",
"type": "object_view",
"title": "Download Excel Spreadsheet",
"condition": function (gadget) {
return (gadget.props.configuration_dict['Dream-Configuration']
.gui.download_excel_spreadsheet);
}
},
"view_capacity_utilization": { "view_capacity_utilization": {
"gadget": "Output_viewCapacityUtilisationGraph", "gadget": "Output_viewCapacityUtilisationGraph",
"type": "object_view", "type": "object_view",
......
...@@ -358,6 +358,7 @@ class Simulation(object): ...@@ -358,6 +358,7 @@ class Simulation(object):
'station_utilisation_graph': 1, 'station_utilisation_graph': 1,
'job_schedule_spreadsheet': 0, 'job_schedule_spreadsheet': 0,
'download_excel_spreadsheet': 0,
'job_gantt': 0, 'job_gantt': 0,
'exit_stat': 1, 'exit_stat': 1,
'queue_stat': 1, 'queue_stat': 1,
......
...@@ -276,11 +276,13 @@ class Simulation(DefaultSimulation): ...@@ -276,11 +276,13 @@ class Simulation(DefaultSimulation):
DefaultSimulation.getConfigurationDict(self)['Dream-Configuration']} DefaultSimulation.getConfigurationDict(self)['Dream-Configuration']}
conf["Dream-Configuration"]["gui"]["exit_stat"] = 0 conf["Dream-Configuration"]["gui"]["exit_stat"] = 0
conf["Dream-Configuration"]["gui"]["debug_json"] = 1 conf["Dream-Configuration"]["gui"]["debug_json"] = 0
conf["Dream-Configuration"]["gui"]["graph_editor"] = 0 conf["Dream-Configuration"]["gui"]["graph_editor"] = 0
conf["Dream-Configuration"]["gui"]["station_utilisation_graph"] = 0 conf["Dream-Configuration"]["gui"]["station_utilisation_graph"] = 0
conf["Dream-Configuration"]["gui"]["exit_stat"] = 0 conf["Dream-Configuration"]["gui"]["exit_stat"] = 0
conf["Dream-Configuration"]["gui"]["queue_stat"] = 0 conf["Dream-Configuration"]["gui"]["queue_stat"] = 0
conf["Dream-Configuration"]["gui"]["download_excel_spreadsheet"] = 1
conf["Dream-Configuration"]["gui"]["dp_capacity_spreadsheet"] = 1 conf["Dream-Configuration"]["gui"]["dp_capacity_spreadsheet"] = 1
conf["Dream-Configuration"]["gui"]["dp_route_spreadsheet"] = 1 conf["Dream-Configuration"]["gui"]["dp_route_spreadsheet"] = 1
......
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