{
return (
-
+
{!dashboard && this.renderLoadingState()}
{dashboard && this.renderDashboard()}
@@ -130,19 +181,26 @@ export class DashboardPage extends PureComponent {
}
}
-const mapStateToProps = (state: StoreState) => ({
- urlUid: state.location.routeParams.uid,
- urlSlug: state.location.routeParams.slug,
- urlType: state.location.routeParams.type,
- panelId: state.location.query.panelId,
- editview: state.location.query.editview,
- loadingState: state.dashboard.loadingState,
- dashboard: state.dashboard.model as DashboardModel,
-});
+const mapStateToProps = (state: StoreState) => {
+ console.log('state location', state.location.query);
+ return {
+ urlUid: state.location.routeParams.uid,
+ urlSlug: state.location.routeParams.slug,
+ urlType: state.location.routeParams.type,
+ editview: state.location.query.editview,
+ urlPanelId: state.location.query.panelId,
+ urlFullscreen: state.location.query.fullscreen === true,
+ urlEdit: state.location.query.edit === true,
+ loadingState: state.dashboard.loadingState,
+ dashboard: state.dashboard.model as DashboardModel,
+ };
+};
const mapDispatchToProps = {
initDashboard,
- setDashboardModel
+ setDashboardModel,
+ notifyApp,
+ updateLocation,
};
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DashboardPage));
diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx
index 658bfad3816..27f699ff3e6 100644
--- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx
+++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx
@@ -1,11 +1,14 @@
-import React from 'react';
+// Libaries
+import React, { PureComponent } from 'react';
import { hot } from 'react-hot-loader';
import ReactGridLayout, { ItemCallback } from 'react-grid-layout';
+import classNames from 'classnames';
+import sizeMe from 'react-sizeme';
+
+// Types
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from 'app/core/constants';
import { DashboardPanel } from './DashboardPanel';
import { DashboardModel, PanelModel } from '../state';
-import classNames from 'classnames';
-import sizeMe from 'react-sizeme';
let lastGridWidth = 1200;
let ignoreNextWidthChange = false;
@@ -76,19 +79,18 @@ function GridWrapper({
const SizedReactLayoutGrid = sizeMe({ monitorWidth: true })(GridWrapper);
-export interface DashboardGridProps {
+export interface Props {
dashboard: DashboardModel;
+ isEditing: boolean;
+ isFullscreen: boolean;
}
-export class DashboardGrid extends React.Component {
+export class DashboardGrid extends PureComponent {
gridToPanelMap: any;
panelMap: { [id: string]: PanelModel };
- constructor(props: DashboardGridProps) {
- super(props);
-
- // subscribe to dashboard events
- const dashboard = this.props.dashboard;
+ componentDidMount() {
+ const { dashboard } = this.props;
dashboard.on('panel-added', this.triggerForceUpdate);
dashboard.on('panel-removed', this.triggerForceUpdate);
dashboard.on('repeats-processed', this.triggerForceUpdate);
@@ -97,6 +99,16 @@ export class DashboardGrid extends React.Component {
dashboard.on('row-expanded', this.triggerForceUpdate);
}
+ componentWillUnmount() {
+ const { dashboard } = this.props;
+ dashboard.off('panel-added', this.triggerForceUpdate);
+ dashboard.off('panel-removed', this.triggerForceUpdate);
+ dashboard.off('repeats-processed', this.triggerForceUpdate);
+ dashboard.off('view-mode-changed', this.onViewModeChanged);
+ dashboard.off('row-collapsed', this.triggerForceUpdate);
+ dashboard.off('row-expanded', this.triggerForceUpdate);
+ }
+
buildLayout() {
const layout = [];
this.panelMap = {};
@@ -151,7 +163,6 @@ export class DashboardGrid extends React.Component {
onViewModeChanged = () => {
ignoreNextWidthChange = true;
- this.forceUpdate();
}
updateGridPos = (item: ReactGridLayout.Layout, layout: ReactGridLayout.Layout[]) => {
@@ -197,18 +208,20 @@ export class DashboardGrid extends React.Component {
}
render() {
+ const { dashboard, isFullscreen } = this.props;
+
return (
{this.renderPanels()}
diff --git a/public/app/features/dashboard/services/DashboardViewStateSrv.ts b/public/app/features/dashboard/services/DashboardViewStateSrv.ts
index fc38c3b241f..f5a68d6f647 100644
--- a/public/app/features/dashboard/services/DashboardViewStateSrv.ts
+++ b/public/app/features/dashboard/services/DashboardViewStateSrv.ts
@@ -98,8 +98,6 @@ export class DashboardViewStateSrv {
if (fromRouteUpdated !== true) {
this.$location.search(this.serializeToUrl());
}
-
- this.syncState();
}
toggleCollapsedPanelRow(panelId) {
@@ -115,34 +113,6 @@ export class DashboardViewStateSrv {
}
}
- syncState() {
- if (this.state.fullscreen) {
- const panel = this.dashboard.getPanelById(this.state.panelId);
-
- if (!panel) {
- this.state.fullscreen = null;
- this.state.panelId = null;
- this.state.edit = null;
-
- this.update(this.state);
-
- setTimeout(() => {
- appEvents.emit('alert-error', ['Error', 'Panel not found']);
- }, 100);
-
- return;
- }
-
- if (!panel.fullscreen) {
- this.enterFullscreen(panel);
- } else if (this.dashboard.meta.isEditing !== this.state.edit) {
- this.dashboard.setViewMode(panel, this.state.fullscreen, this.state.edit);
- }
- } else if (this.fullscreenPanel) {
- this.leaveFullscreen();
- }
- }
-
leaveFullscreen() {
const panel = this.fullscreenPanel;
diff --git a/public/app/routes/GrafanaCtrl.ts b/public/app/routes/GrafanaCtrl.ts
index 70bdf49e5e4..817e6452f44 100644
--- a/public/app/routes/GrafanaCtrl.ts
+++ b/public/app/routes/GrafanaCtrl.ts
@@ -165,6 +165,8 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
for (const drop of Drop.drops) {
drop.destroy();
}
+
+ appEvents.emit('hide-dash-search');
});
// handle kiosk mode
diff --git a/public/app/types/dashboard.ts b/public/app/types/dashboard.ts
index bdea5b04bac..713cd28efb1 100644
--- a/public/app/types/dashboard.ts
+++ b/public/app/types/dashboard.ts
@@ -1,6 +1,10 @@
import { DashboardAcl } from './acl';
export interface MutableDashboard {
+ meta: {
+ fullscreen: boolean;
+ isEditing: boolean;
+ }
}
export enum DashboardLoadingState {
diff --git a/public/views/index-template.html b/public/views/index-template.html
index a1c955d45d6..770ab74eccc 100644
--- a/public/views/index-template.html
+++ b/public/views/index-template.html
@@ -189,7 +189,7 @@
-
+