浏览代码

HUE-1660 [search] Integrate the import/export dashboards

Romain Rigaux 10 年之前
父节点
当前提交
4edf916

+ 21 - 3
apps/search/src/search/templates/admin_collections.mako

@@ -15,7 +15,7 @@
 ## limitations under the License.
 
 <%!
-  from desktop.views import commonheader, commonfooter, commonshare
+  from desktop.views import commonheader, commonfooter, commonshare, commonimportexport
   from django.utils.translation import ugettext as _
 %>
 
@@ -51,26 +51,38 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
         <a data-bind="visible: collections().length > 0 && !isLoading(), click: $root.copyCollections, clickBubble: false, css: {'btn': true, 'disabled': ! atLeastOneSelected()}">
           <i class="fa fa-files-o"></i> ${_('Copy')}
         </a>
+
         <a data-bind="visible: collections().length > 0 && !isLoading(), click: $root.markManyForDeletion, clickBubble: false, css: {'btn': true, 'disabled': ! atLeastOneSelected()}">
           <i class="fa fa-times"></i> ${_('Delete')}
         </a>
-        <a class="share-link btn" rel="tooltip" data-placement="bottom" data-bind="click: function(e){ $root.oneSelected() ? prepareShareModal(e) : void(0) },
+
+        <a class="share-link btn" rel="tooltip" data-placement="bottom" style="margin-left:20px" data-bind="click: function(e){ $root.oneSelected() ? prepareShareModal(e) : void(0) },
           attr: {'data-original-title': '${ _("Share") } ' + name},
           css: {'disabled': ! $root.oneSelected(), 'btn': true}">
           <i class="fa fa-users"></i> ${ _('Share') }
         </a>
+
+        <a data-bind="click: function() { atLeastOneSelected() ? exportDocuments() : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected() }">
+          <i class="fa fa-download"></i> ${ _('Export') }
+        </a>
       </%def>
 
       <%def name="creation()">
         <a data-bind="visible: collections().length > 0 && !isLoading()" class="btn" href="${ url('search:new_search') }" title="${ _('Create a new dashboard') }">
           <i class="fa fa-plus-circle"></i> ${ _('Create') }
         </a>
+        <a data-bind="click: function() { $('#import-documents').modal('show'); }" class="btn">
+          <i class="fa fa-upload"></i> ${ _('Import') }
+        </a>
       </%def>
     </%actionbar:render>
 
     <div class="row-fluid" data-bind="visible: collections().length == 0 && !isLoading()">
       <div class="span10 offset1 center importBtn pointer">
-        <a href="${ url('search:new_search') }"><i class="fa fa-plus-circle waiting"></i></a>
+        <a href="${ url('search:new_search') }">
+          <i class="fa fa-plus-circle waiting"></i>
+        </a>
+
         <h1 class="emptyMessage">
           ${ _('There are currently no dashboards defined.') }<br/>
           <a href="${ url('search:new_search') }">${ _('Click here to add') }</a> ${ _('one or more.') }</h1>
@@ -141,6 +153,7 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
 
 
 ${ commonshare() | n,unicode }
+${ commonimportexport(request) | n,unicode }
 
 
 <script src="${ static('desktop/ext/js/knockout-min.js') }" type="text/javascript" charset="utf-8"></script>
@@ -208,6 +221,11 @@ ${ commonshare() | n,unicode }
       $("#deleteModal").modal('show');
     });
 
+    self.exportDocuments = function() {
+      $('#export-documents').find('input[name=\'documents\']').val(ko.mapping.toJSON($.map(viewModel.selectedCollections(), function(doc) { return doc.id(); })));
+      $('#export-documents').find('form').submit();
+    };
+
     prepareShareModal = function() {
       shareViewModel.setDocId(viewModel.selectedCollections()[0].doc1_id());
       openShareModal();

+ 6 - 6
apps/spark/src/spark/templates/notebooks.mako

@@ -35,12 +35,6 @@ ${ commonheader(_("Notebooks"), "spark", user, "60px") | n,unicode }
 
     <%def name="actions()">
       <div class="btn-toolbar" style="display: inline; vertical-align: middle">
-        <a class="share-link btn" rel="tooltip" data-placement="bottom" data-bind="click: function(e){ oneSelected() ? prepareShareModal(e) : void(0) },
-          attr: {'data-original-title': '${ _("Share") } ' + name},
-          css: {'disabled': ! oneSelected(), 'btn': true}">
-          <i class="fa fa-users"></i> ${ _('Share') }
-        </a>
-
         <a data-bind="click: function(e){ atLeastOneSelected() ? copy(e) : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected()}">
           <i class="fa fa-files-o"></i> ${ _('Copy') }
         </a>
@@ -49,6 +43,12 @@ ${ commonheader(_("Notebooks"), "spark", user, "60px") | n,unicode }
           <i class="fa fa-times"></i> ${ _('Delete') }
         </a>
 
+        <a class="share-link btn" rel="tooltip" data-placement="bottom" style="margin-left:20px" data-bind="click: function(e){ oneSelected() ? prepareShareModal(e) : void(0) },
+          attr: {'data-original-title': '${ _("Share") } ' + name},
+          css: {'disabled': ! oneSelected(), 'btn': true}">
+          <i class="fa fa-users"></i> ${ _('Share') }
+        </a>
+
         <a data-bind="click: function() { atLeastOneSelected() ? exportDocuments() : void(0) }, css: {'btn': true, 'disabled': ! atLeastOneSelected() }">
           <i class="fa fa-download"></i> ${ _('Export') }
         </a>

+ 1 - 1
desktop/core/src/desktop/templates/common_import_export.mako

@@ -42,7 +42,7 @@ from django.utils.translation import ugettext as _
         <span class="btn btn-file" style="line-height: 29px">
           <span class="fileupload-new">${ _('Select file') }</span>
           <span class="fileupload-exists">${ _('Change') }</span>
-          <input type="file" name="documents" accept="application/json" />
+          <input type="file" name="documents" accept=".json" />
         </span>
         &nbsp;&nbsp;<span class="fileupload-preview"></span>
           <a href="#" class="fileupload-exists" data-clear="fileupload"><i class="fa fa-times"></i></a>