mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: Bring back scripted dashboards (#100575)
* Dashboards: Bring back scripted dashboards * Fix scripted dashboard examples * Fix dashboard-solo page not respecnig scripted dashboards
This commit is contained in:
parent
9dd75aee32
commit
7edcde6365
@ -37,6 +37,8 @@ export function DashboardScenePage({ route, queryParams, location }: Props) {
|
||||
stateManager.loadSnapshot(slug!);
|
||||
} else {
|
||||
stateManager.loadDashboard({
|
||||
type,
|
||||
slug,
|
||||
uid: uid ?? '',
|
||||
route: route.routeName as DashboardRoutes,
|
||||
urlFolderUid: queryParams.folderUid,
|
||||
|
@ -63,6 +63,7 @@ export interface LoadDashboardOptions {
|
||||
uid: string;
|
||||
route: DashboardRoutes;
|
||||
type?: string;
|
||||
slug?: string;
|
||||
urlFolderUid?: string;
|
||||
params?: {
|
||||
version: number;
|
||||
@ -266,6 +267,8 @@ export class DashboardScenePageStateManager extends DashboardScenePageStateManag
|
||||
}
|
||||
|
||||
public async fetchDashboard({
|
||||
type,
|
||||
slug,
|
||||
uid,
|
||||
route,
|
||||
urlFolderUid,
|
||||
@ -323,7 +326,7 @@ export class DashboardScenePageStateManager extends DashboardScenePageStateManag
|
||||
}
|
||||
: undefined;
|
||||
|
||||
rsp = await dashboardLoaderSrv.loadDashboard('db', '', uid, queryParams);
|
||||
rsp = await dashboardLoaderSrv.loadDashboard(type || 'db', slug || '', uid, queryParams);
|
||||
|
||||
if (route === DashboardRoutes.Embedded) {
|
||||
rsp.meta.isEmbedded = true;
|
||||
@ -477,6 +480,8 @@ export class DashboardScenePageStateManagerV2 extends DashboardScenePageStateMan
|
||||
}
|
||||
|
||||
public async fetchDashboard({
|
||||
type,
|
||||
slug,
|
||||
uid,
|
||||
route,
|
||||
urlFolderUid,
|
||||
@ -529,7 +534,7 @@ export class DashboardScenePageStateManagerV2 extends DashboardScenePageStateMan
|
||||
...params.variables,
|
||||
}
|
||||
: undefined;
|
||||
rsp = await this.dashboardLoader.loadDashboard('db', '', uid, queryParams);
|
||||
rsp = await this.dashboardLoader.loadDashboard(type || 'db', slug || '', uid, queryParams);
|
||||
if (route === DashboardRoutes.Embedded) {
|
||||
throw new Error('Method not implemented.');
|
||||
// rsp.meta.isEmbedded = true;
|
||||
|
@ -26,12 +26,12 @@ export interface Props extends GrafanaRouteComponentProps<DashboardPageRoutePara
|
||||
export function SoloPanelPage({ queryParams }: Props) {
|
||||
const stateManager = getDashboardScenePageStateManager();
|
||||
const { dashboard, loadError } = stateManager.useState();
|
||||
const { uid = '' } = useParams();
|
||||
const { uid = '', type, slug } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
stateManager.loadDashboard({ uid, route: DashboardRoutes.Embedded });
|
||||
stateManager.loadDashboard({ uid, type, slug, route: DashboardRoutes.Embedded });
|
||||
return () => stateManager.clearState();
|
||||
}, [stateManager, queryParams, uid]);
|
||||
}, [stateManager, queryParams, uid, type, slug]);
|
||||
|
||||
if (!queryParams.panelId) {
|
||||
return <EntityNotFound entity="Panel" />;
|
||||
@ -64,7 +64,6 @@ export function SoloPanelRenderer({ dashboard, panelId }: { dashboard: Dashboard
|
||||
const [panel, error] = useSoloPanel(dashboard, panelId);
|
||||
const { controls } = dashboard.useState();
|
||||
const refreshPicker = controls?.useState()?.refreshPicker;
|
||||
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -51,6 +51,7 @@ function DashboardPageProxy(props: DashboardPageProxyProps) {
|
||||
route: props.route.routeName as DashboardRoutes,
|
||||
uid: params.uid ?? '',
|
||||
type: params.type,
|
||||
slug: params.slug,
|
||||
});
|
||||
}, [params.uid, props.route.routeName]);
|
||||
|
||||
|
@ -96,8 +96,10 @@ export function getAppRoutes(): RouteDescriptor[] {
|
||||
path: '/dashboard-solo/:type/:slug',
|
||||
routeName: DashboardRoutes.Normal,
|
||||
chromeless: true,
|
||||
component: SafeDynamicImport(
|
||||
() => import(/* webpackChunkName: "SoloPanelPage" */ '../features/dashboard/containers/SoloPanelPage')
|
||||
component: SafeDynamicImport(() =>
|
||||
config.featureToggles.dashboardSceneSolo
|
||||
? import(/* webpackChunkName: "SoloPanelPage" */ '../features/dashboard-scene/solo/SoloPanelPage')
|
||||
: import(/* webpackChunkName: "SoloPanelPageOld" */ '../features/dashboard/containers/SoloPanelPage')
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -13,16 +13,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
// accessible variables in this scope
|
||||
let window, document, $, jQuery, moment, kbn;
|
||||
// accessible variables in this scope: window, document, $, jQuery, moment, kbn;
|
||||
|
||||
// Setup some variables
|
||||
let dashboard;
|
||||
|
||||
// All url parameters are available via the ARGS object
|
||||
// eslint-disable-next-line no-redeclare
|
||||
let ARGS;
|
||||
|
||||
// Initialize a skeleton with nothing but a rows array and service object
|
||||
dashboard = {
|
||||
rows: [],
|
||||
@ -56,6 +51,7 @@ for (let i = 0; i < rows; i++) {
|
||||
height: '300px',
|
||||
panels: [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Events',
|
||||
type: 'graph',
|
||||
span: 12,
|
||||
@ -63,23 +59,17 @@ for (let i = 0; i < rows; i++) {
|
||||
linewidth: 2,
|
||||
targets: [
|
||||
{
|
||||
target: "randomWalk('" + seriesName + "')",
|
||||
scenarioId: 'random_walk',
|
||||
refId: 'A',
|
||||
seriesCount: 1,
|
||||
alias: seriesName,
|
||||
},
|
||||
{
|
||||
target: "randomWalk('random walk2')",
|
||||
scenarioId: 'random_walk',
|
||||
refId: 'B',
|
||||
seriesCount: 1,
|
||||
},
|
||||
],
|
||||
seriesOverrides: [
|
||||
{
|
||||
alias: '/random/',
|
||||
yaxis: 2,
|
||||
fill: 0,
|
||||
linewidth: 5,
|
||||
},
|
||||
],
|
||||
tooltip: {
|
||||
shared: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -17,7 +17,7 @@
|
||||
'use strict';
|
||||
|
||||
// accessible variables in this scope
|
||||
let window, document, ARGS, $, jQuery, moment, kbn;
|
||||
// let window, document, ARGS, $, jQuery, moment, kbn;
|
||||
|
||||
return function (callback) {
|
||||
// Setup some variables
|
||||
@ -60,6 +60,7 @@ return function (callback) {
|
||||
height: '300px',
|
||||
panels: [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Async dashboard test',
|
||||
type: 'text',
|
||||
span: 12,
|
||||
|
@ -14,14 +14,14 @@
|
||||
'use strict';
|
||||
|
||||
// accessible variables in this scope
|
||||
let window, document, $, jQuery, moment, kbn;
|
||||
// let window, document, $, jQuery, moment, kbn;
|
||||
|
||||
// Setup some variables
|
||||
let dashboard;
|
||||
|
||||
// All url parameters are available via the ARGS object
|
||||
// eslint-disable-next-line no-redeclare
|
||||
let ARGS;
|
||||
// let ARGS;
|
||||
|
||||
// Initialize a skeleton with nothing but a rows array and service object
|
||||
dashboard = {
|
||||
@ -44,19 +44,22 @@ dashboard.templating = {
|
||||
list: [
|
||||
{
|
||||
name: 'test',
|
||||
query: 'apps.backend.*',
|
||||
refresh: 1,
|
||||
type: 'query',
|
||||
datasource: null,
|
||||
hide: 2,
|
||||
includeAll: false,
|
||||
multi: false,
|
||||
query: 'a,b,c\n',
|
||||
skipUrlSync: false,
|
||||
type: 'custom',
|
||||
},
|
||||
{
|
||||
name: 'test2',
|
||||
query: '*',
|
||||
refresh: 1,
|
||||
type: 'query',
|
||||
datasource: null,
|
||||
hide: 2,
|
||||
name: 'seriesName',
|
||||
label: 'Series name',
|
||||
hide: 0,
|
||||
includeAll: false,
|
||||
multi: false,
|
||||
query: 'series1,series2,series3\n',
|
||||
skipUrlSync: false,
|
||||
type: 'custom',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -78,6 +81,7 @@ for (let i = 0; i < rows; i++) {
|
||||
height: '300px',
|
||||
panels: [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Events',
|
||||
type: 'graph',
|
||||
span: 12,
|
||||
@ -85,10 +89,16 @@ for (let i = 0; i < rows; i++) {
|
||||
linewidth: 2,
|
||||
targets: [
|
||||
{
|
||||
target: "randomWalk('" + seriesName + "')",
|
||||
scenarioId: 'random_walk',
|
||||
refId: 'A',
|
||||
seriesCount: 1,
|
||||
alias: seriesName,
|
||||
},
|
||||
{
|
||||
target: "randomWalk('[[test2]]')",
|
||||
scenarioId: 'random_walk',
|
||||
refId: 'B',
|
||||
seriesCount: 1,
|
||||
alias: '${seriesName}',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user