Commit 541b0a0c by Torkel Ödegaard

fix: fixed bug with redirect after new dashboard saved, related to buggy…

fix: fixed bug with redirect after new dashboard saved, related to buggy angularjs location path/url and base href, fixes #10817
parent 17cbd9d6
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
import { DashboardModel } from './dashboard_model'; import { DashboardModel } from './dashboard_model';
import locationUtil from 'app/core/utils/location_util';
export class DashboardSrv { export class DashboardSrv {
dash: any; dash: any;
...@@ -74,7 +75,7 @@ export class DashboardSrv { ...@@ -74,7 +75,7 @@ export class DashboardSrv {
this.dash.version = data.version; this.dash.version = data.version;
if (data.url !== this.$location.path()) { if (data.url !== this.$location.path()) {
this.$location.url(data.url); this.$location.url(locationUtil.stripBaseFromUrl(data.url)).replace();
} }
this.$rootScope.appEvent('dashboard-saved', this.dash); this.$rootScope.appEvent('dashboard-saved', this.dash);
......
...@@ -93,7 +93,6 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP ...@@ -93,7 +93,6 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
} }
renderPanelItem(panel, index) { renderPanelItem(panel, index) {
console.log('render panel', index);
return ( return (
<div key={index} className="add-panel__item" onClick={() => this.onAddPanel(panel)} title={panel.name}> <div key={index} className="add-panel__item" onClick={() => this.onAddPanel(panel)} title={panel.name}>
<img className="add-panel__item-img" src={panel.info.logos.small} /> <img className="add-panel__item-img" src={panel.info.logos.small} />
......
...@@ -4,6 +4,7 @@ import _ from 'lodash'; ...@@ -4,6 +4,7 @@ import _ from 'lodash';
import angular from 'angular'; import angular from 'angular';
import moment from 'moment'; import moment from 'moment';
import locationUtil from 'app/core/utils/location_util';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../dashboard_model';
import { HistoryListOpts, RevisionsModel, CalculateDiffOptions, HistorySrv } from './history_srv'; import { HistoryListOpts, RevisionsModel, CalculateDiffOptions, HistorySrv } from './history_srv';
...@@ -185,7 +186,7 @@ export class HistoryListCtrl { ...@@ -185,7 +186,7 @@ export class HistoryListCtrl {
return this.historySrv return this.historySrv
.restoreDashboard(this.dashboard, version) .restoreDashboard(this.dashboard, version)
.then(response => { .then(response => {
this.$location.path('dashboard/db/' + response.slug); this.$location.url(locationUtil.stripBaseFromUrl(response.url)).replace();
this.$route.reload(); this.$route.reload();
this.$rootScope.appEvent('alert-success', ['Dashboard restored', 'Restored from version ' + version]); this.$rootScope.appEvent('alert-success', ['Dashboard restored', 'Restored from version ' + version]);
}) })
......
...@@ -23,8 +23,7 @@ export class LoadDashboardCtrl { ...@@ -23,8 +23,7 @@ export class LoadDashboardCtrl {
if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) { if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) {
backendSrv.get(`/api/dashboards/db/${$routeParams.slug}`).then(res => { backendSrv.get(`/api/dashboards/db/${$routeParams.slug}`).then(res => {
if (res) { if (res) {
const url = locationUtil.stripBaseFromUrl(res.meta.url); $location.path(locationUtil.stripBaseFromUrl(res.meta.url)).replace();
$location.path(url).replace();
} }
}); });
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment