diff --git a/base/pub/cloud/fab/hymn.hook b/base/pub/cloud/fab/hymn.hook index 75735100a6..05b8131d63 100644 --- a/base/pub/cloud/fab/hymn.hook +++ b/base/pub/cloud/fab/hymn.hook @@ -9,7 +9,6 @@ !: ^- manx =+ do=(~(get by qix.gas) %'code') -=+ g=(~(get by qix.gas) %'access_token') ;html ;head @@ -21,11 +20,10 @@ ;title: DO & GCE Manager == ;body - ;* =+ d=?~(do ~ (trip u.do)) - =+ g=?~(g ~ (trip u.g)) - ~& d - :_ ~ - ;script: authcode='{?~(d g d)}'; console.log(authcode) + ;script:""" + var authcode = \{} + authcode.do='{?~(do ~ (trip u.do))}' + """ ;div#container; ;script@"/home/pub/cloud/src/main.js"; == diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index 7fe39025d2..faade1da3a 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -9,6 +9,18 @@ tr = React.DOM.tr td = React.DOM.td input = React.DOM.input +function HashToJSON() { + var pairs = window.location.hash.slice(1).split('&'); + var result = {}; + pairs.forEach(function(pair) { + pair = pair.split('='); + result[pair[0]] = decodeURIComponent(pair[1] || ''); + }); + + return JSON.parse(JSON.stringify(result)); +} + + DOControls = React.createClass({ createDroplet: function(){ urb.send({appl: "cloud", @@ -114,8 +126,8 @@ Droplet = React.createClass({ dropletAction:function(id, action){ urb.send({ appl:"cloud", - data: {action: action, - id: id}}) + data: {action:action, + id:id}}) }, render: function() { @@ -143,10 +155,11 @@ Page = recl({ handleClick: function(platform){ return function(){ console.log(platform); + console.log(window.authcode.platform) if(window.authcode.length !== ''){ urb.send({ appl: "cloud", - data: {authcode:window.authcode, + data: {authcode:authcode[platform], platform:platform}, mark: "cloud-auth"}) } else { console.log("nocode") } @@ -182,6 +195,8 @@ Page = recl({ } }) +var hash = HashToJSON() //pull out hash of query string for gce authcode +authcode.gce = hash.access_token mounted = React.render(Page({droplets:[]}), $("#container")[0]) urb.bind("/", function(err,d) {