소스 검색

fix: fixed bug with redirect after new dashboard saved, related to buggy angularjs location path/url and base href, fixes #10817

Torkel Ödegaard 7 년 전
부모
커밋
541b0a0ca1

+ 2 - 1
public/app/features/dashboard/dashboard_srv.ts

@@ -1,5 +1,6 @@
 import coreModule from 'app/core/core_module';
 import { DashboardModel } from './dashboard_model';
+import locationUtil from 'app/core/utils/location_util';
 
 export class DashboardSrv {
   dash: any;
@@ -74,7 +75,7 @@ export class DashboardSrv {
     this.dash.version = data.version;
 
     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);

+ 0 - 1
public/app/features/dashboard/dashgrid/AddPanelPanel.tsx

@@ -93,7 +93,6 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
   }
 
   renderPanelItem(panel, index) {
-    console.log('render panel', index);
     return (
       <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} />

+ 2 - 1
public/app/features/dashboard/history/history.ts

@@ -4,6 +4,7 @@ import _ from 'lodash';
 import angular from 'angular';
 import moment from 'moment';
 
+import locationUtil from 'app/core/utils/location_util';
 import { DashboardModel } from '../dashboard_model';
 import { HistoryListOpts, RevisionsModel, CalculateDiffOptions, HistorySrv } from './history_srv';
 
@@ -185,7 +186,7 @@ export class HistoryListCtrl {
     return this.historySrv
       .restoreDashboard(this.dashboard, version)
       .then(response => {
-        this.$location.path('dashboard/db/' + response.slug);
+        this.$location.url(locationUtil.stripBaseFromUrl(response.url)).replace();
         this.$route.reload();
         this.$rootScope.appEvent('alert-success', ['Dashboard restored', 'Restored from version ' + version]);
       })

+ 1 - 2
public/app/routes/dashboard_loaders.ts

@@ -23,8 +23,7 @@ export class LoadDashboardCtrl {
     if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) {
       backendSrv.get(`/api/dashboards/db/${$routeParams.slug}`).then(res => {
         if (res) {
-          const url = locationUtil.stripBaseFromUrl(res.meta.url);
-          $location.path(url).replace();
+          $location.path(locationUtil.stripBaseFromUrl(res.meta.url)).replace();
         }
       });
       return;