aboutsummaryrefslogtreecommitdiffstats
path: root/view
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-12-21 21:37:10 +0000
committerMario <mario@mariovavti.com>2020-12-21 21:37:10 +0000
commitd118ab71e6aa4f300ba6e42663d13a63a2323122 (patch)
tree08282fa1dfb0a2f975fd9d338df7677fa84ea5e9 /view
parent81a1aedeb9a4e07c3d1e11905ad3e2434d635e86 (diff)
downloadvolse-hubzilla-d118ab71e6aa4f300ba6e42663d13a63a2323122.tar.gz
volse-hubzilla-d118ab71e6aa4f300ba6e42663d13a63a2323122.tar.bz2
volse-hubzilla-d118ab71e6aa4f300ba6e42663d13a63a2323122.zip
files_ng: implement directory and bulk file download
Diffstat (limited to 'view')
-rw-r--r--view/js/mod_cloud.js43
-rw-r--r--view/tpl/cloud_directory.tpl11
2 files changed, 50 insertions, 4 deletions
diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js
index cbd9c2a08..736dec471 100644
--- a/view/js/mod_cloud.js
+++ b/view/js/mod_cloud.js
@@ -56,6 +56,24 @@ $(document).ready(function () {
close_and_deactivate_all_panels();
});
+ $('.cloud-tool-dir-download-btn').on('click', function (e) {
+ e.preventDefault();
+ close_and_deactivate_all_panels()
+
+ let id = $(this).data('id');
+ if(! id) {
+ return false;
+ }
+
+ close_and_deactivate_all_panels();
+
+ // some trickery to trigger download action via ajax
+ let form = $('<form></form>').attr('action', 'attach').attr('method', 'post');
+ form.append($("<input></input>").attr('type', 'hidden').attr('name', 'channel_id').attr('value', channelId));
+ form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', id));
+ form.appendTo('body').submit().remove();
+ });
+
$('.cloud-tool-delete-btn').on('click', function (e) {
e.preventDefault();
let id = $(this).data('id');
@@ -255,14 +273,37 @@ $(document).ready(function () {
$('#cloud-multi-tool-submit, #cloud-multi-tool-categories').show();
});
+ $('#cloud-multi-tool-download-btn').on('click', function (e) {
+ e.preventDefault();
+
+ let post_data = $('.cloud-multi-tool-checkbox:checked');
+
+ if(! post_data.length) {
+ return false;
+ }
+
+ close_and_deactivate_all_panels();
+
+ // some trickery to trigger download action via ajax
+ var form = $('<form></form>').attr('action', 'attach').attr('method', 'post');
+ form.append($("<input></input>").attr('type', 'hidden').attr('name', 'channel_id').attr('value', channelId));
+ post_data.each(function () {
+ form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', this.value));
+ });
+ form.appendTo('body').submit().remove();
+ });
+
$('#cloud-multi-tool-delete-btn').on('click', function (e) {
e.preventDefault();
- let post_data = $('.cloud-multi-tool-checkbox').serializeArray();
+ close_and_deactivate_all_panels();
+
+ let post_data = $('.cloud-multi-tool-checkbox:checked').serializeArray();
if(! post_data.length) {
return false;
}
+
let confirm = confirmDelete();
if (confirm) {
$('body').css('cursor', 'wait');
diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl
index a6993fe97..5886391bb 100644
--- a/view/tpl/cloud_directory.tpl
+++ b/view/tpl/cloud_directory.tpl
@@ -87,6 +87,7 @@
{{/if}}
<a id="cloud-multi-tool-move-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-multi-tool-categories-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
+ <a id="cloud-multi-tool-download-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
<a id="cloud-multi-tool-delete-btn" class="dropdown-item" href="#"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
</div>
</div>
@@ -172,23 +173,27 @@
<a id="cloud-tool-rename-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-rename-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-pencil"></i> Rename</a>
<a id="cloud-tool-move-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-move-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-copy"></i> Move or copy</a>
<a id="cloud-tool-categories-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-categories-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-asterisk"></i> Categories</a>
- {{if !$item.collection}}
{{if $item.is_owner}}
<a id="cloud-tool-share-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-share-btn" href="/rpost?attachment=[attachment]{{$item.resource}},{{$item.revision}}[/attachment]&acl[allow_cid]={{$item.raw_allow_cid}}&acl[allow_gid]={{$item.raw_allow_gid}}&acl[deny_cid]={{$item.raw_deny_cid}}&acl[deny_gid]={{$item.raw_deny_gid}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-share-square-o"></i> Post</a>
{{/if}}
+ {{if $item.collection}}
+ <a id="cloud-tool-dir-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-dir-download-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
+ {{else}}
<a id="cloud-tool-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
{{/if}}
<a id="cloud-tool-delete-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-delete-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-trash-o"></i> {{$delete}}</a>
</div>
</div>
{{else}}
- {{if ($is_admin || !$item.collection) && $item.attach_id}}
+ {{if $is_admin || $item.attach_id}}
<div class="dropdown">
<button class="btn btn-link btn-sm" id="dropdown-button-{{$item.attach_id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-ellipsis-v"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-button-{{$item.attach_id}}">
- {{if !$item.collection}}
+ {{if $item.collection}}
+ <a id="cloud-tool-dir-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-dir-download-btn" href="#" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
+ {{else}}
<a id="cloud-tool-download-btn-{{$item.attach_id}}" class="dropdown-item cloud-tool-download-btn" href="/attach/{{$item.resource}}" data-id="{{$item.attach_id}}"><i class="fa fa-fw fa-cloud-download"></i> Download</a>
{{/if}}
{{if $is_admin}}