forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard_constants.ts
105 lines (90 loc) · 4.04 KB
/
dashboard_constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type { DashboardContainerInput } from '../common';
// ------------------------------------------------------------------
// URL Constants
// ------------------------------------------------------------------
export const DASHBOARD_STATE_STORAGE_KEY = '_a';
export const GLOBAL_STATE_STORAGE_KEY = '_g';
export const LANDING_PAGE_PATH = '/list';
export const CREATE_NEW_DASHBOARD_URL = '/create';
export const VIEW_DASHBOARD_URL = '/view';
export const PRINT_DASHBOARD_URL = '/print';
export const getFullPath = (aliasId?: string, id?: string) =>
`/app/dashboards#${createDashboardEditUrl(aliasId || id)}`;
export const getFullEditPath = (id?: string, editMode?: boolean) => {
return `/app/dashboards#${createDashboardEditUrl(id, editMode)}`;
};
export function createDashboardEditUrl(id?: string, editMode?: boolean) {
if (!id) {
return `${CREATE_NEW_DASHBOARD_URL}`;
}
const edit = editMode ? `?${DASHBOARD_STATE_STORAGE_KEY}=(viewMode:edit)` : '';
return `${VIEW_DASHBOARD_URL}/${id}${edit}`;
}
export function createDashboardListingFilterUrl(filter: string | undefined) {
return filter ? `${LANDING_PAGE_PATH}?filter="${filter}"` : LANDING_PAGE_PATH;
}
// ------------------------------------------------------------------
// Telemetry & Events
// ------------------------------------------------------------------
export const DASHBOARD_LOADED_EVENT = 'dashboard_loaded';
export const SAVED_OBJECT_LOADED_TIME = 'saved_object_loaded_time';
export const SAVED_OBJECT_DELETE_TIME = 'saved_object_delete_time';
export const SAVED_OBJECT_POST_TIME = 'saved_object_post_time';
export const DASHBOARD_UI_METRIC_ID = 'dashboard';
// ------------------------------------------------------------------
// IDs
// ------------------------------------------------------------------
export const DASHBOARD_APP_ID = 'dashboards';
export const LEGACY_DASHBOARD_APP_ID = 'dashboard';
export const SEARCH_SESSION_ID = 'searchSessionId';
// ------------------------------------------------------------------
// Grid
// ------------------------------------------------------------------
export const DEFAULT_PANEL_HEIGHT = 15;
export const DASHBOARD_MARGIN_SIZE = 8;
export const DASHBOARD_GRID_HEIGHT = 20;
export const DASHBOARD_GRID_COLUMN_COUNT = 48;
export const DEFAULT_PANEL_WIDTH = DASHBOARD_GRID_COLUMN_COUNT / 2;
export const CHANGE_CHECK_DEBOUNCE = 100;
export enum PanelPlacementStrategy {
/** Place on the very top of the Dashboard, add the height of this panel to all other panels. */
placeAtTop = 'placeAtTop',
/** Look for the smallest y and x value where the default panel will fit. */
findTopLeftMostOpenSpace = 'findTopLeftMostOpenSpace',
}
// ------------------------------------------------------------------
// Content Management
// ------------------------------------------------------------------
export { CONTENT_ID as DASHBOARD_CONTENT_ID } from '../common/content_management/constants';
export const DASHBOARD_CACHE_SIZE = 20; // only store a max of 20 dashboards
export const DASHBOARD_CACHE_TTL = 1000 * 60 * 5; // time to live = 5 minutes
// ------------------------------------------------------------------
// Default State
// ------------------------------------------------------------------
export const DEFAULT_DASHBOARD_INPUT: Omit<DashboardContainerInput, 'id'> = {
viewMode: 'view',
timeRestore: false,
query: { query: '', language: 'kuery' },
description: '',
filters: [],
panels: {},
title: '',
tags: [],
executionContext: {
type: 'dashboard',
},
// options
useMargins: true,
syncColors: false,
syncCursor: true,
syncTooltips: false,
hidePanelTitles: false,
};