Commit 3474904a authored by Jérome Perrin's avatar Jérome Perrin

use the same JIO attachement for input & output

parent 92b77d35
......@@ -32,7 +32,7 @@
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
"_attachment": "body.json"
})
.push(undefined, function (error) {
if (error.status_code === 404) {
......@@ -46,7 +46,7 @@
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) {
......
......@@ -30,6 +30,7 @@
}
function runSimulation(gadget) {
var result_json;
return new RSVP.Queue()
.push(function () {
return gadget.aq_getAttachment({
......@@ -38,25 +39,42 @@
});
})
.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"
});
})
......
......@@ -99,7 +99,7 @@
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(
......
......@@ -21,7 +21,7 @@
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,
......
......@@ -144,7 +144,7 @@
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
"_attachment": "body.json"
})
.push(function (simulation_json) {
var result = calculate_exit_stat(
......
......@@ -211,7 +211,7 @@
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);
......
......@@ -118,7 +118,7 @@
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "simulation.json"
"_attachment": "body.json"
})
.push(function (simulation_json) {
console.log("rendering view graph");
......
......@@ -222,7 +222,7 @@
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(
......
......@@ -195,7 +195,7 @@
return RSVP.all([
gadget.aq_getAttachment({
"_id": jio_key,
"_attachment": "simulation.json"
"_attachment": "body.json"
}),
gadget.getDeclaredGadget("tableeditor")
]);
......
......@@ -36,7 +36,7 @@
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(
......
......@@ -142,7 +142,7 @@
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(
......
......@@ -76,7 +76,7 @@
.push(function (jio_gadget) {
return jio_gadget.getAttachment({
_id: options.id,
"_attachment": "simulation.json"
"_attachment": "body.json"
});
})
.push(function (sim_json) {
......@@ -113,7 +113,7 @@
.push(function (jio_gadget) {
return jio_gadget.getAttachment({
_id: options.id,
"_attachment": "simulation.json"
"_attachment": "body.json"
});
})
.push(function (sim_json) {
......
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