@@ -51,7 +51,7 @@ class ActionsClass {
5151 'X-Access-Server': '{{ $server -> uuid } } '
5252 },
5353 contentType: 'application/json; charset=utf-8',
54- url: '{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/files /rename',
54+ url: '{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file /rename',
5555 timeout: 10000,
5656 data: JSON.stringify({
5757 from: `${currentPath}${currentName}`,
@@ -77,10 +77,11 @@ class ActionsClass {
7777 }
7878
7979 download() {
80- var baseURL = $(this.menu).find('li[data-action="download"] a').attr('href');
81- var toURL = baseURL + $(this.element).find('td[data-identifier="name"]').data('name');
80+ const nameBlock = $(this.element).find('td[data-identifier="name"]');
81+ const fileName = decodeURIComponent(nameBlock.attr('data-name'));
82+ const filePath = decodeURIComponent(nameBlock.data('path'));
8283
83- window.location = toURL ;
84+ window.location = `/server/ {{ $server -> uuidShort } } /files/download/${filePath}${fileName}` ;
8485 }
8586
8687 rename() {
@@ -128,7 +129,7 @@ class ActionsClass {
128129 'X-Access-Server': '{{ $server -> uuid } } '
129130 },
130131 contentType: 'application/json; charset=utf-8',
131- url: '{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/files /rename',
132+ url: '{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file /rename',
132133 timeout: 10000,
133134 data: JSON.stringify({
134135 from: `${currentPath}${currentName}`,
@@ -184,7 +185,7 @@ class ActionsClass {
184185 }, () => {
185186 $.ajax({
186187 type: 'DELETE',
187- url: `{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file/${delPath}${delName}`,
188+ url: `{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file/f/ ${delPath}${delName}`,
188189 headers: {
189190 'X-Access-Token': '{{ $server -> daemonSecret } } ',
190191 'X-Access-Server': '{{ $server -> uuid } } '
@@ -206,4 +207,77 @@ class ActionsClass {
206207 });
207208 });
208209 }
210+
211+ decompress() {
212+ const nameBlock = $(this.element).find('td[data-identifier="name"]');
213+ const compPath = decodeURIComponent(nameBlock.data('path'));
214+ const compName = decodeURIComponent(nameBlock.data('name'));
215+
216+ $.ajax({
217+ type: 'POST',
218+ url: `{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file/decompress`,
219+ headers: {
220+ 'X-Access-Token': '{{ $server -> daemonSecret } } ',
221+ 'X-Access-Server': '{{ $server -> uuid } } '
222+ },
223+ contentType: 'application/json; charset=utf-8',
224+ data: JSON.stringify({
225+ files: `${compPath}${compName}`
226+ })
227+ }).done(data => {
228+ Files.list(compPath);
229+ }).fail(jqXHR => {
230+ console.error(jqXHR);
231+ var error = 'An error occured while trying to process this request.';
232+ if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') {
233+ error = jqXHR.responseJSON.error;
234+ }
235+ swal({
236+ type: 'error',
237+ title: 'Whoops!',
238+ html: true,
239+ text: error
240+ });
241+ });
242+ }
243+
244+ compress() {
245+ const nameBlock = $(this.element).find('td[data-identifier="name"]');
246+ const compPath = decodeURIComponent(nameBlock.data('path'));
247+ const compName = decodeURIComponent(nameBlock.data('name'));
248+
249+ $.ajax({
250+ type: 'POST',
251+ url: `{{ $node -> scheme } } ://{{ $node -> fqdn } } :{{ $node -> daemonListen } } /server/file/compress`,
252+ headers: {
253+ 'X-Access-Token': '{{ $server -> daemonSecret } } ',
254+ 'X-Access-Server': '{{ $server -> uuid } } '
255+ },
256+ contentType: 'application/json; charset=utf-8',
257+ data: JSON.stringify({
258+ files: `${compPath}${compName}`,
259+ to: compPath.toString()
260+ })
261+ }).done(data => {
262+ Files.list(compPath, err => {
263+ if (err) return;
264+ const fileListing = $('#file_listing').find(`[data-name="${data.saved_as}"]`).parent();
265+ fileListing.addClass('success pulsate').delay(3000).queue(() => {
266+ fileListing.removeClass('success pulsate').dequeue();
267+ });
268+ });
269+ }).fail(jqXHR => {
270+ console.error(jqXHR);
271+ var error = 'An error occured while trying to process this request.';
272+ if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') {
273+ error = jqXHR.responseJSON.error;
274+ }
275+ swal({
276+ type: 'error',
277+ title: 'Whoops!',
278+ html: true,
279+ text: error
280+ });
281+ });
282+ }
209283}
0 commit comments