list shares

This commit is contained in:
aj 2017-09-06 00:25:00 +00:00
parent b5195b1a14
commit 439e58bb25
3 changed files with 50 additions and 3 deletions

View File

@ -354,7 +354,8 @@ app.controller('websiteCtrl', [
vm.Shares.invite = function (r) {
var pkg = Auth.oauth3.pkg('www@daplie.com');
return pkg.invite({
email: r.shareEmail
comment: r.shareEmail
, email: r.shareEmail
, domain: r.domain
, tld: r.tld
, sld: r.sld
@ -374,6 +375,24 @@ app.controller('websiteCtrl', [
vm.listSites();
});
};
vm.Shares.list = function (r) {
var pkg = Auth.oauth3.pkg('www@daplie.com');
console.log('actual record:');
console.log(r);
return pkg.listShares({
domain: r.domain
, hostname: r.domain
, tld: r.tld
, sld: r.sld
//, sub: r.sub
, path: r.sharePath
}).then(function (result) {
console.log('list shares result:');
console.log(result);
r.sharedWith = result.data;
//r.usersnames = r.sharedWith.map().join(',');
});
};
vm.listSites = function () {
var sites = [];

View File

@ -28,6 +28,21 @@ OAUTH3._pkgs['www@daplie.com'] = {
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, strip: opts.strip, path: opts.path })
;
}
, listShares: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
// TODO needs a way to have api and assets for audience
return OAUTH3.request({
method: 'GET'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname)
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path })
, session: session
}).then(function (result) {
return result;
});
}
, invite: function (opts) {
var providerUri = opts.audience;
var session = opts.session;
@ -37,7 +52,15 @@ OAUTH3._pkgs['www@daplie.com'] = {
method: 'POST'
, url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname)
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, mode: opts.mode, path: opts.path })
+ '?' + OAUTH3.utils.query.stringify({
tld: opts.tld
, sld: opts.sld
/*, sub: opts.sub*/
, mode: opts.mode
, path: opts.path
, email: opts.email
, comment: opts.comment
})
, session: session
}).then(function (result) {
return result;

View File

@ -98,12 +98,17 @@
<button class="btn btn-default" ng-click="vm.Sites.contents(r)">List Files</button>
</td>
<td ng-bind="r.path">Sites > blogs > blog.jane.smith.net</td>
<td ng-bind="r.users">jane@smith.net, jack@smith.net, friend@gmail.com</td>
<td><span ng-repeat="share in r.sharedWith" ng-if="!share.me">
<span ng-bind="share.path">/</span>
<span ng-bind="share.comment">friend@email.com</span>
(<span ng-bind="share.mode">rwx</span>)
</span></td>
<td>
<input type="text" ng-model="r.shareEmail" placeholder="ex: john@example.com" />
<input type="text" ng-model="r.sharePath" placeholder="/" />
<input type="text" ng-model="r.shareMode" placeholder="rwx (read, write, invite)" />
<button class="btn btn-default" ng-click="vm.Shares.invite(r)">Invite</button>
<button class="btn btn-default" ng-click="vm.Shares.list(r)">List Shares</button>
</td>
</tr>
</tbody>