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

Display simulation parameters.

parent 90bf2510
......@@ -32,9 +32,6 @@
<a id="run_knowledge_extraction">
<i class="fa fa-spinner fa-spin" id="ke_loading_spinner" style="display:none"></i>
Run Knowledge Extraction</a>
<a id="run_simulation">
<i class="fa fa-spinner fa-spin" id="loading_spinner" style="display:none"></i>
Run Simulation</a>
</div>
</div>
......@@ -45,17 +42,6 @@
</div>
<div class="container">
<div class="four columns">
<div id="simulation_controls">
<h4>Simulation Parameters</h4>
<div title="Configure">
<form>
<fieldset id="general-fieldset">
</fieldset>
</form>
</div>
</div>
</div>
<div class="twelve columns">
<div id="wip_part_spreadsheet" style="display: none; overflow: scroll;"></div>
<div id="shift_spreadsheet" style="display: none; overflow: scroll"></div>
......
......@@ -121,27 +121,6 @@
});
};
that.prepareDialogForGeneralProperties = function () {
var fieldset = $("#general-fieldset"),
previous_data = that.getData()['general'],
previous_value = "",
prefix = "General-";
fieldset.children().remove();
$.each(configuration['Dream-Configuration']['property_list'],
function (idx, property) {
if (property._class === "Dream.Property") {
previous_value = previous_data[property.id] || "";
if (previous_value.length > 0 || typeof previous_value == "number") {
previous_value = ' value="' + previous_value + '"';
}
fieldset.append("<label>" + (property.name || property.id) + "</label>" +
'<input title="' + (property.description || '') + '" type="text" name="' + prefix + property.id + '"' +
previous_value + ' id="' + prefix + property.id + '"' +
' class="text ui-widget-content ui-corner-all"/>');
}
});
};
priv.prepareDialogForElement = function (title, element_id) {
// code to allow changing values on connections. For now we assume
// that it is throughput. But we will need more generic code
......@@ -317,6 +296,7 @@
priv.super_start = that.start;
that.start = function () {
// XXX Migrate this part now!
priv.super_start();
priv.displayTool();
priv.initDialog();
......
......@@ -6,13 +6,22 @@
<title>Run Simulation</title>
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.handlebars.relative_dest %>" type="text/javascript"></script>
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<script src="../<%= curl.jquerymobilejs.relative_dest %>" type="text/javascript"></script>
<script id="label-template" type="text/x-handlebars-template">
<label>{{label}}</label>
</script>
<script src="document_page_mixin.js" type="text/javascript"></script>
<script src="run_simulation.js" type="text/javascript"></script>
</head>
<body>
<form>
<fieldset class="simulation_parameters">
</fieldset>
</form>
<form class="run_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Run Simulation</button>
......
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery */
(function (window, rJS, RSVP, initDocumentPageMixin, $) {
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars */
/*jslint nomen: true, maxlen: 200 */
(function (window, rJS, RSVP, initDocumentPageMixin, $, Handlebars) {
"use strict";
function promiseEventListener(target, type, useCapture) {
......@@ -27,7 +28,16 @@
return new RSVP.Promise(resolver, canceller);
}
var gadget_klass = rJS(window);
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// 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);
initDocumentPageMixin(gadget_klass);
gadget_klass
/////////////////////////////////////////////////////////////////
......@@ -60,7 +70,63 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
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;
queue = gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
})
.push(function (json) {
data = JSON.parse(json).general;
});
function addField(property, value) {
var sub_gadget;
queue
.push(function () {
parent_element.insertAdjacentHTML(
'beforeend',
label_template({label: (property.name || property.id)})
);
return gadget.declareGadget("../string_field/index.html");
})
.push(function (gg) {
sub_gadget = gg;
value = data[property.id] || value;
return sub_gadget.render({field_json: {
title: (property.description || ''),
key: property.id,
value: value
}});
})
.push(function () {
return sub_gadget.getElement();
})
.push(function (sub_element) {
parent_element.appendChild(sub_element);
});
}
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;
})
.declareMethod("startService", function () {
......@@ -123,4 +189,4 @@
return gadget.pleaseRedirectMyHash(url);
});
});
}(window, rJS, RSVP, initDocumentPageMixin, jQuery));
}(window, rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars));
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