Skip to content

Commit

Permalink
[Feature] Table visualization: Raise the upper limit of MAX_JSON_SIZE (
Browse files Browse the repository at this point in the history
…#3310)

* move constant value to clientConfig
* change name maxJsonSize to tableCellMaxJSONSize
* value from environment. default is 50000
  • Loading branch information
swfz authored and kravets-levko committed Feb 13, 2019
1 parent f2df717 commit afaedb9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions client/app/components/dynamic-table/json-cell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -14,8 +12,8 @@ function parseValue(value) {
}
}

export default function init(ngModule) {
ngModule.directive('dynamicTableJsonCell', () => ({
function DynamicTableJsonCell(clientConfig) {
return {
template,
restrict: 'E',
replace: true,
Expand All @@ -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;
1 change: 1 addition & 0 deletions redash/handlers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions redash/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit afaedb9

Please sign in to comment.