Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/plutono-data/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ export interface PlutonoConfig {
dateFormats?: SystemDateFormatSettings;
sentry: SentryConfig;
customTheme?: any;
optionsLimit: number;
}
1 change: 1 addition & 0 deletions packages/plutono-runtime/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class PlutonoBootConfig implements PlutonoConfig {
customTheme?: any;
awsAllowedAuthProviders: string[] = [];
awsAssumeRoleEnabled = false;
optionsLimit = 1000;

constructor(options: PlutonoBootConfig) {
this.theme = options.bootData.user.lightTheme ? getTheme(PlutonoThemeType.Light) : getTheme(PlutonoThemeType.Dark);
Expand Down
1 change: 1 addition & 0 deletions pkg/api/frontendsettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
"editorsCanAdmin": hs.Cfg.EditorsCanAdmin,
"disableSanitizeHtml": hs.Cfg.DisableSanitizeHtml,
"pluginsToPreload": pluginsToPreload,
"optionsLimit": hs.Cfg.OptionsLimit,
"buildInfo": map[string]interface{}{
"hideVersion": hideVersion,
"version": version,
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (hs *HTTPServer) QueryMetricsV2(c *models.ReqContext, reqDTO dtos.MetricReq

request.Queries = append(request.Queries, &tsdb.Query{
RefId: query.Get("refId").MustString("A"),
MaxDataPoints: query.Get("maxDataPoints").MustInt64(100),
MaxDataPoints: query.Get("maxDataPoints").MustInt64(hs.Cfg.MaxDataPoints),
IntervalMs: query.Get("intervalMs").MustInt64(1000),
QueryType: query.Get("queryType").MustString(""),
Model: query,
Expand Down
5 changes: 5 additions & 0 deletions pkg/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ type Cfg struct {

// Data sources
DataSourceLimit int
OptionsLimit int64
MaxDataPoints int64

// Snapshots
SnapshotPublicMode bool
Expand Down Expand Up @@ -1418,6 +1420,9 @@ func (cfg *Cfg) GetContentDeliveryURL(prefix string) string {
}

func (cfg *Cfg) readDataSourcesSettings() {
const MaxDataPointsLimitScale = 10 //for some reason we need to divide by 10 for the max data points limit. IE 100 means 1000. Not clear why that is the case
datasources := cfg.Raw.Section("datasources")
cfg.DataSourceLimit = datasources.Key("datasource_limit").MustInt(5000)
cfg.OptionsLimit = datasources.Key("options_limit").MustInt64(1000)
cfg.MaxDataPoints = cfg.OptionsLimit / MaxDataPointsLimitScale
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
hideOptions,
initialState as optionsPickerInitialState,
moveOptionsHighlight,
OPTIONS_LIMIT,
optionsPickerReducer,
OptionsPickerState,
showOptions,
Expand All @@ -18,6 +17,7 @@ import {
import { reducerTester } from '../../../../../test/core/redux/reducerTester';
import { QueryVariableModel, VariableOption, VariableTag } from '../../types';
import { ALL_VARIABLE_TEXT, ALL_VARIABLE_VALUE } from '../../state/types';
import config from 'app/core/config';

const getVariableTestContext = (extend: Partial<OptionsPickerState>) => {
return {
Expand Down Expand Up @@ -730,7 +730,7 @@ describe('optionsPickerReducer', () => {
const queryValue = 'option:1337';

const options = [];
for (let index = 0; index <= OPTIONS_LIMIT + 337; index++) {
for (let index = 0; index <= config.optionsLimit + 337; index++) {
options.push({ text: `option:${index}`, value: `option:${index}`, selected: false });
}

Expand Down Expand Up @@ -911,7 +911,7 @@ describe('optionsPickerReducer', () => {
const searchQuery = 'option:11256';

const options: VariableOption[] = [];
for (let index = 0; index <= OPTIONS_LIMIT + 11256; index++) {
for (let index = 0; index <= config.optionsLimit + 11256; index++) {
options.push({ text: `option:${index}`, value: `option:${index}`, selected: false });
}

Expand All @@ -937,7 +937,7 @@ describe('optionsPickerReducer', () => {
const searchQuery = '__searchFilter';
const options = [{ text: 'All', value: '$__all', selected: true }];

for (let i = 0; i <= OPTIONS_LIMIT + 137; i++) {
for (let i = 0; i <= config.optionsLimit + 137; i++) {
options.push({ text: `option${i}`, value: `option${i}`, selected: false });
}
const { initialState } = getVariableTestContext({
Expand All @@ -949,7 +949,7 @@ describe('optionsPickerReducer', () => {
.whenActionIsDispatched(updateOptionsFromSearch(options))
.thenStateShouldEqual({
...initialState,
options: options.slice(0, OPTIONS_LIMIT),
options: options.slice(0, config.optionsLimit),
selectedValues: [{ text: 'All', value: '$__all', selected: true }],
highlightIndex: 0,
});
Expand All @@ -967,10 +967,10 @@ describe('optionsPickerReducer', () => {
id: '0',
} as QueryVariableModel;
const checkOptions = [];
for (let index = 0; index < OPTIONS_LIMIT; index++) {
for (let index = 0; index < config.optionsLimit; index++) {
checkOptions.push({ text: `option${index}`, value: `option${index}`, selected: false });
}
for (let i = 1; i <= OPTIONS_LIMIT + 137; i++) {
for (let i = 1; i <= config.optionsLimit + 137; i++) {
payload.options.push({ text: `option${i}`, value: `option${i}`, selected: false });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ALL_VARIABLE_VALUE } from '../../state/types';
import { isMulti, isQuery } from '../../guard';
import { applyStateChanges } from '../../../../core/utils/applyStateChanges';
import { containsSearchFilter } from '../../utils';
import config from 'app/core/config';

export interface ToggleOption {
option?: VariableOption;
Expand Down Expand Up @@ -34,8 +35,6 @@ export const initialState: OptionsPickerState = {
multi: false,
};

export const OPTIONS_LIMIT = 1000;

const getTags = (model: VariableWithMultiSupport) => {
if (isQuery(model) && Array.isArray(model.tags)) {
return cloneDeep(model.tags);
Expand Down Expand Up @@ -86,10 +85,11 @@ const applyLimit = (options: VariableOption[]): VariableOption[] => {
if (!Array.isArray(options)) {
return [];
}
if (options.length <= OPTIONS_LIMIT) {
if (options.length <= config.optionsLimit) {
return options;
}
return options.slice(0, OPTIONS_LIMIT);
console.log('Need to slice!');
return options.slice(0, config.optionsLimit);
};

const updateDefaultSelection = (state: OptionsPickerState): OptionsPickerState => {
Expand Down