2022-04-22 08:33:13 -05:00
|
|
|
import { isString as _isString } from 'lodash';
|
2018-11-08 07:44:12 -06:00
|
|
|
|
2021-10-20 15:01:21 -05:00
|
|
|
import { TimeRange, AppEvents, rangeUtil, dateMath, PanelModel as IPanelModel } from '@grafana/data';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { getTemplateSrv } from '@grafana/runtime';
|
2018-11-08 07:44:12 -06:00
|
|
|
import appEvents from 'app/core/app_events';
|
2019-05-06 08:26:09 -05:00
|
|
|
import config from 'app/core/config';
|
2021-04-27 03:09:37 -05:00
|
|
|
import { LS_PANEL_COPY_KEY, PANEL_BORDER } from 'app/core/constants';
|
2022-04-22 08:33:13 -05:00
|
|
|
import store from 'app/core/store';
|
2020-03-04 03:59:30 -06:00
|
|
|
import { ShareModal } from 'app/features/dashboard/components/ShareModal';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
|
|
|
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
2021-04-13 10:55:31 -05:00
|
|
|
import { AddLibraryPanelModal } from 'app/features/library-panels/components/AddLibraryPanelModal/AddLibraryPanelModal';
|
|
|
|
import { UnlinkModal } from 'app/features/library-panels/components/UnlinkModal/UnlinkModal';
|
2022-04-12 08:12:03 -05:00
|
|
|
import { cleanUpPanelState } from 'app/features/panel/state/actions';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { dispatch } from 'app/store/store';
|
|
|
|
|
|
|
|
import { ShowConfirmModalEvent, ShowModalReactEvent } from '../../../types/events';
|
2020-03-03 06:04:28 -06:00
|
|
|
|
2018-10-25 07:29:03 -05:00
|
|
|
export const removePanel = (dashboard: DashboardModel, panel: PanelModel, ask: boolean) => {
|
|
|
|
// confirm deletion
|
|
|
|
if (ask !== false) {
|
2021-09-15 08:15:50 -05:00
|
|
|
const text2 =
|
2021-10-20 07:45:26 -05:00
|
|
|
panel.alert && !config.unifiedAlertingEnabled
|
2021-09-15 08:15:50 -05:00
|
|
|
? 'Panel includes an alert rule. removing the panel will also remove the alert rule'
|
|
|
|
: undefined;
|
2020-07-09 08:16:35 -05:00
|
|
|
const confirmText = panel.alert ? 'YES' : undefined;
|
2018-10-25 07:29:03 -05:00
|
|
|
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-10 11:03:36 -06:00
|
|
|
appEvents.publish(
|
|
|
|
new ShowConfirmModalEvent({
|
2021-04-01 10:42:57 -05:00
|
|
|
title: 'Remove panel',
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-10 11:03:36 -06:00
|
|
|
text: 'Are you sure you want to remove this panel?',
|
|
|
|
text2: text2,
|
|
|
|
icon: 'trash-alt',
|
|
|
|
confirmText: confirmText,
|
|
|
|
yesText: 'Remove',
|
|
|
|
onConfirm: () => removePanel(dashboard, panel, false),
|
|
|
|
})
|
|
|
|
);
|
2018-10-25 07:29:03 -05:00
|
|
|
return;
|
|
|
|
}
|
2021-01-18 07:34:45 -06:00
|
|
|
|
2018-10-25 07:29:03 -05:00
|
|
|
dashboard.removePanel(panel);
|
2022-04-12 08:12:03 -05:00
|
|
|
dispatch(cleanUpPanelState(panel.key));
|
2018-10-25 07:29:03 -05:00
|
|
|
};
|
|
|
|
|
2018-10-30 08:38:18 -05:00
|
|
|
export const duplicatePanel = (dashboard: DashboardModel, panel: PanelModel) => {
|
|
|
|
dashboard.duplicatePanel(panel);
|
|
|
|
};
|
|
|
|
|
2021-10-20 15:01:21 -05:00
|
|
|
export const copyPanel = (panel: IPanelModel) => {
|
2021-02-25 04:26:28 -06:00
|
|
|
let saveModel = panel;
|
|
|
|
if (panel instanceof PanelModel) {
|
|
|
|
saveModel = panel.getSaveModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
store.set(LS_PANEL_COPY_KEY, JSON.stringify(saveModel));
|
2021-04-01 10:42:57 -05:00
|
|
|
appEvents.emit(AppEvents.alertSuccess, ['Panel copied. Click **Add panel** icon to paste.']);
|
2018-10-30 08:53:04 -05:00
|
|
|
};
|
|
|
|
|
2018-10-30 10:39:08 -05:00
|
|
|
export const sharePanel = (dashboard: DashboardModel, panel: PanelModel) => {
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-10 11:03:36 -06:00
|
|
|
appEvents.publish(
|
|
|
|
new ShowModalReactEvent({
|
|
|
|
component: ShareModal,
|
|
|
|
props: {
|
|
|
|
dashboard: dashboard,
|
|
|
|
panel: panel,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2018-10-30 10:39:08 -05:00
|
|
|
};
|
2018-10-31 07:43:21 -05:00
|
|
|
|
2021-04-13 10:55:31 -05:00
|
|
|
export const addLibraryPanel = (dashboard: DashboardModel, panel: PanelModel) => {
|
|
|
|
appEvents.publish(
|
|
|
|
new ShowModalReactEvent({
|
|
|
|
component: AddLibraryPanelModal,
|
|
|
|
props: {
|
|
|
|
panel,
|
2022-11-17 02:22:57 -06:00
|
|
|
initialFolderUid: dashboard.meta.folderUid,
|
2021-04-13 10:55:31 -05:00
|
|
|
isOpen: true,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const unlinkLibraryPanel = (panel: PanelModel) => {
|
|
|
|
appEvents.publish(
|
|
|
|
new ShowModalReactEvent({
|
|
|
|
component: UnlinkModal,
|
|
|
|
props: {
|
2022-11-02 05:38:48 -05:00
|
|
|
onConfirm: () => panel.unlinkLibraryPanel(),
|
2021-04-13 10:55:31 -05:00
|
|
|
isOpen: true,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-10-31 07:43:21 -05:00
|
|
|
export const refreshPanel = (panel: PanelModel) => {
|
|
|
|
panel.refresh();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const toggleLegend = (panel: PanelModel) => {
|
2022-07-27 14:39:55 -05:00
|
|
|
const newOptions = { ...panel.options };
|
|
|
|
newOptions.legend.showLegend === true
|
|
|
|
? (newOptions.legend.showLegend = false)
|
|
|
|
: (newOptions.legend.showLegend = true);
|
|
|
|
panel.updateOptions(newOptions);
|
2018-10-31 07:43:21 -05:00
|
|
|
};
|
2018-11-08 07:44:12 -06:00
|
|
|
|
2018-11-13 09:01:52 -06:00
|
|
|
export interface TimeOverrideResult {
|
|
|
|
timeRange: TimeRange;
|
|
|
|
timeInfo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function applyPanelTimeOverrides(panel: PanelModel, timeRange: TimeRange): TimeOverrideResult {
|
2018-11-12 04:23:41 -06:00
|
|
|
const newTimeData = {
|
|
|
|
timeInfo: '',
|
|
|
|
timeRange: timeRange,
|
|
|
|
};
|
2018-11-08 07:44:12 -06:00
|
|
|
|
|
|
|
if (panel.timeFrom) {
|
2020-10-01 12:51:23 -05:00
|
|
|
const timeFromInterpolated = getTemplateSrv().replace(panel.timeFrom, panel.scopedVars);
|
2018-11-08 07:44:12 -06:00
|
|
|
const timeFromInfo = rangeUtil.describeTextRange(timeFromInterpolated);
|
|
|
|
if (timeFromInfo.invalid) {
|
|
|
|
newTimeData.timeInfo = 'invalid time override';
|
|
|
|
return newTimeData;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_isString(timeRange.raw.from)) {
|
2020-07-09 08:16:35 -05:00
|
|
|
const timeFromDate = dateMath.parse(timeFromInfo.from)!;
|
2018-11-08 07:44:12 -06:00
|
|
|
newTimeData.timeInfo = timeFromInfo.display;
|
|
|
|
newTimeData.timeRange = {
|
|
|
|
from: timeFromDate,
|
2020-07-09 08:16:35 -05:00
|
|
|
to: dateMath.parse(timeFromInfo.to)!,
|
2018-11-08 07:44:12 -06:00
|
|
|
raw: {
|
|
|
|
from: timeFromInfo.from,
|
|
|
|
to: timeFromInfo.to,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panel.timeShift) {
|
2020-10-01 12:51:23 -05:00
|
|
|
const timeShiftInterpolated = getTemplateSrv().replace(panel.timeShift, panel.scopedVars);
|
2018-11-08 07:44:12 -06:00
|
|
|
const timeShiftInfo = rangeUtil.describeTextRange(timeShiftInterpolated);
|
|
|
|
if (timeShiftInfo.invalid) {
|
|
|
|
newTimeData.timeInfo = 'invalid timeshift';
|
|
|
|
return newTimeData;
|
|
|
|
}
|
|
|
|
|
|
|
|
const timeShift = '-' + timeShiftInterpolated;
|
2018-11-13 08:23:13 -06:00
|
|
|
newTimeData.timeInfo += ' timeshift ' + timeShift;
|
2020-07-09 08:16:35 -05:00
|
|
|
const from = dateMath.parseDateMath(timeShift, newTimeData.timeRange.from, false)!;
|
|
|
|
const to = dateMath.parseDateMath(timeShift, newTimeData.timeRange.to, true)!;
|
2019-01-11 09:49:29 -06:00
|
|
|
|
2018-11-08 07:44:12 -06:00
|
|
|
newTimeData.timeRange = {
|
2019-01-11 09:49:29 -06:00
|
|
|
from,
|
|
|
|
to,
|
|
|
|
raw: {
|
|
|
|
from,
|
|
|
|
to,
|
|
|
|
},
|
2018-11-08 07:44:12 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panel.hideTimeOverride) {
|
|
|
|
newTimeData.timeInfo = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return newTimeData;
|
2018-11-13 09:01:52 -06:00
|
|
|
}
|
2018-11-12 02:32:55 -06:00
|
|
|
|
2018-11-13 09:01:52 -06:00
|
|
|
export function getResolution(panel: PanelModel): number {
|
2018-11-12 02:32:55 -06:00
|
|
|
const htmlEl = document.getElementsByTagName('html')[0];
|
|
|
|
const width = htmlEl.getBoundingClientRect().width; // https://stackoverflow.com/a/21454625
|
|
|
|
|
|
|
|
return panel.maxDataPoints ? panel.maxDataPoints : Math.ceil(width * (panel.gridPos.w / 24));
|
2018-11-13 09:01:52 -06:00
|
|
|
}
|
2019-05-06 08:26:09 -05:00
|
|
|
|
|
|
|
export function calculateInnerPanelHeight(panel: PanelModel, containerHeight: number): number {
|
2019-11-25 15:26:18 -06:00
|
|
|
const chromePadding = panel.plugin && panel.plugin.noPadding ? 0 : config.theme.panelPadding * 2;
|
|
|
|
const headerHeight = panel.hasTitle() ? config.theme.panelHeaderHeight : 0;
|
|
|
|
return containerHeight - headerHeight - chromePadding - PANEL_BORDER;
|
2019-05-06 08:26:09 -05:00
|
|
|
}
|
2023-03-28 04:42:23 -05:00
|
|
|
|
|
|
|
export function calculateNewPanelGridPos(dashboard: DashboardModel): PanelModel['gridPos'] {
|
|
|
|
// Move all panels down by the height of the "add panel" widget.
|
|
|
|
// This is to work around an issue with react-grid-layout that can mess up the layout
|
|
|
|
// in certain configurations. (See https://github.com/react-grid-layout/react-grid-layout/issues/1787)
|
|
|
|
const addPanelWidgetHeight = 8;
|
|
|
|
for (const panel of dashboard.panelIterator()) {
|
|
|
|
panel.gridPos.y += addPanelWidgetHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
return { x: 0, y: 0, w: 12, h: addPanelWidgetHeight };
|
|
|
|
}
|