WIP upload per-domain
This commit is contained in:
parent
3a36bd1f61
commit
723a22439f
|
@ -25,6 +25,20 @@ function handleFiles(ev) {
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
@ -140,26 +154,26 @@ app.controller('websiteCtrl', [
|
||||||
vm.currentHost = record.host; // .replace(new RegExp('\\.' + vm.domain.domain.replace(/\./g, '\\.') + '$', ''));
|
vm.currentHost = record.host; // .replace(new RegExp('\\.' + vm.domain.domain.replace(/\./g, '\\.') + '$', ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
vm._createWebsite = function (pkg) {
|
vm._uploadFile = function (pkg, opts) {
|
||||||
return pkg.add({
|
return pkg.add({
|
||||||
hostname: vm.currentHost
|
hostname: opts.currentHost
|
||||||
, domain: vm.currentHost
|
, domain: opts.currentHost
|
||||||
, tld: vm.domain.tld
|
, tld: opts.domain.tld
|
||||||
, sld: vm.domain.sld
|
, sld: opts.domain.sld
|
||||||
//, sub: vm.record.sub
|
//, sub: opts.record.sub
|
||||||
, multipart: { site: vm.currentFiles[0] }
|
, multipart: { site: opts.currentFiles[0] }
|
||||||
, progress: function (ev) {
|
, progress: function (ev) {
|
||||||
// TODO must digest
|
// TODO must digest
|
||||||
vm.uploadPercent = Math.round((ev.loaded / ev.total) * 100);
|
opts.uploadPercent = Math.round((ev.loaded / ev.total) * 100);
|
||||||
// TODO GiB, MiB, KiB, etc
|
// TODO GiB, MiB, KiB, etc
|
||||||
vm.uploadTotal = (ev.total / (1024 * 1024)).toFixed(2);
|
opts.uploadTotal = (ev.total / (1024 * 1024)).toFixed(2);
|
||||||
vm.uploadProgress = (ev.loaded / (1024 * 1024)).toFixed(2);
|
opts.uploadProgress = (ev.loaded / (1024 * 1024)).toFixed(2);
|
||||||
}
|
}
|
||||||
, unzip: vm.unzip
|
, unzip: opts.unzip
|
||||||
, strip: vm.stripZip
|
, strip: opts.stripZip
|
||||||
, path: vm.webPath
|
, path: opts.webPath
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
vm.uploadTotal = 0;
|
opts.uploadTotal = 0;
|
||||||
window.alert(JSON.stringify(result));
|
window.alert(JSON.stringify(result));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -211,7 +225,7 @@ app.controller('websiteCtrl', [
|
||||||
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));
|
||||||
})) {
|
})) {
|
||||||
vm._createWebsite(pkg);
|
vm._uploadFile(pkg, vm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,13 +270,20 @@ app.controller('websiteCtrl', [
|
||||||
|
|
||||||
return prom.then(function () {
|
return prom.then(function () {
|
||||||
return pkg.claim(domainReq).then(function (result) {
|
return pkg.claim(domainReq).then(function (result) {
|
||||||
return vm._createWebsite(pkg);
|
return vm._uploadFile(pkg, vm);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
vm.createWebsite = vm.Sites.create;
|
vm.Sites.setUpload = function (r) {
|
||||||
|
console.log("Hey! At least it can tell if there's a change!");
|
||||||
|
console.log(r);
|
||||||
|
};
|
||||||
|
vm.Sites.upload = function (r) {
|
||||||
|
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
||||||
|
vm._uploadFile(pkg, r);
|
||||||
|
};
|
||||||
vm.Sites.archive = function (r) {
|
vm.Sites.archive = function (r) {
|
||||||
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
-->
|
-->
|
||||||
<!-- <div class="form-group">
|
<!-- <div class="form-group">
|
||||||
<div class="pull-right"> -->
|
<div class="pull-right"> -->
|
||||||
<button ng-click="vm.createWebsite()" type="button" name="button" class="btn btn-default">Create Website</button>
|
<button ng-click="vm.Sites.create()" type="button" name="button" class="btn btn-default">Create Website</button>
|
||||||
<!-- </div>
|
<!-- </div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
@ -85,9 +85,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="white-well">
|
<div class="white-well">
|
||||||
<h1>Your Websites</h1>
|
<h1>Your Websites</h1>
|
||||||
|
<div ng-repeat="r in vm.sites">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="r in vm.sites">
|
<tr>
|
||||||
<td><a ng-href="https://{{r.domain}}" target="_blank" ng-bind="r.domain">example.com</a>
|
<td><a ng-href="https://{{r.domain}}" target="_blank" ng-bind="r.domain">example.com</a>
|
||||||
<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 -->
|
||||||
|
@ -107,5 +108,21 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="input-group">
|
||||||
|
<div><label>Select upload</label> <input type="file" ng-model="r.newFile" daplie-file-change="vm.Sites.setUpload(r)" /></div>
|
||||||
|
|
||||||
|
<div ng-if="r.isZip" ><label><input type="checkbox" ng-model="r.unzip" /> Unpack .zip</label></div>
|
||||||
|
|
||||||
|
<div ng-if="r.unzip" ><label><input type="checkbox" ng-model="r.stripZip" /> Strip zip directory root</label></div>
|
||||||
|
|
||||||
|
<!-- div ng-if="vm.isZip" ><label>Unzip directory</label> <input type="text" ng-model="vm.unzipPath" /></div -->
|
||||||
|
|
||||||
|
<div ng-if="r.uploadTotal"><span ng-bind="r.uploadPercent">99</span>% | <span ng-bind="r.uploadProgress">1</span> MiB / <span ng-bind="r.uploadTotal">100</span> MiB</div>
|
||||||
|
|
||||||
|
<div><label>Web path</label> <input type="text" ng-model="r.webPath" /></div>
|
||||||
|
|
||||||
|
<button ng-click="vm.Sites.upload(r)" type="button" name="button" class="btn btn-default">Add File</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue