diff --git a/public/demo/index.html b/public/demo/index.html new file mode 100644 index 0000000..a49dfdb --- /dev/null +++ b/public/demo/index.html @@ -0,0 +1,91 @@ + + + + + + unquote + + + + + + + + + + + + + + + + + + + + diff --git a/public/polymer_components/rocon-button.html b/public/polymer_components/rocon-button.html new file mode 100644 index 0000000..b993804 --- /dev/null +++ b/public/polymer_components/rocon-button.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/public/polymer_components/rocon-text.html b/public/polymer_components/rocon-text.html new file mode 100644 index 0000000..e69de29 diff --git a/rocon_composer_blockly/.gitignore b/rocon_composer_blockly/.gitignore index 2fc929b..3e9dd6c 100644 --- a/rocon_composer_blockly/.gitignore +++ b/rocon_composer_blockly/.gitignore @@ -1,5 +1,6 @@ public/components node_modules -.env +.env* test.js tmp + diff --git a/rocon_composer_blockly/bower.json b/rocon_composer_blockly/bower.json index 3226b4d..d19dbf4 100644 --- a/rocon_composer_blockly/bower.json +++ b/rocon_composer_blockly/bower.json @@ -30,7 +30,9 @@ "highlightjs": "~8.4.0", "vkbeautify-wrapper": "*", "angular-sanitize": "~1.3.10", - "jsonselect": "~0.2.1" + "jsonselect": "~0.2.1", + "polymer": "Polymer/polymer#~0.5.5", + "paper-button": "Polymer/paper-button#~0.5.5" }, "overrides": { "jsonselect": { diff --git a/rocon_composer_blockly/public/bundle.js b/rocon_composer_blockly/public/bundle.js index f76e28f..a57ca62 100644 --- a/rocon_composer_blockly/public/bundle.js +++ b/rocon_composer_blockly/public/bundle.js @@ -1,4 +1,4 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o});')({ + data: "'" + JSON.stringify(data) + "'" + }); + return code; +}; +Blockly.JavaScript['ui_button'] = function(block){ + var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE) || "''"; + var name = block.getFieldValue('NAME'); + + console.log(name); + + var code = _.template('layout.push({type: "button", name: "<%= name %>", text: <%= text %>});')({ + text: text, + name: name + }); + return code; +}; +Blockly.JavaScript['ui_text'] = function(block){ + var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE) || "''"; + var name = block.getFieldValue('NAME'); + + console.log(name); + + var code = _.template('layout.push({type: "text", name: "<%= name %>", text: <%= text %>});')({ + text: text, + name: name + }); + return code; +}; + + +var _componentsMeta = function(block){ + var code = Blockly.JavaScript.statementToCode(block, 'COMPS', Blockly.JavaScript.ORDER_NONE) || "''"; + var meta_tpl = _.template('(function(layout){ <%= code %>; return layout; })([]);'); + var meta = meta_tpl({code: code}); + return JSON.stringify(eval(meta)); + +}; + +Blockly.JavaScript['ui_vertical'] = function(block){ + return _.template('layout.push({type: "vertical", children: <%= meta %>});')({meta: _componentsMeta(block)}); +}; +Blockly.JavaScript['ui_horizontal'] = function(block){ + return _.template('layout.push({type: "horizontal", children: <%= meta %>});')({meta: _componentsMeta(block)}); +}; +Blockly.JavaScript['ui_create'] = function(block){ + var name = block.getFieldValue('NAME'); + var tpl = _.template("$engine.createUI('<%= name%>', <%= meta %>);"); + return tpl({name: name, meta: _componentsMeta(block)}); +}; + + +},{}],14:[function(require,module,exports){ (function (global){ var Blockly = (typeof window !== "undefined" ? window.Blockly : typeof global !== "undefined" ? global.Blockly : null), _ = (typeof window !== "undefined" ? window._ : typeof global !== "undefined" ? global._ : null); @@ -2158,14 +2328,14 @@ Blockly.JavaScript['defer'] = function(block) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../config":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/config.json"}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/config.json":[function(require,module,exports){ -module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports={ +},{"../config":15}],15:[function(require,module,exports){ +module.exports={ "action_color": 100, "undo_check_interval": 1000, "undo_max_size": 100 } -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/config_ctrl.js":[function(require,module,exports){ +},{}],16:[function(require,module,exports){ @@ -2291,7 +2461,7 @@ function ConfigCtrl($scope, $rootScope, blocksStore, $http, $modalInstance, rapp module.exports = ConfigCtrl; -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/root_ctrl.js":[function(require,module,exports){ +},{}],17:[function(require,module,exports){ (function (global){ var _ = (typeof window !== "undefined" ? window._ : typeof global !== "undefined" ? global._ : null); @@ -2375,7 +2545,7 @@ module.exports = function($scope, blocksStore, $http, $state, $rootScope) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/services_form_ctrl.js":[function(require,module,exports){ +},{}],18:[function(require,module,exports){ (function (global){ var R = (typeof window !== "undefined" ? window.R : typeof global !== "undefined" ? global.R : null) $ = (typeof window !== "undefined" ? window.$ : typeof global !== "undefined" ? global.$ : null), @@ -2623,13 +2793,13 @@ module.exports = function($scope, blocksStore, $http, serviceAuthoring, $statePa }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../schema/service_form":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/schema/service_form.json","../utils":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/utils.js"}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/services_index_ctrl.js":[function(require,module,exports){ +},{"../schema/service_form":23,"../utils":28}],19:[function(require,module,exports){ module.exports = function ServicesIndex($scope, blocksStore){ }; -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/workflow_blockly_ctrl.js":[function(require,module,exports){ +},{}],20:[function(require,module,exports){ (function (global){ var _ = (typeof window !== "undefined" ? window._ : typeof global !== "undefined" ? global._ : null), $ = (typeof window !== "undefined" ? window.$ : typeof global !== "undefined" ? global.$ : null), @@ -3067,7 +3237,7 @@ module.exports = WorkflowBlocklyCtrl; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../block_gen":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/block_gen.js","../blocks/blocks_defaults":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/blocks/blocks_defaults.js","../undo_manager":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/undo_manager.js","../utils":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/utils.js","./config_ctrl":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/config_ctrl.js"}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/ctrls/workflow_index_ctrl.js":[function(require,module,exports){ +},{"../block_gen":2,"../blocks/blocks_defaults":3,"../undo_manager":27,"../utils":28,"./config_ctrl":16}],21:[function(require,module,exports){ (function (global){ var R = (typeof window !== "undefined" ? window.R : typeof global !== "undefined" ? global.R : null); @@ -3086,7 +3256,7 @@ module.exports = function($scope, blocksStore) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/directives/json-editor.js":[function(require,module,exports){ +},{}],22:[function(require,module,exports){ (function (global){ var R = (typeof window !== "undefined" ? window.R : typeof global !== "undefined" ? global.R : null); @@ -3182,8 +3352,8 @@ module.exports = { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/schema/service_form.json":[function(require,module,exports){ -module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports=module.exports={ +},{}],23:[function(require,module,exports){ +module.exports={ "title": "Create Service", "type": "object", "properties": { @@ -3356,7 +3526,7 @@ module.exports=module.exports=module.exports=module.exports=module.exports=modul } } -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/services/blocks.js":[function(require,module,exports){ +},{}],24:[function(require,module,exports){ module.exports = function($http, $q){ @@ -3415,7 +3585,7 @@ module.exports = function($http, $q){ }; -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/services/services.js":[function(require,module,exports){ +},{}],25:[function(require,module,exports){ module.exports = function($http, $q){ @@ -3439,7 +3609,7 @@ module.exports = function($http, $q){ -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/tools/beautify.js":[function(require,module,exports){ +},{}],26:[function(require,module,exports){ /*jslint onevar: false, plusplus: false */ /* @@ -4583,7 +4753,7 @@ if (typeof exports !== "undefined") module.exports = js_beautify; -},{}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/undo_manager.js":[function(require,module,exports){ +},{}],27:[function(require,module,exports){ var Utils = require('./utils'), config = require('./config'); @@ -4642,7 +4812,7 @@ UndoManager.prototype.undo = function(){ module.exports = UndoManager; -},{"./config":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/config.json","./utils":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/utils.js"}],"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/utils.js":[function(require,module,exports){ +},{"./config":15,"./utils":28}],28:[function(require,module,exports){ (function (global){ var _ = (typeof window !== "undefined" ? window._ : typeof global !== "undefined" ? global._ : null), R = (typeof window !== "undefined" ? window.R : typeof global !== "undefined" ? global.R : null), @@ -4721,4 +4891,4 @@ module.exports = { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./tools/beautify":"/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/tools/beautify.js"}]},{},["/Users/eskim/current/rocon_composer/rocon_composer_blockly/public/js/app2.js"]); +},{"./tools/beautify":26}]},{},[1]); diff --git a/rocon_composer_blockly/public/js/blocks/index.js b/rocon_composer_blockly/public/js/blocks/index.js index b02bfd9..06b5a32 100644 --- a/rocon_composer_blockly/public/js/blocks/index.js +++ b/rocon_composer_blockly/public/js/blocks/index.js @@ -321,3 +321,4 @@ require('./ros_requester'); require('./ros_service'); require('./utils.js'); require('./prezi.js'); +require('./ui'); diff --git a/rocon_composer_blockly/public/js/blocks/ui.js b/rocon_composer_blockly/public/js/blocks/ui.js new file mode 100644 index 0000000..c7ba81a --- /dev/null +++ b/rocon_composer_blockly/public/js/blocks/ui.js @@ -0,0 +1,167 @@ + +Blockly.Blocks['ui_create'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Create UI'); + this.appendDummyInput().appendField(new Blockly.FieldTextInput('name', null), 'NAME') + this.setInputsInline(true); + + this.appendStatementInput('COMPS') + .appendField("components") + + this.setPreviousStatement(true); + return this.setNextStatement(true); + }, + +}; + + +Blockly.Blocks['ui_horizontal'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Layout(horizontal)' + name); + this.setInputsInline(true); + + this.appendStatementInput('COMPS') + .appendField("components") + + this.setPreviousStatement(true); + return this.setNextStatement(true); + }, + +}; + +Blockly.Blocks['ui_vertical'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Layout(vertical)' + name); + this.setInputsInline(true); + + this.appendStatementInput('COMPS') + .appendField("components") + + this.setPreviousStatement(true); + return this.setNextStatement(true); + }, + +}; +Blockly.Blocks['ui_text'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Text' + name); + + this.appendDummyInput().appendField('name:') + .appendField(new Blockly.FieldTextInput('name', null), 'NAME'); + + this.appendValueInput('TEXT').appendField('text:'); + this.setInputsInline(true); + this.setPreviousStatement(true); + return this.setNextStatement(true); + + }, + +}; + +Blockly.Blocks['ui_set_attr'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Set Attribute' + name); + + this.appendDummyInput().appendField('name:') + .appendField(new Blockly.FieldTextInput('name', null), 'NAME'); + + this.appendValueInput('ATTR').appendField('attr:'); + this.appendValueInput('VALUE').appendField('value:'); + this.setInputsInline(true); + this.setPreviousStatement(true); + return this.setNextStatement(true); + + + }, + +}; +Blockly.Blocks['ui_button'] = { + + init: function() { + this.setColour(30); + this.appendDummyInput().appendField('Button' + name); + + this.appendDummyInput().appendField('name:') + .appendField(new Blockly.FieldTextInput('name', null), 'NAME'); + + this.appendValueInput('TEXT').appendField('text:'); + this.setInputsInline(true); + this.setPreviousStatement(true); + return this.setNextStatement(true); + + + }, + +}; +Blockly.JavaScript['ui_set_attr'] = function(block){ + var attr = Blockly.JavaScript.valueToCode(block, 'ATTR', Blockly.JavaScript.ORDER_NONE) || "''"; + var value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_NONE) || "''"; + var name = block.getFieldValue('NAME'); + + + var data = { + rocon_id: name, + attr: eval(attr), + value: eval(value) + }; + var code = _.template('$engine.publish("to-rocon-ui", "std_msgs/String", {data: <%= data %>});')({ + data: "'" + JSON.stringify(data) + "'" + }); + return code; +}; +Blockly.JavaScript['ui_button'] = function(block){ + var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE) || "''"; + var name = block.getFieldValue('NAME'); + + console.log(name); + + var code = _.template('layout.push({type: "button", name: "<%= name %>", text: <%= text %>});')({ + text: text, + name: name + }); + return code; +}; +Blockly.JavaScript['ui_text'] = function(block){ + var text = Blockly.JavaScript.valueToCode(block, 'TEXT', Blockly.JavaScript.ORDER_NONE) || "''"; + var name = block.getFieldValue('NAME'); + + console.log(name); + + var code = _.template('layout.push({type: "text", name: "<%= name %>", text: <%= text %>});')({ + text: text, + name: name + }); + return code; +}; + + +var _componentsMeta = function(block){ + var code = Blockly.JavaScript.statementToCode(block, 'COMPS', Blockly.JavaScript.ORDER_NONE) || "''"; + var meta_tpl = _.template('(function(layout){ <%= code %>; return layout; })([]);'); + var meta = meta_tpl({code: code}); + return JSON.stringify(eval(meta)); + +}; + +Blockly.JavaScript['ui_vertical'] = function(block){ + return _.template('layout.push({type: "vertical", children: <%= meta %>});')({meta: _componentsMeta(block)}); +}; +Blockly.JavaScript['ui_horizontal'] = function(block){ + return _.template('layout.push({type: "horizontal", children: <%= meta %>});')({meta: _componentsMeta(block)}); +}; +Blockly.JavaScript['ui_create'] = function(block){ + var name = block.getFieldValue('NAME'); + var tpl = _.template("$engine.createUI('<%= name%>', <%= meta %>);"); + return tpl({name: name, meta: _componentsMeta(block)}); +}; + diff --git a/rocon_composer_blockly/public/js/tpl/blockly.html b/rocon_composer_blockly/public/js/tpl/blockly.html index 43bf0e9..dd3c172 100644 --- a/rocon_composer_blockly/public/js/tpl/blockly.html +++ b/rocon_composer_blockly/public/js/tpl/blockly.html @@ -349,6 +349,23 @@

List

+ + + + + + + + + + + + + + + + +