add some of the website logic

This commit is contained in:
aj 2017-08-14 19:45:19 +00:00
parent fc3f6c5403
commit 856413a403
2 changed files with 64 additions and 1 deletions

View File

@ -1,3 +1,43 @@
app.controller('WebsiteController', [function($scope) {
app.controller('WebsiteController', [ 'azp@oauth3.org', function ($scope, Oauth3) {
var vm = this;
vm.oauth3 = Oauth3.oauth3;
vm.getDomains = function () {
vm.oauth3.api('domains.list', {}).then(function (result) {
vm.domains = result.registrations || result;
});
};
vm.selectDomain = function (domain) {
vm.domain = domain;
return vm.oauth3.api('dns.list', { }).then(function (records) {
records = records.filter(function (r) {
return /^A(AAA)?$/i.test(r.type) && ((r.sld + '.' + r.tld) === domain || r.zone === domain.domain);
});
vm.records = records;
console.log('records');
console.log(records);
});
};
vm.selectRecord = function (record) {
vm.record = record;
vm.currentHost = record.host; // .replace(new RegExp('\\.' + vm.domain.domain.replace(/\./g, '\\.') + '$', ''));
};
vm.setFiles = function (files) {
console.log('setFiles');
console.log(files);
console.log(vm.newFiles);
};
vm.createWebsite = function () {
var fd = new window.FormData();
var pkg = vm.oauth3.pkg('www@daplie.com');
return pkg.add({ hostname: vm.currentHost, multipart: { site: vm.currentFiles[0] } });
};
//vm.getDomains();
}]);

23
js/www@daplie.com.js Normal file
View File

@ -0,0 +1,23 @@
;(function (exports) {
'use strict';
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3;
OAUTH3._pkgs['www@daplie.com'] = {
add: 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/www/' + opts.hostname
, session: session
, multipart: opts.multipart // special property to be figured out by browser request code
}).then(function (res) {
return res;
});
}
};
}('undefined' !== typeof exports ? exports : window));