var cloudflare = require('../cloudflare'); var React = require('react'); var DevModeToggle = React.createClass({ render: function() { if(this.props.devMode > 0) { var date = new Date(this.props.devMode*1000); var dateString = date.getFullYear()+'/'+(1+date.getMonth())+'/'+date.getDay()+' '+date.getHours()+':'+date.getMinutes(); return (
Active until {dateString}
); } else { return } } }); var PurgeButton = React.createClass({ getInitialState: function() { return {purging: false}; }, purgeCache: function() { this.setState({purging: true}); var reset = function() { this.setState({purging: false}); }.bind(this); cloudflare.purge_cache(this.props.domain).then(function(data) { var timeout = data.attributes.cooldown; setTimeout(reset, timeout*1000); }); }, render: function() { if(this.state.purging) { return } else { return } } }); var Settings = React.createClass({ getInitialState: function() { return {settings: {}}; }, componentDidMount: function() { this.reload(); }, reload: function() { return cloudflare.settings(this.props.domain).then(function(data) { this.setState({settings: data.response.result.objs[0]}); }.bind(this)); }, toggleDevMode: function() { cloudflare.set_devmode(this.props.domain, this.state.settings.dev_mode == 0).then(this.reload); }, render: function() { return (
Development Mode
Purge Cache
); } }); module.exports = Settings;