upload now works

This commit is contained in:
aj 2017-08-18 20:12:22 +00:00
parent a6f17c7105
commit f920f0cccd
2 changed files with 13 additions and 10 deletions

View File

@ -15,7 +15,7 @@ function handleFiles(ev) {
// 'vm' is the Controller As name. // 'vm' is the Controller As name.
vm = $scope.vm; vm = $scope.vm;
vm.currentFiles = ev.target.files; vm.currentFiles = ev.target.files;
console.log(vm.currentFiles); console.log('vm.currentFiles', vm.currentFiles);
} }
window.document.body.addEventListener('change', handleFiles); window.document.body.addEventListener('change', handleFiles);
@ -24,17 +24,14 @@ app.controller('websiteCtrl', [
, function ($scope, $q, Auth, Oauth3) { , function ($scope, $q, Auth, Oauth3) {
var vm = this; var vm = this;
vm.oauth3 = Auth.oauth3;
vm.domains = []; vm.domains = [];
Auth.api = function (apiname, opts) { Auth.api = function (apiname, opts) {
var els = []; var els = [];
return $q.all(Auth.sessions.map(function (session) { return $q.all(Auth.sessions.map(function (session) {
console.log('################ Auth.api session:', session.issuer, session.subject);
return Auth.select(session).then(function (oauth3) { return Auth.select(session).then(function (oauth3) {
console.log('$$$$$$$$$$$$$$$ Auth.api session:', session.issuer, session.subject);
return oauth3.api(apiname, {}).then(function (collection) { return oauth3.api(apiname, {}).then(function (collection) {
@ -57,7 +54,6 @@ app.controller('websiteCtrl', [
}); });
}); });
})).then(function (results) { })).then(function (results) {
console.log('################ Auth.api session END');
return els; return els;
}); });
}; };
@ -68,7 +64,7 @@ app.controller('websiteCtrl', [
}); });
vm.getDomains = function () { 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; vm.domains = result.registrations || result;
}); });
}; };
@ -108,8 +104,7 @@ app.controller('websiteCtrl', [
} }
} }
}); });
console.log('records'); console.log('dns records', records);
console.log(records);
}); });
}; };
@ -121,7 +116,7 @@ app.controller('websiteCtrl', [
vm.createWebsite = function () { vm.createWebsite = function () {
var fd = new window.FormData(); var fd = new window.FormData();
var pkg = vm.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
//vm.unlock('webpreneur'); //vm.unlock('webpreneur');
if (!vm.currentFiles || !vm.currentFiles.length) { if (!vm.currentFiles || !vm.currentFiles.length) {
window.alert('No files chosen.'); window.alert('No files chosen.');
@ -136,7 +131,10 @@ app.controller('websiteCtrl', [
return; 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(); //vm.getDomains();

View File

@ -93,6 +93,11 @@ app.factory('Auth', [
console.log('session.subject:', session.subject); console.log('session.subject:', session.subject);
console.log('session:', session); console.log('session:', session);
promise.then(function (oauth3) {
Auth.session = session;
Auth.oauth3 = oauth3;
})
return promise; return promise;
} }
, signOut: function () { , signOut: function () {