use path and confirm for deleting
This commit is contained in:
parent
7ca86c8074
commit
efbe637e1b
|
@ -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;
|
||||
};
|
||||
}]);
|
||||
|
||||
}());
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<span ng-if="r.pending">(pending)</span>
|
||||
<a ng-href="{{r.download}}" target="_blank">Download</a>
|
||||
<!-- button class="btn btn-link" ng-click="vm.Sites.archive(r)">download</button -->
|
||||
<button class="btn btn-link" ng-click="vm.Sites.remove(r)">Clear</button>
|
||||
<button class="btn btn-link" ng-click="vm.Sites.remove(r, { path: '/', confirm: true })">Clear</button>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" ng-model="r.newPath" placeholder="/" />
|
||||
|
|
Loading…
Reference in New Issue