Skip to content

Commit

Permalink
Merge pull request getredash#2268 from getredash/dashboard-refresh-in…
Browse files Browse the repository at this point in the history
…terval

Make dashboard refresh intervals configurable
  • Loading branch information
arikfr committed Jan 30, 2018
2 parents 817f2ba + a557d9f commit e2042b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions client/app/filters/index.js
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions client/app/pages/dashboards/dashboard.js
@@ -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';
Expand Down Expand Up @@ -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;
});
Expand Down
3 changes: 2 additions & 1 deletion redash/handlers/authentication.py
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions redash/settings/__init__.py
Expand Up @@ -202,6 +202,7 @@ def all_settings():
# 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"))
Expand Down

0 comments on commit e2042b1

Please sign in to comment.