Skip to content

Commit 90460be

Browse files
committed
New button in file manager that triggers the right click menu
Enable’s support on mobile devices and those who cannot right click (blessed be them) closes pterodactyl#182
1 parent 1eb1f96 commit 90460be

File tree

3 files changed

+101
-88
lines changed

3 files changed

+101
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
66
## v0.5.4 (Bodacious Boreopterus)
77
### Added
88
* Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot.
9+
* New button in file manager that triggers the right click menu to enable support on mobile devices and those who cannot right click (blessed be them).
910

1011
### Changed
1112
* File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached.

resources/views/server/files/list.blade.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
<thead>
2222
<tr>
2323
<th style="width:2%;text-align:center;"><i class="fa fa-refresh muted muted-hover use-pointer" data-action="reload-files"></i></th>
24-
<th style="width:45%">File Name</th>
24+
<th style="width:55%">File Name</th>
2525
<th style="width:15%">Size</th>
2626
<th style="width:20%">Last Modified</th>
27+
<th style="width:8%"></th>
2728
</tr>
2829
<tr id="headerTableRow" data-currentdir="{{ $directory['header'] }}">
2930
<th><i class="fa fa-folder-open"></i></th>
30-
<th colspan="3">
31+
<th colspan="4">
3132
<code>/home/container{{ $directory['header'] }}</code>
3233
<small>
3334
<a href="/server/{{ $server->uuidShort }}/files/add/@if($directory['header'] !== '')?dir={{ $directory['header'] }}@endif" class="text-muted">
@@ -44,6 +45,7 @@
4445
<td><a href="/server/{{ $server->uuidShort }}/files" data-action="directory-view">&larr;</a></a></td>
4546
<td></td>
4647
<td></td>
48+
<td></td>
4749
</tr>
4850
@endif
4951
@if (isset($directory['show']) && $directory['show'] === true)
@@ -54,6 +56,7 @@
5456
</td>
5557
<td></td>
5658
<td></td>
59+
<td></td>
5760
</tr>
5861
@endif
5962
@foreach ($folders as $folder)
@@ -73,6 +76,7 @@
7376
{{ $carbon->diffForHumans() }}
7477
@endif
7578
</td>
79+
<td><button class="btn btn-xxs btn-default" data-action="toggleMenu" style="padding:0px 6px;"><i class="fa fa-ellipsis-h"></i></button></td>
7680
</tr>
7781
@endforeach
7882
@foreach ($files as $file)
@@ -149,6 +153,7 @@
149153
{{ $carbon->diffForHumans() }}
150154
@endif
151155
</td>
156+
<td><button class="btn btn-xxs btn-default" data-action="toggleMenu" style="padding:0px 6px;"><i class="fa fa-ellipsis-h"></i></button></td>
152157
</tr>
153158
@endforeach
154159
</tbody>

resources/views/server/js/filemanager/contextmenu.blade.php

Lines changed: 93 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -56,102 +56,109 @@ class ContextMenuClass {
5656
}
5757

5858
rightClick() {
59+
$('[data-action="toggleMenu"]').on('mousedown', () => {
60+
event.preventDefault();
61+
this.showMenu(event);
62+
});
5963
$('#file_listing > tbody td').on('contextmenu', event => {
64+
this.showMenu(event);
65+
});
66+
}
6067

61-
const parent = $(event.target).closest('tr');
62-
const menu = $(this.makeMenu(parent));
68+
showMenu(event) {
69+
const parent = $(event.target).closest('tr');
70+
const menu = $(this.makeMenu(parent));
6371

64-
if (parent.data('type') === 'disabled') return;
65-
event.preventDefault();
72+
if (parent.data('type') === 'disabled') return;
73+
event.preventDefault();
74+
75+
$(menu).appendTo('body');
76+
$(menu).data('invokedOn', $(event.target)).show().css({
77+
position: 'absolute',
78+
left: event.pageX - 150,
79+
top: event.pageY,
80+
});
81+
82+
this.activeLine = parent;
83+
this.activeLine.addClass('active');
84+
85+
@can('download-files', $server)
86+
if (parent.data('type') === 'file') {
87+
$(menu).find('li[data-action="download"]').removeClass('hidden');
88+
}
89+
@endcan
90+
91+
@can('compress-files', $server)
92+
if (parent.data('type') === 'folder') {
93+
$(menu).find('li[data-action="compress"]').removeClass('hidden');
94+
}
95+
@endcan
96+
97+
@can('decompress-files', $server)
98+
if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) {
99+
$(menu).find('li[data-action="decompress"]').removeClass('hidden');
100+
}
101+
@endcan
102+
103+
// Handle Events
104+
const Actions = new ActionsClass(parent, menu);
105+
@can('move-files', $server)
106+
$(menu).find('li[data-action="move"]').unbind().on('click', e => {
107+
e.preventDefault();
108+
Actions.move();
109+
});
110+
@endcan
111+
112+
@can('copy-files', $server)
113+
$(menu).find('li[data-action="copy"]').unbind().on('click', e => {
114+
e.preventDefault();
115+
Actions.copy();
116+
});
117+
@endcan
118+
119+
@can('move-files', $server)
120+
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
121+
e.preventDefault();
122+
Actions.rename();
123+
});
124+
@endcan
125+
126+
@can('compress-files', $server)
127+
$(menu).find('li[data-action="compress"]').unbind().on('click', e => {
128+
e.preventDefault();
129+
Actions.compress();
130+
});
131+
@endcan
66132

