Commit 5dbbe938 authored by Jérome Perrin's avatar Jérome Perrin

publish static version

parent 884247aa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Create Document</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="Input_viewAttachDocument.js" type="text/javascript"></script>
</head>
<body>
<form class="attach_document">
<input type="file" required="" name="import_file">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right">Attach Document</button>
</form>
</body>
</html>
\ No newline at end of file
/*global rJS, RSVP, promiseEventListener, promiseReadAsDataURL,
initGadgetMixin */
(function(window, rJS, RSVP, promiseEventListener, promiseReadAsDataURL, initGadgetMixin) {
"use strict";
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("startService", function() {
var gadget = this, encoded_data, button;
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("attach_document")[0], "submit", false);
}).push(function(evt) {
button = evt.target.getElementsByClassName("ui-btn")[0];
button.disabled = true;
var file = evt.target.import_file.files[0];
return promiseReadAsDataURL(file);
}).push(function(filecontent) {
encoded_data = filecontent;
// get fresh version
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(jio_data) {
var data = JSON.parse(jio_data);
data.input[gadget.props.action_definition.input_id] = encoded_data;
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data)
});
}).push(function() {
button.disabled = false;
});
}).declareMethod("render", function(options) {
this.props.jio_key = options.id;
this.props.action_definition = options.action_definition;
});
})(window, rJS, RSVP, promiseEventListener, promiseReadAsDataURL, initGadgetMixin);
\ No newline at end of file
......@@ -4,16 +4,18 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Debug JSON</title>
<link rel="stylesheet" href="../lib/codemirror.css"></link>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/codemirror-compressed.js" type="text/javascript"></script>
<script src="../lib/jsonlint.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="Input_viewDebugJson.js" type="text/javascript"></script>
</head>
<body>
<div xdata-gadget-url="https://softinst52398.node.vifib.com/gadget_codemirror.html"
data-gadget-scope="editor"
data-gadget-sandbox="iframe"></div>
<label for="json">JSON</label>
<a class="save_button ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Save</a>
<textarea spellcheck="false" rows="20" name="json" class="json"></textarea>
</body>
</html>
/*global rJS, initGadgetMixin */
(function(window, rJS, initGadgetMixin) {
/*global rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror */
(function(window, rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror) {
"use strict";
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("startService", function() {
var gadget = this;
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.querySelector(".save_button"), "click", false);
}).push(function() {
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: gadget.props.codemirror.getValue()
});
});
}).declareMethod("render", function(options) {
var gadget = this;
this.props.jio_key = options.id;
this.props.result = options.result;
......@@ -11,8 +22,28 @@
_id: gadget.props.jio_key,
_attachment: "body.json"
}).push(function(result_json) {
var document = JSON.parse(result_json);
gadget.props.element.querySelector(".json").textContent = JSON.stringify(document, undefined, " ");
var jsonTextArea = gadget.props.element.querySelector(".json"), document = JSON.parse(result_json);
jsonTextArea.textContent = JSON.stringify(document, undefined, " ");
gadget.props.codemirror = CodeMirror.fromTextArea(jsonTextArea, {
lineNumbers: true,
mode: {
name: "javascript",
json: true
},
foldGutter: true,
lint: true,
gutters: [ "CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers" ],
extraKeys: {
"Ctrl-S": function(instance) {
// XXX this is outside of promise chain.
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: instance.getValue()
});
}
}
});
});
});
})(window, rJS, initGadgetMixin);
\ No newline at end of file
})(window, rJS, promiseEventListener, initGadgetMixin, RSVP, CodeMirror);
\ No newline at end of file
......@@ -46,23 +46,23 @@
gadget.props.jio_key = jio_key;
// view_##### is the formulatino of the names
gadget.props.name = options.action.substr(5, options.action.length);
// Use input_id from action definition
if (options.action_definition.configuration.input_id) {
gadget.props.name = options.action_definition.configuration.input_id;
}
gadget.props.configuration = options.action_definition.configuration;
return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key,
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
var i, content, result = JSON.parse(result_list[0]), config = result.application_configuration.input;
var content, result = JSON.parse(result_list[0]);
// if there are previously stored data in input for this sprSheet
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
// otherwise use the clean configuration
for (i = 0; i <= Object.keys(config).length; i += 1) {
if (Object.keys(config)[i] === options.action) {
content = config[options.action].configuration.columns;
}
}
content = options.action_definition.configuration.columns;
}
// application_configuration.input.view_???_spreasheet.configuration
return result_list[1].render(JSON.stringify(content), {
......
......@@ -39,6 +39,8 @@
<a href="javascript: location.reload()">Click here to reload the page</a><br/>
The error detail is:
<pre>{{error}}</pre>
<br/>Stack Trace is:
<pre>{{error_stack}}</pre>
</script>
</head>
......
......@@ -25,101 +25,6 @@
type: "object_fast_input",
title: "Create Document"
}
},
// TODO: remove this once everything is merged.
Input: {
view: {
gadget: "Input_viewProductionLine",
type: "object_view",
title: "Production Line"
},
view_wip_part_spreadsheet: {
gadget: "Input_viewWipPartSpreadsheet",
type: "object_view",
title: "WIP Part Spreadsheet"
},
view_shift_spreadsheet: {
gadget: "Input_viewShiftSpreadsheet",
type: "object_view",
title: "Shift Spreadsheet"
},
view_available_capacity_spreadsheet: {
gadget: "Input_viewAvailableCapacitySpreadsheet",
type: "object_view",
title: "Available Capacity Spreadsheet"
},
view_required_capacity_spreadsheet: {
gadget: "Input_viewRequiredCapacitySpreadsheet",
type: "object_view",
title: "Required Capacity Spreadsheet"
},
view_dp_capacity_spreadsheet: {
gadget: "Input_viewDemandPlanningCapacitySpreadsheet",
type: "object_view",
title: "Demand Planning Required Capacity Spreadsheet"
},
view_dp_route_spreadsheet: {
gadget: "Input_viewDemandPlanningRouteSpreadsheet",
type: "object_view",
title: "Demand Planning Route Spreadsheet"
},
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"
},
download_excel_spreadsheet: {
gadget: "Output_viewDownloadExcelSpreadsheet",
type: "object_view",
title: "Download Excel Spreadsheet"
},
view_capacity_utilization: {
gadget: "Output_viewCapacityUtilisationGraph",
type: "object_view",
title: "Capacity 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, error_template, gadget_klass = rJS(window);
function calculateTabHTML(gadget, options, key, title, active) {
......@@ -358,6 +263,7 @@
portal_types.Input = data.application_configuration.input;
portal_types.Output = data.application_configuration.output;
}
options.action_definition = portal_types[portal_type][options.action];
// Get the action information
return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html");
}).push(function(g) {
......@@ -405,7 +311,8 @@
}
console.error(error.stack);
document.querySelector("article[class='gadget_container']").innerHTML = error_template({
error: error
error: error,
error_stack: error.stack
});
});
});
......
......@@ -72,4 +72,16 @@
reader.readAsText(file);
});
};
window.promiseReadAsDataURL = function(file) {
return new RSVP.Promise(function(resolve, reject) {
var reader = new FileReader();
reader.onload = function(evt) {
resolve(evt.target.result);
};
reader.onerror = function(evt) {
reject(evt);
};
reader.readAsDataURL(file);
});
};
})(window, RSVP, FileReader);
\ No newline at end of file
......@@ -149,14 +149,6 @@
gadget.props.element.children[2].style.display = "none";
}
}
function handleSelectChange() {
try {
return _handleSelectChange.bind(this)();
} catch (e) {
console.log("ERROR in handleSelectChange", e);
console.log(e.stack);
}
}
function _handleSelectChange() {
//evt) {
console.log("UPDATING FIELDS DUE TO SELECTION CHANGE");
......@@ -183,6 +175,14 @@
}
syncField(gadget);
}
function handleSelectChange() {
try {
return _handleSelectChange.bind(this)();
} catch (e) {
console.log("ERROR in handleSelectChange", e);
console.log(e.stack);
}
}
function waitForListFieldSelection(gadget) {
var element = gadget.props.element.getElementsByTagName("select")[0];
console.log("INITIATING A LOOP EVENT LISTENER FOR OPTION CHANGE");
......
......@@ -25,7 +25,7 @@
name: property_definition.name || property_definition.description || property_id
}));
// use expandable field if we have a oneOf in the schema
if (property_definition.oneOf) {
if (property_definition.oneOf && property_definition.properties && Object.keys(property_definition.properties).length === 1) {
property_definition = {
allOf: [ {
properties: property_definition.properties
......
......@@ -303,7 +303,7 @@
// references
// XXX this should probably be moved to fieldset ( and not handle
// class_definition here)
var referenced, i, property, class_definition = clone(class_definition), expanded_class_definition = clone(class_definition) || {};
var referenced, i, property, expanded_class_definition = clone(class_definition) || {};
if (!expanded_class_definition.properties) {
expanded_class_definition.properties = {};
}
......@@ -563,7 +563,14 @@
function resolver(resolve, reject) {
callback = function(evt) {
try {
var class_name = JSON.parse(evt.dataTransfer.getData("text")), offset = $(gadget.props.main).offset(), relative_position = convertToRelativePosition(gadget, evt.clientX - offset.left + "px", evt.clientY - offset.top + "px");
var class_name, offset = $(gadget.props.main).offset(), relative_position = convertToRelativePosition(gadget, evt.clientX - offset.left + "px", evt.clientY - offset.top + "px");
try {
// html5 compliant browser
class_name = JSON.parse(evt.dataTransfer.getData("application/json"));
} catch (e) {
// internet explorer
class_name = JSON.parse(evt.dataTransfer.getData("text"));
}
addNode(gadget, generateNodeId(gadget, {
_class: class_name
}), {
......
......@@ -150,7 +150,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("text", type, "The drag&dropped element must have data type text");
equal("application/json", type, "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......@@ -397,7 +397,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("text", type, "The drag&dropped element must have data type text");
equal("application/json", type, "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......@@ -471,7 +471,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("text", type, "The drag&dropped element must have data type text");
equal("application/json", type, "The drag&dropped element must have data type application/json");
return JSON.stringify("Example.Node");
}
};
......
......@@ -14,7 +14,16 @@
function itsANonResolvableTrap(resolve, reject) {
callback = function(evt) {
try {
// Internet explorer only accepts text and URI as types for dataTranser
// but firefox will replace location.href with the data if type is set to
// text or URI. We try to use application/json as type, and if it fails
// fallback to text.
try {
// IE will raise an error setting this.
evt.dataTransfer.setData("application/json", tool.dataset.class_name);
} catch (e) {
evt.dataTransfer.setData("text", tool.dataset.class_name);
}
} catch (e) {
reject(e);
}
......
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