walnut_launchpad.html/js/controllers/website-controller.js

46 lines
1.2 KiB
JavaScript

app.controller('websiteCtrl', [
'$scope', '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();
}]);