nutella_framework 0.6.6 → 0.6.7
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/framework_components/roomcast-main-app/.gitignore +2 -0
- data/framework_components/roomcast-main-app/README.md +9 -0
- data/framework_components/roomcast-main-app/dist/LICENSE +21 -0
- data/framework_components/roomcast-main-app/dist/app.js +54280 -0
- data/framework_components/roomcast-main-app/dist/assets/Logo.png +0 -0
- data/framework_components/roomcast-main-app/dist/assets/Logo_alpha.png +0 -0
- data/framework_components/roomcast-main-app/dist/assets/Logo_grid.svg +216 -0
- data/framework_components/roomcast-main-app/dist/css/ionicons.min.css +11 -0
- data/framework_components/roomcast-main-app/dist/fonts/ionicons.eot +0 -0
- data/framework_components/roomcast-main-app/dist/fonts/ionicons.svg +2230 -0
- data/framework_components/roomcast-main-app/dist/fonts/ionicons.ttf +0 -0
- data/framework_components/roomcast-main-app/dist/fonts/ionicons.woff +0 -0
- data/framework_components/roomcast-main-app/dist/main.css +3227 -0
- data/framework_components/roomcast-main-app/gulp/config.js +47 -0
- data/framework_components/roomcast-main-app/gulp/tasks/browserify.js +77 -0
- data/framework_components/roomcast-main-app/gulp/tasks/build.js +3 -0
- data/framework_components/roomcast-main-app/gulp/tasks/css.js +7 -0
- data/framework_components/roomcast-main-app/gulp/tasks/default.js +3 -0
- data/framework_components/roomcast-main-app/gulp/tasks/fonts.js +7 -0
- data/framework_components/roomcast-main-app/gulp/tasks/less.js +16 -0
- data/framework_components/roomcast-main-app/gulp/tasks/markup.js +7 -0
- data/framework_components/roomcast-main-app/gulp/tasks/setWatch.js +5 -0
- data/framework_components/roomcast-main-app/gulp/tasks/svgs.js +7 -0
- data/framework_components/roomcast-main-app/gulp/tasks/watch.js +12 -0
- data/framework_components/roomcast-main-app/gulp/util/bundleLogger.js +21 -0
- data/framework_components/roomcast-main-app/gulp/util/handleErrors.js +15 -0
- data/framework_components/roomcast-main-app/gulpfile.js +16 -0
- data/framework_components/roomcast-main-app/index.html +38 -0
- data/framework_components/roomcast-main-app/nutella.json +6 -0
- data/framework_components/roomcast-main-app/package.json +47 -0
- data/framework_components/roomcast-main-app/src/app/app.js +15 -0
- data/framework_components/roomcast-main-app/src/app/components/app/Channel.js +72 -0
- data/framework_components/roomcast-main-app/src/app/components/app/NutellaMixin.js +23 -0
- data/framework_components/roomcast-main-app/src/app/components/app/Player.js +129 -0
- data/framework_components/roomcast-main-app/src/app/components/app/iOSMixin.js +22 -0
- data/framework_components/roomcast-main-app/src/app/components/app/main.js +519 -0
- data/framework_components/roomcast-main-app/src/app/components/app/material-ui/menu-item.jsx +79 -0
- data/framework_components/roomcast-main-app/src/app/components/app/material-ui/menu.jsx +177 -0
- data/framework_components/roomcast-main-app/src/app/components/app/material-ui/overlay.jsx +21 -0
- data/framework_components/roomcast-main-app/src/app/components/app/material-ui/right-nav.jsx +108 -0
- data/framework_components/roomcast-main-app/src/app/components/identity-selector/IdentitiesGrid.js +91 -0
- data/framework_components/roomcast-main-app/src/app/components/identity-selector/IdentityCard.js +86 -0
- data/framework_components/roomcast-main-app/src/app/components/identity-selector/iOSMixin.js +19 -0
- data/framework_components/roomcast-main-app/src/app/components/identity-selector/main.js +105 -0
- data/framework_components/roomcast-main-app/src/app/components/login/AppIdPage.js +97 -0
- data/framework_components/roomcast-main-app/src/app/components/login/BrokerPage.js +139 -0
- data/framework_components/roomcast-main-app/src/app/components/login/IdentitiesGrid.js +93 -0
- data/framework_components/roomcast-main-app/src/app/components/login/IdentityCard.js +99 -0
- data/framework_components/roomcast-main-app/src/app/components/login/RunIdPage.js +78 -0
- data/framework_components/roomcast-main-app/src/app/components/login/iOSMixin.js +23 -0
- data/framework_components/roomcast-main-app/src/app/components/login/main.js +121 -0
- data/framework_components/roomcast-main-app/src/app/components/main.js +64 -0
- data/framework_components/roomcast-main-app/src/less/main.less +364 -0
- data/framework_components/roomcast-main-app/src/less/my_overrides.less +39 -0
- data/framework_components/roomcast-main-app/src/less/right-nav.less +31 -0
- data/framework_components/roomcast-package-creator/dist/app.js +17830 -3473
- data/framework_components/roomcast-package-creator/dist/fonts/material-ui-icons.eot +0 -0
- data/framework_components/roomcast-package-creator/dist/fonts/material-ui-icons.svg +0 -0
- data/framework_components/roomcast-package-creator/dist/fonts/material-ui-icons.ttf +0 -0
- data/framework_components/roomcast-package-creator/dist/fonts/material-ui-icons.woff +0 -0
- data/framework_components/roomcast-package-creator/dist/main.css +2 -1
- data/framework_components/roomcast-package-creator/dist/nutella_lib.js +4110 -4050
- data/framework_components/roomcast-package-creator/index.html +0 -13
- data/framework_components/roomcast-package-creator/package.json +33 -32
- data/framework_components/roomcast-package-creator/src/app/app.js +14 -4
- data/framework_components/roomcast-package-creator/src/app/components/ChannelCard.js +14 -1
- data/framework_components/roomcast-package-creator/src/app/components/main.js +0 -4
- data/framework_components/roomcast-package-creator/src/less/main.less +1 -0
- metadata +57 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var Mui = require('material-ui');
|
|
4
|
+
var TextField = Mui.TextField;
|
|
5
|
+
var RaisedButton = Mui.RaisedButton;
|
|
6
|
+
var NUTELLA = require('nutella_lib');
|
|
7
|
+
|
|
8
|
+
var BrokerPage = React.createClass({
|
|
9
|
+
|
|
10
|
+
componentWillMount: function() {
|
|
11
|
+
this.updateDimensions();
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
componentDidMount: function() {
|
|
15
|
+
window.addEventListener("resize", this.updateDimensions);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
componentWillUnmount: function() {
|
|
19
|
+
window.removeEventListener("resize", this.updateDimensions);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
updateDimensions: function() {
|
|
23
|
+
this.setState({innerHeight: window.innerHeight});
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
handleSetBroker: function() {
|
|
27
|
+
var self = this;
|
|
28
|
+
var broker = this.refs.textFieldBroker.getValue();
|
|
29
|
+
|
|
30
|
+
if(broker.length !== 0) {
|
|
31
|
+
|
|
32
|
+
// Start nutella
|
|
33
|
+
window.nutella = NUTELLA.init(broker, 'app_id', 'run_id', 'login-screens', function(connected) {
|
|
34
|
+
if(connected) {
|
|
35
|
+
|
|
36
|
+
var callback = function() {
|
|
37
|
+
if(!self.state.app_ids) {
|
|
38
|
+
self.setErrorText('Invalid broker.');
|
|
39
|
+
} else {
|
|
40
|
+
window.ReactMain.login.broker = broker;
|
|
41
|
+
self.props.onSwitchPage(2, {app_ids: self.state.app_ids});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
nutella.net.request('runs_list', 'req', function (response) {
|
|
46
|
+
var app_ids = [];
|
|
47
|
+
for (var app_id in response) {
|
|
48
|
+
if (response.hasOwnProperty(app_id)) {
|
|
49
|
+
app_ids.push(app_id);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
self.setState({
|
|
53
|
+
app_ids: app_ids
|
|
54
|
+
}, callback);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
} else {
|
|
58
|
+
self.setErrorText('Invalid broker.');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
} else {
|
|
63
|
+
this.setErrorText('You must set a broker.');
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
getInitialState: function () {
|
|
68
|
+
return {
|
|
69
|
+
errorText: null,
|
|
70
|
+
innerHeight: window.innerHeight,
|
|
71
|
+
app_ids: undefined
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
setErrorText: function(value) {
|
|
76
|
+
this.setState({
|
|
77
|
+
errorText: value
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
validateInput: function() {
|
|
82
|
+
var input = this.refs.textFieldBroker.getValue();
|
|
83
|
+
if (input.length === 0) {
|
|
84
|
+
this.setErrorText('You must set a broker.');
|
|
85
|
+
} else {
|
|
86
|
+
this.setErrorText(null);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
render: function () {
|
|
91
|
+
var self = this;
|
|
92
|
+
|
|
93
|
+
var titlesDivStyle = {
|
|
94
|
+
height: this.state.innerHeight * (0.4)
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var gridDivStyle = {
|
|
98
|
+
height: this.state.innerHeight * (0.6)
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
|
|
103
|
+
<div className='main-div' >
|
|
104
|
+
|
|
105
|
+
<div className='titles-div' style={titlesDivStyle} >
|
|
106
|
+
|
|
107
|
+
<span className='title' > RoomCast login </span>
|
|
108
|
+
<span className='title' > broker: </span>
|
|
109
|
+
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<div className='broker-div titles-div' style={gridDivStyle} >
|
|
113
|
+
|
|
114
|
+
<div className='text-field-broker'>
|
|
115
|
+
<TextField
|
|
116
|
+
ref='textFieldBroker'
|
|
117
|
+
hintText={'broker IP address'}
|
|
118
|
+
multiLine={false}
|
|
119
|
+
errorText={this.state.errorText}
|
|
120
|
+
onChange={this.validateInput} />
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div className='submit-broker'>
|
|
126
|
+
<RaisedButton
|
|
127
|
+
label='Submit'
|
|
128
|
+
secondary={true}
|
|
129
|
+
onTouchTap={this.handleSetBroker} />
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
module.exports = BrokerPage;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var IdentityCard = require('./IdentityCard');
|
|
4
|
+
|
|
5
|
+
var IdentitiesGrid = React.createClass({
|
|
6
|
+
|
|
7
|
+
componentWillMount: function() {
|
|
8
|
+
this._externalMargin = 20;
|
|
9
|
+
this._cardMargin = 20;
|
|
10
|
+
this._heightRatio = 0.6;
|
|
11
|
+
|
|
12
|
+
this.computeGrid(this.props.identities);
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
componentWillReceiveProps: function(nextProps) {
|
|
16
|
+
this.computeGrid(nextProps.identities);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
getInitialState: function () {
|
|
20
|
+
return {
|
|
21
|
+
hasBeenSelected: false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
setHasBeenSelected: function(b) {
|
|
26
|
+
this.setState({
|
|
27
|
+
hasBeenSelected: b
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Computes grid size based on given number of configs.
|
|
33
|
+
*/
|
|
34
|
+
computeGrid: function(identities) {
|
|
35
|
+
var N = identities.length; // num of total cards
|
|
36
|
+
var i = 1; // num of rows
|
|
37
|
+
var j = 2; // num of columns
|
|
38
|
+
for(var n=1; n<=N; n++) {
|
|
39
|
+
var p = i * j;
|
|
40
|
+
if(n > p) {
|
|
41
|
+
if(i < j) {
|
|
42
|
+
i++;
|
|
43
|
+
} else {
|
|
44
|
+
j++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var cardWidth = (window.innerWidth - this._externalMargin*2 - this._cardMargin*2*j) / j;
|
|
49
|
+
var cardHeight = (window.innerHeight*this._heightRatio - this._externalMargin - this._cardMargin*2*i) / i;
|
|
50
|
+
this._cardSize = [cardWidth, cardHeight];
|
|
51
|
+
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
render: function () {
|
|
55
|
+
var self = this;
|
|
56
|
+
|
|
57
|
+
var cards = [];
|
|
58
|
+
|
|
59
|
+
var height = window.innerHeight * this._heightRatio;
|
|
60
|
+
var gridStyle = {height: height};
|
|
61
|
+
|
|
62
|
+
var cardStyle = {
|
|
63
|
+
width: this._cardSize[0],
|
|
64
|
+
height: this._cardSize[1],
|
|
65
|
+
//position: 'absolute',
|
|
66
|
+
flexBasis: this._cardSize[0]
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.props.identities.forEach(function(i, key) {
|
|
70
|
+
cards.push(
|
|
71
|
+
<IdentityCard
|
|
72
|
+
key={key}
|
|
73
|
+
name={i}
|
|
74
|
+
type={self.props.type}
|
|
75
|
+
cardStyle={cardStyle}
|
|
76
|
+
hasBeenSelected={self.state.hasBeenSelected}
|
|
77
|
+
onSelectedIdentity={self.setHasBeenSelected}
|
|
78
|
+
onSwitchPage={self.props.onSwitchPage}
|
|
79
|
+
onLogin={self.props.onLogin} />);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
|
|
84
|
+
<div className='identities-grid' style={gridStyle} >
|
|
85
|
+
{cards}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
module.exports = IdentitiesGrid;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var Mui = require('material-ui');
|
|
4
|
+
var Paper = Mui.Paper;
|
|
5
|
+
var iOSMixin = require('./iOSMixin');
|
|
6
|
+
|
|
7
|
+
var IdentityCard = React.createClass({
|
|
8
|
+
|
|
9
|
+
mixins: [iOSMixin],
|
|
10
|
+
|
|
11
|
+
componentDidMount: function() {
|
|
12
|
+
var self= this;
|
|
13
|
+
this._colorSelected = '#00bcd4';
|
|
14
|
+
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
getInitialState: function () {
|
|
18
|
+
return {
|
|
19
|
+
isSelected: false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
handleSelectedIdentity: function() {
|
|
24
|
+
var self = this;
|
|
25
|
+
|
|
26
|
+
if(!this.props.hasBeenSelected) {
|
|
27
|
+
|
|
28
|
+
this.props.onSelectedIdentity(true);
|
|
29
|
+
|
|
30
|
+
// Show selection
|
|
31
|
+
this.setState({
|
|
32
|
+
isSelected: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var callback = function() {
|
|
36
|
+
|
|
37
|
+
if(self.props.type === 'app_id') {
|
|
38
|
+
ReactMain.login.app_id = self.props.name;
|
|
39
|
+
self.props.onSwitchPage(3, {app_id: self.props.name});
|
|
40
|
+
|
|
41
|
+
} else {
|
|
42
|
+
|
|
43
|
+
if(self.props.type === 'run_id') {
|
|
44
|
+
var actionParameters = {
|
|
45
|
+
broker: ReactMain.login.broker,
|
|
46
|
+
app_id: ReactMain.login.app_id,
|
|
47
|
+
run_id: self.props.name
|
|
48
|
+
};
|
|
49
|
+
// Exit point from login
|
|
50
|
+
self.props.onLogin(actionParameters);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
setTimeout(callback, 500);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
render: function () {
|
|
61
|
+
|
|
62
|
+
var selectedCardStyle = {
|
|
63
|
+
backgroundColor: this._colorSelected,
|
|
64
|
+
color: 'white'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Copy
|
|
68
|
+
var cardStyle = {};
|
|
69
|
+
for(var p_ in this.props.cardStyle) {
|
|
70
|
+
cardStyle[p_] = this.props.cardStyle[p_];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var className='identity-card';
|
|
74
|
+
|
|
75
|
+
// Add properties if selected
|
|
76
|
+
if(this.state.isSelected) {
|
|
77
|
+
className += ' identity-card-selected';
|
|
78
|
+
for(var p in selectedCardStyle) {
|
|
79
|
+
cardStyle[p] = selectedCardStyle[p];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
|
|
86
|
+
<Paper className={className} style={cardStyle} onTouchTap={this.handleSelectedIdentity} >
|
|
87
|
+
|
|
88
|
+
<div className='card-name'>
|
|
89
|
+
|
|
90
|
+
<span> {this.props.name} </span>
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
</Paper>);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
module.exports = IdentityCard;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var IdentitiesGrid = require('./IdentitiesGrid');
|
|
4
|
+
|
|
5
|
+
var RunIdPage = React.createClass({
|
|
6
|
+
|
|
7
|
+
componentWillMount: function() {
|
|
8
|
+
var self = this;
|
|
9
|
+
var run_ids = [];
|
|
10
|
+
nutella.net.request('runs_list', 'req', function(response) {
|
|
11
|
+
response[self.props.app_id].runs.forEach(function(run_id) {
|
|
12
|
+
run_ids.push(run_id);
|
|
13
|
+
});
|
|
14
|
+
self.setState({
|
|
15
|
+
values: run_ids
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
getInitialState: function () {
|
|
21
|
+
return {
|
|
22
|
+
hasBeenSelected: false,
|
|
23
|
+
values: undefined
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
render: function () {
|
|
28
|
+
|
|
29
|
+
var titlesDivStyle = {
|
|
30
|
+
height: window.innerHeight * (0.4)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var gridDivStyle = {
|
|
34
|
+
height: window.innerHeight * (0.6)
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var run_ids_grid = null;
|
|
38
|
+
|
|
39
|
+
if(this.state.values) {
|
|
40
|
+
var backgroundMessage = null;
|
|
41
|
+
if(this.state.values.length === 0) {
|
|
42
|
+
backgroundMessage = <p className='backgroundMessage' > No available runs </p>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
run_ids_grid = (
|
|
46
|
+
<div className='grid-div' style={gridDivStyle} >
|
|
47
|
+
|
|
48
|
+
{backgroundMessage}
|
|
49
|
+
<IdentitiesGrid
|
|
50
|
+
identities={this.state.values}
|
|
51
|
+
type='run_id'
|
|
52
|
+
onLogin={this.props.onLogin} />
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
|
|
60
|
+
<div className='main-div' >
|
|
61
|
+
|
|
62
|
+
<div className='titles-div' style={titlesDivStyle} >
|
|
63
|
+
|
|
64
|
+
<img src='dist/assets/Logo_alpha.png' className='rc-logo' />
|
|
65
|
+
<span className='title' > run name: </span>
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
{run_ids_grid}
|
|
70
|
+
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
module.exports = RunIdPage;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
var iOSMixin = {
|
|
3
|
+
|
|
4
|
+
iOScall: function(actionType, actionParameters) {
|
|
5
|
+
|
|
6
|
+
// JavaScript to send an action to iOS code
|
|
7
|
+
var appName = 'roomcast';
|
|
8
|
+
var url;
|
|
9
|
+
if(actionParameters) {
|
|
10
|
+
var jsonString = (JSON.stringify(actionParameters));
|
|
11
|
+
var escapedJsonParameters = escape(jsonString);
|
|
12
|
+
url = appName + '://' + actionType + "#" + escapedJsonParameters;
|
|
13
|
+
} else {
|
|
14
|
+
url = appName + '://' + actionType;
|
|
15
|
+
}
|
|
16
|
+
document.location.href = url;
|
|
17
|
+
console.log('launching url: ', url);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = iOSMixin;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var Mui = require('material-ui');
|
|
4
|
+
var IdentitiesGrid = require('./IdentitiesGrid');
|
|
5
|
+
|
|
6
|
+
var BrokerPage = require('./BrokerPage');
|
|
7
|
+
var AppIdPage = require('./AppIdPage');
|
|
8
|
+
var RunIdPage = require('./RunIdPage');
|
|
9
|
+
var NUTELLA = require('nutella_lib');
|
|
10
|
+
|
|
11
|
+
var Main = React.createClass({
|
|
12
|
+
|
|
13
|
+
componentDidMount: function() {
|
|
14
|
+
var broker = '52.1.142.215';
|
|
15
|
+
this.initWithBroker(broker);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
initWithBroker: function(broker) {
|
|
19
|
+
var self = this;
|
|
20
|
+
|
|
21
|
+
// Start nutella
|
|
22
|
+
window.nutella = NUTELLA.init(broker, 'app_id', 'run_id', 'login', function(connected) {
|
|
23
|
+
if(connected) {
|
|
24
|
+
|
|
25
|
+
nutella.net.request('runs_list', 'req', function (response) {
|
|
26
|
+
var app_ids = [];
|
|
27
|
+
for (var app_id in response) {
|
|
28
|
+
if (response.hasOwnProperty(app_id)) {
|
|
29
|
+
app_ids.push(app_id);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
self.setState({
|
|
33
|
+
app_ids: app_ids
|
|
34
|
+
}, callback);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var callback = function() {
|
|
38
|
+
if(!self.state.app_ids) {
|
|
39
|
+
console.log('Invalid broker.');
|
|
40
|
+
} else {
|
|
41
|
+
window.ReactMain.login.broker = broker;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} else {
|
|
46
|
+
console.log('Invalid broker.');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
getInitialState: function () {
|
|
52
|
+
return {
|
|
53
|
+
identities: [],
|
|
54
|
+
page: 2,
|
|
55
|
+
app_ids: undefined,
|
|
56
|
+
app_id: undefined
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
setIdentities: function(ids) {
|
|
61
|
+
this.setState({
|
|
62
|
+
identities: ids
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
setPage: function(page) {
|
|
67
|
+
this.setState({
|
|
68
|
+
page: page
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
handleSwitchPage: function(page, params) {
|
|
73
|
+
this.setPage(page);
|
|
74
|
+
if(params) {
|
|
75
|
+
if(params.app_ids) {
|
|
76
|
+
this.setState({
|
|
77
|
+
app_ids: params.app_ids
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if(params.app_id) {
|
|
81
|
+
this.setState({
|
|
82
|
+
app_id: params.app_id
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
handleLogin: function(params) {
|
|
89
|
+
this.props.onSwitchPage(2, params);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
render: function () {
|
|
93
|
+
|
|
94
|
+
var page = null;
|
|
95
|
+
switch(this.state.page) {
|
|
96
|
+
case 1:
|
|
97
|
+
page = <BrokerPage
|
|
98
|
+
onSwitchPage={this.handleSwitchPage} />;
|
|
99
|
+
break;
|
|
100
|
+
case 2:
|
|
101
|
+
page = <AppIdPage
|
|
102
|
+
onSwitchPage={this.handleSwitchPage}
|
|
103
|
+
values={this.state.app_ids}
|
|
104
|
+
initWithBroker={this.initWithBroker} />;
|
|
105
|
+
break;
|
|
106
|
+
case 3:
|
|
107
|
+
page = <RunIdPage
|
|
108
|
+
onSwitchPage={this.handleSwitchPage}
|
|
109
|
+
app_id={this.state.app_id}
|
|
110
|
+
values={[]}
|
|
111
|
+
onLogin={this.handleLogin} />;
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return page;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
module.exports = Main;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
var React = require('react');
|
|
3
|
+
var Mui = require('material-ui');
|
|
4
|
+
|
|
5
|
+
var Login = require('./login/main');
|
|
6
|
+
var App = require('./app/main');
|
|
7
|
+
var NUTELLA = require('nutella_lib');
|
|
8
|
+
|
|
9
|
+
var Main = React.createClass({
|
|
10
|
+
|
|
11
|
+
componentDidMount: function() {
|
|
12
|
+
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
getInitialState: function () {
|
|
16
|
+
return {
|
|
17
|
+
page: 1,
|
|
18
|
+
params: undefined
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setPage: function(page) {
|
|
23
|
+
this.setState({
|
|
24
|
+
page: page
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
handleSwitchPage: function(page, params) {
|
|
29
|
+
if(params) {
|
|
30
|
+
if(params) {
|
|
31
|
+
this.setState({
|
|
32
|
+
page: page,
|
|
33
|
+
params: params
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
this.setState({
|
|
38
|
+
page: page
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
render: function () {
|
|
44
|
+
|
|
45
|
+
var page = null;
|
|
46
|
+
switch(this.state.page) {
|
|
47
|
+
case 1:
|
|
48
|
+
page = <Login
|
|
49
|
+
onSwitchPage={this.handleSwitchPage} />;
|
|
50
|
+
break;
|
|
51
|
+
case 2:
|
|
52
|
+
page = <App
|
|
53
|
+
onSwitchPage={this.handleSwitchPage}
|
|
54
|
+
params={this.state.params} />;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return page;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
module.exports = Main;
|