Преглед на файлове

HUE-1223 [core] Filechooser opens on bad default path

Switched from cookie to totalStorage, the path is now saved per user
Enrico Berti преди 12 години
родител
ревизия
f8c87c3

+ 0 - 2
apps/beeswax/src/beeswax/templates/execute.mako

@@ -439,8 +439,6 @@ ${layout.menubar(section='query')}
 
 </style>
 
-<script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
-<script src="/static/ext/js/jquery/plugins/jquery.total-storage.min.js"></script>
 <script src="/static/ext/js/jquery/plugins/jquery-fieldselection.js" type="text/javascript"></script>
 
 <script type="text/javascript" charset="utf-8">

+ 0 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -33,7 +33,6 @@ from django.utils.translation import ugettext as _
 </%def>
 
 <%def name="_table(files, path, current_request_path, view)">
-    <script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
     <script src="/static/ext/js/knockout-2.1.0.js" type="text/javascript" charset="utf-8"></script>
     <script src="/static/ext/js/datatables-paging-0.1.js" type="text/javascript" charset="utf-8"></script>
     <style type="text/css">

+ 0 - 1
apps/metastore/src/metastore/templates/databases.mako

@@ -85,7 +85,6 @@ ${ commonheader(_('Databases'), 'metastore', user) | n,unicode }
 
 <link rel="stylesheet" href="/metastore/static/css/metastore.css" type="text/css">
 
-<script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
 <script src="/static/ext/js/knockout-2.1.0.js" type="text/javascript" charset="utf-8"></script>
 
 <script type="text/javascript" charset="utf-8">

+ 0 - 1
apps/metastore/src/metastore/templates/tables.mako

@@ -97,7 +97,6 @@ ${ commonheader(_('Tables'), 'metastore', user) | n,unicode }
 
 <link rel="stylesheet" href="/metastore/static/css/metastore.css" type="text/css">
 
-<script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
 <script src="/static/ext/js/knockout-2.1.0.js" type="text/javascript" charset="utf-8"></script>
 
 <script type="text/javascript" charset="utf-8">

+ 3 - 1
desktop/core/src/desktop/templates/common_header.mako

@@ -71,7 +71,8 @@ from django.utils.translation import ugettext as _
           FILE_NOT_FOUND:"${_('The file has not been found')}",
           UPLOAD_FILE:"${_('Upload a file')}",
           FAILED:"${_('Failed')}"
-        }
+        },
+        user: "${ user.username }"
       };
 
       jHueTableExtenderGlobals = {
@@ -93,6 +94,7 @@ from django.utils.translation import ugettext as _
   <script src="/static/js/Source/jHue/jquery.tableextender.js"></script>
   <script src="/static/js/Source/jHue/jquery.scrollup.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
+  <script src="/static/ext/js/jquery/plugins/jquery.total-storage.min.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.simpleplaceholder.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.dataTables.1.8.2.min.js"></script>
   <script src="/static/js/Source/jHue/jquery.datatables.sorting.js"></script>

+ 8 - 6
desktop/core/static/js/Source/jHue/jquery.filechooser.js

@@ -39,6 +39,7 @@
                 UPLOAD_FILE: "Upload a file",
                 FAILED: "Failed"
             },
+            user: "",
             onFileChoose:function () {
             },
             onFolderChoose:function () {
@@ -47,7 +48,8 @@
             },
             onError:function () {
             }
-        };
+        },
+        STORAGE_PREFIX = "hueFileBrowserLastPathForUser_";
 
     function Plugin(element, options) {
         this.element = element;
@@ -77,8 +79,8 @@
           if ($.trim(this.options.initialPath) != "") {
             this.navigateTo(this.options.initialPath);
           }
-          else if ($.cookie("hueFileBrowserLastPath") != null) {
-            this.navigateTo($.cookie("hueFileBrowserLastPath"));
+          else if ($.totalStorage(STORAGE_PREFIX + this.options.user) != null) {
+            this.navigateTo($.totalStorage(STORAGE_PREFIX + this.options.user));
           }
           else {
             this.navigateTo("/?default_to_home");
@@ -111,7 +113,7 @@
                     _parent.navigateTo(data.view.dirname);
                     return;
                 }
-                $.cookie("hueFileBrowserLastPath", path, { expires: 90 });
+                $.totalStorage(STORAGE_PREFIX + _parent.options.user, path);
                 _parent.previousPath = path;
                 var _breadcrumbs = $("<ul>").addClass("hueBreadcrumb").css("padding", "0");
                 var _home = $("<li>");
@@ -294,8 +296,8 @@
         if ($.trim(this.options.initialPath) != "") {
             this.navigateTo(this.options.initialPath);
         }
-        else if ($.cookie("hueFileBrowserLastPath") != null) {
-            this.navigateTo($.cookie("hueFileBrowserLastPath"));
+        else if ($.totalStorage(STORAGE_PREFIX + this.options.user) != null) {
+            this.navigateTo($.totalStorage(STORAGE_PREFIX + this.options.user));
         }
         else {
             this.navigateTo("/?default_to_home");