Use url params for explore state

- putting state in the path components led to 400 on reload
- use `/explore?state=JSON` instead
This commit is contained in:
David Kaltschmidt
2018-07-17 12:56:05 +02:00
parent a1f0dffe01
commit c6e9ffb168
5 changed files with 5 additions and 6 deletions

View File

@@ -73,8 +73,7 @@ func (hs *HTTPServer) registerRoutes() {
r.Get("/dashboards/", reqSignedIn, Index) r.Get("/dashboards/", reqSignedIn, Index)
r.Get("/dashboards/*", reqSignedIn, Index) r.Get("/dashboards/*", reqSignedIn, Index)
r.Get("/explore/", reqEditorRole, Index) r.Get("/explore", reqEditorRole, Index)
r.Get("/explore/*", reqEditorRole, Index)
r.Get("/playlists/", reqSignedIn, Index) r.Get("/playlists/", reqSignedIn, Index)
r.Get("/playlists/*", reqSignedIn, Index) r.Get("/playlists/*", reqSignedIn, Index)

View File

@@ -67,7 +67,7 @@ interface IExploreState {
export class Explore extends React.Component<any, IExploreState> { export class Explore extends React.Component<any, IExploreState> {
constructor(props) { constructor(props) {
super(props); super(props);
const { datasource, queries, range } = parseInitialState(props.routeParams.initial); const { datasource, queries, range } = parseInitialState(props.routeParams.state);
this.state = { this.state = {
datasource: null, datasource: null,
datasourceError: null, datasourceError: null,

View File

@@ -191,7 +191,7 @@ export class KeybindingSrv {
range, range,
}; };
const exploreState = encodePathComponent(JSON.stringify(state)); const exploreState = encodePathComponent(JSON.stringify(state));
this.$location.url(`/explore/${exploreState}`); this.$location.url(`/explore?state=${exploreState}`);
} }
} }
}); });

View File

@@ -332,7 +332,7 @@ class MetricsPanelCtrl extends PanelCtrl {
range, range,
}; };
const exploreState = encodePathComponent(JSON.stringify(state)); const exploreState = encodePathComponent(JSON.stringify(state));
this.$location.url(`/explore/${exploreState}`); this.$location.url(`/explore?state=${exploreState}`);
} }
addQuery(target) { addQuery(target) {

View File

@@ -112,7 +112,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
controller: 'FolderDashboardsCtrl', controller: 'FolderDashboardsCtrl',
controllerAs: 'ctrl', controllerAs: 'ctrl',
}) })
.when('/explore/:initial?', { .when('/explore', {
template: '<react-container />', template: '<react-container />',
resolve: { resolve: {
roles: () => ['Editor', 'Admin'], roles: () => ['Editor', 'Admin'],