nutella_framework 0.4.5 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +14 -15
  3. data/VERSION +1 -1
  4. data/framework_components/beacon-cloud-bot/README.md +27 -0
  5. data/framework_components/beacon-cloud-bot/beacon_cloud_bot.rb +154 -0
  6. data/framework_components/beacon-cloud-bot/nutella.json +6 -0
  7. data/framework_components/beacon-cloud-bot/startup +4 -0
  8. data/framework_components/beacon-cloud-interface/LICENSE +21 -0
  9. data/framework_components/beacon-cloud-interface/Readme.md +0 -0
  10. data/framework_components/beacon-cloud-interface/bower.json +29 -0
  11. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/.bower.json +23 -0
  12. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/bower.json +14 -0
  13. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/mqttws31.js +2081 -0
  14. data/framework_components/beacon-cloud-interface/bower_components/bower-mqttws/readme.md +4 -0
  15. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/.bower.json +37 -0
  16. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/LICENSE +21 -0
  17. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/README.md +15 -0
  18. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/bower.json +28 -0
  19. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/mqtt_client_hello_world.html +23 -0
  20. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/browser/nutella_hello_world.html +52 -0
  21. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/mqtt_client_hello_world.js +14 -0
  22. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/examples/node/nutella_hello_world.js +38 -0
  23. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/nutella_lib.js +789 -0
  24. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/package.json +30 -0
  25. data/framework_components/beacon-cloud-interface/bower_components/nutella_lib/simple-js-mqtt-client.js +428 -0
  26. data/framework_components/beacon-cloud-interface/css/animation.css +17 -0
  27. data/framework_components/beacon-cloud-interface/css/cursor.css +16 -0
  28. data/framework_components/beacon-cloud-interface/css/page_layout.css +73 -0
  29. data/framework_components/beacon-cloud-interface/index.html +157 -0
  30. data/framework_components/beacon-cloud-interface/js/lib/nutella_lib.js +4039 -0
  31. data/framework_components/beacon-cloud-interface/js/react/beacon-add.js +102 -0
  32. data/framework_components/beacon-cloud-interface/js/react/beacon-table.js +73 -0
  33. data/framework_components/beacon-cloud-interface/js/react/beacon.js +97 -0
  34. data/framework_components/beacon-cloud-interface/nutella.json +6 -0
  35. data/framework_components/example_framework_web_interface/index.html +11 -2
  36. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/.npmignore +10 -0
  37. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/.travis.yml +5 -0
  38. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/LICENSE +21 -0
  39. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/README.md +27 -0
  40. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js +4039 -0
  41. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/dist/nutella_lib.js.map +1 -0
  42. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/browser_hello_world.html +67 -0
  43. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/examples/node_hello_world.js +51 -0
  44. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/gulpfile.js +31 -0
  45. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/package.json +41 -0
  46. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core.js +19 -0
  47. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_core_browser.js +17 -0
  48. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_log.js +50 -0
  49. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_net.js +279 -0
  50. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/app_persist.js +20 -0
  51. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_core_browser.js +17 -0
  52. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_log.js +50 -0
  53. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/fr_net.js +499 -0
  54. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i.js +74 -0
  55. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_i_browser.js +130 -0
  56. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib.js +91 -0
  57. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/nutella_lib_browser.js +90 -0
  58. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_log.js +51 -0
  59. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_net.js +84 -0
  60. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/run_persist.js +20 -0
  61. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/src/util/net.js +327 -0
  62. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/test/nutella.test.js +16 -0
  63. data/framework_components/example_framework_web_interface/node_modules/nutella_lib/test/runner.html +22 -0
  64. data/framework_components/example_framework_web_interface/package.json +15 -0
  65. data/framework_components/{order.json.example → order.json} +0 -0
  66. data/framework_components/runs_list_bot/{app_runs_list_bot.rb → runs_list_bot.rb} +9 -3
  67. data/framework_components/runs_list_bot/startup +1 -1
  68. data/lib/commands/meta/run_command.rb +21 -36
  69. data/lib/commands/start.rb +9 -199
  70. data/lib/commands/util/components_list.rb +68 -0
  71. data/lib/commands/util/components_starter.rb +169 -0
  72. data/nutella_framework.gemspec +109 -47
  73. data/nutella_lib/framework_net.rb +17 -13
  74. metadata +84 -106
