diff --git a/unleash-server/public/js/unleash.jsx b/unleash-server/public/js/unleash.jsx
index c88cd8d44e..2545049c69 100644
--- a/unleash-server/public/js/unleash.jsx
+++ b/unleash-server/public/js/unleash.jsx
@@ -19,9 +19,22 @@ var UnsavedFeature = React.createClass({
});
var SavedFeature = React.createClass({
+
+ onChange: function(event) {
+ this.props.onChange({
+ name: this.props.feature.name,
+ field: 'enabled',
+ value: event.target.checked
+ });
+ },
+
render: function() {
return (
-
{this.props.feature.name}
+
+ {this.props.feature.name}
+ {this.props.feature.strategy}
+
+
);
}
});
@@ -32,16 +45,16 @@ var FeatureList = React.createClass({
this.props.unsavedFeatures.forEach(function(feature) {
featureNodes.push();
- });
+ }.bind(this));
this.props.savedFeatures.forEach(function(feature) {
featureNodes.push(
-
+
);
- });
+ }.bind(this));
return ({featureNodes}
);
}
@@ -55,7 +68,7 @@ var Unleash = React.createClass({
componentDidMount: function () {
this.loadFeaturesFromServer();
- setInterval(this.loadFeaturesFromServer, this.props.pollInterval);
+ // setInterval(this.loadFeaturesFromServer, this.props.pollInterval);
},
loadFeaturesFromServer: function () {
@@ -67,12 +80,28 @@ var Unleash = React.createClass({
},
handleError: function (error) {
- // TODO: ErrorComponent
+ // TODO: ErrorComponent could use ...
window.alert(error);
},
updateFeature: function (changeRequest) {
- console.log(changeRequest);
+ var newFeatures = this.state.savedFeatures;
+ newFeatures.forEach(function(f){
+ if(f.name === changeRequest.name) {
+ f[changeRequest.field] = changeRequest.value;
+ }
+ });
+
+ this.setState({features: newFeatures});
+
+ reqwest({
+ url: 'features/' + changeRequest.name,
+ method: 'patch',
+ type: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(changeRequest)
+ }).then(function() {
+ }, this.handleError.bind(this));
},
createFeature: function (feature) {
@@ -82,12 +111,19 @@ var Unleash = React.createClass({
render: function() {
return (
);
}