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
|
// Angular file upload hack
|
||||||
//
|
//
|
||||||
|
@ -9,6 +13,7 @@ function analyzeFile(file, vm) {
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
function handleFiles(ev) {
|
function handleFiles(ev) {
|
||||||
var selector = 'js-file-upload';
|
var selector = 'js-file-upload';
|
||||||
var $scope;
|
var $scope;
|
||||||
|
@ -29,30 +34,23 @@ function handleFiles(ev) {
|
||||||
console.log(vm.currentFiles);
|
console.log(vm.currentFiles);
|
||||||
}
|
}
|
||||||
window.document.body.addEventListener('change', handleFiles);
|
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', [
|
app.controller('websiteCtrl', [
|
||||||
'$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout'
|
'$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout'
|
||||||
, function ($scope, $q, Auth, Oauth3, $timeout) {
|
, function ($scope, $q, Auth, Oauth3, $timeout) {
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
var angular = window.angular;
|
||||||
vm.domains = [];
|
vm.domains = [];
|
||||||
//vm.unzipPath = '/';
|
//vm.unzipPath = '/';
|
||||||
vm.uploadPath = '/';
|
vm.uploadPath = '/';
|
||||||
|
|
||||||
|
// already validated
|
||||||
|
function domainIsVerified(r) {
|
||||||
|
return r.verifiedAt || r.mode;
|
||||||
|
}
|
||||||
|
|
||||||
Auth.api = function (apiname, opts) {
|
Auth.api = function (apiname, opts) {
|
||||||
var els = [];
|
var els = [];
|
||||||
|
|
||||||
|
@ -161,13 +159,13 @@ app.controller('websiteCtrl', [
|
||||||
|
|
||||||
vm._uploadFileVm = function (pkg, opts) {
|
vm._uploadFileVm = function (pkg, opts) {
|
||||||
return vm._uploadFile(pkg, {
|
return vm._uploadFile(pkg, {
|
||||||
domain: vm.currentHost
|
domain: opts.currentHost
|
||||||
, tld: vm.domain.tld
|
, tld: opts.domain.tld
|
||||||
, sld: vm.domain.sld
|
, sld: opts.domain.sld
|
||||||
, sub: vm.domain.sub
|
, sub: opts.domain.sub
|
||||||
, newFile: vm.currentFiles[0]
|
, newFile: opts.newFile
|
||||||
, uploadPath: vm.uploadPath
|
, uploadPath: opts.uploadPath
|
||||||
, progress: vm
|
, progress: opts
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
vm._uploadFile = function (pkg, opts) {
|
vm._uploadFile = function (pkg, opts) {
|
||||||
|
@ -207,6 +205,7 @@ app.controller('websiteCtrl', [
|
||||||
var sld;
|
var sld;
|
||||||
var tld;
|
var tld;
|
||||||
|
|
||||||
|
/*
|
||||||
//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.');
|
||||||
|
@ -216,6 +215,11 @@ app.controller('websiteCtrl', [
|
||||||
window.alert('Too many files chosen.');
|
window.alert('Too many files chosen.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if (!vm.newFile) {
|
||||||
|
window.alert('No file chosen.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!vm.currentHost) {
|
if (!vm.currentHost) {
|
||||||
window.alert('No hostname chosen.');
|
window.alert('No hostname chosen.');
|
||||||
return;
|
return;
|
||||||
|
@ -238,9 +242,8 @@ app.controller('websiteCtrl', [
|
||||||
sub = parts.join('.');
|
sub = parts.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// already validated
|
|
||||||
if (vm.sites.some(function (r) {
|
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);
|
vm._uploadFileVm(pkg, vm);
|
||||||
return;
|
return;
|
||||||
|
@ -319,7 +322,7 @@ app.controller('websiteCtrl', [
|
||||||
window.open(result.data.url);
|
window.open(result.data.url);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
vm.Sites.remove = function (r) {
|
vm.Sites.remove = function (r, opts) {
|
||||||
if (!window.confirm("Delete files for this site?")) {
|
if (!window.confirm("Delete files for this site?")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +334,8 @@ app.controller('websiteCtrl', [
|
||||||
, tld: r.tld
|
, tld: r.tld
|
||||||
, sld: r.sld
|
, sld: r.sld
|
||||||
//, sub: vm.record.sub
|
//, sub: vm.record.sub
|
||||||
//, path: vm.uploadPath
|
, path: opts.path || r.path
|
||||||
|
, confirm: opts.confirm || r.confirm
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
window.alert(JSON.stringify(result));
|
window.alert(JSON.stringify(result));
|
||||||
});
|
});
|
||||||
|
@ -445,6 +449,9 @@ app.controller('websiteCtrl', [
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})).then(function () {
|
})).then(function () {
|
||||||
|
sites.forEach(function (site) {
|
||||||
|
site.pending = !domainIsVerified(site);
|
||||||
|
});
|
||||||
console.log('[listSites] sites:');
|
console.log('[listSites] sites:');
|
||||||
console.log(sites);
|
console.log(sites);
|
||||||
vm.sites = sites;
|
vm.sites = sites;
|
||||||
|
@ -483,3 +490,5 @@ app.controller('websiteCtrl', [
|
||||||
return matches;
|
return matches;
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
}());
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
<span ng-if="r.pending">(pending)</span>
|
<span ng-if="r.pending">(pending)</span>
|
||||||
<a ng-href="{{r.download}}" target="_blank">Download</a>
|
<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.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>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" ng-model="r.newPath" placeholder="/" />
|
<input type="text" ng-model="r.newPath" placeholder="/" />
|
||||||
|
|
Loading…
Reference in New Issue