diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 3b26ead..182c992 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -158,7 +158,8 @@ app.controller('websiteCtrl', [ return -1 !== ('.' + sub).indexOf(('.' + domain)); }; - vm.createWebsite = function () { + vm.Sites = {}; + vm.Sites.create = function () { console.log('##### Auth.oauth3'); console.log(Auth.oauth3); @@ -269,6 +270,40 @@ app.controller('websiteCtrl', [ }); }; + vm.createWebsite = vm.Sites.create; + vm.Sites.archive = function (r) { + var pkg = Auth.oauth3.pkg('www@daplie.com'); + + return pkg.archive({ + hostname: r.domain + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: vm.record.sub + //, path: vm.webPath + }).then(function (result) { + window.alert(JSON.stringify(result)); + // TODO use iframe to initiate download? + window.open(result.data.url); + }); + }; + vm.Sites.remove = function (r) { + if (!window.confirm("Delete files for this site?")) { + return; + } + + var pkg = Auth.oauth3.pkg('www@daplie.com'); + return pkg.remove({ + hostname: r.domain + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: vm.record.sub + //, path: vm.webPath + }).then(function (result) { + window.alert(JSON.stringify(result)); + }); + }; vm.listSites = function () { var sites = []; @@ -295,6 +330,8 @@ app.controller('websiteCtrl', [ }); }); })).then(function () { + console.log('[www] sites'); + console.log(sites); vm.sites = sites; }); }; diff --git a/js/www@daplie.com.js b/js/www@daplie.com.js index 2cb17b6..c3ffa19 100644 --- a/js/www@daplie.com.js +++ b/js/www@daplie.com.js @@ -11,7 +11,7 @@ OAUTH3._pkgs['www@daplie.com'] = { return OAUTH3.request({ method: 'POST' , url: OAUTH3.url.normalize(providerUri) - + '/api/www@daplie.com/acl/add/' + opts.hostname + + '/api/www@daplie.com/acl/sites/' + opts.hostname + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, unzip: opts.unzip, strip: opts.strip, path: opts.path }) , session: session , multipart: opts.multipart // special property to be figured out by browser request code @@ -19,6 +19,35 @@ OAUTH3._pkgs['www@daplie.com'] = { return result; }); } +, archive: function (opts) { + var providerUri = opts.audience; + var session = opts.session; + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/www@daplie.com/acl/archives/' + opts.hostname + + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, strip: opts.strip, path: opts.path }) + , session: session + }).then(function (result) { + return result; + }); + } +, remove: function (opts) { + var providerUri = opts.audience; + var session = opts.session; + + return OAUTH3.request({ + method: 'DELETE' + , url: OAUTH3.url.normalize(providerUri) + + '/api/www@daplie.com/acl/sites/' + opts.hostname + + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path }) + , session: session + , multipart: opts.multipart // special property to be figured out by browser request code + }).then(function (result) { + return result; + }); + } , list: function (opts) { var providerUri = opts.audience; var session = opts.session; diff --git a/templates/website.html b/templates/website.html index 0dede8b..6f6195b 100644 --- a/templates/website.html +++ b/templates/website.html @@ -74,7 +74,7 @@
example.com | +example.com | Sites > blogs > blog.jane.smith.net | jane@smith.net, jack@smith.net, friend@gmail.com |