Merge pull request #2268 from getredash/dashboard-refresh-interval

Make dashboard refresh intervals configurable
This commit is contained in:
Arik Fraimovich 2018-01-30 13:49:19 +02:00 committed by GitHub
commit e2042b13b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 5 deletions

View File

@ -9,16 +9,20 @@ export function durationHumanize(duration) {
humanized = '-';
} else if (duration < 60) {
const seconds = Math.round(duration);
humanized = `${seconds}s`;
humanized = `${seconds} seconds`;
} else if (duration > 3600 * 24) {
const days = Math.round(parseFloat(duration) / 60.0 / 60.0 / 24.0);
humanized = `${days}days`;
humanized = `${days} days`;
} else if (duration === 3600) {
humanized = '1 hour';
} else if (duration >= 3600) {
const hours = Math.round(parseFloat(duration) / 60.0 / 60.0);
humanized = `${hours}h`;
humanized = `${hours} hours`;
} else if (duration === 60) {
humanized = '1 minute';
} else {
const minutes = Math.round(parseFloat(duration) / 60.0);
humanized = `${minutes}m`;
humanized = `${minutes} minutes`;
}
return humanized;
}

View File

@ -1,5 +1,6 @@
import * as _ from 'underscore';
import PromiseRejectionError from '@/lib/promise-rejection-error';
import { durationHumanize } from '@/filters';
import template from './dashboard.html';
import shareDashboardTemplate from './share-dashboard.html';
import './dashboard.less';
@ -79,6 +80,9 @@ function DashboardCtrl(
{ name: '24 hour', rate: 24 * 60 * 60 },
];
this.refreshRates =
clientConfig.dashboardRefreshIntervals.map(interval => ({ name: durationHumanize(interval), rate: interval }));
$rootScope.$on('gridster-mobile-changed', ($event, gridster) => {
this.isGridDisabled = gridster.isMobile;
});

View File

@ -175,7 +175,8 @@ def client_config():
'autoPublishNamedQueries': settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES,
'dateFormat': date_format,
'dateTimeFormat': "{0} HH:mm".format(date_format),
'mailSettingsMissing': settings.MAIL_DEFAULT_SENDER is None
'mailSettingsMissing': settings.MAIL_DEFAULT_SENDER is None,
'dashboardRefreshIntervals': settings.DASHBOARD_REFRESH_INTERVALS
}
client_config.update(defaults)

View File

@ -202,6 +202,7 @@ SENTRY_DSN = os.environ.get("REDASH_SENTRY_DSN", "")
# Client side toggles:
ALLOW_SCRIPTS_IN_USER_INPUT = parse_boolean(os.environ.get("REDASH_ALLOW_SCRIPTS_IN_USER_INPUT", "false"))
DATE_FORMAT = os.environ.get("REDASH_DATE_FORMAT", "DD/MM/YY")
DASHBOARD_REFRESH_INTERVALS = map(int, array_from_string(os.environ.get("REDASH_DASHBOARD_REFRESH_INTERVALS", "60,300,600,1800,3600,43200,86400")))
# Features:
VERSION_CHECK = parse_boolean(os.environ.get("REDASH_VERSION_CHECK", "true"))