nutella_framework 0.6.19 → 0.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,11 +29,11 @@ nutella.version = nutella_version.version;
29
29
  * @param {string} run_id - the run_id this component is launched in
30
30
  * @param {string} component_id - the name of this component
31
31
  */
32
- nutella.init = function(broker_hostname, app_id, run_id, component_id) {
32
+ nutella.init = function(broker_hostname, app_id, run_id, component_id, done_cb) {
33
33
  if (broker_hostname===undefined || app_id===undefined || run_id===undefined || component_id=== undefined) {
34
34
  console.warn("Couldn't initialize nutella. Make sure you are setting all four required parameters (broker_hostname, app_id, run_id, component_id)");
35
35
  }
36
- return new nutella_i.RunNutellaInstance(broker_hostname, app_id, run_id, component_id);
36
+ return new nutella_i.RunNutellaInstance(broker_hostname, app_id, run_id, component_id, done_cb);
37
37
  };
38
38
 
39
39
 
@@ -46,11 +46,11 @@ nutella.init = function(broker_hostname, app_id, run_id, component_id) {
46
46
  * @param {string} app_id - the app_id this component belongs to
47
47
  * @param {string} component_id - the name of this component
48
48
  */
49
- nutella.initApp = function(broker_hostname, app_id, component_id) {
49
+ nutella.initApp = function(broker_hostname, app_id, component_id, done_cb) {
50
50
  if (broker_hostname===undefined || app_id===undefined || component_id=== undefined) {
51
51
  console.warn("Couldn't initialize nutella. Make sure you are setting all three required parameters (broker_hostname, app_id, component_id)");
52
52
  }
53
- return new nutella_i.AppNutellaInstance(broker_hostname, app_id, component_id);
53
+ return new nutella_i.AppNutellaInstance(broker_hostname, app_id, component_id, done_cb);
54
54
  };
55
55
 
56
56
 
@@ -62,11 +62,11 @@ nutella.initApp = function(broker_hostname, app_id, component_id) {
62
62
  * @param {string} broker_hostname - the hostname of the broker.*
63
63
  * @param {string} component_id - the name of this component
64
64
  */
65
- nutella.initFramework = function(broker_hostname, component_id) {
65
+ nutella.initFramework = function(broker_hostname, component_id, done_cb) {
66
66
  if (broker_hostname===undefined || component_id=== undefined) {
67
67
  console.warn("Couldn't initialize nutella. Make sure you are setting all two required parameters (broker_hostname, component_id)");
68
68
  }
69
- return new nutella_i.FrNutellaInstance(broker_hostname, component_id);
69
+ return new nutella_i.FrNutellaInstance(broker_hostname, component_id, done_cb);
70
70
  };
71
71
 
72
72
 
@@ -1648,9 +1648,9 @@ var LocationSubModule = require('./run_location');
1648
1648
  * @param {string} broker_hostname - the hostname of the broker.
1649
1649
  * @param {string} component_id - the name of this component
1650
1650
  */
1651
- var RunNutellaInstance = function (broker_hostname, app_id, run_id, component_id) {
1651
+ var RunNutellaInstance = function (broker_hostname, app_id, run_id, component_id, done_cb) {
1652
1652
  //Initialize parameters
1653
- this.mqtt_client = new SimpleMQTTClient(broker_hostname);
1653
+ this.mqtt_client = new SimpleMQTTClient(broker_hostname, done_cb);
1654
1654
  this.appId = app_id;
1655
1655
  this.runId = run_id;
1656
1656
  this.componentId = component_id;
@@ -1681,9 +1681,9 @@ RunNutellaInstance.prototype.setResourceId = function(resource_id){
1681
1681
  * @param {string} broker_hostname - the hostname of the broker.
1682
1682
  * @param {string} component_id - the name of this component
1683
1683
  */
1684
- var AppNutellaInstance = function (broker_hostname, app_id, component_id) {
1684
+ var AppNutellaInstance = function (broker_hostname, app_id, component_id, done_cb) {
1685
1685
  //Initialize parameters
1686
- this.mqtt_client = new SimpleMQTTClient(broker_hostname);
1686
+ this.mqtt_client = new SimpleMQTTClient(broker_hostname, done_cb);
1687
1687
  this.appId = app_id;
1688
1688
  this.componentId = component_id;
1689
1689
  // Initialized the various sub-modules
@@ -1720,9 +1720,9 @@ AppNutellaInstance.prototype.setResourceId = function(resource_id){
1720
1720
  * @param {string} broker_hostname - the hostname of the broker.
1721
1721
  * @param {string} component_id - the name of this component
1722
1722
  */
1723
- var FrNutellaInstance = function (broker_hostname, component_id) {
1723
+ var FrNutellaInstance = function (broker_hostname, component_id, done_cb) {
1724
1724
  //Initialize parameters
1725
- this.mqtt_client = new SimpleMQTTClient(broker_hostname);
1725
+ this.mqtt_client = new SimpleMQTTClient(broker_hostname, done_cb);
1726
1726
  this.componentId = component_id;
1727
1727
  // Initialize the various sub-modules
1728
1728
  this.f = new FrSubModule(this);
@@ -2358,21 +2358,17 @@ var mqtt_lib = require('./paho/mqttws31');
2358
2358
  * Defines a Simple MQTT client.
2359
2359
  *
2360
2360
  * @param {string} host - the hostname of the broker.
2361
- * @param {string} [clientId] - the unique name of this client. If no ID is provided a random one is generated
2361
+ * @param {function} [err_cb] - optional callback fired whenever an error occurs
2362
2362
  */
2363
- var SimpleMQTTClient = function (host, clientId) {
2363
+ var SimpleMQTTClient = function (host, done_cb) {
2364
2364
  // Initializes the object that stores subscriptions
2365
2365
  this.subscriptions = {};
2366
2366
  // Initializes the object that holds the internal client
2367
2367
  this.client = {};
2368
2368
  // Functions backlog
2369
2369
  this.backlog = [];
2370
- // Handles the optional clientId parameter
2371
- if (arguments.length === 1 || clientId === undefined) {
2372
- clientId = generateRandomClientId();
2373
- }
2374
2370
  // Connect
2375
- this.client = connectBrowser(this.subscriptions, this.backlog, host, clientId);
2371
+ this.client = connectBrowser(this.subscriptions, this.backlog, host, done_cb);
2376
2372
  };
2377
2373
 
2378
2374
  //
@@ -2391,9 +2387,9 @@ function generateRandomClientId() {
2391
2387
  //
2392
2388
  // Helper function that connects the MQTT client in the browser
2393
2389
  //
2394
- function connectBrowser (subscriptions, backlog, host, clientId) {
2390
+ function connectBrowser (subscriptions, backlog, host, done_cb) {
2395
2391
  // Create client
2396
- var client = new mqtt_lib.Client(host, Number(1884), clientId);
2392
+ var client = new mqtt_lib.Client(host, Number(1884), generateRandomClientId());
2397
2393
  // Register callback for connection lost
2398
2394
  client.onConnectionLost = function() {
2399
2395
  // TODO try to reconnect
@@ -2415,11 +2411,21 @@ function connectBrowser (subscriptions, backlog, host, clientId) {
2415
2411
  };
2416
2412
  // Connect
2417
2413
  client.connect({onSuccess: function() {
2414
+ // Execute optional done callback passing true
2415
+ if (done_cb!==undefined)
2416
+ done_cb(true);
2418
2417
  // Execute the backlog of operations performed while the client wasn't connected
2419
2418
  backlog.forEach(function(e) {
2420
2419
  e.op.apply(this, e.params);
2421
2420
  });
2422
- }});
2421
+ },
2422
+ onFailure: function() {
2423
+ // Execute optional done callback passing false
2424
+ if (done_cb!==undefined)
2425
+ done_cb(false);
2426
+ else
2427
+ console.error('There was a problem initializing nutella.');
2428
+ }});
2423
2429
  return client;
2424
2430
  }
2425
2431
 
@@ -4972,6 +4978,7 @@ AbstractNet.prototype.request_to = function( channel, message, callback, appId,
4972
4978
  AbstractNet.prototype.handle_requests_on = function( channel, callback, appId, runId, done_callback) {
4973
4979
  // Save nutella reference
4974
4980
  var nut = this.nutella;
4981
+ var abstract_net = this;
4975
4982
  // Pad channel
4976
4983
  var padded_channel = this.pad_channel(channel, appId, runId);
4977
4984
  var mqtt_cb = function(request) {
@@ -4981,7 +4988,7 @@ AbstractNet.prototype.handle_requests_on = function( channel, callback, appId, r
4981
4988
  // Only handle requests that have proper id set
4982
4989
  if(f.type!=='request' || f.id===undefined) return;
4983
4990
  // Execute callback and send response
4984
- var m = this.prepare_message_for_response(callback(f.payload, f.from), f.id);
4991
+ var m = abstract_net.prepare_message_for_response(callback(f.payload, f.from), f.id);
4985
4992
  nut.mqtt_client.publish( padded_channel, m );
4986
4993
  } catch(e) {
4987
4994
  if (e instanceof SyntaxError) {
@@ -5116,6 +5123,6 @@ AbstractNet.prototype.prepare_message_for_response = function (response, id) {
5116
5123
  // Export module
5117
5124
  module.exports = AbstractNet;
5118
5125
  },{}],17:[function(require,module,exports){
5119
- module.exports.version = '0.5.7';
5126
+ module.exports.version = '0.5.10';
5120
5127
  },{}]},{},[1])(1)
5121
5128
  });
@@ -12,18 +12,6 @@
12
12
 
13
13
  <body>
14
14
 
15
- <!-- Nutella -->
16
- <script src="dist/nutella_lib.js" type="text/javascript" charset="utf-8"></script>
17
- <script type="text/javascript">
18
-
19
- // Parse the query parameters
20
- var query_parameters = NUTELLA.parseURLParameters();
21
-
22
- // Get an instance of nutella.
23
- var nutella = NUTELLA.init(query_parameters.broker, query_parameters.app_id, query_parameters.run_id, 'roomcast-teacher-interface');
24
-
25
- </script>
26
-
27
15
  <!-- This script adds the Roboto font to our project. For more detail go to this site: http://www.google.com/fonts#UsePlace:use/Collection:Roboto:400,300,500 -->
28
16
  <script>
29
17
  var WebFontConfig = {
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "d3": "^3.5.5",
33
33
  "material-ui": "^0.7.0",
34
- "nutella_lib": "^0.5.1",
34
+ "nutella_lib": "^0.5.10",
35
35
  "react": "^0.13.0",
36
36
  "react-tap-event-plugin": "^0.1.3"
37
37
  }
@@ -3,20 +3,26 @@
3
3
 
4
4
  var React = require('react'),
5
5
  injectTapEventPlugin = require("react-tap-event-plugin"),
6
- Main = require('./components/main.js'); // Our custom react component
6
+ Main = require('./components/main.js'), // Our custom react component
7
+ NUTELLA = require('nutella_lib');
7
8
 
8
9
  //Needed for React Developer Tools
9
10
  window.React = React;
10
11
 
11
- //Needed for onTouchTap
12
- //Can go away when react 1.0 release
13
- //Check this repo:
14
- //https://github.com/zilverline/react-tap-event-plugin
15
12
  injectTapEventPlugin();
16
13
 
17
- // Render the main app react component into the document body.
18
- // For more details see: https://facebook.github.io/react/docs/top-level-api.html#react.render
19
- //window.ReactMain = 'Main component';
20
- window.ReactMain = React.render(<Main />, document.body);
14
+ var query_parameters = NUTELLA.parseURLParameters();
15
+ if(query_parameters.broker) {
16
+ window.nutella = NUTELLA.init(query_parameters.broker, query_parameters.app_id, query_parameters.run_id, 'roomcast-teacher-controls', function(connected) {
17
+ if(connected) {
18
+ window.ReactMain = React.render( <Main /> , document.body);
19
+ }
20
+ });
21
+ } else {
22
+ // for debugging purposes - works with tests outside of nutella
23
+ window.nutella = NUTELLA.init('ltg.evl.uic.edu', 'wallcology', '6BAM', 'roomcast-teacher-controls', function(connected) {
24
+ window.ReactMain = React.render( <Main /> , document.body);
25
+ });
26
+ }
21
27
 
22
28
  })();
@@ -151,13 +151,13 @@ var ActivityCard = React.createClass({
151
151
  cardStyle[p] = selectedCardStyle[p];
152
152
  }
153
153
  }
154
- timer = this.formatTimer(this.props.timer);
154
+ timer = <span>{this.formatTimer(this.props.timer)}</span>;
155
155
  spanStyle = {
156
156
  width: this.props.cardStyle.width,
157
157
  textAlign: 'center',
158
158
  fontWeight: '400',
159
- fontSize: '2.6em',
160
- marginBottom: '20px'};
159
+ fontSize: '2.6em'
160
+ };
161
161
  }
162
162
 
163
163
  return (
@@ -168,8 +168,10 @@ var ActivityCard = React.createClass({
168
168
 
169
169
  <div className='card-name'>
170
170
 
171
- <span style={spanStyle} >{this.props.configName}</span>
172
- <span>{timer}</span>
171
+ <div className='card-text'>
172
+ <span style={spanStyle} >{this.props.configName}</span>
173
+ {timer}
174
+ </div>
173
175
 
174
176
  </div>
175
177
 
@@ -1,3 +1,4 @@
1
+ var NUTELLA = require('nutella_lib');
1
2
 
2
3
  var NutellaMixin = {
3
4
 
@@ -70,21 +70,31 @@ html, body {
70
70
  height: 100%;
71
71
  width: 100%;
72
72
  position: absolute;
73
- display: flex;
74
- flex-direction: row;
75
- flex-wrap: wrap;
73
+ //display: flex;
74
+ //flex-direction: row;
75
+ //flex-wrap: wrap;
76
76
  justify-content: center;
77
77
  align-items: center;
78
78
  align-content: center;
79
+ display: table;
80
+ text-align: center;
81
+
82
+ .card-text {
83
+ display: table-cell;
84
+ vertical-align: middle;
85
+ }
79
86
 
80
87
  span {
81
88
  font-size: 2em;
82
89
  font-weight: 300;
90
+ display: block;
91
+ line-height: 1.2em;
92
+ padding: 10px;
83
93
 
84
94
  // flex item properties
85
- flex-grow: 0;
86
- flex-shrink: 0;
87
- flex-basis: main-size;
95
+ //flex-grow: 0;
96
+ //flex-shrink: 0;
97
+ //flex-basis: main-size;
88
98
  }
89
99
  }
90
100
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutella_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.19
4
+ version: 0.6.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Gnoli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-17 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic