Bug 242 - delete error not reported
[osm/UI.git] / skyquake / plugins / composer / src / src / components / filemanager / FileManagerSource.js
index 95703b2..1f0fd80 100644 (file)
@@ -18,7 +18,6 @@
  */
 'use strict';
 
-import _ from 'lodash'
 import $ from 'jquery'
 import alt from '../../alt'
 import utils from '../../libraries/utils'
@@ -101,16 +100,26 @@ const FileManagerSource = {
                         beforeSend: Utils.addAuthorizationStub,
                         url: 'api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id + '&package_path=' + path ,
                         success: function(data) {
-                            resolve({
-                                data: data,
-                                path: path
-                            });
+                            if (data.output.status == 'True') {
+                                resolve({
+                                    data: data,
+                                    path: path
+                                });
+                            } else {
+                                reject({
+                                    data: data,
+                                    path: path
+                                })
+                            }
                         },
                         error: function(error) {
                             if (typeof error == 'string') {
                                 error = JSON.parse(error);
                             }
-                            reject(error);
+                            reject({
+                                path: path,
+                                data: error
+                            });
                         }
                     }).fail(function(xhr){
                         //Authentication and the handling of fail states should be wrapped up into a connection class.
@@ -146,11 +155,11 @@ const FileManagerSource = {
                 return new Promise(function(resolve, reject) {
                     //api/operational/download-jobs/job/
                    $.ajax({
-                    url: '/socket-polling?api_server=' + API_SERVER ,
+                    url: '/socket-polling?api_server=' + API_SERVER,
                     type: 'POST',
                     beforeSend: Utils.addAuthorizationStub,
                     data: {
-                      url: 'http://localhost:8000/composer/api/file-manager/jobs/' + packageID + '?api_server=' + API_SERVER,
+                      url: 'composer/api/file-manager/jobs/' + packageID + '?api_server=' + API_SERVER,
                     },
                     success: function(data, textStatus, jqXHR) {
                         Utils.checkAndResolveSocketRequest(data, resolve, reject);
@@ -171,11 +180,11 @@ const FileManagerSource = {
                 return new Promise(function(resolve, reject) {
                     //api/operational/download-jobs/job/
                    $.ajax({
-                    url: '/socket-polling?api_server=' + API_SERVER ,
+                    url: '/socket-polling?api_server=' + API_SERVER,
                     type: 'POST',
                     beforeSend: Utils.addAuthorizationStub,
                     data: {
-                      url: 'http://localhost:8000/composer/api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id
+                      url: 'composer/api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id
                     },
                     success: function(data, textStatus, jqXHR) {
                         Utils.checkAndResolveSocketRequest(data, resolve, reject);