@@ -0,0 +1,102 @@
1
+ var BeaconAdd = React.createClass({
2
+ getInitialState: function() {
3
+ return {
4
+ beacon: {rid: "", uuid: "", major: "", minor: ""}
5
+ };
6
+ },
7
+ handleChangeRid: function(e) {
8
+ var beacon = this.state.beacon;
9
+ beacon.rid = event.target.value;
10
+ this.setState({beacon: beacon});
11
+ },
12
+ handleChangeUuid: function(e) {
13
+ var beacon = this.state.beacon;
14
+ beacon.uuid = event.target.value;
15
+
16
+ // If it is not a valid UUID try to fix it
17
+ if(!beacon.uuid.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)) {
18
+ var uuid = beacon.uuid;
19
+
20
+ var re = new RegExp("-", 'g');
21
+ uuid = uuid.replace(re, '');
22
+
23
+ var uuidTemp = "";
24
+
25
+ uuidTemp += uuid.substring(0,8);
26
+ if(uuid.length >= 8) {
27
+ uuidTemp += "-";
28
+ }
29
+ uuidTemp += uuid.substring(8,12);
30
+ if(uuid.length >= 12) {
31
+ uuidTemp += "-";
32
+ }
33
+ uuidTemp += uuid.substring(12,16);
34
+ if(uuid.length >= 16) {
35
+ uuidTemp += "-";
36
+ }
37
+ uuidTemp += uuid.substring(16,20);
38
+ if(uuid.length >= 20) {
39
+ uuidTemp += "-";
40
+ }
41
+ uuidTemp += uuid.substring(20,32);
42
+ beacon.uuid = uuidTemp;
43
+ }
44
+
45
+
46
+ this.setState({beacon: beacon});
47
+ },
48
+ handleChangeMajor: function(e) {
49
+ var beacon = this.state.beacon;
50
+ if(event.target.value.match(/^[0-9]*$/i)) {
51
+ beacon.major = event.target.value;
52
+ this.setState({beacon: beacon});
53
+ }
54
+ },
55
+ handleChangeMinor: function(e) {
56
+ var beacon = this.state.beacon;
57
+ if(event.target.value.match(/^[0-9]*$/i)) {
58
+ beacon.minor = event.target.value;
59
+ this.setState({beacon: beacon});
60
+ }
61
+ },
62
+ handleKeyDownUUID: function(evt) {
63
+ var beacon = this.state.beacon;
64
+ if (evt.keyCode == 8 &&
65
+ (
66
+ beacon.uuid.length == 9 ||
67
+ beacon.uuid.length == 14 ||
68
+ beacon.uuid.length == 19 ||
69
+ beacon.uuid.length == 24
70
+ )
71
+ ) {
72
+ beacon.uuid = beacon.uuid.substring(0, beacon.uuid.length - 1);
73
+ this.setState({beacon: beacon});
74
+ }
75
+ this.handleKeyDown(evt);
76
+ },
77
+ handleKeyDown: function(evt) {
78
+ if (evt.keyCode == 13 ) {
79
+ if( this.state.beacon.rid != "" &&
80
+ this.state.beacon.uuid != "" &&
81
+ this.state.beacon.major != "" &&
82
+ this.state.beacon.minor != "") {
83
+ this.props.addBeacon(this.state.beacon);
84
+ this.setState({beacon: {rid: "", uuid: "", major: "", minor: ""}})
85
+ }
86
+ else {
87
+ alert("Incomplete beacon")
88
+ }
89
+
90
+ }
91
+ },
92
+ render: function() {
93
+ return (
94
+ <tr>
95
+ <td className="col-md-2 col-sm-2 col-xs-2 add"><input type="text" onKeyDown={this.handleKeyDown} className="form-control" value={this.state.beacon.rid} placeholder="rid" onChange={this.handleChangeRid} ref="rid"/></td>
96
+ <td className="col-md-6 col-sm-6 col-xs-6 add"><input type="text" onKeyDown={this.handleKeyDownUUID} className="form-control" value={this.state.beacon.uuid} placeholder="uuid" onChange={this.handleChangeUuid} ref="uuid"/></td>
97
+ <td className="col-md-2 col-sm-2 col-xs-2 add"><input type="text" onKeyDown={this.handleKeyDown} className="form-control" value={this.state.beacon.major} placeholder="major" onChange={this.handleChangeMajor} ref="major"/></td>
98
+ <td className="col-md-2 col-sm-2 col-xs-2 add"><input type="text" onKeyDown={this.handleKeyDown} className="form-control" value={this.state.beacon.minor} placeholder="minor" onChange={this.handleChangeMinor} ref="minor"/></td>
99
+ </tr>
100
+ );
101
+ }
102
+ });
@@ -0,0 +1,73 @@
1
+ var BeaconTable = React.createClass({
2
+ getInitialState: function() {
3
+ return {
4
+ beaconData: []
5
+ };
6
+ },
7
+ componentDidMount: function() {
8
+ self = this;
9
+
10
+ // Download all beacons
11
+ nutella.f.net.request("beacon/beacons", {}, function(reply) {
12
+ self.setState({beaconData: reply.beacons});
13
+ });
14
+
15
+ // Wait for new added beacons
16
+ nutella.f.net.subscribe("beacon/beacons/added", function(message) {
17
+ var data = self.state.beaconData;
18
+ data = data.concat(message.beacons);
19
+
20
+ self.setState({beaconData: data});
21
+ });
22
+
23
+ // Wait for removed beacons
24
+ nutella.f.net.subscribe("beacon/beacons/removed", function(message) {
25
+ var data = self.state.beaconData;
26
+ data = data.filter(function(d) {
27
+ return $.inArray(d.rid, message.beacons.map(function(r) {
28
+ return r.rid;
29
+ })) == -1;
30
+ });
31
+
32
+ self.setState({beaconData: data});
33
+ });
34
+ },
35
+ hendleBeaconAdd: function(beacon) {
36
+ nutella.f.net.publish("beacon/beacon/add", beacon);
37
+ },
38
+ hendleBeaconRemove: function(beacon) {
39
+ nutella.f.net.publish("beacon/beacon/remove", {rid: beacon.rid});
40
+ },
41
+ render: function() {
42
+ var self = this;
43
+
44
+ // Reorder the beacons
45
+ var beaconData = this.state.beaconData;
46
+ beaconData = beaconData.sort(function(a, b) {
47
+ return a.rid.localeCompare(b.rid)
48
+ });
49
+
50
+ var beacons = beaconData.map(function (beacon, index) {
51
+ return <Beacon beacon={beacon} key={beacon.rid} removeBeacon={self.hendleBeaconRemove} addBeacon={self.hendleBeaconAdd}/>
52
+ });
53
+
54
+ return (
55
+ <div className="table-responsive col-md-8 col-md-offset-2 col-sm-12">
56
+ <table className="table table-bordered table-striped table-hover">
57
+ <thead>
58
+ <tr>
59
+ <th className="col-md-2 col-sm-2 col-xs-2">Resource Id</th>
60
+ <th className="col-md-6 col-sm-6 col-xs-6">UUID</th>
61
+ <th className="col-md-2 col-sm-2 col-xs-2">Major</th>
62
+ <th className="col-md-2 col-sm-2 col-xs-2">Minor</th>
63
+ </tr>
64
+ </thead>
65
+ <tbody>
66
+ {beacons}
67
+ <BeaconAdd addBeacon={this.hendleBeaconAdd} />
68
+ </tbody>
69
+ </table>
70
+ </div>
71
+ );
72
+ }
73
+ });
@@ -0,0 +1,97 @@
1
+ var Beacon = React.createClass({
2
+ getInitialState: function() {
3
+ return {ridEdit: false, uuidEdit: false, majorEdit: false, minorEdit: false};
4
+ },
5
+ handleRemoveButton: function() {
6
+ this.props.removeBeacon(this.props.beacon);
7
+ },
8
+ handleRidClicked: function() {
9
+ this.replaceState({ridEdit: true});
10
+ },
11
+ handleUuidClicked: function() {
12
+ this.replaceState({uuidEdit: true});
13
+ },
14
+ handleMajorClicked: function() {
15
+ this.replaceState({majorEdit: true});
16
+ },
17
+ handleMinorClicked: function() {
18
+ this.replaceState({minorEdit: true});
19
+ },
20
+ handleKeyDownRid: function(evt) {
21
+ if (evt.keyCode == 13 ) {
22
+ var beacon = this.props.beacon;
23
+ this.props.removeBeacon(beacon);
24
+ beacon.rid = this.refs.rid.getDOMNode().value.trim();
25
+ this.props.addBeacon(beacon);
26
+ }
27
+ },
28
+ handleKeyDownUuid: function(evt) {
29
+ if (evt.keyCode == 13 ) {
30
+ var beacon = this.props.beacon;
31
+ this.props.removeBeacon(beacon);
32
+ beacon.uuid = this.refs.uuid.getDOMNode().value.trim();
33
+ this.props.addBeacon(beacon);
34
+ }
35
+ },
36
+ handleKeyDownMajor: function(evt) {
37
+ if (evt.keyCode == 13 ) {
38
+ var beacon = this.props.beacon;
39
+ this.props.removeBeacon(beacon);
40
+ beacon.major = this.refs.major.getDOMNode().value.trim();
41
+ this.props.addBeacon(beacon);
42
+ }
43
+ },
44
+ handleKeyDownMinor: function(evt) {
45
+ if (evt.keyCode == 13 ) {
46
+ var beacon = this.props.beacon;
47
+ this.props.removeBeacon(beacon);
48
+ beacon.minor = this.refs.minor.getDOMNode().value.trim();
49
+ this.props.addBeacon(beacon);
50
+ }
51
+ },
52
+ render: function() {
53
+ var b = {};
54
+
55
+ if(this.state.ridEdit)
56
+ b.rid = <input type="text" onKeyDown={this.handleKeyDownRid} className="form-control" defaultValue={this.props.beacon.rid} placeholder="rid" onChange={this.handleChangeRid} ref="rid"/>;
57
+ else
58
+ b.rid = this.props.beacon.rid;
59
+
60
+ if(this.state.uuidEdit)
61
+ b.uuid = <input type="text" onKeyDown={this.handleKeyDownUuid} className="form-control" defaultValue={this.props.beacon.uuid} placeholder="uuid" onChange={this.handleChangeUuid} ref="uuid"/>;
62
+ else
63
+ b.uuid = this.props.beacon.uuid;
64
+
65
+ if(this.state.majorEdit)
66
+ b.major = <input type="text" onKeyDown={this.handleKeyDownMajor} className="form-control" defaultValue={this.props.beacon.major} placeholder="major" onChange={this.handleChangeMajor} ref="major"/>;
67
+ else
68
+ b.major = this.props.beacon.major;
69
+
70
+ if(this.state.minorEdit)
71
+ b.minor = <input type="text" onKeyDown={this.handleKeyDownMinor} className="form-control" defaultValue={this.props.beacon.minor} placeholder="minor" onChange={this.handleChangeMinor} ref="minor"/>;
72
+ else
73
+ b.minor = this.props.beacon.minor;
74
+
75
+ if(this.state.ridEdit || this.state.uuidEdit || this.state.majorEdit || this.state.minorEdit)
76
+ add = "add";
77
+ else
78
+ add = "";
79
+
80
+ return (
81
+
82
+ <tr>
83
+ <td className={"col-md-2 col-sm-2 col-xs-2 "+add} onClick={this.handleRidClicked}>{b.rid}</td>
84
+ <td className={"col-md-6 col-sm-6 col-xs-6 "+add} onClick={this.handleUuidClicked}>{b.uuid}</td>
85
+ <td className={"col-md-2 col-sm-2 col-xs-2 "+add} onClick={this.handleMajorClicked}>{b.major}</td>
86
+ <td className={"col-md-2 col-sm-2 col-xs-2 "+add} onClick={this.handleMinorClicked}>
87
+ <span>
88
+ {b.minor}
89
+ </span>
90
+ <button type="button" className="btn btn-danger btn-xs right" onClick={this.handleRemoveButton}>
91
+ <span className="glyphicon glyphicon-remove" aria-hidden="true"></span>
92
+ </button>
93
+ </td>
94
+ </tr>
95
+ );
96
+ }
97
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "beacon-cloud-interface",
3
+ "version": "0.0.1",
4
+ "type": "interface",
5
+ "description": "The web interface of Beacon Cloud"
6
+ }
@@ -8,8 +8,17 @@
8
8
  </head>
9
9
  <body>
10
10
  <h1>Example framework interface</h1>
11
- <p>This is an example of a framework interface. Use this template to write your own framework interface.
12
- WE NEED TO COMPLETE THIS TEMPLATE BUT IN ORDER FOR THAT TO HAPPEN, I NEED JAVASCRIPT APIs!!!</p>
13
11
 
12
+ <script src="node_modules/nutella_lib/dist/nutella_lib.js"></script>
13
+ <!-- Scripts -->
14
+ <script>
15
+ var urlParams = NUTELLA.parseURLParameters();
16
+ var nutella = NUTELLA.initFramework(urlParams.broker, 'example_framework_interface');
17
+ // Now you can code happily using nutella!
18
+ // If you need to know what application and run this interface is executing within,
19
+ // simply access those values via url query parameters as such:
20
+ // urlParams.app_id
21
+ // urlParams.run_id
22
+ </script>
14
23
  </body>
15
24
  </html>
@@ -0,0 +1,10 @@
1
+ # npm modules (except simple-mqtt-client)
2
+ node_modules/*
3
+ !node_modules/simple-mqtt-client
4
+ docs/
5
+
6
+ # Mac
7
+ .DS_Store
8
+
9
+ # WebStorm
10
+ .idea/
@@ -0,0 +1,5 @@
1
+ language: node_js
2
+ node_js:
3
+ - "0.10"
4
+ notifications:
5
+ email: false
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 by The Board of Trustees of the University of Illinois at Chicago
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ [![Build Status](https://travis-ci.org/nutella-framework/nutella_lib.js.svg?branch=master)](https://travis-ci.org/nutella-framework/nutella_lib.js)
2
+
3
+ # nutella library for node.js and the browser
4
+
5
+ ## Installation
6
+ For node.js projects do
7
+ ```
8
+ npm install nutella_lib
9
+ ```
10
+
11
+ For browser projects either:
12
+
13
+ 1. `npm install nutella_lib` and then use [browserify](http://browserify.org/) OR
14
+ 2. use the bundled `nutella_lib.js` in `dist`
15
+
16
+
17
+ ## Building the project
18
+ For developers working on the library. We are using gulp + browserify + watchify to continuously and incrementally build the library as we develop.
19
+
20
+ **To contribute**: Clone the repo and `gulp bundle` inside the project directory. Every time you make a change to any of the files required by the library gulp will rebuild it.
21
+
22
+
23
+ ## Releasing a new version
24
+ For developers working on the library, to release a new version:
25
+
26
+ - Update the version in the `package.json`
27
+ - Publish to npm by doing `npm publish`