Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into transforms
Browse files Browse the repository at this point in the history
* grafana/master:
  Explore: Support user timezone (grafana#16469)
  Plugins: rename vizPlugin to panelPlugin (grafana#16802)
  Plugins: move app/feature/plugin properties into PluginMeta (grafana#16809)
  Plugins: move PanelPluginMeta to grafana/ui (grafana#16804)
  Plugins: move datasource specific meta out of the main meta type (grafana#16803)
  updates changelog for 6.1.6
  Fix: Fetch histogram series from other api route (grafana#16768)
  phantomjs: set web-security to true
  Chore: Lowered implicit anys limit to 5668
  • Loading branch information
ryantxu committed Apr 29, 2019
2 parents 2080d9b + 02cb7ff commit 1b65b2a
Show file tree
Hide file tree
Showing 62 changed files with 769 additions and 449 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# 6.2.0 (unreleased)

# 6.1.6 (2019-04-29)
### Features / Enhancements
* **Security**: Bump jQuery to 3.4.0 . [#16761](https://github.com/grafana/grafana/pull/16761), [@dprokop](https://github.com/dprokop)

### Bug Fixes
* **Playlist**: Fix loading dashboards by tag. [#16727](https://github.com/grafana/grafana/pull/16727), [@marefr](https://github.com/marefr)

# 6.1.5 (2019-04-29)

* **Security**: Urgent security patch release. Please read more in our [blog](https://grafana.com/blog/2019/04/29/grafana-5.4.4-and-6.1.6-released-with-important-security-fix/)

# 6.1.4 (2019-04-16)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions latest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"stable": "6.1.3",
"testing": "6.1.3"
"stable": "6.1.6",
"testing": "6.1.6"
}
28 changes: 25 additions & 3 deletions packages/grafana-ui/src/types/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ export class DataSourcePlugin<TOptions = {}, TQuery extends DataQuery = DataQuer
}
}

export interface DataSourcePluginMeta extends PluginMeta {
builtIn?: boolean; // Is this for all
metrics?: boolean;
tables?: boolean;
logs?: boolean;
explore?: boolean;
annotations?: boolean;
mixed?: boolean;
hasQueryHelp?: boolean;
queryOptions?: PluginMetaQueryOptions;
}

interface PluginMetaQueryOptions {
cacheTimeout?: boolean;
maxDataPoints?: boolean;
minInterval?: boolean;
}

export interface DataSourcePluginComponents<TOptions = {}, TQuery extends DataQuery = DataQuery> {
QueryCtrl?: any;
ConfigCtrl?: any;
Expand Down Expand Up @@ -137,7 +155,11 @@ export interface DataSourceApi<TQuery extends DataQuery = DataQuery> {
* we attach the components to this instance for easy access
*/
components?: DataSourcePluginComponents;
meta?: PluginMeta;

/**
* static information about the datasource
*/
meta?: DataSourcePluginMeta;
}

export interface ExploreDataSourceApi<TQuery extends DataQuery = DataQuery> extends DataSourceApi {
Expand Down Expand Up @@ -340,7 +362,7 @@ export interface DataSourceInstanceSettings {
id: number;
type: string;
name: string;
meta: PluginMeta;
meta: DataSourcePluginMeta;
url?: string;
jsonData: { [str: string]: any };
username?: string;
Expand All @@ -359,6 +381,6 @@ export interface DataSourceInstanceSettings {
export interface DataSourceSelectItem {
name: string;
value: string | null;
meta: PluginMeta;
meta: DataSourcePluginMeta;
sort: string;
}
19 changes: 19 additions & 0 deletions packages/grafana-ui/src/types/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ import { ComponentClass, ComponentType } from 'react';
import { LoadingState, SeriesData } from './data';
import { TimeRange } from './time';
import { ScopedVars, DataQueryRequest, DataQueryError, LegacyResponseData } from './datasource';
import { PluginMeta } from './plugin';

export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string;

export interface PanelPluginMeta extends PluginMeta {
hideFromList?: boolean;
sort: number;
angularPlugin: AngularPanelPlugin | null;
panelPlugin: PanelPlugin | null;
hasBeenImported?: boolean;

// if length>0 the query tab will show up
// Before 6.2 this could be table and/or series, but 6.2+ supports both transparently
// so it will be deprecated soon
dataFormats?: PanelDataFormat[];
}

export enum PanelDataFormat {
Table = 'table',
TimeSeries = 'time_series',
}

export interface PanelData {
state: LoadingState;
series: SeriesData[];
Expand Down
21 changes: 4 additions & 17 deletions packages/grafana-ui/src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,10 @@ export interface PluginMeta {
// Filled in by the backend
jsonData?: { [str: string]: any };
enabled?: boolean;

// Datasource-specific
builtIn?: boolean;
metrics?: boolean;
tables?: boolean;
logs?: boolean;
explore?: boolean;
annotations?: boolean;
mixed?: boolean;
hasQueryHelp?: boolean;
queryOptions?: PluginMetaQueryOptions;
}

interface PluginMetaQueryOptions {
cacheTimeout?: boolean;
maxDataPoints?: boolean;
minInterval?: boolean;
defaultNavUrl?: string;
hasUpdate?: boolean;
latestVersion?: string;
pinned?: boolean;
}

export enum PluginIncludeType {
Expand Down
19 changes: 19 additions & 0 deletions packages/grafana-ui/src/types/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@ export interface TimeRange {
raw: RawTimeRange;
}

export interface AbsoluteTimeRange {
from: number;
to: number;
}

export interface IntervalValues {
interval: string; // 10s,5m
intervalMs: number;
}

export interface TimeZone {
raw: string;
isUtc: boolean;
}

export const parseTimeZone = (raw: string): TimeZone => {
return {
raw,
isUtc: raw === 'utc',
};
};

export const DefaultTimeZone = parseTimeZone('browser');

export interface TimeOption {
from: string;
to: string;
Expand Down
3 changes: 2 additions & 1 deletion pkg/services/rendering/phantomjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) (

cmdArgs := []string{
"--ignore-ssl-errors=true",
"--web-security=false",
"--web-security=true",
"--local-url-access=false",
phantomDebugArg,
scriptPath,
fmt.Sprintf("url=%v", url),
Expand Down
3 changes: 1 addition & 2 deletions public/app/core/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from 'lodash';
import { PanelPluginMeta } from 'app/types/plugins';
import { GrafanaTheme, getTheme, GrafanaThemeType, DataSourceInstanceSettings } from '@grafana/ui';
import { GrafanaTheme, getTheme, GrafanaThemeType, PanelPluginMeta, DataSourceInstanceSettings } from '@grafana/ui';

export interface BuildInfo {
version: string;
Expand Down
72 changes: 55 additions & 17 deletions public/app/core/utils/explore.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// Libraries
import _ from 'lodash';
import moment, { Moment } from 'moment';

// Services & Utils
import * as dateMath from 'app/core/utils/datemath';
import { renderUrl } from 'app/core/utils/url';
import kbn from 'app/core/utils/kbn';
import store from 'app/core/store';
import { parse as parseDate } from 'app/core/utils/datemath';
import { colors } from '@grafana/ui';
import TableModel, { mergeTablesIntoModel } from 'app/core/table_model';
import { getNextRefIdChar } from './query';

// Types
import { RawTimeRange, IntervalValues, DataQuery, DataSourceApi } from '@grafana/ui';
import { colors, TimeRange, RawTimeRange, TimeZone, IntervalValues, DataQuery, DataSourceApi } from '@grafana/ui';
import TimeSeries from 'app/core/time_series2';
import {
ExploreUrlState,
Expand Down Expand Up @@ -104,7 +103,7 @@ export function buildQueryTransaction(
rowIndex: number,
resultType: ResultType,
queryOptions: QueryOptions,
range: RawTimeRange,
range: TimeRange,
queryIntervals: QueryIntervals,
scanning: boolean
): QueryTransaction {
Expand All @@ -131,12 +130,8 @@ export function buildQueryTransaction(
intervalMs,
panelId,
targets: configuredQueries, // Datasources rely on DataQueries being passed under the targets key.
range: {
from: dateMath.parse(range.from, false),
to: dateMath.parse(range.to, true),
raw: range,
},
rangeRaw: range,
range,
rangeRaw: range.raw,
scopedVars: {
__interval: { text: interval, value: interval },
__interval_ms: { text: intervalMs, value: intervalMs },
Expand Down Expand Up @@ -315,17 +310,12 @@ export function calculateResultsFromQueryTransactions(
};
}

export function getIntervals(range: RawTimeRange, lowLimit: string, resolution: number): IntervalValues {
export function getIntervals(range: TimeRange, lowLimit: string, resolution: number): IntervalValues {
if (!resolution) {
return { interval: '1s', intervalMs: 1000 };
}

const absoluteRange: RawTimeRange = {
from: parseDate(range.from, false),
to: parseDate(range.to, true),
};

return kbn.calculateInterval(absoluteRange, resolution, lowLimit);
return kbn.calculateInterval(range, resolution, lowLimit);
}

export const makeTimeSeriesList: ResultGetter = (dataList, transaction, allTransactions) => {
Expand Down Expand Up @@ -395,3 +385,51 @@ export const getQueryKeys = (queries: DataQuery[], datasourceInstance: DataSourc

return queryKeys;
};

export const getTimeRange = (timeZone: TimeZone, rawRange: RawTimeRange): TimeRange => {
return {
from: dateMath.parse(rawRange.from, false, timeZone.raw as any),
to: dateMath.parse(rawRange.to, true, timeZone.raw as any),
raw: rawRange,
};
};

const parseRawTime = (value): Moment | string => {
if (value === null) {
return null;
}

if (value.indexOf('now') !== -1) {
return value;
}
if (value.length === 8) {
return moment.utc(value, 'YYYYMMDD');
}
if (value.length === 15) {
return moment.utc(value, 'YYYYMMDDTHHmmss');
}
// Backward compatibility
if (value.length === 19) {
return moment.utc(value, 'YYYY-MM-DD HH:mm:ss');
}

if (!isNaN(value)) {
const epoch = parseInt(value, 10);
return moment.utc(epoch);
}

return null;
};

export const getTimeRangeFromUrl = (range: RawTimeRange, timeZone: TimeZone): TimeRange => {
const raw = {
from: parseRawTime(range.from),
to: parseRawTime(range.to),
};

return {
from: dateMath.parse(raw.from, false, timeZone.raw as any),
to: dateMath.parse(raw.to, true, timeZone.raw as any),
raw,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import config from 'app/core/config';
import { DashboardExporter } from './DashboardExporter';
import { DashboardModel } from '../../state/DashboardModel';
import { DatasourceSrv } from 'app/features/plugins/datasource_srv';
import { PanelPluginMeta } from 'app/types';
import { PanelPluginMeta } from '@grafana/ui';

describe('given dashboard with repeated panels', () => {
let dash: any, exported: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from 'app/core/config';
import { DashboardModel } from '../../state/DashboardModel';
import DatasourceSrv from 'app/features/plugins/datasource_srv';
import { PanelModel } from 'app/features/dashboard/state';
import { PanelPluginMeta } from 'app/types/plugins';
import { PanelPluginMeta } from '@grafana/ui';

interface Input {
name: string;
Expand Down
7 changes: 3 additions & 4 deletions public/app/features/dashboard/dashgrid/DashboardPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { PanelResizer } from './PanelResizer';

// Types
import { PanelModel, DashboardModel } from '../state';
import { PanelPluginMeta } from 'app/types';
import { AngularPanelPlugin, PanelPlugin } from '@grafana/ui/src/types/panel';
import { PanelPluginMeta, AngularPanelPlugin, PanelPlugin } from '@grafana/ui/src/types/panel';
import { AutoSizer } from 'react-virtualized';

export interface Props {
Expand Down Expand Up @@ -102,7 +101,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
if (importedPlugin instanceof AngularPanelPlugin) {
plugin.angularPlugin = importedPlugin as AngularPanelPlugin;
} else if (importedPlugin instanceof PanelPlugin) {
plugin.vizPlugin = importedPlugin as PanelPlugin;
plugin.panelPlugin = importedPlugin as PanelPlugin;
}
} catch (e) {
plugin = getPanelPluginNotFound(plugin.id);
Expand Down Expand Up @@ -210,7 +209,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
onMouseLeave={this.onMouseLeave}
style={styles}
>
{plugin.vizPlugin && this.renderReactPanel()}
{plugin.panelPlugin && this.renderReactPanel()}
{plugin.angularPlugin && this.renderAngularPanel()}
</div>
)}
Expand Down
7 changes: 3 additions & 4 deletions public/app/features/dashboard/dashgrid/PanelChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import config from 'app/core/config';

// Types
import { DashboardModel, PanelModel } from '../state';
import { PanelPluginMeta } from 'app/types';
import { LoadingState, PanelData } from '@grafana/ui';
import { PanelPluginMeta, LoadingState, PanelData } from '@grafana/ui';
import { ScopedVars } from '@grafana/ui';

import templateSrv from 'app/features/templating/template_srv';
Expand Down Expand Up @@ -216,7 +215,7 @@ export class PanelChrome extends PureComponent<Props, State> {
renderPanel(width: number, height: number): JSX.Element {
const { panel, plugin } = this.props;
const { renderCounter, data, isFirstLoad } = this.state;
const PanelComponent = plugin.vizPlugin.panel;
const PanelComponent = plugin.panelPlugin.panel;

// This is only done to increase a counter that is used by backend
// image rendering (phantomjs/headless chrome) to know when to capture image
Expand All @@ -237,7 +236,7 @@ export class PanelChrome extends PureComponent<Props, State> {
<PanelComponent
data={data}
timeRange={data.request ? data.request.range : this.timeSrv.timeRange()}
options={panel.getOptions(plugin.vizPlugin.defaults)}
options={panel.getOptions(plugin.panelPlugin.defaults)}
width={width - 2 * config.theme.panelPadding.horizontal}
height={height - PANEL_HEADER_HEIGHT - config.theme.panelPadding.vertical}
renderCounter={renderCounter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React, { PureComponent } from 'react';
import { AlertBox } from 'app/core/components/AlertBox/AlertBox';

// Types
import { PanelPluginMeta, AppNotificationSeverity } from 'app/types';
import { PanelProps, PanelPlugin, PluginType } from '@grafana/ui';
import { AppNotificationSeverity } from 'app/types';
import { PanelPluginMeta, PanelProps, PanelPlugin, PluginType } from '@grafana/ui';

interface Props {
pluginId: string;
Expand Down Expand Up @@ -63,7 +63,7 @@ export function getPanelPluginNotFound(id: string): PanelPluginMeta {
updated: '',
version: '',
},
vizPlugin: new PanelPlugin(NotFound),
panelPlugin: new PanelPlugin(NotFound),
angularPlugin: null,
};
}
Loading

0 comments on commit 1b65b2a

Please sign in to comment.