var UIJSONAttribute = React.createClass ({ getInitialState: function() { return({ type: "string", value: "", key: "", application: undefined, instance: undefined, component: undefined }) }, handleTypeChange: function(type) { this.setState({type: type}); this.updateJson = true; }, handleKeyChange: function(event) { /* switch(this.state.type) { case "string": this.setState({key: event.target.value}); break; } */ this.setState({key: event.target.value}); this.props.updateJSON(); }, handleValueChange: function() { switch(this.state.type) { case "string": case "number": this.setState({value: event.target.value}); break; } this.props.updateJSON(); }, getJson: function() { if(this.props.keyEnabled) { var json = {}; switch (this.state.type) { case "string": json[this.refs.key.getDOMNode().value] = this.refs.value.getDOMNode().value; break; case "number": json[this.refs.key.getDOMNode().value] = parseFloat(this.refs.value.getDOMNode().value); break; case "array": // TODO: check refs json[this.refs.key.getDOMNode().value] = this.refs.array.getJson(); break; case "object": json[this.refs.key.getDOMNode().value] = this.refs.object.getJson(); break; } return json; } else { switch (this.state.type) { case "string": return this.refs.value.getDOMNode().value; break; case "number": return parseFloat(this.refs.value.getDOMNode().value); break; case "array": // TODO: check refs return this.refs.array.getJson(); break; case "object": return this.refs.object.getJson(); break; } } }, render: function() { var self = this; var inputBox = ""; switch(this.state.type) { case "string": case "number": inputBox =
{JSON.stringify(this.props.json, null, 4)}
);
},
/*
componentDidUpdate: function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
}
*/
});
var UIMessageSend = React.createClass ({
getInitialState: function() {
return {
application: undefined,
instance: undefined,
component: undefined,
json: {}
}
},
componentDidMount: function() {
var self = this;
notificationCenter.subscribe(Notifications.alerts.ALERT_CHANGE, function() {
self.setState({
application: alertsModel.application,
instance: alertsModel.instance,
component: alertsModel.component
});
});
},
updateJSON: function() {
//alert("Update JSON");
this.setState({json: this.refs.jsonObject.getJson()})
},
sendMessage: function() {
alert("Send message");
var payload = this.refs.jsonObject.getJson();
console.log(payload);
var channel = messageModel.channel;
nutellaFramework.f.net.publish_to_run(this.state.application, this.state.instance, channel, payload)
},
render: function() {
var self = this;
subscription = [];
if(this.state.application != undefined) {
subscription.push(application: {this.state.application});
}
if(this.state.instance != undefined) {
subscription.push( instance: {this.state.instance});
}
if(this.state.component != undefined) {
subscription.push( component: {this.state.component});
}
subscription.push( on channel: {messageModel.channel});
return (