Commit 3927e127 authored by Jérome Perrin's avatar Jérome Perrin

GUI: remove obsolete gadgets

parent 037dcbb3
<!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_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
if (evt) {
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 () {
if (evt) {
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,
minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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_viewDemandPlanningCapacitySpreadsheet.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
if (evt) {
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.dp_capacity_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 () {
if (evt) {
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])
.dp_capacity_spreadsheet),
{ minSpareCols: 1,
minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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_viewDemandPlanningRouteSpreadsheet.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
if (evt) {
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.dp_route_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 () {
if (evt) {
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])
.dp_route_spreadsheet),
{ minSpareCols: 1,
minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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 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_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
if (evt) {
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 () {
if (evt) {
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),
{ minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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 Shift 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_viewShiftSpreadsheet.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
if (evt) {
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.shift_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 () {
if (evt) {
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]).shift_spreadsheet),
{ minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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 Wip Part 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="mixin_promise.js" type="text/javascript"></script>
<script src="Input_viewWipPartSpreadsheet.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
if (evt) {
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.wip_part_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 () {
if (evt) {
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]).wip_part_spreadsheet),
{ minSpareRows: 1,
onChange: function () {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(
saveSpreadsheet.bind(gadget),
100
);
}
}
);
});
})
.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(data, result_id) {
var available_capacity_by_station = {},
station_id,
series,
graph_list = [],
options,
capacity_usage_by_station = {},
input_data = data,
output_data = data.result.result_list[result_id];
// Compute availability by station
$.each(input_data.graph.node, 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.graph.node[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": "body.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));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Job Gantt</title>
<link rel="stylesheet" href="../<%= copy.dhtmlxganttcss.relative_dest %>">
<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="../<%= copy.dhtmlxganttjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewJobGantt.js" type="text/javascript"></script>
</head>
<body>
<div class="gant_container" style="height: 800px;"></div>
</body>
</html>
/*global rJS, RSVP, jQuery, gantt,
initGadgetMixin */
/*jslint nomen: true, unparam: true */
(function (window, rJS, RSVP, $, gantt,
initGadgetMixin) {
"use strict";
gantt.templates.task_class = function (start, end, obj) {
return obj.parent ? "sub_task" : "";
};
function job_gantt_widget(data, result_id) {
// XXX: use dhx_gantt zoom level feature (
// http://dhtmlx.com/docs/products/dhtmlxGantt/02_features.html )
var now = new Date(),
start_date,
gantt_data = {
data: [
{
id: "by_order",
text: "By Order",
start_date: start_date,
duration: 0,
project: 1,
open: true
},
{
id: "by_station",
text: "By Station",
start_date: start_date,
duration: 0,
project: 1,
open: true
}
],
link: []
},
input_data = data,
output_data = data.result.result_list[result_id];
// temporary hack
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
start_date = input_data.general.currentDate;
if ((start_date !== undefined) && (start_date !== "")) {
start_date = new Date(start_date);
} else {
start_date = new Date(now.getTime());
}
function isVisibleStation(station) {
// we should be able to define in the backend which
// station is visible
return (input_data.graph.node[station].family !== 'Buffer' &&
input_data.graph.node[station].family !== 'Exit');
}
$.each(
output_data.elementList.sort(function (a, b) {
return a.id < b.id ? -1 : 1;
}),
function (idx, obj) {
var input_job = null,
input_order = null,
i,
j,
node,
node_key,
order,
component,
duration,
seen_parts = {};
if (obj.family === 'Job') {
// find the corresponding input
// find the input order and order component for this job
for (node_key in input_data.graph.node) {
if (input_data.graph.node.hasOwnProperty(node_key)) {
node = input_data.graph.node[node_key];
if (node.wip) {
for (i = 0; i < node.wip.length; i += 1) {
order = node.wip[i];
if (order.id === obj.id) {
input_job = input_order = order;
}
if (input_job === null && order.componentsList) {
for (j = 0; j < order.componentsList.length; j += 1) {
component = order.componentsList[j];
if (component.id === obj.id) {
input_order = order;
input_job = component;
}
}
}
}
}
}
}
duration = 0;
if (input_job === input_order) {
// if we are on the order definition
gantt_data.data.push({
id: input_order.id,
text: input_order.name,
project: 1,
open: false,
parent: "by_order"
});
}
seen_parts = {};
$.each(obj.results.schedule, function (i, schedule) {
var task_start_date,
job_full_id;
// Filter intermediate steps in part job shop
if (isVisibleStation(schedule.stationId)) {
if (schedule.exitTime) {
duration = 24 * (schedule.exitTime - schedule.entranceTime);
} else {
if (obj.results.schedule[i + 1]) {
duration = obj.results.schedule[i + 1].entranceTime -
schedule.entranceTime;
} else {
duration = obj.results.completionTime -
schedule.entranceTime;
}
}
if (duration > 0.0) {
task_start_date = new Date(start_date.getTime());
// for simulation time unit as days
// task_start_date.setDate(task_start_date.getDate() +
// schedule['entranceTime']);
// for simulation time unit as days hours
task_start_date.setTime(task_start_date.getTime() +
schedule.entranceTime * 1000 * 3600 * 24);
job_full_id = input_job.id + "." + input_order.id;
if (seen_parts[job_full_id] === undefined) {
gantt_data.data.push({
id: job_full_id,
text: input_job.name,
parent: input_order.id
});
seen_parts[job_full_id] = 1;
}
gantt_data.data.push({
id: input_order.id + '.' + idx + '_' + i,
text: schedule.stationId,
start_date: task_start_date,
duration: duration,
parent: job_full_id
});
gantt_data.data.push({
id: 'job.' + obj.id + '.' + idx + '_' + i,
text: input_order.name + "-" + input_job.name,
start_date: task_start_date,
duration: duration,
parent: schedule.stationId,
by_station: 1
});
}
}
});
} else {
if (isVisibleStation(obj.id)) {
gantt_data.data.push({
id: obj.id,
text: obj.id,
project: 1,
open: false,
parent: "by_station"
});
}
}
}
);
// gantt_output_height = 35 * (gantt_data.data.length + 1) + 1;
gantt_data.data.sort(function (a, b) {
// sort gantt data in a chronological order
var result;
if (a.start_date === undefined && b.start_date !== undefined) {
result = 1;
} else if (a.start_date !== undefined && b.start_date === undefined) {
result = -1;
} else if (a.start_date === undefined && b.start_date === undefined) {
result = 0;
} else if (a.start_date > b.start_date) {
result = 1;
} else if (a.start_date < b.start_date) {
result = -1;
} else {
result = 0;
}
return result;
});
return gantt_data;
}
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": "body.json"
})
.push(function (simulation_json) {
gadget.props.result = job_gantt_widget(
JSON.parse(simulation_json), gadget.props.result
);
});
})
.declareMethod("startService", function () {
$(this.props.element).find('.gant_container').dhx_gantt({
data: this.props.result,
readonly: true,
/* for days has simulation time unit
scale_unit: 'day',
step: 7
*/
// for hours has simulation time unit
scale_unit: 'day',
duration_unit: 60 * 60 * 1000,
//date_grid: "%H:%i",
date_scale: "%M/%d",
step: 1,
subscales: [{unit: "hour", step: 4, date: "%H:%i"}]
});
return new RSVP.Queue()
.push(function () {
// Infinite wait, until cancelled
return (new RSVP.defer()).promise;
})
.push(undefined, function (error) {
gantt.clearAll();
throw error;
});
});
}(window, rJS, RSVP, jQuery, gantt, initGadgetMixin));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Job Schedule</title>
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= curl.momentjs.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewJobScheduleSpreadsheet.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
</body>
</html>
/*global rJS, RSVP, moment, initGadgetMixin */
/*jslint nomen: true */
(function (window, rJS, RSVP, moment, initGadgetMixin) {
"use strict";
function job_schedule_spreadsheet_widget(data, result_id) {
var now = new Date(),
name,
input_data = data,
output_data = data.result.result_list[result_id],
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.family === 'Job') {
input_job = null;
input_order = null;
// find the input order and order component for this job
// XXX this has no real meaning with capacity project
for (node_id in input_data.graph.node) {
if (input_data.graph.node.hasOwnProperty(node_id)) {
node = input_data.graph.node[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 && order.componentsList) {
for (k = 0; k < order.componentsList.length; k += 1) {
component = order.componentsList[k];
if (component.id === obj.id) {
input_order = order;
input_job = component;
}
}
}
}
}
}
}
// XXX does not make sense in the case of capacity project
due_date = new Date(simulation_start_date.getTime() +
input_order.dueDate * 1000 * 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 * 1000 * 3600);
duration = 0;
if (schedule.exitTime) {
duration = (schedule.exitTime - schedule.entranceTime * 24);
} else {
// When duration is not returned by ManPy, it 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;
}
}
name = "";
if (obj._class === 'Dream.CapacityProject') {
name = input_order.name + '-' + schedule.stationId;
} else {
name = input_order.name + "-" + input_job.name;
}
// 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.
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);
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 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(
job_schedule_spreadsheet_widget(
JSON.parse(result_list[0]), gadget.props.result
)
)
);
// job_schedule_spreadsheet.show();
// job_schedule_spreadsheet.handsontable({
// data: spreadsheet_header.concat(spreadsheet_data),
// width: function () {
// return $(window).width() -
// job_schedule_spreadsheet.offset().left +
// $(window).scrollLeft();
// },
// readOnly: true
// });
// job_schedule_spreadsheet.find('.htCore')
// .width(job_schedule_spreadsheet.width());
});
})
.declareMethod("startService", function () {
return this.getDeclaredGadget("tableeditor")
.push(function (tableeditor) {
return tableeditor.startService();
});
});
}(window, rJS, RSVP, moment, initGadgetMixin));
<!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_viewStationUtilisationGraph.js" type="text/javascript"></script>
</head>
<body>
<div class="graph_container" style="width: 100%;height:300px"></div>
</body>
</html>
/*global rJS, jQuery, initGadgetMixin */
/*jslint unparam: true */
(function (window, rJS, $, initGadgetMixin) {
"use strict";
function station_utilisation_graph_widget(data, result_id) {
var blockage_data = [],
waiting_data = [],
failure_data = [],
working_data = [],
ticks = [],
counter = 1,
series,
options;
// XXX output is still elementList ???
$.each(
data.result.result_list[result_id].elementList.sort(
function (a, b) {
return a.id < b.id ? -1 : 1;
}
),
function (idx, obj) {
// add each object that has a working ratio
if ((obj.results !== undefined) &&
(obj.results.working_ratio !== undefined)) {
/* when there is only one replication, the ratio is given as a float,
otherwise we have a mapping avg, ub lb */
var blockage_ratio = 0.0,
working_ratio = 0.0,
waiting_ratio = 0.0,
failure_ratio = 0.0;
if (obj.results.blockage_ratio !== undefined) {
if (obj.results.blockage_ratio.avg !== undefined) {
blockage_ratio = obj.results.blockage_ratio.avg;
} else {
blockage_ratio = obj.results.blockage_ratio;
}
}
blockage_data.push([counter, blockage_ratio]);
// XXX merge setup & loading ratio in working ratio for now
if (obj.results.setup_ratio !== undefined) {
if (obj.results.setup_ratio.avg !== undefined) {
working_ratio += obj.results.setup_ratio.avg;
} else {
working_ratio += obj.results.setup_ratio;
}
}
if (obj.results.loading_ratio !== undefined) {
if (obj.results.loading_ratio.avg !== undefined) {
working_ratio += obj.results.loading_ratio.avg;
} else {
working_ratio += obj.results.loading_ratio;
}
}
if (obj.results.working_ratio !== undefined) {
if (obj.results.working_ratio.avg !== undefined) {
working_ratio += obj.results.working_ratio.avg;
} else {
working_ratio += obj.results.working_ratio;
}
}
working_data.push([counter, working_ratio]);
if (obj.results.waiting_ratio !== undefined) {
if (obj.results.waiting_ratio.avg !== undefined) {
waiting_ratio = obj.results.waiting_ratio.avg;
} else {
waiting_ratio = obj.results.waiting_ratio;
}
}
waiting_data.push([counter, waiting_ratio]);
if (obj.results.failure_ratio !== undefined) {
if (obj.results.failure_ratio.avg !== undefined) {
failure_ratio = obj.results.failure_ratio.avg;
} else {
failure_ratio = obj.results.failure_ratio;
}
}
failure_data.push([counter, failure_ratio]);
ticks.push([counter, obj.id]);
counter += 1;
}
}
);
series = [{
label: "Working",
data: working_data
}, {
label: "Waiting",
data: waiting_data
}, {
label: "Failures",
data: failure_data
}, {
label: "Blockage",
data: blockage_data
}];
options = {
xaxis: {
minTickSize: 1,
ticks: ticks
},
yaxis: {
max: 100
},
series: {
bars: {
show: true,
barWidth: 0.8,
align: "center"
},
stack: true
}
};
return [series, options];
}
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": "body.json"
})
.push(function (simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget(
JSON.parse(simulation_json), gadget.props.result
);
});
})
.declareMethod("startService", function () {
// XXX Manually calculate width and height when resizing
$.plot(
this.props.element.querySelector(".graph_container"),
this.props.result_list[0],
this.props.result_list[1]
);
});
}(window, rJS, jQuery, initGadgetMixin));
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