reorganized frontend components

This commit is contained in:
Henry Ault 2015-05-21 19:53:50 -07:00
parent b5d7375817
commit 8515db0b3a

View File

@ -9,6 +9,88 @@ tr = React.DOM.tr
td = React.DOM.td
input = React.DOM.input
DOControls = React.createClass({
createDroplet: function(){
urb.send({appl: "cloud",
data: {
action:'create',
name:$('#name').val(),
region:$('#region').val(),
size:$('#size').val(),
image:$('#image').val(),
ssh:[], // $('#ssh').val()]
backups:null,//$('#backups').val(),
ipv6:null,//$('#ipv6').val(),
priv_networking:null,//$('#priv-networking').val(),
user_data:null//$('#user-data').val()
},
mark: "json"})
},
render: function(){
href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fcloud%2Ffab&response_type=code&scope=read+write"
return (
div({}, [
div({},
a({href:href},"get authcode"),
b({onClick:this.props.handleClick('do')}, "Send Authcode")
),
div({}, [
input({id:"appsecret"},
b({onClick:this.props.sendSecret('do','#appsecret')}, "Send Secret"))
]),
div({}, [
b({onClick:this.createDroplet}, "Create Droplet"),
input({id:"name",placeholder:"Name of droplet"}),
input({id:"region",placeholder:"Region"}),
input({id:"size",placeholder:"Size (str ending in mb"}),
input({id:"image",placeholder:"Image"}),
input({id:"ssh",placeholder:"ssh keys (optional)"}),
input({id:"backups",placeholder:"backups (optional)"}),
input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}),
input({id:"user-data",placeholder:" user-data string (optional)"}),
input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"})
])
])
)
}
})
GCEControls = React.createClass({
createDroplet: function(){
urb.send({
})
}
render: function(){
ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com"
return(
div({}, [
div({}, [
a({href:ghref},"Get Google Authcode"),
b({onClick:this.props.handleClick('gce','#gappsecret')}, "Send Google Authcode")
]),
div({}, [
input({id:"gappsecret"},
b({onClick:this.props.sendSecret('gce')}, "Send Google Secret"))
]),
div({}, [
b({onClick:this.createDroplet}, "Create Droplet"),
input({id:"project",placeholder:"project"}),
input({id:"zone",placeholder:"zone"}),
input({id:"name",placeholder:"Name of droplet"}),
input({id:"size",placeholder:"Size (str ending in mb"}),
input({id:"image",placeholder:"Image"}),
input({id:"ssh",placeholder:"ssh keys (optional)"}),
input({id:"backups",placeholder:"backups (optional)"}),
input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}),
input({id:"user-data",placeholder:" user-data string (optional)"}),
input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"})
])
)}
})
Droplet = React.createClass({
dropletAction:function(id, action){
urb.send({
@ -17,13 +99,6 @@ Droplet = React.createClass({
id: id}})
},
rebootDroplet: function() {
urb.send({
appl: "cloud",
data: {action: 'reboot',
id: this.props.id}})
},
render: function() {
var $this = this //local var, else it always points at second
var acts = ["reboot","power_cycle","shutdown","power_off","power_on","password_reset",
@ -79,65 +154,13 @@ Page = recl({
mark: "json"})
},
createDroplet: function(){
urb.send({appl: "cloud",
data: {
action:'create',
name:$('#name').val(),
region:$('#region').val(),
size:$('#size').val(),
image:$('#image').val(),
ssh:[], // $('#ssh').val()]
backups:null,//$('#backups').val(),
ipv6:null,//$('#ipv6').val(),
priv_networking:null,//$('#priv-networking').val(),
user_data:null//$('#user-data').val()
},
mark: "json"})
},
render: function(){
href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fcloud%2Ffab&response_type=code&scope=read+write"
ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com"
return (div({}, [
div({},
a({href:href},[
"get authcode"
]),
b({onClick:this.handleClick('do')}, "Send Authcode")
),
div({}, [
input({id:"appsecret"},
b({onClick:this.sendSecret('do','#appsecret')}, "Send Secret"))
]),
b({onClick:this.getList}, "Get List"),
div({},
a({href:ghref},[
"Get Google Authcode"
]),
b({onClick:this.handleClick('gce','#gappsecret')}, "Send Google Authcode")
),
div({}, [
input({id:"gappsecret"},
b({onClick:this.sendSecret('gce')}, "Send Google Secret"))
]),
div({}, [
b({onClick:this.createDroplet}, "Create Droplet"),
input({id:"name",placeholder:"Name of droplet"}),
input({id:"region",placeholder:"Region"}),
input({id:"size",placeholder:"Size (str ending in mb"}),
input({id:"image",placeholder:"Image"}),
input({id:"ssh",placeholder:"ssh keys (optional)"}),
input({id:"backups",placeholder:"backups (optional)"}),
input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}),
input({id:"user-data",placeholder:" user-data string (optional)"}),
input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"})
]),
div({},
this.props.droplets.map(Droplet)
)
])
)
return (div({},
DOControls({handleClick:this.handleClick,sendSecret:this.sendSecret}),
GCEControls({handleClick:this.handleClick,sendSecret:this.sendSecret})
))
//this.props.droplets.map(Droplet)
}
})