Commit 147826e9 authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Publish static files.

parent 2ae6d546
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
// Precompile the templates while loading the first gadget instance // Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("table-template").innerHTML, table_template = Handlebars.compile(source); var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("table-template").innerHTML, table_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_allDocs", "allDocs").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisPage", "whoWantToDisplayThisPage").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_allDocs", "allDocs").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("render", function(options) {
var gadget = this; var gadget = this;
return gadget.aq_allDocs({ return gadget.aq_allDocs({
select_list: [ "title", "modified" ] select_list: [ "title", "modified" ]
}).push(function(document_list) { }).push(function(document_list) {
var result_list = [ gadget.whoWantToDisplayThisPage("InputModule_viewAddDocumentDialog") ], doc, i; var result_list = [], doc, i;
for (i = 0; i < document_list.data.total_rows; i += 1) { for (i = 0; i < document_list.data.total_rows; i += 1) {
doc = document_list.data.rows[i]; doc = document_list.data.rows[i];
result_list.push(RSVP.all([ gadget.whoWantToDisplayThisDocument(doc.id), doc.value.title, doc.value.modified ])); result_list.push(RSVP.all([ gadget.whoWantToDisplayThisDocument(doc.id), doc.value.title, doc.value.modified ]));
...@@ -21,13 +21,15 @@ ...@@ -21,13 +21,15 @@
return RSVP.all(result_list); return RSVP.all(result_list);
}).push(function(document_list) { }).push(function(document_list) {
// Create new doc if nothing exists // Create new doc if nothing exists
if (document_list.length === 1) { if (document_list.length === 0) {
return gadget.pleaseRedirectMyHash(document_list[0]); return gadget.whoWantToDisplayThisDocument(undefined, "view_fast_input").push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
} }
var i, parameter_list = [], doc; var i, parameter_list = [], doc;
for (i = 1; i < document_list.length; i += 1) { for (i = 0; i < document_list.length; i += 1) {
doc = document_list[i]; doc = document_list[i];
parameter_list[i - 1] = { parameter_list[i] = {
link: doc[0], link: doc[0],
title: doc[1] + " (" + doc[2] + ")" title: doc[1] + " (" + doc[2] + ")"
}; };
...@@ -37,12 +39,5 @@ ...@@ -37,12 +39,5 @@
documentlist: parameter_list documentlist: parameter_list
}); });
}); });
}).declareMethod("getNavigationList", function() {
return this.whoWantToDisplayThisPage("InputModule_viewAddDocumentDialog").push(function(url) {
return [ {
title: "New Document",
link: url
} ];
});
}); });
})(window, rJS, RSVP, Handlebars, initGadgetMixin); })(window, rJS, RSVP, Handlebars, initGadgetMixin);
\ No newline at end of file
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="mixin_gadget.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="mixin_promise.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewDocumentManagement.js" type="text/javascript"></script> <script src="Input_viewDocumentManagement.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, /*global console, rJS, RSVP, jQuery,
promiseEventListener, initGadgetMixin */ promiseEventListener, initGadgetMixin */
(function(window, rJS, RSVP, initDocumentPageMixin, $, promiseEventListener, initGadgetMixin) { (function(window, rJS, RSVP, $, promiseEventListener, initGadgetMixin) {
"use strict"; "use strict";
function datatouri(data, mime_type) { function datatouri(data, mime_type) {
var result = "data:"; var result = "data:";
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_remove", "jio_remove").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_get", "jio_get").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareAcquiredMethod("whoWantToDisplayHome", "whoWantToDisplayHome").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_remove", "jio_remove").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_get", "jio_get").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareAcquiredMethod("whoWantToDisplayHome", "whoWantToDisplayHome").declareMethod("render", function(options) {
this.props.jio_key = options.id; this.props.jio_key = options.id;
var gadget = this; var gadget = this;
...@@ -94,4 +93,4 @@ ...@@ -94,4 +93,4 @@
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
return RSVP.all([ waitForDeletion(this), waitForKnowledgeExtraction(this) ]); return RSVP.all([ waitForDeletion(this), waitForKnowledgeExtraction(this) ]);
}); });
})(window, rJS, RSVP, initDocumentPageMixin, jQuery, promiseEventListener, initGadgetMixin); })(window, rJS, RSVP, jQuery, promiseEventListener, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<script src="../lib/rsvp.min.js" type="text/javascript"></script> <script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script> <script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewProductionLine.js" type="text/javascript"></script> <script src="Input_viewProductionLine.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global window, rJS, RSVP, initDocumentPageMixin */ /*global window, rJS, RSVP */
/*jslint nomen: true */ (function(window, rJS, RSVP) {
(function(window, rJS, RSVP, initDocumentPageMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
gadget_klass.ready(function(g) { gadget_klass.ready(function(g) {
g.props = {}; g.props = {};
}).ready(function(g) { }).ready(function(g) {
...@@ -14,6 +12,7 @@ ...@@ -14,6 +12,7 @@
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
/*jslint nomen: true*/
return RSVP.all([ gadget.aq_getAttachment({ return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key, _id: jio_key,
_attachment: "body.json" _attachment: "body.json"
...@@ -26,4 +25,4 @@ ...@@ -26,4 +25,4 @@
return productionline.startService(); return productionline.startService();
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin); })(window, rJS, RSVP);
\ No newline at end of file \ 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>Result List</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/handlebars.min.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><a href="{{link}}">{{title}}</a></li>
{{/documentlist}}
</ul>
</script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewResultList.js" type="text/javascript"></script>
</head>
<body>
<section class="document_list"></section>
</body>
</html>
/*global console, rJS, RSVP, Handlebars, initGadgetMixin */
/*jslint nomen: true */
(function(window, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
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_getAttachment", "jio_getAttachment").declareAcquiredMethod("whoWantToDisplayThisResult", "whoWantToDisplayThisResult").declareMethod("render", function(options) {
var gadget = this;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json"
}).push(function(sim_json) {
var document_list = JSON.parse(sim_json), result_list = [], i;
for (i = 0; i < document_list.length; i += 1) {
result_list.push(RSVP.all([ gadget.whoWantToDisplayThisResult(gadget.props.jio_key, i), document_list[i].score, document_list[i].key ]));
}
return RSVP.all(result_list);
}).push(function(document_list) {
var i, parameter_list = [], doc;
for (i = 0; i < document_list.length; i += 1) {
doc = document_list[i];
parameter_list[i] = {
link: doc[0],
title: doc[1] + " " + doc[2]
};
}
gadget.props.element.querySelector(".document_list").innerHTML = table_template({
documentlist: parameter_list
});
});
});
})(window, rJS, RSVP, Handlebars, initGadgetMixin);
\ No newline at end of file
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
<script src="mixin_gadget.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="mixin_promise.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewSimulation.js" type="text/javascript"></script> <script src="Input_viewSimulation.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars, /*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin */ promiseEventListener, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, $, Handlebars, promiseEventListener, initGadgetMixin) { (function(window, rJS, RSVP, $, Handlebars, promiseEventListener, initGadgetMixin) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Handlebars // Handlebars
...@@ -9,16 +9,9 @@ ...@@ -9,16 +9,9 @@
// Precompile the templates while loading the first gadget instance // Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("label-template").innerHTML, label_template = Handlebars.compile(source); var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("label-template").innerHTML, label_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass); gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("render", function(options) {
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocumentPage", "whoWantToDisplayThisDocumentPage").declareMethod("render", function(options) { var i, gadget = this, property, parent_element = gadget.props.element.querySelector(".simulation_parameters"), value, queue, data;
var i, gadget = this, property, parent_element = gadget.props.element.querySelector(".simulation_parameters"), value, queue, data, property_list = options.configuration_dict["Dream-Configuration"].property_list;
this.props.jio_key = options.id; this.props.jio_key = options.id;
queue = gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
}).push(function(json) {
data = JSON.parse(json).general;
});
function addField(property, value) { function addField(property, value) {
var sub_gadget; var sub_gadget;
queue.push(function() { queue.push(function() {
...@@ -42,13 +35,22 @@ ...@@ -42,13 +35,22 @@
parent_element.appendChild(sub_element); parent_element.appendChild(sub_element);
}); });
} }
for (i = 0; i < property_list.length; i += 1) { queue = gadget.aq_getAttachment({
property = property_list[i]; _id: gadget.props.jio_key,
if (property._class === "Dream.Property") { _attachment: "body.json"
value = property._default || ""; }).push(function(json) {
addField(property, value); data = JSON.parse(json).general;
return gadget.aq_getConfigurationDict();
}).push(function(configuration_dict) {
var property_list = configuration_dict["Dream-Configuration"].property_list;
for (i = 0; i < property_list.length; i += 1) {
property = property_list[i];
if (property._class === "Dream.Property") {
value = property._default || "";
addField(property, value);
}
} }
} });
return queue; return queue;
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var gadget = this; var gadget = this;
...@@ -89,9 +91,9 @@ ...@@ -89,9 +91,9 @@
_mimetype: "application/json" _mimetype: "application/json"
}); });
}).push(function(result) { }).push(function(result) {
return gadget.whoWantToDisplayThisDocumentPage("Output_viewDebugJson", gadget.props.jio_key); return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key, "view_result");
}).push(function(url) { }).push(function(url) {
return gadget.pleaseRedirectMyHash(url); return gadget.pleaseRedirectMyHash(url);
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars, promiseEventListener, initGadgetMixin); })(window, rJS, RSVP, jQuery, Handlebars, promiseEventListener, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<script src="../lib/renderjs.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_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Input_viewTable.js" type="text/javascript"></script> <script src="Input_viewTable.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */ /*global console, rJS, RSVP, initGadgetMixin */
(function(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) { (function(window, rJS, RSVP, initGadgetMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initDocumentPageMixin(gadget_klass);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
...@@ -20,4 +19,4 @@ ...@@ -20,4 +19,4 @@
return tableeditor.startService(); return tableeditor.startService();
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin); })(window, rJS, RSVP, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<script src="../lib/rsvp.min.js" type="text/javascript"></script> <script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.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_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewDebugJson.js" type="text/javascript"></script> <script src="Output_viewDebugJson.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, initGadgetMixin */ /*global console, rJS, RSVP, initGadgetMixin */
(function(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin) { (function(window, rJS, RSVP, initGadgetMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var gadget = this; var gadget = this;
this.props.jio_key = options.id; this.props.jio_key = options.id;
return new RSVP.Queue().push(function() { this.props.result = options.result;
return RSVP.all([ gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "body.json" _attachment: "simulation.json"
}), gadget.aq_getAttachment({ }).push(function(result_json) {
_id: gadget.props.jio_key, var result = JSON.parse(result_json);
_attachment: "simulation.json" gadget.props.element.querySelector(".json_input").textContent = JSON.stringify(result[gadget.props.result].input);
}) ]); gadget.props.element.querySelector(".json_output").textContent = JSON.stringify(result[gadget.props.result].result);
}).push(function(result_list) {
gadget.props.element.querySelector(".json_input").textContent = result_list[0];
// XXX Hardcoded result
gadget.props.element.querySelector(".json_output").textContent = JSON.stringify(JSON.parse(result_list[1])[0].result);
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, initGadgetMixin); })(window, rJS, RSVP, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<script src="../lib/renderjs.min.js" type="text/javascript"></script> <script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/handlebars.min.js" type="text/javascript"></script> <script src="../lib/handlebars.min.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewExitStatistics.js" type="text/javascript"></script> <script src="Output_viewExitStatistics.js" type="text/javascript"></script>
<script id="interval-through-metric-template" type="text/x-handlebars-template"> <script id="interval-through-metric-template" type="text/x-handlebars-template">
......
/*global console, rJS, RSVP, initDocumentPageMixin, Handlebars, /*global console, rJS, RSVP, Handlebars,
initGadgetMixin */ initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, Handlebars, initGadgetMixin) { (function(window, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Handlebars // Handlebars
...@@ -85,17 +85,16 @@ ...@@ -85,17 +85,16 @@
return result; return result;
} }
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
var result = calculate_exit_stat(// XXX Hardcoded result var result = calculate_exit_stat(JSON.parse(simulation_json)[gadget.props.result].result);
JSON.parse(simulation_json)[0].result);
gadget.props.element.innerHTML = result; gadget.props.element.innerHTML = result;
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, Handlebars, initGadgetMixin); })(window, rJS, RSVP, Handlebars, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="../lib/jquery.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="../lib/dhtmlxgantt.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewJobGantt.js" type="text/javascript"></script> <script src="Output_viewJobGantt.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, gantt, /*global console, rJS, RSVP, jQuery, gantt,
initGadgetMixin */ initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, $, gantt, initGadgetMixin) { (function(window, rJS, RSVP, $, gantt, initGadgetMixin) {
"use strict"; "use strict";
gantt.templates.task_class = function(start, end, obj) { gantt.templates.task_class = function(start, end, obj) {
return obj.parent ? "sub_task" : ""; return obj.parent ? "sub_task" : "";
...@@ -161,16 +161,15 @@ ...@@ -161,16 +161,15 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
gadget.props.result = job_gantt_widget(// XXX Hardcoded result gadget.props.result = job_gantt_widget(JSON.parse(simulation_json)[gadget.props.result]);
JSON.parse(simulation_json)[0]);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
$(this.props.element).find(".gant_container").dhx_gantt({ $(this.props.element).find(".gant_container").dhx_gantt({
...@@ -200,4 +199,4 @@ ...@@ -200,4 +199,4 @@
throw error; throw error;
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, jQuery, gantt, initGadgetMixin); })(window, rJS, RSVP, jQuery, gantt, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="../lib/moment.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="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewJobScheduleSpreadsheet.js" type="text/javascript"></script> <script src="Output_viewJobScheduleSpreadsheet.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin */ /*global console, rJS, RSVP, moment, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin) { (function(window, rJS, RSVP, moment, initGadgetMixin) {
"use strict"; "use strict";
function job_schedule_spreadsheet_widget(all_data) { function job_schedule_spreadsheet_widget(all_data) {
var now = new Date(), input_data = all_data.input, output_data = all_data.result, 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; var now = new Date(), input_data = all_data.input, output_data = all_data.result, 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;
...@@ -90,22 +90,21 @@ ...@@ -90,22 +90,21 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({ return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key, _id: jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}), gadget.getDeclaredGadget("tableeditor") ]); }), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) { }).push(function(result_list) {
// XXX Hardcoded result return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0])[gadget.props.result])));
return result_list[1].render(JSON.stringify(job_schedule_spreadsheet_widget(JSON.parse(result_list[0])[0])));
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) { return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService(); return tableeditor.startService();
}); });
}); });
})(window, rJS, RSVP, initDocumentPageMixin, moment, initGadgetMixin); })(window, rJS, RSVP, moment, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="../lib/jquery.flot.js"></script> <script src="../lib/jquery.flot.js"></script>
<script src="../lib/jquery.flot.stack.js"></script> <script src="../lib/jquery.flot.stack.js"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewQueueStatGraph.js" type="text/javascript"></script> <script src="Output_viewQueueStatGraph.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */ /*global console, rJS, RSVP, jQuery, initGadgetMixin */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) { (function(window, rJS, RSVP, $, initGadgetMixin) {
"use strict"; "use strict";
function queue_stat_widget(output_data) { function queue_stat_widget(output_data) {
/* FIXME: does not support more than one replic. /* FIXME: does not support more than one replic.
...@@ -19,19 +19,18 @@ ...@@ -19,19 +19,18 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
gadget.props.series = queue_stat_widget(// XXX Hardcoded result gadget.props.series = queue_stat_widget(JSON.parse(simulation_json)[gadget.props.result].result);
JSON.parse(simulation_json)[0].result);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
// XXX Manually calculate width and height when resizing // XXX Manually calculate width and height when resizing
$.plot(this.props.element.querySelector(".graph_container"), this.props.series); $.plot(this.props.element.querySelector(".graph_container"), this.props.series);
}); });
})(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin); })(window, rJS, RSVP, jQuery, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<script src="../lib/jquery.flot.js"></script> <script src="../lib/jquery.flot.js"></script>
<script src="../lib/jquery.flot.stack.js"></script> <script src="../lib/jquery.flot.stack.js"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_document_page.js" type="text/javascript"></script>
<script src="Output_viewStationUtilisationGraph.js" type="text/javascript"></script> <script src="Output_viewStationUtilisationGraph.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin */ /*global console, rJS, RSVP, jQuery, initGadgetMixin */
(function(window, rJS, RSVP, initDocumentPageMixin, $, initGadgetMixin) { (function(window, rJS, RSVP, $, initGadgetMixin) {
"use strict"; "use strict";
function station_utilisation_graph_widget(output_data) { function station_utilisation_graph_widget(output_data) {
var blockage_data = [], waiting_data = [], failure_data = [], working_data = [], ticks = [], counter = 1, series, options; var blockage_data = [], waiting_data = [], failure_data = [], working_data = [], ticks = [], counter = 1, series, options;
...@@ -97,19 +97,18 @@ ...@@ -97,19 +97,18 @@
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
initDocumentPageMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
gadget.props.result = options.result;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "simulation.json" _attachment: "simulation.json"
}).push(function(simulation_json) { }).push(function(simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget(// XXX Hardcoded result gadget.props.result_list = station_utilisation_graph_widget(JSON.parse(simulation_json)[gadget.props.result].result);
JSON.parse(simulation_json)[0].result);
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
// XXX Manually calculate width and height when resizing // 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]); $.plot(this.props.element.querySelector(".graph_container"), this.props.result_list[0], this.props.result_list[1]);
}); });
})(window, rJS, RSVP, initDocumentPageMixin, jQuery, initGadgetMixin); })(window, rJS, RSVP, jQuery, initGadgetMixin);
\ No newline at end of file \ No newline at end of file
@media (min-width:35em){.jqm-navmenu-panel.ui-panel-closed{visibility:visible!important;width:17em;-webkit-transition:none!important;-moz-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;transform:none!important;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;height:100%;position:absolute;display:block}.ui-panel-page-content-open{width:auto}.ui-panel-page-content-open.ui-panel-page-content-position-left{margin-right:17em}.ui-panel-dismiss,.menu_link{display:none!important}.gadget_container,header{margin-left:17em}.close-entry{display:none!important}.gadget_container{padding:1em}}[data-gadget-scope=productionline] #main{position:relative;margin:20px auto;font-size:80%;border:1px solid #999;width:100%;height:600px;overflow:hidden;border-radius:10px;background-color:#eaedef;text-align:center}[data-gadget-scope=productionline] .selected{color:#bd0b0b!important}[data-gadget-scope=productionline] .window,[data-gadget-scope=productionline] .label{background-color:#fff;text-align:center;z-index:23;cursor:pointer;box-shadow:2px 2px 19px #aaa;-o-box-shadow:2px 2px 19px #aaa;-webkit-box-shadow:2px 2px 19px #aaa;-moz-box-shadow:2px 2px 19px #aaa}[data-gadget-scope=productionline] path,[data-gadget-scope=productionline] ._jsPlumb_endpoint{cursor:pointer}[data-gadget-scope=productionline] ._jsPlumb_endpoint_drop_allowed{border:4px solid #123456;box-shadow:6px 6px 19px #444;-o-box-shadow:6px 6px 19px #444;-webkit-box-shadow:6px 6px 19px #444;-moz-box-shadow:6px 6px 19px #444}[data-gadget-scope=productionline] ._jsPlumb_connector{z-index:18}[data-gadget-scope=productionline] ._jsPlumb_endpoint{z-index:19}[data-gadget-scope=productionline] ._jsPlumb_overlay{z-index:23}[data-gadget-scope=productionline] ._jsPlumb_connector._jsPlumb_hover{z-index:21!important}[data-gadget-scope=productionline] ._jsPlumb_endpoint._jsPlumb_hover{z-index:22!important}[data-gadget-scope=productionline] ._jsPlumb_overlay{border:1px solid #346789;opacity:.8;filter:alpha(opacity=80);background-color:#fff;color:#000;font-family:helvetica;padding:.5em}[data-gadget-scope=productionline] .Dream-Source,[data-gadget-scope=productionline] .Dream-BatchSource{border:1px solid #bbc;background-color:#ffe;background-image:linear-gradient(to bottom,#ffe 0,#dde 100%)}[data-gadget-scope=productionline] .Dream-Machine,[data-gadget-scope=productionline] .Dream-MachineJobShop,[data-gadget-scope=productionline] .Dream-BatchScrapMachine,[data-gadget-scope=productionline] .Dream-MachineManagedJob,[data-gadget-scope=productionline] .Dream-MouldAssembly{border:1px solid #cbc;background-color:#fef;background-image:linear-gradient(to bottom,#fef 0,#ede 100%)}[data-gadget-scope=productionline] .Dream-Queue,[data-gadget-scope=productionline] .Dream-QueueJobShop,[data-gadget-scope=productionline] .Dream-LineClearance,[data-gadget-scope=productionline] .Dream-QueueManagedJob,[data-gadget-scope=productionline] .Dream-ConditionalBuffer,[data-gadget-scope=productionline] .Dream-OrderDecomposition,[data-gadget-scope=productionline] .Dream-MouldAssemblyBuffer{border:1px solid #bcc;background-color:#eff;background-image:linear-gradient(to bottom,#eff 0,#dee 100%)}[data-gadget-scope=productionline] .Dream-Exit,[data-gadget-scope=productionline] .Dream-ExitJobShop{border:1px solid #ccb;background-color:#eef;background-image:linear-gradient(to bottom,#eef 0,#dde 100%)}[data-gadget-scope=productionline] .Dream-EventGenerator{border:1px solid #cba;background-color:#fdc;background-image:linear-gradient(to bottom,#fdc 0,#ecb 100%)}[data-gadget-scope=productionline] .Dream-BatchDecomposition,[data-gadget-scope=productionline] .Dream-BatchDecompositionStartTime,[data-gadget-scope=productionline] .Dream-BatchReassembly{border:1px solid #bcb;background-color:#dfd;background-image:linear-gradient(to bottom,#dfd 0,#cec 100%)}[data-gadget-scope=productionline] .Dream-Repairman{border:1px solid #cbb;background-color:#fdd;background-image:linear-gradient(to bottom,#fdd 0,#dcc 100%)}[data-gadget-scope=productionline] .window,[data-gadget-scope=productionline] .dummy_window{border:1px solid #d3d3d3;width:100px;height:64px;position:absolute;color:#000;font-family:serif;font-style:italic;padding-top:.9em;font-size:.9em;cursor:move;font-size:11px;-webkit-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;transition:background-color .1s ease-in;border-radius:5px}[data-gadget-scope=productionline] .window:hover{background-color:#5c96bc;background-image:none;color:#fff}[data-gadget-scope=productionline] .dummy_window{position:absolute;top:0;left:0;visibility:hidden}[data-gadget-scope=productionline] .ep{position:absolute;bottom:37%;right:5px;width:1em;height:1em;background-color:orange;cursor:pointer;box-shadow:0 0 2px #000;-webkit-transition:-webkit-box-shadow .25s ease-in;-moz-transition:-moz-box-shadow .25s ease-in;transition:box-shadow .25s ease-in}[data-gadget-scope=productionline] ._jsPlumb_source_hover,[data-gadget-scope=productionline] ._jsPlumb_target_hover,[data-gadget-scope=productionline] .dragHover{background-color:#1e8151;background-image:none;color:#fff}[data-gadget-scope=productionline] path{cursor:pointer} @media (min-width:35em){.jqm-navmenu-panel.ui-panel-closed{visibility:visible!important;width:17em;-webkit-transition:none!important;-moz-transition:none!important;transition:none!important;-webkit-transform:none!important;-moz-transform:none!important;transform:none!important;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;height:100%;position:absolute;display:block}.ui-panel-page-content-open{width:auto}.ui-panel-page-content-open.ui-panel-page-content-position-left{margin-right:17em}.ui-panel-dismiss,.menu_link{display:none!important}.gadget_container,header,nav{margin-left:17em}.close-entry{display:none!important}.gadget_container{padding:1em}}[data-gadget-scope=productionline] #main{position:relative;margin:20px auto;font-size:80%;border:1px solid #999;width:100%;height:600px;overflow:hidden;border-radius:10px;background-color:#eaedef;text-align:center}[data-gadget-scope=productionline] .selected{color:#bd0b0b!important}[data-gadget-scope=productionline] .window,[data-gadget-scope=productionline] .label{background-color:#fff;text-align:center;z-index:23;cursor:pointer;box-shadow:2px 2px 19px #aaa;-o-box-shadow:2px 2px 19px #aaa;-webkit-box-shadow:2px 2px 19px #aaa;-moz-box-shadow:2px 2px 19px #aaa}[data-gadget-scope=productionline] path,[data-gadget-scope=productionline] ._jsPlumb_endpoint{cursor:pointer}[data-gadget-scope=productionline] ._jsPlumb_endpoint_drop_allowed{border:4px solid #123456;box-shadow:6px 6px 19px #444;-o-box-shadow:6px 6px 19px #444;-webkit-box-shadow:6px 6px 19px #444;-moz-box-shadow:6px 6px 19px #444}[data-gadget-scope=productionline] ._jsPlumb_connector{z-index:18}[data-gadget-scope=productionline] ._jsPlumb_endpoint{z-index:19}[data-gadget-scope=productionline] ._jsPlumb_overlay{z-index:23}[data-gadget-scope=productionline] ._jsPlumb_connector._jsPlumb_hover{z-index:21!important}[data-gadget-scope=productionline] ._jsPlumb_endpoint._jsPlumb_hover{z-index:22!important}[data-gadget-scope=productionline] ._jsPlumb_overlay{border:1px solid #346789;opacity:.8;filter:alpha(opacity=80);background-color:#fff;color:#000;font-family:helvetica;padding:.5em}[data-gadget-scope=productionline] .Dream-Source,[data-gadget-scope=productionline] .Dream-BatchSource{border:1px solid #bbc;background-color:#ffe;background-image:linear-gradient(to bottom,#ffe 0,#dde 100%)}[data-gadget-scope=productionline] .Dream-Machine,[data-gadget-scope=productionline] .Dream-MachineJobShop,[data-gadget-scope=productionline] .Dream-BatchScrapMachine,[data-gadget-scope=productionline] .Dream-MachineManagedJob,[data-gadget-scope=productionline] .Dream-MouldAssembly{border:1px solid #cbc;background-color:#fef;background-image:linear-gradient(to bottom,#fef 0,#ede 100%)}[data-gadget-scope=productionline] .Dream-Queue,[data-gadget-scope=productionline] .Dream-QueueJobShop,[data-gadget-scope=productionline] .Dream-LineClearance,[data-gadget-scope=productionline] .Dream-QueueManagedJob,[data-gadget-scope=productionline] .Dream-ConditionalBuffer,[data-gadget-scope=productionline] .Dream-OrderDecomposition,[data-gadget-scope=productionline] .Dream-MouldAssemblyBuffer{border:1px solid #bcc;background-color:#eff;background-image:linear-gradient(to bottom,#eff 0,#dee 100%)}[data-gadget-scope=productionline] .Dream-Exit,[data-gadget-scope=productionline] .Dream-ExitJobShop{border:1px solid #ccb;background-color:#eef;background-image:linear-gradient(to bottom,#eef 0,#dde 100%)}[data-gadget-scope=productionline] .Dream-EventGenerator{border:1px solid #cba;background-color:#fdc;background-image:linear-gradient(to bottom,#fdc 0,#ecb 100%)}[data-gadget-scope=productionline] .Dream-BatchDecomposition,[data-gadget-scope=productionline] .Dream-BatchDecompositionStartTime,[data-gadget-scope=productionline] .Dream-BatchReassembly{border:1px solid #bcb;background-color:#dfd;background-image:linear-gradient(to bottom,#dfd 0,#cec 100%)}[data-gadget-scope=productionline] .Dream-Repairman{border:1px solid #cbb;background-color:#fdd;background-image:linear-gradient(to bottom,#fdd 0,#dcc 100%)}[data-gadget-scope=productionline] .window,[data-gadget-scope=productionline] .dummy_window{border:1px solid #d3d3d3;width:100px;height:64px;position:absolute;color:#000;font-family:serif;font-style:italic;padding-top:.9em;font-size:.9em;cursor:move;font-size:11px;-webkit-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;transition:background-color .1s ease-in;border-radius:5px}[data-gadget-scope=productionline] .window:hover{background-color:#5c96bc;background-image:none;color:#fff}[data-gadget-scope=productionline] .dummy_window{position:absolute;top:0;left:0;visibility:hidden}[data-gadget-scope=productionline] .ep{position:absolute;bottom:37%;right:5px;width:1em;height:1em;background-color:orange;cursor:pointer;box-shadow:0 0 2px #000;-webkit-transition:-webkit-box-shadow .25s ease-in;-moz-transition:-moz-box-shadow .25s ease-in;transition:box-shadow .25s ease-in}[data-gadget-scope=productionline] ._jsPlumb_source_hover,[data-gadget-scope=productionline] ._jsPlumb_target_hover,[data-gadget-scope=productionline] .dragHover{background-color:#1e8151;background-image:none;color:#fff}[data-gadget-scope=productionline] path{cursor:pointer}
\ No newline at end of file \ No newline at end of file
...@@ -16,13 +16,24 @@ ...@@ -16,13 +16,24 @@
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script> <script src="index.js" type="text/javascript"></script>
<script id="navigation-template" type="text/x-handlebars-template"> <script id="panel-template" type="text/x-handlebars-template">
<ul data-role="listview"> <ul data-role="listview">
<li><a class="home_link ui-btn ui-icon-home ui-btn-icon-left" data-icon="home">Documents</a></li>
<li><a class="fast_input_link ui-btn ui-icon-plus ui-btn-icon-left" data-icon="plus">New Document</a></li>
{{#navigationlist}} {{#navigationlist}}
<li><a href="{{link}}">{{title}}</a></li> <li><a href="{{link}}">{{title}}</a></li>
{{/navigationlist}} {{/navigationlist}}
</ul> </ul>
</script> </script>
<script id="active-navigation-template" type="text/x-handlebars-template">
<li><a class="ui-btn-active ui-state-persist" href="{{link}}">{{title}}</a></li>
</script>
<script id="navigation-template" type="text/x-handlebars-template">
<li><a href="{{link}}">{{title}}</a></li>
</script>
</head> </head>
<body> <body>
...@@ -36,11 +47,14 @@ ...@@ -36,11 +47,14 @@
</div> </div>
<header data-role="header"> <header data-role="header">
<a href="#leftpanel" class="menu_link">Menu</a> <a href="#leftpanel"
data-icon="bars"
class="menu_link ui-btn ui-icon-bars ui-btn-icon-left">Menu</a>
<h1>Dream Simulation</h1> <h1>Dream Simulation</h1>
<a class="home_link ui-btn ui-icon-home ui-btn-icon-left" data-icon="home">Home</a>
</header> </header>
<div class="nav_container"></div>
<article class="gadget_container"></article> <article class="gadget_container"></article>
<aside> <aside>
......
...@@ -9,7 +9,128 @@ ...@@ -9,7 +9,128 @@
$.mobile.linkBindingEnabled = false; $.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false; $.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false; $.mobile.pushStateEnabled = false;
var navigation_template, gadget_klass = rJS(window); /////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration
/////////////////////////////////////////////////////////////////
var portal_types = {
"Input Module": {
view: {
gadget: "InputModule_viewInputList",
type: "object_list",
title: "Document List"
},
view_fast_input: {
gadget: "InputModule_viewAddDocumentDialog",
type: "object_fast_input",
title: "Create Document"
}
},
Input: {
view: {
gadget: "Input_viewProductionLine",
type: "object_view",
title: "Production Line"
},
view_table: {
gadget: "Input_viewTable",
type: "object_view",
title: "Edit table"
},
view_simu: {
gadget: "Input_viewSimulation",
type: "object_view",
title: "Run simulation"
},
view_management: {
gadget: "Input_viewDocumentManagement",
type: "object_view",
title: "Manage document"
},
view_result: {
gadget: "Input_viewResultList",
type: "object_view",
title: "Results"
}
},
Output: {
view: {
gadget: "Output_viewStationUtilisationGraph",
type: "object_view",
title: "Stations Utilization"
},
view_queue_stat: {
gadget: "Output_viewQueueStatGraph",
type: "object_view",
title: "Queues Statistics"
},
view_exit_stat: {
gadget: "Output_viewExitStatistics",
type: "object_view",
title: "Exit Statistics"
},
view_gantt: {
gadget: "Output_viewJobGantt",
type: "object_view",
title: "Job Gantt"
},
view_schedule: {
gadget: "Output_viewJobScheduleSpreadsheet",
type: "object_view",
title: "Job Schedule"
},
view_debug: {
gadget: "Output_viewDebugJson",
type: "object_view",
title: "Debug JSON"
}
}
}, panel_template, navigation_template, active_navigation_template, gadget_klass = rJS(window);
function calculateTabHTML(gadget, options, key, title, active) {
return new RSVP.Queue().push(function() {
var kw = {
action: key,
id: options.id
};
if (options.result !== undefined) {
kw.result = options.result;
}
return gadget.aq_pleasePublishMyState(kw);
}).push(function(url) {
var kw = {
title: title,
link: url
};
if (active === true) {
return active_navigation_template(kw);
}
return navigation_template(kw);
});
}
function calculateNavigationHTML(gadget, portal_type, options) {
var nav_html, action;
if (portal_types[portal_type][options.action].type === "object_view") {
return new RSVP.Queue().push(function() {
var url_list = [], key2;
for (key2 in portal_types[portal_type]) {
if (portal_types[portal_type].hasOwnProperty(key2)) {
action = portal_types[portal_type][key2];
if (action.type === "object_view") {
url_list.push(calculateTabHTML(gadget, options, key2, action.title, key2 === options.action));
}
}
}
return RSVP.all(url_list);
}).push(function(entry_list) {
var i;
nav_html = '<nav data-role="navbar" data-collapsible="true"><ul>';
for (i = 0; i < entry_list.length; i += 1) {
nav_html += entry_list[i];
}
nav_html += "</ul></nav>";
return nav_html;
});
}
}
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("allDocs", function(param_list) { gadget_klass.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("allDocs", function(param_list) {
return this.getDeclaredGadget("jio").push(function(jio_gadget) { return this.getDeclaredGadget("jio").push(function(jio_gadget) {
...@@ -42,26 +163,45 @@ ...@@ -42,26 +163,45 @@
}).allowPublicAcquisition("whoWantToDisplayHome", function(param_list) { }).allowPublicAcquisition("whoWantToDisplayHome", function(param_list) {
// Hey, I want to display some URL // Hey, I want to display some URL
return this.aq_pleasePublishMyState({}); return this.aq_pleasePublishMyState({});
}).allowPublicAcquisition("whoWantToDisplayThisPage", function(param_list) {
// Hey, I want to display some URL
return this.aq_pleasePublishMyState({
page: param_list[0]
});
}).allowPublicAcquisition("whoWantToDisplayThisDocument", function(param_list) { }).allowPublicAcquisition("whoWantToDisplayThisDocument", function(param_list) {
// Hey, I want to display some jIO document // Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({ var kw = {
page: "Input_viewTable", action: param_list[1] || "view"
id: param_list[0] };
}); if (param_list[0] !== undefined) {
}).allowPublicAcquisition("whoWantToDisplayThisDocumentPage", function(param_list) { kw.id = param_list[0];
}
return this.aq_pleasePublishMyState(kw);
}).allowPublicAcquisition("whoWantToDisplayThisResult", function(param_list) {
// Hey, I want to display some jIO document // Hey, I want to display some jIO document
return this.aq_pleasePublishMyState({ return this.aq_pleasePublishMyState({
page: param_list[0], action: "view",
id: param_list[1] id: param_list[0],
result: param_list[1]
}); });
}).allowPublicAcquisition("getConfigurationDict", function(param_list) {
return this.props.configuration_dict;
}).ready(function(g) { }).ready(function(g) {
return g.aq_pleasePublishMyState({}).push(function(link) { if (panel_template === undefined) {
g.props.element.getElementsByClassName("home_link")[0].href = link; // XXX Only works as root gadget
panel_template = Handlebars.compile(document.getElementById("panel-template").innerHTML);
navigation_template = Handlebars.compile(document.getElementById("navigation-template").innerHTML);
active_navigation_template = Handlebars.compile(document.getElementById("active-navigation-template").innerHTML);
}
}).ready(function(g) {
return new RSVP.Queue().push(function() {
return RSVP.all([ g.aq_pleasePublishMyState({}), g.aq_pleasePublishMyState({
action: "view_fast_input"
}) ]);
}).push(function(link_list) {
var panel = g.props.element.querySelector("#leftpanel");
panel.innerHTML = panel_template({
navigationlist: []
});
panel.getElementsByClassName("home_link")[0].href = link_list[0];
panel.getElementsByClassName("fast_input_link")[0].href = link_list[1];
// XXX JQuery mobile
$(panel).trigger("create");
}); });
}).ready(function(g) { }).ready(function(g) {
var jio_gadget; var jio_gadget;
...@@ -80,43 +220,42 @@ ...@@ -80,43 +220,42 @@
}).push(function(evt) { }).push(function(evt) {
g.props.configuration_dict = JSON.parse(evt.target.responseText); g.props.configuration_dict = JSON.parse(evt.target.responseText);
}); });
}).ready(function(g) {
if (navigation_template === undefined) {
// XXX Only works as root gadget
var source = document.getElementById("navigation-template").innerHTML;
navigation_template = Handlebars.compile(source);
}
}).declareMethod("render", function(options) { }).declareMethod("render", function(options) {
var gadget = this, page_gadget, element = gadget.props.element.getElementsByClassName("gadget_container")[0]; var gadget = this, page_gadget, portal_type = "Input Module", nav_element = gadget.props.element.getElementsByClassName("nav_container")[0], element = gadget.props.element.getElementsByClassName("gadget_container")[0];
options.configuration_dict = gadget.props.configuration_dict; if (options.action === undefined) {
if (options.page === undefined) { // Redirect to the view action
// Redirect to the about page options.action = "view";
return gadget.aq_pleasePublishMyState({ return gadget.aq_pleasePublishMyState(options).push(gadget.pleaseRedirectMyHash.bind(gadget));
page: "InputModule_viewInputList"
}).push(gadget.pleaseRedirectMyHash.bind(gadget));
} }
return gadget.declareGadget(options.page + ".html").push(function(g) { // Detect what is the kind of document displayed
if (options.id !== undefined) {
if (options.result === undefined) {
portal_type = "Input";
} else {
portal_type = "Output";
}
}
// Get the action informations
return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html").push(function(g) {
page_gadget = g; page_gadget = g;
if (page_gadget.render !== undefined) { if (page_gadget.render !== undefined) {
return page_gadget.render(options); return page_gadget.render(options);
} }
}).push(function() { }).push(function() {
var navigation_list = []; return RSVP.all([ page_gadget.getElement(), calculateNavigationHTML(gadget, portal_type, options) ]);
if (page_gadget.getNavigationList !== undefined) {
navigation_list = page_gadget.getNavigationList();
}
return RSVP.all([ page_gadget.getTitle(), page_gadget.getElement(), navigation_list ]);
}).push(function(result_list) { }).push(function(result_list) {
var title = result_list[0], page_element = result_list[1], navigation_list = result_list[2], panel = gadget.props.element.querySelector("#leftpanel"); var nav_html = result_list[1], page_element = result_list[0];
gadget.props.element.querySelector("header h1").textContent = title; // Update title
while (panel.firstChild) { gadget.props.element.querySelector("header h1").textContent = portal_type;
panel.removeChild(panel.firstChild); // Update the navigation panel
// Clear the previous rendering
while (nav_element.firstChild) {
nav_element.removeChild(nav_element.firstChild);
}
if (nav_html !== undefined) {
nav_element.innerHTML = nav_html;
$(nav_element).trigger("create");
} }
panel.innerHTML = navigation_template({
navigationlist: navigation_list
});
// XXX JQuery mobile
$(panel).trigger("create");
// Append in the DOM at the end to reduce flickering and reduce DOM // Append in the DOM at the end to reduce flickering and reduce DOM
// modifications // modifications
// Clear the previous rendering // Clear the previous rendering
......
...@@ -2,14 +2,25 @@ ...@@ -2,14 +2,25 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<!--link rel="stylesheet" href="lib/jquery-ui.css"--> <link rel="stylesheet" href="../lib/jquery-ui.css">
<link rel="stylesheet" href="jsplumb.css">
<!--script src="curl.jquery.relative_dest %>"></script-->
<!--script src="curl.jqueryuijs.relative_dest %>"></script-->
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.jsplumb.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js"></script>
<script src="../lib/jquery-ui.js"></script>
<script src="../lib/rsvp.min.js"></script>
<script src="../lib/renderjs.min.js"></script>
<script src="../lib/jquery.jsplumb.min.js"></script>
<script src="../lib/handlebars.min.js"></script>
<script id="node-template" type="text/x-handlebars-template">
<div class="window {{class}}"
id="{{element_id}}"
title="{{title}}">
{{id}}
<div class="ep"></div>
</div>
</script>
<script src="jsplumb.js"></script> <script src="jsplumb.js"></script>
</head> </head>
<body> <body>
......
#main{position:relative;margin:20px auto;font-size:80%;border:1px solid #999;width:100%;height:600px;overflow:hidden;border-radius:10px;background-color:#eaedef;text-align:center}.selected{color:#bd0b0b!important}.window,.label{background-color:#fff;text-align:center;z-index:23;cursor:pointer;box-shadow:2px 2px 19px #aaa;-o-box-shadow:2px 2px 19px #aaa;-webkit-box-shadow:2px 2px 19px #aaa;-moz-box-shadow:2px 2px 19px #aaa}path,._jsPlumb_endpoint{cursor:pointer}._jsPlumb_endpoint_drop_allowed{border:4px solid #123456;box-shadow:6px 6px 19px #444;-o-box-shadow:6px 6px 19px #444;-webkit-box-shadow:6px 6px 19px #444;-moz-box-shadow:6px 6px 19px #444}._jsPlumb_connector{z-index:18}._jsPlumb_endpoint{z-index:19}._jsPlumb_overlay{z-index:23}._jsPlumb_connector._jsPlumb_hover{z-index:21!important}._jsPlumb_endpoint._jsPlumb_hover{z-index:22!important}._jsPlumb_overlay{border:1px solid #346789;opacity:.8;filter:alpha(opacity=80);background-color:#fff;color:#000;font-family:helvetica;padding:.5em}.Dream-Source,.Dream-BatchSource{border:1px solid #bbc;background-color:#ffe;background-image:linear-gradient(to bottom,#ffe 0,#dde 100%)}.Dream-Machine,.Dream-MachineJobShop,.Dream-BatchScrapMachine,.Dream-MachineManagedJob,.Dream-MouldAssembly{border:1px solid #cbc;background-color:#fef;background-image:linear-gradient(to bottom,#fef 0,#ede 100%)}.Dream-Queue,.Dream-QueueJobShop,.Dream-LineClearance,.Dream-QueueManagedJob,.Dream-ConditionalBuffer,.Dream-OrderDecomposition,.Dream-MouldAssemblyBuffer{border:1px solid #bcc;background-color:#eff;background-image:linear-gradient(to bottom,#eff 0,#dee 100%)}.Dream-Exit,.Dream-ExitJobShop{border:1px solid #ccb;background-color:#eef;background-image:linear-gradient(to bottom,#eef 0,#dde 100%)}.Dream-EventGenerator{border:1px solid #cba;background-color:#fdc;background-image:linear-gradient(to bottom,#fdc 0,#ecb 100%)}.Dream-BatchDecomposition,.Dream-BatchDecompositionStartTime,.Dream-BatchReassembly{border:1px solid #bcb;background-color:#dfd;background-image:linear-gradient(to bottom,#dfd 0,#cec 100%)}.Dream-Repairman{border:1px solid #cbb;background-color:#fdd;background-image:linear-gradient(to bottom,#fdd 0,#dcc 100%)}.window,.dummy_window{border:1px solid #d3d3d3;width:100px;height:64px;position:absolute;color:#000;font-family:serif;font-style:italic;padding-top:.9em;font-size:.9em;cursor:move;font-size:11px;-webkit-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;transition:background-color .1s ease-in;border-radius:5px}.window:hover{background-color:#5c96bc;background-image:none;color:#fff}.dummy_window{position:absolute;top:0;left:0;visibility:hidden}.ep{position:absolute;bottom:37%;right:5px;width:1em;height:1em;background-color:orange;cursor:pointer;box-shadow:0 0 2px #000;-webkit-transition:-webkit-box-shadow .25s ease-in;-moz-transition:-moz-box-shadow .25s ease-in;transition:box-shadow .25s ease-in}._jsPlumb_source_hover,._jsPlumb_target_hover,.dragHover{background-color:#1e8151;background-image:none;color:#fff}path{cursor:pointer}
\ No newline at end of file
...@@ -15,391 +15,100 @@ ...@@ -15,391 +15,100 @@
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with DREAM. If not, see <http://www.gnu.org/licenses/>. * along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* ======================================================================== */ * ==========================================================================*/
/*global jsPlumb, rJS, RSVP */ /*global RSVP, rJS, $, jsPlumb, Handlebars*/
/*jslint maxlen: 200 */ (function(RSVP, rJS, $, jsPlumb, Handlebars) {
(function(jsPlumb, rJS, RSVP) {
"use strict"; "use strict";
// var that = {}, priv = {}, gadget_element; /*jslint nomen: true*/
// var gadget_klass = rJS(window), node_template_source = gadget_klass.__template_element.getElementById("node-template").innerHTML, node_template = Handlebars.compile(node_template_source);
// that.getNodeId = function (element_id) { function getNodeId(node_container, element_id) {
// var node_id; var node_id;
// $.each(priv.node_container, function (k, v) { $.each(node_container, function(k, v) {
// if (v.element_id === element_id) { if (v.element_id === element_id) {
// node_id = k; node_id = k;
// return false; return false;
// } }
// }); });
// return node_id; return node_id;
// }; }
// function getElementId(node_container, node_id) {
// that.getElementId = function (node_id) { return node_container[node_id].element_id;
// return priv.node_container[node_id].element_id; }
// }; // function generateNodeId(node_container, element_type, option) {
// // var n = 1;
// that.generateNodeId = function (element_type, option) { // while (node_container[
// var n = 1; // ((option.short_id || element_type) + n)
// while (((option.short_id || element_type) + n) in priv.node_container) { // ] !== undefined) {
// n += 1; // n += 1;
// } // }
// return (option.short_id || element_type) + n; // return (option.short_id || element_type) + n;
// }; // }
// // function generateElementId(gadget_element) {
// that.generateElementId = function () { // var n = 1;
// var n = 1; // while ($(gadget_element).find('#DreamNode_' + n).length > 0) {
// while ($(gadget_element).find('#DreamNode_' + n).length > 0) { // n += 1;
// n += 1; // }
// } // return 'DreamNode_' + n;
// return 'DreamNode_' + n; // }
// }; function onDataChange() {
// //$.publish("Dream.Gui.onDataChange", g.private.getData());
// priv.initJsPlumb = function () { return undefined;
// jsPlumb.setRenderMode(jsPlumb.SVG); }
// jsPlumb.importDefaults({ function convertToAbsolutePosition(gadget, x, y) {
// HoverPaintStyle: { var zoom_level = (gadget.private.preference_container.zoom_level || 1) * 1.1111, canvas_size_x = $(gadget.private.element).find("#main").width(), canvas_size_y = $(gadget.private.element).find("#main").height(), size_x = $(gadget.private.element).find(".dummy_window").width() * zoom_level, size_y = $(gadget.private.element).find(".dummy_window").height() * zoom_level, top = Math.floor(y * (canvas_size_y - size_y)) + "px", left = Math.floor(x * (canvas_size_x - size_x)) + "px";
// strokeStyle: "#1e8151", return [ left, top ];
// lineWidth: 2 }
// }, function convertToRelativePosition(gadget, x, y) {
// Endpoint: ["Dot", { var zoom_level = (gadget.private.preference_container.zoom_level || 1) * 1.1111, canvas_size_x = $(gadget.private.element).find("#main").width(), canvas_size_y = $(gadget.private.element).find("#main").height(), size_x = $(gadget.private.element).find(".dummy_window").width() * zoom_level, size_y = $(gadget.private.element).find(".dummy_window").height() * zoom_level, top = Math.max(Math.min(y.replace("px", "") / (canvas_size_y - size_y), 1), 0), left = Math.max(Math.min(x.replace("px", "") / (canvas_size_x - size_x), 1), 0);
// radius: 2 return [ left, top ];
// }], }
// ConnectionOverlays: [ function updateElementCoordinate(gadget, node_id, coordinate) {
// ["Arrow", { var element_id = gadget.private.node_container[node_id].element_id, coordinates = gadget.private.preference_container.coordinates || {}, element, relative_position;
// location: 1, if (coordinate === undefined) {
// id: "arrow", coordinate = {};
// length: 14, element = $(gadget.private.element).find("#" + element_id);
// foldback: 0.8 relative_position = convertToRelativePosition(gadget, element.css("left"), element.css("top"));
// }] coordinate.top = relative_position[1];
// ], coordinate.left = relative_position[0];
// Container: "main" }
// }); coordinates[node_id] = coordinate;
// // listen for clicks on connections, and offer to change values on click. gadget.private.preference_container.coordinates = coordinates;
// jsPlumb.bind("click", function (conn) { onDataChange();
// jsPlumb.detach(conn); return coordinate;
// }); }
// function draggable(gadget) {
// jsPlumb.bind("beforeDetach", function (conn) { var jsplumb_instance = gadget.private.jsplumb_instance, stop = function(element) {
// return confirm("Delete connection?"); updateElementCoordinate(gadget, getNodeId(gadget.private.node_container, element.target.id));
// }); };
// jsplumb_instance.draggable(jsplumb_instance.getSelector(".window"), {
// jsPlumb.bind("connectionDrag", function (connection) {}); containment: "parent",
// grid: [ 10, 10 ],
// jsPlumb.bind("connectionDragStop", function (connection) {}); stop: stop
// // split in 2 methods ? one for events one for manip });
// that.updateConnectionData = function (connection, remove, edge_data) { jsplumb_instance.makeSource(jsplumb_instance.getSelector(".window"), {
// if (remove) { filter: ".ep",
// delete(priv.edge_container[connection.id]); anchor: "Continuous",
// } else { connector: [ "StateMachine", {
// priv.edge_container[connection.id] = [ curviness: 20
// that.getNodeId(connection.sourceId), } ],
// that.getNodeId(connection.targetId), edge_data || {} connectorStyle: {
// ]; strokeStyle: "#5c96bc",
// } lineWidth: 2,
// priv.onDataChange(); outlineColor: "transparent",
// }; outlineWidth: 4
// }
// // bind to connection/connectionDetached events, and update the list of connections on screen. });
// jsPlumb.bind("connection", function (info, originalEvent) { jsplumb_instance.makeTarget(jsplumb_instance.getSelector(".window"), {
// that.updateConnectionData(info.connection); dropOptions: {
// }); hoverClass: "dragHover"
// jsPlumb.bind("connectionDetached", function (info, originalEvent) { },
// that.updateConnectionData(info.connection, true); anchor: "Continuous"
// }); });
// priv.onDataChange(); }
// priv.draggable(); function initJsPlumb(gadget) {
// }; var jsplumb_instance = gadget.private.jsplumb_instance;
// jsplumb_instance.setRenderMode(jsplumb_instance.SVG);
// priv.updateElementCoordinate = function (node_id, coordinate) { jsplumb_instance.importDefaults({
// var element_id = priv.node_container[node_id].element_id;
// var coordinates = priv.preference_container['coordinates'] || {}, element;
// if (coordinate === undefined) {
// coordinate = {};
// element = $(gadget_element).find("#" + element_id);
// var relative_position = that.convertToRelativePosition(
// element.css('left'), element.css('top'));
// coordinate.top = relative_position[1];
// coordinate.left = relative_position[0];
// }
// coordinates[node_id] = coordinate;
// priv.preference_container['coordinates'] = coordinates;
// priv.onDataChange();
// return coordinate;
// };
//
// priv.updateNodeStyle = function (element_id) {
// var zoom_level = (priv.preference_container['zoom_level'] || 1.0) * 1.1111;
// var element = $(gadget_element).find("#" + element_id);
// console.log(gadget_element);
// $.each(priv.style_attr_list, function (i, j) {
// var new_value = $(gadget_element).find('.dummy_window').css(j).replace('px', '') * zoom_level + 'px';
// element.css(j, new_value);
// });
// };
//
// priv.convertToAbsolutePosition = function (x, y) {
// var zoom_level = (priv.preference_container['zoom_level'] || 1.0) * 1.1111;
// var canvas_size_x = $(gadget_element).find('#main').width();
// var canvas_size_y = $(gadget_element).find('#main').height();
// var size_x = $(gadget_element).find('.dummy_window').width() * zoom_level;
// var size_y = $(gadget_element).find('.dummy_window').height() * zoom_level;
// var top = Math.floor(y * (canvas_size_y - size_y)) + "px";
// var left = Math.floor(x * (canvas_size_x - size_x)) + "px";
// return [left, top];
// };
//
// that.convertToRelativePosition = function (x, y) {
// var zoom_level = (priv.preference_container['zoom_level'] || 1.0) * 1.1111;
// var canvas_size_x = $(gadget_element).find('#main').width();
// var canvas_size_y = $(gadget_element).find('#main').height();
// var size_x = $(gadget_element).find('.dummy_window').width() * zoom_level;
// var size_y = $(gadget_element).find('.dummy_window').height() * zoom_level;
// var top = Math.max(Math.min(y.replace('px', '') / (canvas_size_y - size_y), 1), 0);
// var left = Math.max(Math.min(x.replace('px', '') / (canvas_size_x - size_x), 1), 0);
// return [left, top];
// };
// priv.draggable = function () {
// var stop = function (element) {
// priv.updateElementCoordinate(that.getNodeId(element.target.id));
// };
//
// jsPlumb.draggable(jsPlumb.getSelector(".window"), {
// containment: 'parent',
// grid: [10, 10],
// stop: stop // FIXME: we should only accept if dropped in #main
// });
//
// jsPlumb.makeSource(jsPlumb.getSelector(".window"), {
// filter: ".ep",
// anchor: "Continuous",
// connector: ["StateMachine", {
// curviness: 20
// }],
// connectorStyle: {
// strokeStyle: "#5c96bc",
// lineWidth: 2,
// outlineColor: "transparent",
// outlineWidth: 4
// }
// });
//
// jsPlumb.makeTarget(jsPlumb.getSelector(".window"), {
// dropOptions: {
// hoverClass: "dragHover"
// },
// anchor: "Continuous"
// });
//
// };
// priv.addElementToContainer = function (element) {
// // Now update the container of elements
// var element_data = {
// _class: element._class,
// element_id: element.element_id,
// };
// priv.node_container[element.id] = element_data;
// };
// priv.onDataChange = function () {
// //$.publish("Dream.Gui.onDataChange", priv.getData());
// };
// priv.style_attr_list = ['width', 'height', 'padding-top', 'line-height'];
// that.positionGraph = function () {
// $.ajax(
// '/positionGraph', {
// data: JSON.stringify(priv.getData()),
// contentType: 'application/json',
// type: 'POST',
// success: function (data, textStatus, jqXHR) {
// $.each(data, function (node, pos) {
// var absolute_position = priv.convertToAbsolutePosition(
// pos.left, pos.top);
// priv.updateElementCoordinate(node, {
// top: pos.top,
// left: pos.left
// });
// });
// that.redraw();
// }
// });
//
// };
// that.setZoom = function (zoom_level) {
// $.each(priv.style_attr_list, function (i, j) {
// var new_value = $(gadget_element).find('.dummy_window').css(j).replace('px', '') * zoom_level + 'px';
// $(gadget_element).find('.window').css(j, new_value);
// });
// };
//
// that.zoom_in = function () {
// var zoom_level = (priv.preference_container['zoom_level'] || 1.0) * 1.1111;
// that.setZoom(zoom_level);
// priv.preference_container['zoom_level'] = zoom_level;
// priv.onDataChange();
// that.redraw();
// };
//
// that.zoom_out = function () {
// var zoom_level = (priv.preference_container['zoom_level'] || 1.0) * 0.9;
// that.setZoom(zoom_level);
// priv.preference_container['zoom_level'] = zoom_level;
// priv.onDataChange();
// that.redraw();
// };
//
// that.redraw = function () {
// var coordinates = priv.preference_container['coordinates'] || {};
// $.each(coordinates, function (node_id, v) {
// var absolute_position = priv.convertToAbsolutePosition(
// v['left'], v['top']);
// var element = $(gadget_element).find('#' + that.getElementId(node_id));
// element.css('top', absolute_position[1]);
// element.css('left', absolute_position[0]);
// jsPlumb.repaint(element);
// });
// };
//
// priv.getData = function () {
// var data = {
// "nodes": priv.node_container,
// "edges": priv.edge_container,
// "preference": priv.preference_container,
// "general": priv.general_container
// };
// var wip_spreadsheet = $(gadget_element).find('#wip_spreadsheet');
// if (wip_spreadsheet.length > 0) {
// data['wip_spreadsheet'] = wip_spreadsheet.handsontable('getData');
// }
// var wip_part_spreadsheet = $(gadget_element).find('#wip_part_spreadsheet');
// if (wip_part_spreadsheet.length > 0) {
// data['wip_part_spreadsheet'] = wip_part_spreadsheet.handsontable('getData');
// }
// var shift_spreadsheet = $(gadget_element).find('#shift_spreadsheet');
// if (shift_spreadsheet.length > 0) {
// data['shift_spreadsheet'] = shift_spreadsheet.handsontable('getData');
// }
// return data;
// };
// priv.removeElement = function (node_id) {
// var element_id = priv.node_container[node_id].element_id;
// jsPlumb.removeAllEndpoints($(gadget_element).find("#" + element_id));
// $(gadget_element).find("#" + element_id).remove();
// delete(priv.node_container[node_id]);
// delete(priv.preference_container['coordinates'][node_id]);
// $.each(priv.edge_container, function (k, v) {
// if (node_id == v[0] || node_id == v[1]) {
// delete(priv.edge_container[k]);
// }
// });
// priv.onDataChange();
// };
//
// that.updateElementData = function (node_id, data) {
// var element_id = priv.node_container[node_id].element_id;
// if (data['name']) {
// $(gadget_element).find("#" + element_id).text(data["name"]).append('<div class="ep"></div></div>');
// priv.node_container[node_id].name = data['name'];
// }
// var new_id = data['id'];
// delete(data['id']);
// $.extend(priv.node_container[node_id], data.data);
// if (new_id && new_id !== node_id) {
// priv.node_container[new_id] = priv.node_container[node_id];
// delete(priv.node_container[node_id]);
// $.each(priv.edge_container, function (k, v) {
// if (v[0] === node_id) {
// v[0] = new_id;
// }
// if (v[1] === node_id) {
// v[1] = new_id;
// }
// });
// priv.preference_container['coordinates'][new_id] = priv.preference_container['coordinates'][node_id];
// delete(priv.preference_container['coordinates'][node_id]);
// }
// priv.onDataChange();
// };
//
// that.removeElement = function (node_id) {
// priv.removeElement(node_id);
// };
//
// that.getData = function () {
// return priv.getData();
// };
//
// that.clearAll = function () {
// $.each(priv.node_container, function (node_id) {
// priv.removeElement(node_id);
// });
// // delete anything if still remains
// $(gadget_element).find("#main").children().remove();
// priv.node_container = {};
// priv.edge_container = {};
// priv.preference_container = {};
// priv.general_container = {};
// that.initGeneralProperties();
// that.prepareDialogForGeneralProperties();
// };
// that.addEdge = function (edge_id, edge_data) {
// var source_id = edge_data[0],
// target_id = edge_data[1],
// data = edge_data[2],
// overlays = []
//
// if (data && data.title){
// overlays = [ ["Label", { cssClass:"l1 component label",
// label: data.title,
// }] ]
//
// }
// var connection = jsPlumb.connect({
// source: that.getElementId(source_id),
// target: that.getElementId(target_id),
// Connector: [ "Bezier", { curviness:75 } ],
// overlays:overlays
//
// });
// // call again updateConnectionData to set the connection data that
// // was not passed to the connection hook
// that.updateConnectionData(connection, 0, data)
// };
//
// that.setPreferences = function (preferences) {
// priv.preference_container = preferences;
// var zoom_level = priv.preference_container['zoom_level'] || 1.0;
// that.setZoom(zoom_level);
// };
// that.setGeneralProperties = function (properties) {
// priv.general_container = properties;
// priv.onDataChange();
// };
//
// that.updateGeneralProperties = function (properties) {
// $.extend(priv.general_container, properties);
// priv.onDataChange();
// };
// that.newElement = function (element, option) {
// element.name = element.name || option.name;
// priv.addElementToContainer(element);
// var render_element, style_string = "",
// coordinate = element.coordinate,
// box;
// render_element = $(gadget_element).find("#main");
// if (coordinate !== undefined) {
// coordinate = priv.updateElementCoordinate(element.id, coordinate);
// }
// render_element.append('<div class="window ' + element._class.replace('.', '-') + '" id="' +
// element.element_id + '" title="' + (element.name || element.id) + '">' + element.id + '<div class="ep"></div></div>');
// box = $(gadget_element).find("#" + element.element_id);
// var absolute_position = priv.convertToAbsolutePosition(
// coordinate.left, coordinate.top);
// box.css("top", absolute_position[1]);
// box.css("left", absolute_position[0]);
// priv.updateNodeStyle(element.element_id);
// priv.draggable();
// priv.onDataChange();
// };
function initJsPlumb(container) {
var j = jsPlumb.getInstance({
HoverPaintStyle: { HoverPaintStyle: {
strokeStyle: "#1e8151", strokeStyle: "#1e8151",
lineWidth: 2 lineWidth: 2
...@@ -413,31 +122,248 @@ ...@@ -413,31 +122,248 @@
length: 14, length: 14,
foldback: .8 foldback: .8
} ] ], } ] ],
Container: container Container: "main"
});
// listen for clicks on connections,
// and offer to change values on click.
// jsplumb_instance.bind("click", function (conn) {
// jsplumb_instance.detach(conn);
// });
// jsplumb_instance.bind("beforeDetach", function (conn) {
// return confirm("Delete connection?");
// });
// jsplumb_instance
// .bind("connectionDrag", function (connection) {
// return undefined;
// });
// jsplumb_instance
// .bind("connectionDragStop", function (connection) {
// return undefined;
// });
// split in 2 methods ? one for events one for manip
gadget.private.updateConnectionData = function(connection, remove, edge_data) {
if (remove) {
delete gadget.private.edge_container[connection.id];
} else {
gadget.private.edge_container[connection.id] = [ getNodeId(gadget.private.node_container, connection.sourceId), getNodeId(gadget.private.node_container, connection.targetId), edge_data || {} ];
}
onDataChange();
};
// bind to connection/connectionDetached events,
// and update the list of connections on screen.
// jsplumb_instance
// .bind("connection", function (info, originalEvent) {
// gadget.private.updateConnectionData(info.connection);
// });
// jsplumb_instance
// .bind("connectionDetached", function (info, originalEvent) {
// gadget.private.updateConnectionData(info.connection, true);
// });
onDataChange();
draggable(gadget);
}
function updateNodeStyle(gadget, element_id) {
var zoom_level = (gadget.private.preference_container.zoom_level || 1) * 1.1111, element = $(gadget.private.element).find("#" + element_id), new_value;
$.each(gadget.private.style_attr_list, function(i, j) {
new_value = $(gadget.private.element).find(".dummy_window").css(j).replace("px", "") * zoom_level + "px";
element.css(j, new_value);
});
}
function addElementToContainer(node_container, element) {
// Now update the container of elements
/*jslint nomen: true*/
var element_data = {
_class: element._class,
element_id: element.element_id
};
node_container[element.id] = element_data;
}
function redraw(gadget) {
var coordinates = gadget.private.preference_container.coordinates || {}, absolute_position, element;
$.each(coordinates, function(node_id, v) {
absolute_position = convertToAbsolutePosition(gadget, v.left, v.top);
element = $(gadget.private.element).find("#" + getElementId(gadget.private.node_container, node_id));
element.css("top", absolute_position[1]);
element.css("left", absolute_position[0]);
gadget.private.jsplumb_instance.repaint(element);
}); });
j.setRenderMode(jsPlumb.SVG);
return j;
} }
rJS(window).ready(function(g) { // function positionGraph(gadget) {
g.props = { // $.ajax(
// '/positionGraph',
// {
// data: JSON.stringify(getData()),
// contentType: 'application/json',
// type: 'POST',
// success: function (data, textStatus, jqXHR) {
// $.each(data, function (node, pos) {
// convertToAbsolutePosition(
// gadget,
// pos.left,
// pos.top
// );
// updateElementCoordinate(gadget, node, {
// top: pos.top,
// left: pos.left
// });
// });
// redraw(gadget);
// }
// }
// );
// }
// function setZoom(gadget, zoom_level) {
// $.each(gadget.private.style_attr_list, function (i, j) {
// var new_value = $(gadget.private.element).find('.dummy_window')
// .css(j).replace('px', '') * zoom_level + 'px';
// $(gadget.private.element).find('.window').css(j, new_value);
// });
// }
// function zoom_in(gadget) {
// var zoom_level = (gadget.private.preference_container.zoom_level || 1.0) *
// 1.1111;
// setZoom(gadget, zoom_level);
// gadget.private.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(gadget);
// }
// function zoom_out(gadget) {
// var zoom_level = (gadget.private.preference_container.zoom_level || 1.0) *
// 0.9;
// setZoom(gadget, zoom_level);
// gadget.private.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(gadget);
// }
// function removeElement(gadget, node_id) {
// var element_id = gadget.private.node_container[node_id].element_id;
// gadget.private.jsplumb_instance.removeAllEndpoints(
// $(gadget.private.element).find("#" + element_id)
// );
// $(gadget.private.element).find("#" + element_id).remove();
// delete gadget.private.node_container[node_id];
// delete gadget.private.preference_container.coordinates[node_id];
// $.each(gadget.private.edge_container, function (k, v) {
// if (node_id === v[0] || node_id === v[1]) {
// delete gadget.private.edge_container[k];
// }
// });
// onDataChange();
// }
function updateElementData(gadget, node_id, data) {
var element_id = gadget.private.node_container[node_id].element_id, new_id = data.id;
if (data.name) {
$(gadget.private.element).find("#" + element_id).text(data.name).append('<div class="ep"></div></div>');
gadget.private.node_container[node_id].name = data.name;
}
delete data.id;
$.extend(gadget.private.node_container[node_id], data.data);
if (new_id && new_id !== node_id) {
gadget.private.node_container[new_id] = gadget.private.node_container[node_id];
delete gadget.private.node_container[node_id];
$.each(gadget.private.edge_container, function(k, v) {
if (v[0] === node_id) {
v[0] = new_id;
}
if (v[1] === node_id) {
v[1] = new_id;
}
});
gadget.private.preference_container.coordinates[new_id] = gadget.private.preference_container.coordinates[node_id];
delete gadget.private.preference_container.coordinates[node_id];
}
onDataChange();
}
// function clearAll(gadget) {
// $.each(gadget.private.node_container, function (node_id) {
// removeElement(gadget, node_id);
// });
// // delete anything if still remains
// $(gadget.private.element).find("#main").children().remove();
// gadget.private.node_container = {};
// gadget.private.edge_container = {};
// gadget.private.preference_container = {};
// gadget.private.general_container = {};
// gadget.private.initGeneralProperties();
// gadget.private.prepareDialogForGeneralProperties();
// }
function addEdge(gadget, edge_id, edge_data) {
var source_id = edge_data[0], target_id = edge_data[1], data = edge_data[2], overlays = [], connection;
if (data && data.title) {
overlays = [ [ "Label", {
cssClass: "l1 component label",
label: data.title
} ] ];
}
connection = gadget.private.jsplumb_instance.connect({
source: getElementId(gadget.private.node_container, source_id),
target: getElementId(gadget.private.node_container, target_id),
Connector: [ "Bezier", {
curviness: 75
} ],
overlays: overlays
});
// call again updateConnectionData to set the connection data that
// was not passed to the connection hook
gadget.private.updateConnectionData(connection, 0, data);
}
// function setPreferences(gadget, preferences) {
// gadget.private.preference_container = preferences;
// var zoom_level = gadget.private.preference_container.zoom_level || 1.0;
// setZoom(gadget, zoom_level);
// }
// function setGeneralProperties(gadget, properties) {
// gadget.private.general_container = properties;
// onDataChange();
// }
// function updateGeneralProperties(gadget, properties) {
// $.extend(gadget.private.general_container, properties);
// onDataChange();
// }
function newElement(gadget, element, option) {
element.name = element.name || option.name;
addElementToContainer(gadget.private.node_container, element);
var render_element = $(gadget.private.element).find("#main"), coordinate = element.coordinate, box, absolute_position;
if (coordinate !== undefined) {
coordinate = updateElementCoordinate(gadget, element.id, coordinate);
}
/*jslint nomen: true*/
render_element.append(node_template({
"class": element._class.replace(".", "-"),
element_id: element.element_id,
title: element.name || element.id,
id: element.id
}));
box = $(gadget.private.element).find("#" + element.element_id);
absolute_position = convertToAbsolutePosition(gadget, coordinate.left, coordinate.top);
box.css("top", absolute_position[1]);
box.css("left", absolute_position[0]);
updateNodeStyle(gadget, element.element_id);
draggable(gadget);
onDataChange();
}
gadget_klass.ready(function(g) {
g.private = {
node_container: {}, node_container: {},
edge_container: {}, edge_container: {},
preference_container: {}, preference_container: {},
general_container: {} style_attr_list: [ "width", "height", "padding-top", "line-height" ]
}; };
return g.getElement().push(function(element) {
g.props.element = element;
});
}).declareMethod("render", function(data) { }).declareMethod("render", function(data) {
this.props.data = JSON.parse(data); this.private.data = JSON.parse(data);
this.private.jsplumb_instance = jsPlumb.getInstance();
}).declareMethod("getData", function() {
return JSON.stringify({
nodes: this.private.node_container,
edges: this.private.edge_container,
preference: this.private.preference_container
});
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var gadget = this, // Create jsPlumb instance var gadget = this, preference = gadget.private.data.preference !== undefined ? gadget.private.data.preference : {}, coordinates = preference.coordinates;
// jsplumb = initJsPlumb(gadget.props.element), return gadget.getElement().then(function(el) {
preference = gadget.props.data.preference || {}, coordinates = preference.coordinates, key, value; gadget.private.element = el;
initJsPlumb(gadget.props.element); initJsPlumb(gadget);
for (key in gadget.props.data.nodes) { $.each(gadget.private.data.nodes, function(key, value) {
if (gadget.props.data.nodes.hasOwnProperty(key)) {
value = gadget.props.data.nodes[key];
if (coordinates === undefined || coordinates[key] === undefined) { if (coordinates === undefined || coordinates[key] === undefined) {
value.coordinate = { value.coordinate = {
top: 0, top: 0,
...@@ -447,12 +373,18 @@ ...@@ -447,12 +373,18 @@
value.coordinate = coordinates[key]; value.coordinate = coordinates[key];
} }
value.id = key; value.id = key;
} newElement(gadget, value);
} if (value.data) {
for (key in gadget.props.data.edges) { // backward compatibility
if (gadget.props.data.edges.hasOwnProperty(key)) { updateElementData(gadget, key, {
value = gadget.props.data.edges[key]; data: value.data
} });
} }
});
$.each(gadget.private.data.edges, function(key, value) {
addEdge(gadget, key, value);
});
redraw(gadget);
});
}); });
})(jsPlumb, rJS, RSVP); })(RSVP, rJS, $, jsPlumb, Handlebars);
\ No newline at end of file \ 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