diff --git a/client/app/components/dynamic-table/json-cell/index.js b/client/app/components/dynamic-table/json-cell/index.js index a70f465252..200825dac3 100644 --- a/client/app/components/dynamic-table/json-cell/index.js +++ b/client/app/components/dynamic-table/json-cell/index.js @@ -2,10 +2,8 @@ import { isUndefined, isString } from 'lodash'; import renderJsonView from './json-view-interactive'; import template from './template.html'; -const MAX_JSON_SIZE = 50000; - -function parseValue(value) { - if (isString(value) && value.length <= MAX_JSON_SIZE) { +function parseValue(value, clientConfig) { + if (isString(value) && value.length <= clientConfig.tableCellMaxJSONSize) { try { return JSON.parse(value); } catch (e) { @@ -14,8 +12,8 @@ function parseValue(value) { } } -export default function init(ngModule) { - ngModule.directive('dynamicTableJsonCell', () => ({ +function DynamicTableJsonCell(clientConfig) { + return { template, restrict: 'E', replace: true, @@ -30,13 +28,17 @@ export default function init(ngModule) { $scope.parsedValue = null; $scope.$watch('value', () => { - $scope.parsedValue = parseValue($scope.value); + $scope.parsedValue = parseValue($scope.value, clientConfig); $scope.isValid = !isUndefined($scope.parsedValue); container.empty(); renderJsonView(container, $scope.parsedValue); }); }, - })); + }; +} + +export default function init(ngModule) { + ngModule.directive('dynamicTableJsonCell', DynamicTableJsonCell); } init.init = true; diff --git a/redash/handlers/authentication.py b/redash/handlers/authentication.py index a46181f497..eb7bdcec38 100644 --- a/redash/handlers/authentication.py +++ b/redash/handlers/authentication.py @@ -226,6 +226,7 @@ def client_config(): 'googleLoginEnabled': settings.GOOGLE_OAUTH_ENABLED, 'pageSize': settings.PAGE_SIZE, 'pageSizeOptions': settings.PAGE_SIZE_OPTIONS, + 'tableCellMaxJSONSize': settings.TABLE_CELL_MAX_JSON_SIZE, } client_config.update(defaults) diff --git a/redash/settings/__init__.py b/redash/settings/__init__.py index a995b382fb..47dbb99e77 100644 --- a/redash/settings/__init__.py +++ b/redash/settings/__init__.py @@ -227,6 +227,7 @@ def all_settings(): QUERY_REFRESH_INTERVALS = map(int, array_from_string(os.environ.get("REDASH_QUERY_REFRESH_INTERVALS", "60, 300, 600, 900, 1800, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 32400, 36000, 39600, 43200, 86400, 604800, 1209600, 2592000"))) PAGE_SIZE = int(os.environ.get('REDASH_PAGE_SIZE', 20)) PAGE_SIZE_OPTIONS = map(int, array_from_string(os.environ.get("REDASH_PAGE_SIZE_OPTIONS", "5,10,20,50,100"))) +TABLE_CELL_MAX_JSON_SIZE = int(os.environ.get('REDASH_TABLE_CELL_MAX_JSON_SIZE', 50000)) # Features: VERSION_CHECK = parse_boolean(os.environ.get("REDASH_VERSION_CHECK", "true"))