Просмотр исходного кода

final fixes for fullscreen url state, #672

Torkel Ödegaard 11 лет назад
Родитель
Сommit
dee0e5fce7

+ 1 - 0
src/app/controllers/dashLoader.js

@@ -75,6 +75,7 @@ function (angular, _, moment, config) {
         .then(function(result) {
           alertSrv.set('Dashboard Saved', 'Dashboard has been saved as "' + result.title + '"','success', 5000);
 
+          $location.search({});
           $location.path(result.url);
 
           $rootScope.$emit('dashboard-saved', $scope.dashboard);

+ 1 - 0
src/app/controllers/search.js

@@ -41,6 +41,7 @@ function (angular, _, config, $) {
 
         var selectedDash = $scope.results.dashboards[$scope.selectedIndex];
         if (selectedDash) {
+          $location.search({});
           $location.path("/dashboard/db/" + selectedDash.id);
           setTimeout(function() {
             $('body').click(); // hack to force dropdown to close;

+ 5 - 5
src/app/services/dashboard/dashboardSrv.js

@@ -52,11 +52,11 @@ function (angular, $, kbn, _) {
     p.getNextPanelId = function() {
       var i, j, row, panel, max = 0;
       for (i = 0; i < this.rows.length; i++) {
-       row = this.rows[i];
-       for (j = 0; j < row.panels.length; j++) {
-         panel = row.panels[j];
-         if (panel.id > max) { max = panel.id; }
-       }
+        row = this.rows[i];
+        for (j = 0; j < row.panels.length; j++) {
+          panel = row.panels[j];
+          if (panel.id > max) { max = panel.id; }
+        }
       }
       return max + 1;
     };

+ 1 - 0
src/app/services/dashboard/dashboardViewStateSrv.js

@@ -25,6 +25,7 @@ function (angular, _, $) {
 
       $scope.onAppEvent('$routeUpdate', function() {
         var urlState = self.getQueryStringState();
+        console.log("route updated!");
         if (self.needsSync(urlState)) {
           self.update(urlState, true);
         }

+ 1 - 0
src/app/services/playlistSrv.js

@@ -68,6 +68,7 @@ function (angular, _, kbn) {
       timerInstance = setInterval(function() {
         $rootScope.$apply(function() {
           angular.element(window).unbind('resize');
+          $location.search({});
           $location.path(dashboards[index % dashboards.length].url);
           index++;
         });

+ 7 - 0
src/app/services/unsavedChangesSrv.js

@@ -28,10 +28,12 @@ function(angular, _, config) {
     $rootScope.$on("dashboard-saved", function(event, savedDashboard) {
       self.original = angular.copy(savedDashboard);
       self.current = savedDashboard;
+      self.orignalPath = $location.path();
     });
 
     $rootScope.$on("$routeChangeSuccess", function() {
       self.original = null;
+      self.originalPath = $location.path();
     });
 
     window.onbeforeunload = function() {
@@ -42,6 +44,11 @@ function(angular, _, config) {
 
     this.init = function() {
       $rootScope.$on("$locationChangeStart", function(event, next) {
+        if (self.originalPath === $location.path()) {
+          console.log("skipping");
+          return;
+        }
+
         if (self.has_unsaved_changes()) {
           event.preventDefault();
           self.next = next;