Browse Source

HUE-5141 [core] Home page import document popup should provide information about the import

krish 9 years ago
parent
commit
a830936

+ 24 - 1
desktop/core/src/desktop/static/desktop/js/document/hueFileEntry.js

@@ -78,6 +78,8 @@ var HueFileEntry = (function () {
 
     self.document = ko.observable();
     self.selectedDocsWithDependents = ko.observable([]);
+    self.importedDocSummary = ko.observable();
+    self.showTable = ko.observable();
 
     self.getSelectedDocsWithDependents = function() {
       self.selectedDocsWithDependents([]);
@@ -542,6 +544,7 @@ var HueFileEntry = (function () {
     var self = this;
     if (self.app === 'documents') {
       $('#importDocumentsModal').modal('hide');
+      $('#importDocumentData').modal('hide');
       $('#importDocumentInput').val('');
     }
     // Allow the modal to hide
@@ -558,12 +561,19 @@ var HueFileEntry = (function () {
       self.uploading(true);
       self.uploadComplete(false);
       self.uploadFailed(false);
+      self.importedDocSummary(null);
+      self.showTable(false);
       self.apiHelper.uploadDocument({
         formData: new FormData($('#importDocumentsForm')[0]),
-        successCallback: function () {
+        successCallback: function (data) {
           self.uploading(false);
           self.uploadComplete(true);
           self.load();
+
+          $('#importDocumentsModal').modal('hide');
+          $('#importDocumentData').modal('show');
+
+          self.importedDocSummary(data);
         },
         progressHandler: function (event) {
           $("#importDocumentsProgress").val(Math.round((event.loaded / event.total) * 100));
@@ -577,6 +587,19 @@ var HueFileEntry = (function () {
     }
   };
 
+  HueFileEntry.prototype.importedDocumentCount = function () {
+    var self = this;
+    if (self.importedDocSummary()) {
+      return self.importedDocSummary()['documents'].length;
+    }
+    return 0;
+  };
+
+  HueFileEntry.prototype.toggleShowTable = function () {
+    var self = this;
+    self.showTable(!self.showTable());
+  };
+
   HueFileEntry.prototype.makeActive = function () {
     var self = this;
     self.activeEntry(this);

+ 42 - 0
desktop/core/src/desktop/templates/document_browser.mako

@@ -463,6 +463,48 @@ from desktop.views import _ko
       <!-- /ko -->
     </div>
 
+    <div id="importDocumentData" data-keyboard="true" class="modal hide fade" tabindex="-1">
+      <!-- ko with: activeEntry -->
+      <div class="modal-body">
+        <div class="center animated" style="display: none;" data-bind="visible: importedDocumentCount() == 0">
+          <i class="fa fa-spinner fa-spin fa-2x"></i>
+        </div>
+        <!-- ko if: importedDocumentCount() > 0 -->
+          <h3> ${_('Document Summary')} </h3>
+          <ul>
+            <li> ${_('Imported: ')} <span data-bind="text: importedDocSummary()['count']"></span></li>
+            <li> ${_('Created: ')} <span data-bind="text: importedDocSummary()['created_count']"></span></li>
+            <li> ${_('Updated: ')} <span data-bind="text: importedDocSummary()['updated_count']"></span></li>
+          </ul>
+
+          ${_('Show Details')}
+          <button id="show-details-caret" class="btn toolbarBtn" data-bind="click: toggleShowTable"><span class="caret"></span></button>
+          <!-- ko if: showTable() -->
+            <table class="table table-striped table-condensed">
+              <thead>
+                <tr>
+                  <th>${_('Name')}</th>
+                  <th>${_('Type')}</th>
+                  <th>${_('Owner')}</th>
+                </tr>
+              </thead>
+              <tbody data-bind="foreach: importedDocSummary()['documents']">
+                <tr>
+                  <td data-bind="text: $data.name"> </td>
+                  <td data-bind="text: $data.type"> </td>
+                  <td data-bind="text: $data.owner"> </td>
+                </tr>
+              </tbody>
+            </table>
+          <!-- /ko -->
+        <!-- /ko -->
+      </div>
+      <div class="modal-footer">
+        <input id="import-document-data-close" data-dismiss="modal" type="button" class="btn" value="${ _('Close') }" data-bind="click: closeUploadModal"/>
+      </div>
+      <!-- /ko -->
+    </div>
+
     <div id="createDirectoryModal" data-keyboard="true" class="modal hide fade" tabindex="-1">
       <!-- ko with: activeEntry -->
       <form class="form-horizontal">