Ver código fonte

HUE-6248 [sentry] Remember the current app path in Hue 4

Enrico Berti 8 anos atrás
pai
commit
2e0df2c

+ 2 - 0
apps/security/src/security/static/security/js/hdfs.ko.js

@@ -116,6 +116,7 @@ var HdfsViewModel = (function () {
       self.pagenum(1);
       self.fetchPath();
       window.location.hash = path;
+      vm.lastHash = window.location.hash;
     });
     self.pathType = ko.observable('');
     self.recursive = ko.observable(false);
@@ -608,6 +609,7 @@ var HdfsViewModel = (function () {
     var self = this;
 
     self.assist = new Assist(self, initial);
+    self.lastHash = '';
 
     self.doAs = ko.observable(initial.user);
     self.doAs.subscribe(function () {

+ 4 - 0
apps/security/src/security/static/security/js/hive.ko.js

@@ -1271,6 +1271,8 @@ var HiveViewModel = (function () {
       });
     }
 
+    self.lastHash = '';
+
     self.updatePathHash = function (path) {
       var _hash = window.location.hash.replace(/(<([^>]+)>)/ig, "");
       if (_hash.indexOf("@") == -1) {
@@ -1279,6 +1281,7 @@ var HiveViewModel = (function () {
       else {
         window.location.hash = path + "@" + _hash.split("@")[1];
       }
+      self.lastHash = window.location.hash;
     }
 
     self.updateSectionHash = function (section) {
@@ -1292,6 +1295,7 @@ var HiveViewModel = (function () {
       else {
         window.location.hash = _hash.split("@")[0] + "@" + section;
       }
+      self.lastHash = window.location.hash;
     }
 
     self.getPathHash = function () {

+ 4 - 0
apps/security/src/security/static/security/js/sentry.ko.js

@@ -1340,6 +1340,8 @@ var SentryViewModel = (function () {
       });
     }
 
+    self.lastHash = '';
+
     self.updatePathHash = function (path) {
       var _hash = window.location.hash.replace(/(<([^>]+)>)/ig, "");
       if (_hash.indexOf("@") == -1) {
@@ -1348,6 +1350,7 @@ var SentryViewModel = (function () {
       else {
         window.location.hash = path + "@" + _hash.split("@")[1];
       }
+      self.lastHash = window.location.hash;
     }
 
     self.updateSectionHash = function (section) {
@@ -1361,6 +1364,7 @@ var SentryViewModel = (function () {
       else {
         window.location.hash = _hash.split("@")[0] + "@" + section;
       }
+      self.lastHash = window.location.hash;
     }
 
     self.getPathHash = function () {

+ 6 - 0
apps/security/src/security/templates/hdfs.mako

@@ -380,6 +380,12 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         show: false
       });
 
+      huePubSub.subscribe('app.gained.focus', function (app) {
+        if (app === 'security_hdfs') {
+          window.location.hash = viewModel.lastHash;
+        }
+      }, 'security_hdfs');
+
     });
   })();
 </script>

+ 7 - 0
apps/security/src/security/templates/hive.mako

@@ -798,6 +798,13 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
       $("#deletePrivilegeModal").modal({
         show: false
       });
+
+      huePubSub.subscribe('app.gained.focus', function (app) {
+        if (app === 'security_hive') {
+          window.location.hash = viewModel.lastHash;
+          showMainSection(viewModel.getSectionHash());
+        }
+      }, 'security_hive');
     });
   })();
 </script>

+ 12 - 0
apps/security/src/security/templates/sentry.mako

@@ -856,6 +856,18 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
       $("#deletePrivilegeModal").modal({
         show: false
       });
+
+      %if component == 'hive':
+      var loadedApp = 'security_hive2';
+      %else:
+      var loadedApp = 'security_solr';
+      %endif
+      huePubSub.subscribe('app.gained.focus', function (app) {
+        if (app === loadedApp) {
+          window.location.hash = viewModel.lastHash;
+          showMainSection(viewModel.getSectionHash());
+        }
+      }, loadedApp);
     });
   })();
 </script>