From cfbe6917a89cbf3b4af12ee07cbabe08b4478333 Mon Sep 17 00:00:00 2001 From: Volodymyr Polishchuk Date: Mon, 25 May 2020 16:34:21 +0300 Subject: [PATCH 1/4] DP-96 Add installation of munch - Fix typo --- .../adf-scripts/examples/example.scripts.python3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From e72a140d70fba1379860ad3477b42e0d81f24f9b Mon Sep 17 00:00:00 2001 From: Yaroslav Mokhurenko Date: Wed, 6 May 2020 17:39:25 +0300 Subject: [PATCH 2/4] DP-199 Uncommenting DF_ALWAYS_WRAP_RESOURCES breaks the Services tab - Change wrap default $http requests --- .../dreamfactory-application.js | 61 +++++++++++++------ dist/index.html | 2 +- dist/scripts/app.61c6194f.js | 1 + 3 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 dist/scripts/app.61c6194f.js diff --git a/app/admin_components/adf-application/dreamfactory-application.js b/app/admin_components/adf-application/dreamfactory-application.js index 4c72bc4f..04d1a803 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', '$injector', '$rootScope', '$location', function ($q, $http, INSTANCE_URL, dfObjectService, UserDataService, dfSystemData, $injector, $rootScope, $location) { var dfApplicationObj = { apis: {} @@ -647,7 +647,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 +658,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 +669,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/dist/index.html b/dist/index.html index 8ef794e5..2935ebee 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.