diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index f6b77f2..29fe4bb 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -1,3 +1,7 @@ +(function () { +'use strict'; + +var app = window.app; // // Angular file upload hack // @@ -9,6 +13,7 @@ function analyzeFile(file, vm) { return vm; } +/* function handleFiles(ev) { var selector = 'js-file-upload'; var $scope; @@ -29,30 +34,23 @@ function handleFiles(ev) { console.log(vm.currentFiles); } window.document.body.addEventListener('change', handleFiles); - -app.directive('daplieFileChange', function () { - return { - restrict: 'A', - require:"ngModel", - link: function (scope, element, attrs, ngModel) { - element.bind('change', function (event) { - var files = event.target.files; - ngModel.$setViewValue(files[0]); - scope.$eval(attrs.daplieFileChange); - }); - } - }; -}); +*/ app.controller('websiteCtrl', [ '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout' , function ($scope, $q, Auth, Oauth3, $timeout) { var vm = this; + var angular = window.angular; vm.domains = []; //vm.unzipPath = '/'; vm.uploadPath = '/'; + // already validated + function domainIsVerified(r) { + return r.verifiedAt || r.mode; + } + Auth.api = function (apiname, opts) { var els = []; @@ -161,13 +159,13 @@ app.controller('websiteCtrl', [ vm._uploadFileVm = function (pkg, opts) { return vm._uploadFile(pkg, { - domain: vm.currentHost - , tld: vm.domain.tld - , sld: vm.domain.sld - , sub: vm.domain.sub - , newFile: vm.currentFiles[0] - , uploadPath: vm.uploadPath - , progress: vm + domain: opts.currentHost + , tld: opts.domain.tld + , sld: opts.domain.sld + , sub: opts.domain.sub + , newFile: opts.newFile + , uploadPath: opts.uploadPath + , progress: opts }); }; vm._uploadFile = function (pkg, opts) { @@ -207,6 +205,7 @@ app.controller('websiteCtrl', [ var sld; var tld; + /* //vm.unlock('webpreneur'); if (!vm.currentFiles || !vm.currentFiles.length) { window.alert('No files chosen.'); @@ -216,6 +215,11 @@ app.controller('websiteCtrl', [ window.alert('Too many files chosen.'); return; } + */ + if (!vm.newFile) { + window.alert('No file chosen.'); + return; + } if (!vm.currentHost) { window.alert('No hostname chosen.'); return; @@ -238,9 +242,8 @@ app.controller('websiteCtrl', [ sub = parts.join('.'); } - // already validated if (vm.sites.some(function (r) { - return -1 !== ('.' + vm.currentHost).indexOf(('.' + r.domain)); + return (-1 !== ('.' + vm.currentHost).indexOf(('.' + r.domain))) && domainIsVerified(r); })) { vm._uploadFileVm(pkg, vm); return; @@ -319,7 +322,7 @@ app.controller('websiteCtrl', [ window.open(result.data.url); }); }; - vm.Sites.remove = function (r) { + vm.Sites.remove = function (r, opts) { if (!window.confirm("Delete files for this site?")) { return; } @@ -331,7 +334,8 @@ app.controller('websiteCtrl', [ , tld: r.tld , sld: r.sld //, sub: vm.record.sub - //, path: vm.uploadPath + , path: opts.path || r.path + , confirm: opts.confirm || r.confirm }).then(function (result) { window.alert(JSON.stringify(result)); }); @@ -445,6 +449,9 @@ app.controller('websiteCtrl', [ }); }); })).then(function () { + sites.forEach(function (site) { + site.pending = !domainIsVerified(site); + }); console.log('[listSites] sites:'); console.log(sites); vm.sites = sites; @@ -483,3 +490,5 @@ app.controller('websiteCtrl', [ return matches; }; }]); + +}()); diff --git a/templates/website.html b/templates/website.html index 344b370..db20386 100644 --- a/templates/website.html +++ b/templates/website.html @@ -94,7 +94,7 @@ (pending) Download - +