File tree Expand file tree Collapse file tree 3 files changed +47
-5
lines changed
resources/views/server/js/filemanager Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Original file line number Diff line number Diff line change @@ -116,4 +116,44 @@ class ActionsClass {
116116 });
117117 });
118118 }
119+
120+ delete() {
121+ const nameBlock = $(this.element).find('td[data-identifier="name"]');
122+ const delPath = decodeURIComponent(nameBlock.data('path'));
123+ const delName = decodeURIComponent(nameBlock.data('name'));
124+
125+ swal({
126+ type: 'warning',
127+ title: '',
128+ text: 'Are you sure you want to delete <code >' + delName + '</code >? There is <strong >no</strong > reversing this action.',
129+ html: true,
130+ showCancelButton: true,
131+ showConfirmButton: true,
132+ closeOnConfirm: false,
133+ showLoaderOnConfirm: true
134+ }, () => {
135+ $.ajax({
136+ type: 'DELETE',
137+ url: `{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file/${delPath}${delName}`,
138+ headers: {
139+ 'X-Access-Token': '{{ $server -> daemonSecret } } ',
140+ 'X-Access-Server': '{{ $server -> uuid } } '
141+ }
142+ }).done(data => {
143+ // nameBlock.parent().addClass('warning').delay(200).fadeOut();
144+ swal({
145+ type: 'success',
146+ title: 'File Deleted'
147+ });
148+ }).fail(jqXHR => {
149+ console.error(jqXHR);
150+ swal({
151+ type: 'error',
152+ title: 'Whoops!',
153+ html: true,
154+ text: 'An error occured while attempting to delete this file. Please try again.',
155+ });
156+ });
157+ });
158+ }
119159}
Original file line number Diff line number Diff line change @@ -77,10 +77,12 @@ class ContextMenuClass {
7777 // Handle Events
7878 const Actions = new ActionsClass(parent, menu);
7979 $(menu).find('li[data-action="move"]').unbind().on('click', e => {
80+ e.preventDefault();
8081 Actions.move();
8182 });
8283
8384 $(menu).find('li[data-action="rename"]').unbind().on('click', e => {
85+ e.preventDefault();
8486 Actions.rename();
8587 });
8688
@@ -89,6 +91,11 @@ class ContextMenuClass {
8991 Actions.download();
9092 });
9193
94+ $(menu).find('li[data-action="delete"]').unbind().on('click', e => {
95+ e.preventDefault();
96+ Actions.delete();
97+ });
98+
9299 $(window).on('click', () => {
93100 $(menu).remove();
94101 if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active');
@@ -103,7 +110,6 @@ class ContextMenuClass {
103110 const path = $(this).parent().data('path') || '';
104111 const name = $(this).parent().data('name') || '';
105112
106- console.log('changing hash');
107113 window.location.hash = encodeURIComponent(path + name);
108114 Files.list();
109115 });
Original file line number Diff line number Diff line change @@ -24,10 +24,6 @@ class FileManager {
2424 this.list(this.decodeHash());
2525 }
2626
27- reload() {
28- $('[data-toggle="tooltip"]').tooltip();
29- }
30-
3127 list(path, isError) {
3228 if (_.isUndefined(path)) {
3329 path = this.decodeHash();
You can’t perform that action at this time.
0 commit comments