Commit 1560fbb8 authored by Jérome Perrin's avatar Jérome Perrin

update latest widgets to renderjs widgets

parent 4a2cc112
...@@ -75,6 +75,15 @@ ...@@ -75,6 +75,15 @@
"Machines", // XXX more generic name ? "Machines", // XXX more generic name ?
"Start", "Start",
"End" "End"
]],
capacity_by_project_spreadsheet: [[
"Project Name",
"Sequence",
"Capacity Requirements"
]],
capacity_by_station_spreadsheet: [[
"Day",
"CS1"
]] ]]
}, },
name = "FromScratch"; name = "FromScratch";
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Available Capacity 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="../<%= curl.jquerymobilejs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewAvailableCapacitySpreadsheet.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";
function saveSpreadsheet(evt) {
var gadget = this,
editor_data,
editor_gadget;
return new RSVP.Queue()
.push(function () {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
})
.push(function (data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
});
})
.push(function (body) {
var data = JSON.parse(body);
data.capacity_by_project_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json",
"_data": JSON.stringify(data, null, 2),
"_mimetype": "application/json"
});
})
.push(function () {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
});
}
function waitForSave(gadget) {
return loopEventListener(
gadget.props.element.getElementsByClassName("save_form")[0],
'submit',
false,
saveSpreadsheet.bind(gadget)
);
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("aq_putAttachment", "jio_putAttachment")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.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) {
return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0])
.capacity_by_project_spreadsheet)
);
});
})
.declareMethod("startService", function () {
var gadget = this;
return this.getDeclaredGadget("tableeditor")
.push(function (tableeditor) {
return RSVP.all([
tableeditor.startService(),
waitForSave(gadget)
]);
});
});
}(window, rJS, RSVP, initGadgetMixin, loopEventListener));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Required Capacity 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="../<%= curl.jquerymobilejs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewRequiredCapacitySpreadsheet.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";
function saveSpreadsheet(evt) {
var gadget = this,
editor_data,
editor_gadget;
return new RSVP.Queue()
.push(function () {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.getDeclaredGadget("tableeditor");
})
.push(function (tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
})
.push(function (data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
});
})
.push(function (body) {
var data = JSON.parse(body);
data.capacity_by_station_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json",
"_data": JSON.stringify(data, null, 2),
"_mimetype": "application/json"
});
})
.push(function () {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
});
}
function waitForSave(gadget) {
return loopEventListener(
gadget.props.element.getElementsByClassName("save_form")[0],
'submit',
false,
saveSpreadsheet.bind(gadget)
);
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("aq_putAttachment", "jio_putAttachment")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.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) {
return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0])
.capacity_by_station_spreadsheet),
{minSpareCols: 1}
);
});
})
.declareMethod("startService", function () {
var gadget = this;
return this.getDeclaredGadget("tableeditor")
.push(function (tableeditor) {
return RSVP.all([
tableeditor.startService(),
waitForSave(gadget)
]);
});
});
}(window, rJS, RSVP, initGadgetMixin, loopEventListener));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stations Utilization</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="../<%= curl.jqueryflot.relative_dest %>"></script>
<script src="../<%= curl.jqueryflotstack.relative_dest %>"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewCapacityUtilisationGraph.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
/*global rJS, jQuery, initGadgetMixin */
/*jslint unparam: true */
(function (window, rJS, $, initGadgetMixin) {
"use strict";
function capacity_utilisation_graph_widget(all_data) {
var available_capacity_by_station = {},
station_id,
series,
graph_list = [],
options,
capacity_usage_by_station = {},
input_data = all_data.input,
output_data = all_data.result;
// Compute availability by station
$.each(input_data.nodes, function (idx, obj) {
var available_capacity = [];
if (obj.intervalCapacity !== undefined) {
$.each(obj.intervalCapacity, function (i, capacity) {
available_capacity.push([i, capacity]);
});
available_capacity_by_station[obj.id] = available_capacity;
}
});
// Compute used capacity by station
$.each(output_data.elementList.sort(
function (a, b) { return a.id < b.id ? -1 : 1; }
),
function (idx, obj) {
if (obj.results !== undefined &&
obj.results.capacityUsed !== undefined) {
var capacity_usage = [];
$.each(obj.results.capacityUsed, function (i, step) {
var period = 0, usage = 0;
$.each(step, function (k, v) {
if (k === 'period') {
period = v;
}
});
$.each(step, function (k, v) {
if (k !== 'utilization' && k !== 'period') {
usage += v;
}
});
capacity_usage.push([period, usage]);
});
capacity_usage_by_station[obj.id] = capacity_usage;
}
});
for (station_id in available_capacity_by_station) {
if (available_capacity_by_station.hasOwnProperty(station_id)) {
series = [{
label: "Capacity",
data: available_capacity_by_station[station_id],
color: "green"
}, {
label: "Utilisation",
data: capacity_usage_by_station[station_id],
color: "red"
}];
options = {
series: {
lines: {
show: true,
fill: true
}
}
};
graph_list.push([
input_data.nodes[station_id].name || station_id,
series,
options]);
}
}
return graph_list;
}
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) {
gadget.props.result_list = capacity_utilisation_graph_widget(
JSON.parse(simulation_json)[gadget.props.result]
);
});
})
.declareMethod("startService", function () {
var element = $(this.props.element), graph;
$.each(this.props.result_list, function (idx, result) {
graph = $("<div class='capacity_graph' " +
"style='width: 70%; height: 250px'></div>");
element.append($("<h2>").text(result[0]), graph);
$.plot(graph, result[1], result[2]);
});
});
}(window, rJS, jQuery, initGadgetMixin));
...@@ -51,6 +51,24 @@ ...@@ -51,6 +51,24 @@
.gui.shift_spreadsheet); .gui.shift_spreadsheet);
} }
}, },
"view_available_capacity_spreadsheet": {
"gadget": "Input_viewAvailableCapacitySpreadsheet",
"type": "object_view",
"title": "Available Capacity Spreadsheet",
"condition": function (gadget) {
return (gadget.props.configuration_dict['Dream-Configuration']
.gui.capacity_by_project_spreadsheet);
}
},
"view_required_capacity_spreadsheet": {
"gadget": "Input_viewRequiredCapacitySpreadsheet",
"type": "object_view",
"title": "Required Capacity Spreadsheet",
"condition": function (gadget) {
return (gadget.props.configuration_dict['Dream-Configuration']
.gui.capacity_by_station_spreadsheet);
}
},
"view_simu": { "view_simu": {
"gadget": "Input_viewSimulation", "gadget": "Input_viewSimulation",
"type": "object_view", "type": "object_view",
...@@ -77,6 +95,15 @@ ...@@ -77,6 +95,15 @@
.gui.station_utilisation_graph); .gui.station_utilisation_graph);
} }
}, },
"view_capacity_utilization": {
"gadget": "Output_viewCapacityUtilisationGraph",
"type": "object_view",
"title": "Capacity Utilization",
"condition": function (gadget) {
return (gadget.props.configuration_dict['Dream-Configuration']
.gui.capacity_utilisation_graph);
}
},
"view_queue_stat": { "view_queue_stat": {
"gadget": "Output_viewQueueStatGraph", "gadget": "Output_viewQueueStatGraph",
"type": "object_view", "type": "object_view",
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
general: {}, general: {},
wip_part_spreadsheet: [ [ "Order ID", "Due Date", "Priority", "Project Manager", "Part", "Part Type", "Sequence", "Processing Times", "Prerequisites Parts" ] ], wip_part_spreadsheet: [ [ "Order ID", "Due Date", "Priority", "Project Manager", "Part", "Part Type", "Sequence", "Processing Times", "Prerequisites Parts" ] ],
shift_spreadsheet: [ [ "Day", "Machines", // XXX more generic name ? shift_spreadsheet: [ [ "Day", "Machines", // XXX more generic name ?
"Start", "End" ] ] "Start", "End" ] ],
capacity_by_project_spreadsheet: [ [ "Project Name", "Sequence", "Capacity Requirements" ] ],
capacity_by_station_spreadsheet: [ [ "Day", "CS1" ] ]
}, name = "FromScratch"; }, name = "FromScratch";
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false); return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
......
...@@ -47,6 +47,22 @@ ...@@ -47,6 +47,22 @@
return gadget.props.configuration_dict["Dream-Configuration"].gui.shift_spreadsheet; return gadget.props.configuration_dict["Dream-Configuration"].gui.shift_spreadsheet;
} }
}, },
view_available_capacity_spreadsheet: {
gadget: "Input_viewAvailableCapacitySpreadsheet",
type: "object_view",
title: "Available Capacity Spreadsheet",
condition: function(gadget) {
return gadget.props.configuration_dict["Dream-Configuration"].gui.capacity_by_project_spreadsheet;
}
},
view_required_capacity_spreadsheet: {
gadget: "Input_viewRequiredCapacitySpreadsheet",
type: "object_view",
title: "Required Capacity Spreadsheet",
condition: function(gadget) {
return gadget.props.configuration_dict["Dream-Configuration"].gui.capacity_by_station_spreadsheet;
}
},
view_simu: { view_simu: {
gadget: "Input_viewSimulation", gadget: "Input_viewSimulation",
type: "object_view", type: "object_view",
...@@ -72,6 +88,14 @@ ...@@ -72,6 +88,14 @@
return gadget.props.configuration_dict["Dream-Configuration"].gui.station_utilisation_graph; return gadget.props.configuration_dict["Dream-Configuration"].gui.station_utilisation_graph;
} }
}, },
view_capacity_utilization: {
gadget: "Output_viewCapacityUtilisationGraph",
type: "object_view",
title: "Capacity Utilization",
condition: function(gadget) {
return gadget.props.configuration_dict["Dream-Configuration"].gui.capacity_utilisation_graph;
}
},
view_queue_stat: { view_queue_stat: {
gadget: "Output_viewQueueStatGraph", gadget: "Output_viewQueueStatGraph",
type: "object_view", type: "object_view",
......
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