67-
$(menu).appendTo('body');
68-
$(menu).data('invokedOn', $(event.target)).show().css({
69-
position: 'absolute',
70-
left: event.pageX,
71-
top: event.pageY,
133+
@can('decompress-files', $server)
134+
$(menu).find('li[data-action="decompress"]').unbind().on('click', e => {
135+
e.preventDefault();
136+
Actions.decompress();
72137
});
138+
@endcan
73139

74-
this.activeLine = parent;
75-
this.activeLine.addClass('active');
76-
77-
@can('download-files', $server)
78-
if (parent.data('type') === 'file') {
79-
$(menu).find('li[data-action="download"]').removeClass('hidden');
80-
}
81-
@endcan
82-
83-
@can('compress-files', $server)
84-
if (parent.data('type') === 'folder') {
85-
$(menu).find('li[data-action="compress"]').removeClass('hidden');
86-
}
87-
@endcan
88-
89-
@can('decompress-files', $server)
90-
if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) {
91-
$(menu).find('li[data-action="decompress"]').removeClass('hidden');
92-
}
93-
@endcan
94-
95-
// Handle Events
96-
const Actions = new ActionsClass(parent, menu);
97-
@can('move-files', $server)
98-
$(menu).find('li[data-action="move"]').unbind().on('click', e => {
99-
e.preventDefault();
100-
Actions.move();
101-
});
102-
@endcan
103-
104-
@can('copy-files', $server)
105-
$(menu).find('li[data-action="copy"]').unbind().on('click', e => {
106-
e.preventDefault();
107-
Actions.copy();
108-
});
109-
@endcan
110-
111-
@can('move-files', $server)
112-
$(menu).find('li[data-action="rename"]').unbind().on('click', e => {
113-
e.preventDefault();
114-
Actions.rename();
115-
});
116-
@endcan
117-
118-
@can('compress-files', $server)
119-
$(menu).find('li[data-action="compress"]').unbind().on('click', e => {
120-
e.preventDefault();
121-
Actions.compress();
122-
});
123-
@endcan
124-
125-
@can('decompress-files', $server)
126-
$(menu).find('li[data-action="decompress"]').unbind().on('click', e => {
127-
e.preventDefault();
128-
Actions.decompress();
129-
});
130-
@endcan
131-
132-
@can('create-files', $server)
133-
$(menu).find('li[data-action="folder"]').unbind().on('click', e => {
134-
e.preventDefault();
135-
Actions.folder();
136-
});
137-
@endcan
138-
139-
@can('download-files', $server)
140-
$(menu).find('li[data-action="download"]').unbind().on('click', e => {
141-
e.preventDefault();
142-
Actions.download();
143-
});
144-
@endcan
145-
146-
$(menu).find('li[data-action="delete"]').unbind().on('click', e => {
140+
@can('create-files', $server)
141+
$(menu).find('li[data-action="folder"]').unbind().on('click', e => {
147142
e.preventDefault();
148-
Actions.delete();
143+
Actions.folder();
149144
});
145+
@endcan
150146

151-
$(window).on('click', () => {
152-
$(menu).remove();
153-
if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
147+
@can('download-files', $server)
148+
$(menu).find('li[data-action="download"]').unbind().on('click', e => {
149+
e.preventDefault();
150+
Actions.download();
154151
});
152+
@endcan
153+
154+
$(menu).find('li[data-action="delete"]').unbind().on('click', e => {
155+
e.preventDefault();
156+
Actions.delete();
157+
});
158+
159+
$(window).on('click', () => {
160+
$(menu).remove();
161+
if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
155162
});
156163
}
157164

0 commit comments

Comments
 (0)