Commit 69c45e44 authored by Jérome Perrin's avatar Jérome Perrin

update static version

parent e435f12b
......@@ -13,7 +13,7 @@
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(undefined, function(error) {
if (error.status_code === 404) {
// Simulation not yet generated
......@@ -22,7 +22,7 @@
throw error;
}).push(function(sim_json) {
var result = JSON.parse(sim_json).result, result_list = [], document_list = [], i;
if (result) {
if (result && result.result_list) {
document_list = result.result_list;
}
for (i = 0; i < document_list.length; i += 1) {
......
......@@ -25,30 +25,46 @@
});
}
function runSimulation(gadget) {
var result_json;
return new RSVP.Queue().push(function() {
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body_json) {
// do not send previous results to simulation engine
var json_without_result = JSON.parse(body_json);
json_without_result.result.result_list = [];
// XXX Hardcoded relative URL
return gadget.aq_ajax({
url: "../../runSimulation",
type: "POST",
data: body_json,
data: JSON.stringify(json_without_result),
headers: {
"Content-Type": "application/json"
}
});
}).push(function(evt) {
var json_data = JSON.parse(evt.target.responseText);
if (json_data.success !== true) {
throw new Error(json_data.error);
result_json = JSON.parse(evt.target.responseText);
if (result_json.success !== true) {
throw new Error(result_json.error);
}
// get latest version
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(data) {
data = JSON.parse(data);
// XXX option to always add ?
if (data.general.reset_result_list) {
data.result.result_list = [];
}
data.result.result_list = data.result.result_list.concat(result_json.data.result.result_list);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json",
_data: JSON.stringify(json_data.data, null, 2),
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
......
/*global rJS, RSVP, initGadgetMixin, loopEventListener */
(function(window, rJS, RSVP, initGadgetMixin, loopEventListener) {
/*global rJS, RSVP, initGadgetMixin, loopEventListener, $ */
(function(window, rJS, RSVP, initGadgetMixin, loopEventListener, $) {
"use strict";
function saveSpreadsheet(evt) {
var gadget = this, editor_data, editor_gadget;
......@@ -50,22 +50,13 @@
if (options.action_definition.configuration.input_id) {
gadget.props.name = options.action_definition.configuration.input_id;
}
gadget.props.configuration = options.action_definition.configuration;
return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key,
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
var content, result = JSON.parse(result_list[0]);
// if there are previously stored data in input for this sprSheet
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
}
// application_configuration.input.view_???_spreasheet.configuration
return result_list[1].render(JSON.stringify(content), {
var content, result = JSON.parse(result_list[0]), handsontable_options = {
minSpareRows: 1,
onChange: function() {
if (gadget.timeout) {
......@@ -73,7 +64,15 @@
}
gadget.timeout = window.setTimeout(saveSpreadsheet.bind(gadget), 100);
}
});
};
// if there are previously stored data in input for this sprSheet
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
}
$.extend(handsontable_options, options.action_definition.configuration.handsontable_options || {});
return result_list[1].render(JSON.stringify(content), handsontable_options);
});
}).declareMethod("startService", function() {
var gadget = this;
......@@ -81,4 +80,4 @@
return RSVP.all([ tableeditor.startService(), waitForSave(gadget) ]);
});
});
})(window, rJS, RSVP, initGadgetMixin, loopEventListener);
\ No newline at end of file
})(window, rJS, RSVP, initGadgetMixin, loopEventListener, $);
\ No newline at end of file
......@@ -69,7 +69,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
gadget.props.result_list = capacity_utilisation_graph_widget(JSON.parse(simulation_json), gadget.props.result);
});
......
......@@ -10,7 +10,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.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";
......
......@@ -91,7 +91,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
var result = calculate_exit_stat(gadget.props.result, JSON.parse(simulation_json));
gadget.props.element.innerHTML = result;
......
......@@ -160,7 +160,7 @@
gadget.props.action = options.action;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
var json_data = JSON.parse(simulation_json);
gadget.props.result = gantt_widget(json_data, gadget);
......
......@@ -90,7 +90,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
console.log("rendering view graph");
var json_data = JSON.parse(simulation_json), config = json_data.application_configuration.output[options.action].configuration;
......
......@@ -171,7 +171,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
gadget.props.result = job_gantt_widget(JSON.parse(simulation_json), gadget.props.result);
});
......
......@@ -117,7 +117,7 @@
return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0]), gadget.props.result)));
......
......@@ -25,7 +25,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
gadget.props.series = queue_stat_widget(JSON.parse(simulation_json).result.result_list[gadget.props.result]);
});
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Shift Spreadsheet</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../lib/jquerymobile.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewSpreadsheet.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
<form class="save_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right">Save</button>
</form>
</body>
</html>
/*global rJS, RSVP, initGadgetMixin, loopEventListener, $ */
(function(window, rJS, RSVP, initGadgetMixin, loopEventListener, $) {
"use strict";
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.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: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
var content = JSON.parse(result_list[0]).result.result_list[options.result][options.action_definition.configuration.output_id], handsontable_options = {
readOnly: true
};
$.extend(handsontable_options, options.action_definition.configuration.handsontable_options || {});
result_list[1].render(JSON.stringify(content), handsontable_options);
});
}).declareMethod("startService", function() {
var gadget = this;
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService();
});
});
})(window, rJS, RSVP, initGadgetMixin, loopEventListener, $);
\ No newline at end of file
......@@ -104,7 +104,7 @@
gadget.props.result = options.result;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
_attachment: "body.json"
}).push(function(simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget(JSON.parse(simulation_json), gadget.props.result);
});
......
......@@ -61,7 +61,7 @@
}).push(function(jio_gadget) {
return jio_gadget.getAttachment({
_id: options.id,
_attachment: "simulation.json"
_attachment: "body.json"
});
}).push(function(sim_json) {
var document_list = JSON.parse(sim_json), current = parseInt(options.result, 10);
......@@ -94,7 +94,7 @@
title = gadget.getDeclaredGadget("jio").push(function(jio_gadget) {
return jio_gadget.getAttachment({
_id: options.id,
_attachment: "simulation.json"
_attachment: "body.json"
});
}).push(function(sim_json) {
var document_list = JSON.parse(sim_json).result.result_list;
......
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