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

Update static version

parent 3927e127
/* ====================== listview checkbox ======================== */
/* allow checkbox and radio in split listview */
html body .ui-listview li.ui-li-has-checkbox {
padding-right: 2.25em;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 0;
}
html body .ui-listview li.ui-li-has-checkbox label {
border-left-width: 0px;
-moz-box-sizing: border-box;
}
html .ui-listview li.ui-li-has-alt a.ui-btn.ui-icon-caret-right:after,
html .ui-listview li.ui-li-has-alt a.ui-btn.ui-icon-carat-r:after {
content: "";
}
html .ui-listview li div.ui-radio,
html .ui-listview li div.ui-checkbox {
height: 100%;
margin: 0;
padding: 0;
position: absolute;
right: 0;
top: 0;
width: 2.5em;
z-index: 2;
}
html body .ui-listview li div.ui-radio label.ui-btn,
html body .ui-listview li div.ui-checkbox label.ui-btn {
border-radius: .375em;
height: 100%;
min-height: 1em;
padding: 0;
width: auto;
}
html body .ui-listview li div.ui-radio,
html body .ui-listview li div.ui-radio label.ui-btn,
html body .ui-listview li div.ui-checkbox,
html body .ui-listview li div.ui-checkbox label.ui-btn {
box-shadow: 0;
-webkit-box-shadow: 0;
border-radius: 0;
-webkit-border-radius: 0;
}
html body .ui-listview li.ui-first-child div.ui-radio,
html body .ui-listview li.ui-first-child div.ui-radio label.ui-btn,
html body .ui-listview li.ui-first-child div.ui-checkbox,
html body .ui-listview li.ui-first-child div.ui-checkbox label.ui-btn {
border-top-right-radius: .375em;
-webkit-border-top-right-radius: .375em;
}
html body .ui-listview li.ui-last-child div.ui-radio,
html body .ui-listview li.ui-last-child div.ui-radio label,
html body .ui-listview li.ui-last-child div.ui-checkbox,
html body .ui-listview li.ui-last-child div.ui-checkbox label {
border-bottom-right-radius: .375em;
-webkit-border-bottom-right-radius: .375em;
border-bottom-width: 1px;
margin-bottom: -1px;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Choose Instance</title>
<link rel="stylesheet" href="InputModule_viewAddInstanceDefinitionDialog.css" />
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/handlebars.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="InputModule_viewAddInstanceDefinitionDialog.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<ul data-role="listview" data-inset="true" class="document-listview">
{{#documentlist}}
<li>
<div>
<!--div class="ui-btn ui-input-btn">{{title}} -->
<input type="submit" value="{{title}}" name= "{{name}}">
</div>
<div class="ui-checkbox">
<label class="ui-corner-all ui-btn-inherit ui-btn-icon-left ui-icon-checkbox-off ui-checkbox-off">
<!--label class="ui-corner-all ui-btn-inherit"-->
<input type="checkbox" value="" name="{{name}}">
</label>
</div>
</li>
{{/documentlist}}
</ul>
</script>
</head>
<body>
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<form class="new_form">
<button type="submit" class="ui-btn ui-btn ui-btn-inline ui-icon-plus ui-btn-icon-right">Default</button>
</form>
<form class="import_form">
<input id="dream_import" type="file" required=""
name="dream_import" class="ui-btn ui-btn-b ui-btn-inline">
<button type="submit" class="ui-btn ui-btn ui-btn-inline ui-icon-plus ui-btn-icon-right">Import</button>
</form>
</div>
<div class="ui-block-b">
<form method="post" action="#">
<input type="hidden" name="method" value="delete_status" ></input>
<section class="document_list"></section>
<!--ul data-role="listview" class="document-list" data-inset="true"></ul-->
<div class="ui-input-btn ui-btn ui-icon-delete ui-btn-inline ui-btn-icon-left">
Delete
<input type="submit" data-enhanced="true" value="Delete">
</div>
</form>
</div>
</div>
</body>
</html>
/*global $, rJS, RSVP, promiseEventListener, promiseReadAsText,
initGadgetMixin, Handlebars, console */
(function(window, rJS, RSVP, promiseEventListener, promiseReadAsText, initGadgetMixin, Handlebars) {
/* Handlebars*/
"use strict";
// delete last session document
function removeLastSession(gadget, name) {
var now = new Date(), documents, element_list, element, i, len, promise_list;
promise_list = [];
gadget.aq_allDocs({
include_docs: true,
query: 'type:= "DreamLastInstance"',
select_list: [ "title", "modified" ]
}).push(function(docs) {
documents = docs;
if (documents.data.total_rows === undefined) {
console.log("Last instance data is undefined");
} else if (documents.data.total_rows === 0) {
console.log("There is no record of DreamLastInstance type");
} else if (documents.data.total_rows > 0) {
//aq_remove should be performed here
element_list = documents.data.rows;
for (i = 0, len = element_list.length; i < len; i += 1) {
element = element_list[i];
//.nextSibling;
promise_list[i] = gadget.aq_remove({
_id: element.id
});
}
}
});
// create last instance jIO document
promise_list[promise_list.length] = gadget.aq_post({
title: name,
type: "DreamLastInstance",
format: "application/json",
modified: now.toUTCString(),
date: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()
});
return RSVP.all(promise_list);
}
// create a jIO document
function createDocument(gadget, name) {
var now = new Date(), documents, element_list, element, i, len, promise_list;
promise_list = [];
gadget.aq_allDocs({
include_docs: true,
query: 'type:= "DreamLastInstance"',
select_list: [ "title", "modified" ]
}).push(function(docs) {
documents = docs;
if (documents.data.total_rows === undefined) {
console.log("Last instance data is undefined");
} else if (documents.data.total_rows === 0) {
console.log("There is no record in the last", "instance list, can proceed without deleting");
} else if (documents.data.total_rows > 0) {
//aq_remove should be performed here
element_list = documents.data.rows;
for (i = 0, len = element_list.length; i < len; i += 1) {
element = element_list[i];
//.nextSibling;
promise_list[i] = gadget.aq_remove({
_id: element.id
});
}
}
});
// Create jIO document
promise_list[promise_list.length] = gadget.aq_post({
title: name,
type: "DreamInstance",
format: "application/json",
modified: now.toUTCString(),
date: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()
});
// create last instance jIO document
promise_list[promise_list.length] = gadget.aq_post({
title: name,
type: "DreamLastInstance",
format: "application/json",
modified: now.toUTCString(),
date: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()
});
return RSVP.all(promise_list);
}
function waitForImport(gadget) {
// here import definition dict from a local file
var json_data, name;
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("import_form")[0], "submit", false);
}).push(function(evt) {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
var file = evt.target.dream_import.files[0];
name = file.name;
return promiseReadAsText(file);
}).push(function(json) {
json_data = json;
gadget.configurationIsSet(true);
gadget.setConfigurationDict(json_data);
return createDocument(gadget, name);
}).push(function(jio_document_list) {
// Add JSON as attachment
return RSVP.all([ gadget.aq_putAttachment({
_id: jio_document_list[0].id,
_attachment: "body.json",
_data: json_data,
_mimetype: "application/json"
}), gadget.aq_putAttachment({
_id: jio_document_list[1].id,
_attachment: "body.json",
_data: json_data,
_mimetype: "application/json"
}) ]);
});
}
function waitForDefault(gadget) {
var name = "DefaultInstance", json_data = {};
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
}).push(function(evt) {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}).push(function() {
//return gadget.getConfigurationDict();
return gadget.getDefaultConfigurationDict();
}).push(function(data) {
json_data = data || {};
gadget.configurationIsSet(true);
return createDocument(gadget, name);
}).push(function(jio_document_list) {
// Add JSON as attachment
return RSVP.all([ gadget.aq_putAttachment({
_id: jio_document_list[0].id,
_attachment: "body.json",
_data: JSON.stringify(json_data),
_mimetype: "application/json"
}), gadget.aq_putAttachment({
_id: jio_document_list[1].id,
_attachment: "body.json",
_data: JSON.stringify(json_data),
_mimetype: "application/json"
}) ]);
});
}
var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("table-template").innerHTML, table_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_allDocs", "jio_allDocs").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_remove", "jio_remove").declareAcquiredMethod("whoWantsToDisplayHome", "whoWantsToDisplayHome").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareAcquiredMethod("aq_startListenTo", "startListenTo").declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("getDefaultConfigurationDict", "getDefaultConfigurationDict").declareAcquiredMethod("configurationIsSet", "configurationIsSet").declareAcquiredMethod("setConfigurationDict", "setConfigurationDict").ready(function(gadget) {
gadget.state_parameter_dict = {};
}).declareMethod("render", function() {
console.log("VIEWADDINSTANCE RENDER 1");
var gadget, doc_list, innerHTML;
gadget = this;
doc_list = gadget.props.element.querySelector(".document_list");
// helper: add options to selects
function makeListItems(row_list) {
console.log("MAKEDOCUMENTLIST 1");
var i, len, record, item, //button, box, label, fragment
param_list;
//test;
param_list = [];
//fragment = document.createDocumentFragment();
len = row_list.length;
if (len === 1) {
if (row_list[0].doc === "none") {
item = document.createElement("div");
item.innerHTML = "no records";
doc_list.appendChild(item);
} else {
record = row_list[0].doc;
param_list[0] = {
title: record.title + " (" + record.date + ")",
name: "record_" + record._id,
date: new Date(record.date)
};
}
} else {
for (i = 0; i < len; i += 1) {
record = row_list[i].doc;
param_list[i] = {
title: record.title + " (" + record.date + ")",
name: "record_" + record._id,
date: new Date(record.date)
};
}
param_list.sort(function(a, b) {
return b.date - a.date;
});
}
innerHTML = table_template({
documentlist: param_list
});
console.log("MAKEDOCUMENTLIST 2");
}
// helper: select a configuration dictionary from a doc
function handleDictSelect(e) {
var form, element, id, json_data;
//prevent default
e.preventDefault();
form = e.target;
element = form.querySelector("div.ui-focus");
if (element === null || element === "undefined") {
element = form.querySelector("input.ui-state-focus");
id = element.name.replace("record_", "");
} else {
id = element.childNodes[1].name.replace("record_", "");
}
return gadget.aq_getAttachment({
_id: id,
_attachment: "body.json"
}).push(function(json) {
json_data = json;
gadget.configurationIsSet(true);
gadget.setConfigurationDict(json_data);
}).push(function() {
console.log("to remove last session");
return removeLastSession(gadget);
}).push(function(jio_document_list) {
// receive jio_document_list
return gadget.aq_putAttachment({
_id: jio_document_list[0].id,
_attachment: "body.json",
_data: JSON.stringify(json_data),
_mimetype: "application/json"
});
}).push(function() {
return gadget.whoWantsToDisplayThisDocument(id);
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
}
// helper: delete a doc
function handleDelete(e) {
var form, element_list, promise_list, i, len, element, list_element, id, fragment, $doc;
//prevent default
console.log("HANDLING DELETE 1");
e.preventDefault();
form = e.target;
promise_list = [];
element_list = form.querySelectorAll("label.ui-checkbox-on");
if (element_list) {
for (i = 0, len = element_list.length; i < len; i += 1) {
element = element_list[i].nextSibling;
id = element.name.replace("record_", "");
list_element = element.parentNode.parentNode.parentNode;
list_element.parentNode.removeChild(list_element);
if (form.querySelector("ul").children.length === 0) {
fragment = document.createElement("li");
fragment.innerHTML = "No records";
form.querySelector("ul").appendChild(fragment);
}
promise_list[i] = gadget.aq_remove({
_id: id
});
}
// enhance/refresh
$doc = $(doc_list);
if ($doc.listview("instance")) {
$doc.listview("refresh");
}
}
console.log("HANDLING DELETE 2");
return RSVP.all(promise_list);
}
return gadget.aq_allDocs({
include_docs: true,
query: 'type:= "DreamInstance"',
select_list: [ "title", "modified" ]
}).push(function(document_list) {
var len, data, $doc;
data = document_list.data;
len = data.total_rows;
if (len > 0) {
makeListItems(data.rows);
} else {
makeListItems([ {
doc: "none"
} ]);
}
// append
while (doc_list.firstChild) {
doc_list.removeChild(doc_list.firstChild);
}
doc_list.innerHTML = innerHTML;
// enhance/refresh
$doc = $(doc_list);
if ($doc.listview("instance")) {
$doc.listview("refresh");
}
}).push(function() {
console.log("VIEWADDINSTANCE RENDER 3");
if (!gadget.state_parameter_dict.bound) {
gadget.state_parameter_dict.bound = true;
return RSVP.all([ gadget.aq_startListenTo(gadget.props.element.getElementsByTagName("FORM")[2], "submit", handleDelete), // XXXXXXXXXXXXXXXXXXXXX
gadget.aq_startListenTo(gadget.props.element.getElementsByTagName("FORM")[2], "submit", handleDictSelect) ]);
}
});
}).declareMethod("startService", function() {
console.log("VIEWADDINSTANCE STARTSERVICE 1");
var gadget = this;
return new RSVP.Queue().push(function() {
return RSVP.any([ waitForImport(gadget), waitForDefault(gadget) ]);
}).push(function(result) {
return gadget.whoWantsToDisplayThisDocument(result[0].id);
}).push(function(url) {
console.log("VIEWADDINSTANCE STARTSERVICE 4");
return gadget.pleaseRedirectMyHash(url);
});
});
})(window, rJS, RSVP, promiseEventListener, promiseReadAsText, initGadgetMixin, Handlebars);
\ No newline at end of file
<!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="../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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
/*global rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror */ /*global rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror, setTimeout, $ */
(function(window, rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror) { (function(window, rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("startService", function() { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("startService", function() {
var gadget = this; var gadget = this;
gadget.props.codemirror.refresh();
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.querySelector(".save_button"), "click", false); return promiseEventListener(gadget.props.element.querySelector(".save_button"), "click", false);
}).push(function() { }).push(function() {
...@@ -12,6 +13,16 @@ ...@@ -12,6 +13,16 @@
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "body.json", _attachment: "body.json",
_data: gadget.props.codemirror.getValue() _data: gadget.props.codemirror.getValue()
}).push(function() {
// XXX quick way to get a popup message
$.mobile.loading("show", {
text: "Configuration saved",
textVisible: true,
textonly: true
});
setTimeout(function() {
$.mobile.loading("hide");
}, 1e3);
}); });
}); });
}).declareMethod("render", function(options) { }).declareMethod("render", function(options) {
...@@ -40,6 +51,16 @@ ...@@ -40,6 +51,16 @@
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "body.json", _attachment: "body.json",
_data: instance.getValue() _data: instance.getValue()
}).push(function() {
// XXX quick way to get a popup message
$.mobile.loading("show", {
text: "Configuration saved",
textVisible: true,
textonly: true
});
setTimeout(function() {
$.mobile.loading("hide");
}, 1e3);
}); });
} }
} }
......
<!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="../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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
<!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="../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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
<!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="../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="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_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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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
});
});
}).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);
\ No newline at end of file
<!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="../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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
<!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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit table</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewTable.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
</body>
</html>
/*global console, rJS, RSVP, initGadgetMixin */
(function(window, rJS, RSVP, initGadgetMixin) {
"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) {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet));
});
}).declareMethod("startService", function() {
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService();
});
});
})(window, rJS, RSVP, initGadgetMixin);
\ No newline at end of file
<!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="../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="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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").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);
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stations Utilization</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/jquery.flot.js"></script>
<script src="../lib/jquery.flot.stack.js"></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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").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);
\ No newline at end of file
<!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="../lib/dhtmlxgantt.css">
<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/dhtmlxgantt.js" 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) {
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 * 1e3 * 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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").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 * 1e3,
//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);
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Job Schedule</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/moment.js" 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 * 1e3 * 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 * 1e3 * 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.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").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)));
});
}).declareMethod("startService", function() {
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService();
});
});
})(window, rJS, RSVP, moment, initGadgetMixin);
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stations Utilization</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/jquery.flot.js"></script>
<script src="../lib/jquery.flot.stack.js"></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, working_ratio = 0, waiting_ratio = 0, failure_ratio = 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: .8,
align: "center"
},
stack: true
}
};
return [ series, options ];
}
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;
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);
\ No newline at end of file
...@@ -7,4 +7,4 @@ This software is allowed to use under GPL or you need to obtain Commercial or En ...@@ -7,4 +7,4 @@ This software is allowed to use under GPL or you need to obtain Commercial or En
/* dream fixes */ /* dream fixes */
.gantt_task_content { .gantt_task_content {
color: #454545; color: #454545;
} }
\ No newline at end of file
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