diff --git a/app/admin_components/adf-application/dreamfactory-application.js b/app/admin_components/adf-application/dreamfactory-application.js index 4c72bc4f..3bd44a2f 100644 --- a/app/admin_components/adf-application/dreamfactory-application.js +++ b/app/admin_components/adf-application/dreamfactory-application.js @@ -7,7 +7,7 @@ angular.module('dfApplication', ['dfUtility', 'dfUserManagement', 'ngResource']) }]) - .service('dfApplicationData', ['$q', '$http', 'INSTANCE_URL', 'dfObjectService', 'UserDataService', 'dfSystemData', '$rootScope', '$location', '$injector', function ($q, $http, INSTANCE_URL, dfObjectService, UserDataService, dfSystemData, $rootScope, $location, $injector) { + .service('dfApplicationData', ['$q', '$http', 'INSTANCE_URL', 'dfObjectService', 'UserDataService', 'dfSystemData', 'dfDataWrapper', '$rootScope', '$location', function ($q, $http, INSTANCE_URL, dfObjectService, UserDataService, dfSystemData, dfDataWrapper, $rootScope, $location) { var dfApplicationObj = { apis: {} @@ -146,12 +146,7 @@ angular.module('dfApplication', ['dfUtility', 'dfUserManagement', 'ngResource']) if (xhr.readyState == 4 && xhr.status == 200) { if (Array.isArray(angular.fromJson(xhr.responseText))) { - var systemConfigDataService = $injector.get('SystemConfigDataService'); - var resourcesWrapper = systemConfigDataService.getSystemConfig().config.resources_wrapper; - var result = {}; - - result[resourcesWrapper] = angular.fromJson(xhr.responseText); - dfApplicationObj.apis[api] = result; + dfApplicationObj.apis[api] = dfDataWrapper.wrapArrayResponse(xhr.responseText); } else { dfApplicationObj.apis[api] = angular.fromJson(xhr.responseText); } @@ -647,7 +642,7 @@ angular.module('dfApplication', ['dfUtility', 'dfUserManagement', 'ngResource']) }; }]) - .service('dfSystemData', ['INSTANCE_URL', '$resource', 'dfObjectService', '$injector', function (INSTANCE_URL, $resource, dfObjectService, $injector) { + .service('dfSystemData', ['INSTANCE_URL', '$resource', 'dfObjectService', 'dfDataWrapper', function (INSTANCE_URL, $resource, dfObjectService, dfDataWrapper) { return { @@ -658,8 +653,6 @@ angular.module('dfApplication', ['dfUtility', 'dfUserManagement', 'ngResource']) var defaults = { headers: '' }; - var systemConfigDataService = $injector.get('SystemConfigDataService'); - options = dfObjectService.mergeObjects(options, defaults); var url = options.url || INSTANCE_URL.url + '/system/:api/:id'; var queryParams = options.queryParams || { api: '@api', id: '@id' }; @@ -671,39 +664,64 @@ angular.module('dfApplication', ['dfUtility', 'dfUserManagement', 'ngResource']) get: { method: 'GET', headers: options.headers, - transformResponse: function (data) { - var jsonData = angular.fromJson(data); - if (Array.isArray(jsonData)) { - var result = {}; - var resourcesWrapper = systemConfigDataService.getSystemConfig().config.resources_wrapper; - - result[resourcesWrapper] = jsonData; - return result; - } - return jsonData; - } + transformResponse: dfDataWrapper.wrapArrayResponse }, post: { method: 'POST', - headers: options.headers + headers: options.headers, + transformResponse: dfDataWrapper.wrapArrayResponse }, put: { method: 'PUT', - headers: options.headers + headers: options.headers, + transformResponse: dfDataWrapper.wrapArrayResponse }, patch: { method: 'PATCH', - headers: options.headers + headers: options.headers, + transformResponse: dfDataWrapper.wrapArrayResponse }, delete: { method: 'DELETE', - headers: options.headers + headers: options.headers, + transformResponse: dfDataWrapper.wrapArrayResponse } }); } }; }]) + .service('dfDataWrapper', ['$injector', '$http', function ($injector, $http) { + + function _wrapArrayResponse(data) { + try { + angular.fromJson(data); + } catch (error) { + return data; + } + var jsonData = angular.fromJson(data); + try { + var systemConfigDataService = $injector.get('SystemConfigDataService'); + var resourcesWrapper = systemConfigDataService.getSystemConfig().config.resources_wrapper; + } catch (error) { + return jsonData; + } + + if (Array.isArray(jsonData)) { + var result = {}; + result[resourcesWrapper] = jsonData; + return result; + } + return jsonData; + } + + $http.defaults.transformResponse.push(_wrapArrayResponse); + + return { + wrapArrayResponse: _wrapArrayResponse, + }; + }]) + // Intercepts outgoing http calls. Checks for valid session. If 401 will trigger a pop up login screen. .factory('httpValidSession', ['$q', '$rootScope', '$location', 'INSTANCE_URL', '$injector', function ($q, $rootScope, $location, INSTANCE_URL, $injector) { diff --git a/app/admin_components/adf-package-manager/dreamfactory-package-manager.js b/app/admin_components/adf-package-manager/dreamfactory-package-manager.js index 46211052..2afdccf5 100644 --- a/app/admin_components/adf-package-manager/dreamfactory-package-manager.js +++ b/app/admin_components/adf-package-manager/dreamfactory-package-manager.js @@ -82,7 +82,7 @@ angular.module('dfPackageManager', ['ngRoute', 'dfUtility', 'ngclipboard']) $scope.dataLoading = true; // these are required - var primaryApis = ['service_list', 'service_type_list', 'environment', 'package']; + var primaryApis = ['service_list', 'service_type_list', 'package']; // this one is optional, needed if we want to automatically add an app's storage service when the app is added // the storage service must be in service_list, meaning user has access to it, for this to work @@ -331,7 +331,7 @@ angular.module('dfPackageManager', ['ngRoute', 'dfUtility', 'ngclipboard']) } }; }]) - .directive('dfSelectContent', ['$http', '$timeout', 'MOD_PACKAGE_MANAGER_ASSET_PATH', 'dfApplicationData', 'dfNotify', function ($http, $timeout, MOD_PACKAGE_MANAGER_ASSET_PATH, dfApplicationData, dfNotify) { + .directive('dfSelectContent', ['$http', '$timeout', 'MOD_PACKAGE_MANAGER_ASSET_PATH', 'dfApplicationData', 'dfNotify', 'SystemConfigDataService', function ($http, $timeout, MOD_PACKAGE_MANAGER_ASSET_PATH, dfApplicationData, dfNotify, SystemConfigDataService) { return { restrict: 'E', @@ -376,7 +376,7 @@ angular.module('dfPackageManager', ['ngRoute', 'dfUtility', 'ngclipboard']) scope.initVars(); - var env = scope.apiData.environment; + var env = SystemConfigDataService.getSystemConfig(); scope.enablePassword = env['platform']['secured_package_export']; var _serviceTypes = scope.apiData.service_type_list; diff --git a/app/admin_components/adf-scripts/examples/example.scripts.python3.py b/app/admin_components/adf-scripts/examples/example.scripts.python3.py index 4e118be8..bd6ea04d 100644 --- a/app/admin_components/adf-scripts/examples/example.scripts.python3.py +++ b/app/admin_components/adf-scripts/examples/example.scripts.python3.py @@ -1,5 +1,5 @@ # Here are a few basic Python3 examples. -# Requires Munch dictionary for dot notation, use PIP to install. +# Requires Munch dictionary for dot notation, use PIP3 to install. # See wiki.dreamfactory.com for more examples. # ****************** Pre-processing script on a table ****************** @@ -32,4 +32,4 @@ print(record); record.extraField = 'Feed the dog'; print("extraField: ", end=""); - print(record.extraField); \ No newline at end of file + print(record.extraField); diff --git a/dist/admin_components/adf-scripts/examples/example.scripts.python3.py b/dist/admin_components/adf-scripts/examples/example.scripts.python3.py index 4e118be8..bd6ea04d 100644 --- a/dist/admin_components/adf-scripts/examples/example.scripts.python3.py +++ b/dist/admin_components/adf-scripts/examples/example.scripts.python3.py @@ -1,5 +1,5 @@ # Here are a few basic Python3 examples. -# Requires Munch dictionary for dot notation, use PIP to install. +# Requires Munch dictionary for dot notation, use PIP3 to install. # See wiki.dreamfactory.com for more examples. # ****************** Pre-processing script on a table ****************** @@ -32,4 +32,4 @@ print(record); record.extraField = 'Feed the dog'; print("extraField: ", end=""); - print(record.extraField); \ No newline at end of file + print(record.extraField); diff --git a/dist/index.html b/dist/index.html index 8ef794e5..f40ae8c0 100644 --- a/dist/index.html +++ b/dist/index.html @@ -2,7 +2,7 @@
You are using an outdated browser. Please upgrade your browser to improve your experience.