From f920f0cccd3f82583d00a56774223179c834120a Mon Sep 17 00:00:00 2001 From: aj Date: Fri, 18 Aug 2017 20:12:22 +0000 Subject: [PATCH] upload now works --- js/controllers/website-controller.js | 18 ++++++++---------- js/services/auth-service.js | 5 +++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 9edecb4..3911950 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -15,7 +15,7 @@ function handleFiles(ev) { // 'vm' is the Controller As name. vm = $scope.vm; vm.currentFiles = ev.target.files; - console.log(vm.currentFiles); + console.log('vm.currentFiles', vm.currentFiles); } window.document.body.addEventListener('change', handleFiles); @@ -24,17 +24,14 @@ app.controller('websiteCtrl', [ , function ($scope, $q, Auth, Oauth3) { var vm = this; - vm.oauth3 = Auth.oauth3; vm.domains = []; Auth.api = function (apiname, opts) { var els = []; return $q.all(Auth.sessions.map(function (session) { - console.log('################ Auth.api session:', session.issuer, session.subject); return Auth.select(session).then(function (oauth3) { - console.log('$$$$$$$$$$$$$$$ Auth.api session:', session.issuer, session.subject); return oauth3.api(apiname, {}).then(function (collection) { @@ -57,7 +54,6 @@ app.controller('websiteCtrl', [ }); }); })).then(function (results) { - console.log('################ Auth.api session END'); return els; }); }; @@ -68,7 +64,7 @@ app.controller('websiteCtrl', [ }); vm.getDomains = function () { - return vm.oauth3.api('domains.list', {}).then(function (result) { + return Auth.oauth3.api('domains.list', {}).then(function (result) { vm.domains = result.registrations || result; }); }; @@ -108,8 +104,7 @@ app.controller('websiteCtrl', [ } } }); - console.log('records'); - console.log(records); + console.log('dns records', records); }); }; @@ -121,7 +116,7 @@ app.controller('websiteCtrl', [ vm.createWebsite = function () { var fd = new window.FormData(); - var pkg = vm.oauth3.pkg('www@daplie.com'); + var pkg = Auth.oauth3.pkg('www@daplie.com'); //vm.unlock('webpreneur'); if (!vm.currentFiles || !vm.currentFiles.length) { window.alert('No files chosen.'); @@ -136,7 +131,10 @@ app.controller('websiteCtrl', [ return; } - return pkg.add({ hostname: vm.currentHost, multipart: { site: vm.currentFiles[0] } }); + console.log('Auth.oauth3', Auth.oauth3); + return pkg.add({ hostname: vm.currentHost, multipart: { site: vm.currentFiles[0] } }).then(function (result) { + window.alert(JSON.stringify(result)); + }); }; //vm.getDomains(); diff --git a/js/services/auth-service.js b/js/services/auth-service.js index 3888949..8ace457 100644 --- a/js/services/auth-service.js +++ b/js/services/auth-service.js @@ -93,6 +93,11 @@ app.factory('Auth', [ console.log('session.subject:', session.subject); console.log('session:', session); + promise.then(function (oauth3) { + Auth.session = session; + Auth.oauth3 = oauth3; + }) + return promise; } , signOut: function () {