mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* First try * Update * app with drilldowns * Progres * Progress * update * Update * update * Update * Update * Progress * Update * Progress * Update * Progress * logs url sync * related metrics * Progress * progress * Progress * Update * Update * Update * Update * Update * fix * Update * update * Update * update * Update * Update * Update * Update * Update * Update * Update * Update * Update * Update * update * Update * Update * Settings * Update * Tweaks * update * Improve auto queries * Update * Update * Fixes * Update * Update * Update * fix * Update * Removing logs view, cleanup * Update * Update * disabled not implemented buttons * Update * Feature toggle on dashboard menu * remove unused prometheus change * removed bit * Fix failing test * chore: added `/public/app/features/trails/` to CODEOWNERS * go mod tidy * go mod tidy * fix: added missing arg * Moved panel action * Moved panel action --------- Co-authored-by: André Pereira <adrapereira@gmail.com> Co-authored-by: Darren Janeczek <darren.janeczek@grafana.com>
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { urlUtil } from '@grafana/data';
|
|
import { config } from '@grafana/runtime';
|
|
import { getUrlSyncManager, sceneGraph, SceneObject, SceneTimeRange } from '@grafana/scenes';
|
|
|
|
import { DataTrail } from './DataTrail';
|
|
import { DataTrailSettings } from './DataTrailSettings';
|
|
import { MetricScene } from './MetricScene';
|
|
|
|
export function getTrailFor(model: SceneObject): DataTrail {
|
|
return sceneGraph.getAncestor(model, DataTrail);
|
|
}
|
|
|
|
export function getTrailSettings(model: SceneObject): DataTrailSettings {
|
|
return sceneGraph.getAncestor(model, DataTrail).state.settings;
|
|
}
|
|
|
|
export function newMetricsTrail(): DataTrail {
|
|
return new DataTrail({
|
|
//initialDS: 'gdev-prometheus',
|
|
$timeRange: new SceneTimeRange({ from: 'now-1h', to: 'now' }),
|
|
//initialFilters: [{ key: 'job', operator: '=', value: 'grafana' }],
|
|
embedded: false,
|
|
});
|
|
}
|
|
|
|
export function getUrlForTrail(trail: DataTrail) {
|
|
const params = getUrlSyncManager().getUrlState(trail);
|
|
return urlUtil.renderUrl('/data-trails/trail', params);
|
|
}
|
|
|
|
export function getMetricSceneFor(model: SceneObject): MetricScene {
|
|
if (model instanceof MetricScene) {
|
|
return model;
|
|
}
|
|
|
|
if (model.parent) {
|
|
return getMetricSceneFor(model.parent);
|
|
}
|
|
|
|
console.error('Unable to find graph view for', model);
|
|
|
|
throw new Error('Unable to find trail');
|
|
}
|
|
|
|
export function getColorByIndex(index: number) {
|
|
const visTheme = config.theme2.visualization;
|
|
return visTheme.getColorByName(visTheme.palette[index % 8]);
|
|
}
|