Эх сурвалжийг харах

HUE-6012 [metastore] Add links to open the importer in responsive

Romain Rigaux 8 жил өмнө
parent
commit
0b265ad

+ 2 - 3
apps/metastore/src/metastore/templates/metastore.mako

@@ -556,8 +556,7 @@ ${ components.menubar() }
     <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceType: 'hive' }); }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }" title="${_('Refresh')}"></i></a>
     % if has_write_access:
       % if is_embeddable:
-        <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { onePageViewModel.currentApp('importer') }" title="${_('Create a new database')}"><i class="fa fa-plus"></i></a>
-        ## huePubSub.publish('open.app', {'app': 'importer', 'prefill': {'source_type: 'all', 'target_type': 'table'}, 'database': 'huedb'})
+        <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }'); }" title="${_('Create a new database')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
       % elif ENABLE_NEW_CREATE_TABLE.get():
         <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' }" title="${_('Create a new database')}"><i class="fa fa-plus"></i></a>
       % else:
@@ -572,7 +571,7 @@ ${ components.menubar() }
     <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceType: 'hive' }); }" title="${_('Refresh')}"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
     % if has_write_access:
       % if is_embeddable:
-        <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { onePageViewModel.currentApp('importer') }" title="${_('Create a new table')}"><i class="fa fa-plus"></i></a>
+        <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + database().name ); }" title="${_('Create a new table')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
       % elif ENABLE_NEW_CREATE_TABLE.get():
         <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + database().name }" title="${_('Create a new table')}"><i class="fa fa-plus"></i></a>
       % else:

+ 12 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -662,10 +662,20 @@ from notebook.conf import get_ordered_interpreters
       % if ENABLE_NEW_CREATE_TABLE.get():
         <!-- ko if: sourceType === 'hive' || sourceType === 'impala' -->
         <!-- ko if: typeof databaseName !== 'undefined' -->
-        <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName }"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+          <!-- ko if: IS_HUE_4 -->
+            <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName ); }" title="${_('Create table')}" href="javascript:void(0)"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+          <!-- /ko -->
+          <!-- ko if: ! IS_HUE_4 -->
+            <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName }"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+          <!-- /ko -->
         <!-- /ko -->
         <!-- ko if: typeof databases !== 'undefined' -->
-        <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' }"><i class="pointer fa fa-plus" title="${_('Create database')}"></i></a>
+          <!-- ko if: IS_HUE_4 -->
+            <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }'); }" href="javascript:void(0)"><i class="pointer fa fa-plus" title="${_('Create database')}"></i></a>
+          <!-- /ko -->
+          <!-- ko if: ! IS_HUE_4 -->
+            <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }' }"><i class="pointer fa fa-plus" title="${_('Create database')}"></i></a>
+          <!-- /ko -->
         <!-- /ko -->
         <!-- /ko -->
       % endif

+ 8 - 0
desktop/core/src/desktop/templates/responsive.mako

@@ -673,6 +673,14 @@ ${ assist.assistPanel() }
             self.getActiveAppViewModel(function (metastoreViewModel) {
               metastoreViewModel.loadURL();
             });
+          } else if (href.startsWith('/indexer/importer/prefill')){
+              self.currentApp('importer');
+              self.getActiveAppViewModel(function (viewModel) {
+                var arguments = href.match(/\/indexer\/importer\/prefill\/?([^/]+)\/?([^/]+)\/?([^/]+)/);
+                viewModel.createWizard.prefill.source_type(arguments[1] ? arguments[1] : '');
+                viewModel.createWizard.prefill.target_type(arguments[2] ? arguments[2] : '');
+                viewModel.createWizard.prefill.target_path(arguments[3] ? arguments[3] : '');
+              })
           } else if (href.startsWith('/notebook')){
             self.currentApp('notebook');
           } else if (href.startsWith('/pig')){

+ 8 - 8
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -392,13 +392,13 @@ ${ assist.assistPanel() }
       <h3 class="card-heading simple">${_('Source')}</h3>
       <div class="card-body">
         <div>
-          <div class="control-group" data-bind="visible: !createWizard.prefill.target_type || !createWizard.prefill.target_type() || createWizard.prefill.source_type() == 'all'">
+          <div class="control-group" data-bind="visible: createWizard.prefill.target_type().length == 0 || createWizard.prefill.source_type() == 'all'">
             <label for="sourceType" class="control-label"><div>${ _('Type') }</div>
               <select id="sourceType" data-bind="selectize: createWizard.source.inputFormats, value: createWizard.source.inputFormat, optionsText: 'name', optionsValue: 'value'"></select>
             </label>
           </div>
 
-          <div class="control-group" data-bind="visible: createWizard.prefill.target_type && createWizard.prefill.target_type() == 'database'">
+          <div class="control-group" data-bind="visible: createWizard.prefill.target_type() == 'database'">
             <label for="sourceType" class="control-label">${ _('No source is needed for creating a database.') }</label>
           </div>
 
@@ -436,7 +436,7 @@ ${ assist.assistPanel() }
       <!-- ko ifnot: createWizard.isGuessingFormat -->
       <h3 class="card-heading simple">${_('Format')}</h3>
       <div class="card-body">
-        <label data-bind="visible: (! createWizard.prefill.source_type) && createWizard.source.inputFormat() != 'table'">
+        <label data-bind="visible: createWizard.prefill.source_type().length == 0 && createWizard.source.inputFormat() != 'table'">
           <div>${_('File Type')}</div>
           <select data-bind="selectize: $root.createWizard.fileTypes, value: $root.createWizard.fileTypeName, optionsText: 'description', optionsValue: 'name'"></select>
         </label>
@@ -496,7 +496,7 @@ ${ assist.assistPanel() }
         <h3 class="card-heading simple">${_('Destination')}</h3>
         <div class="card-body">
           <div class="control-group">
-            <label for="destinationType" class="control-label" data-bind="visible: ! $parent.createWizard.prefill.target_type"><div>${ _('Type') }</div>
+            <label for="destinationType" class="control-label" data-bind="visible: $parent.createWizard.prefill.target_type().length == 0"><div>${ _('Type') }</div>
               <select id="destinationType" data-bind="selectize: outputFormats, value: outputFormat, optionsValue: 'value', optionsText: 'name'"></select>
             </label>
           </div>
@@ -1156,7 +1156,7 @@ ${ assist.assistPanel() }
           ##{'value': 'dbms', 'name': 'DBMS'},
           ##{'value': 'text', 'name': 'Paste Text'},
       ]);
-      if (wizard.prefill.source_type) {
+      if (wizard.prefill.source_type().length > 0) {
         self.inputFormats([
             {'value': 'file', 'name': 'File'},
             {'value': 'manual', 'name': 'Manually'},
@@ -1233,7 +1233,7 @@ ${ assist.assistPanel() }
         var name = ''
 
         if (self.inputFormat() == 'file') {
-          name = wizard.prefill.target_path ? wizard.prefill.target_path() : 'default';
+          name = wizard.prefill.target_path().length > 0 ? wizard.prefill.target_path() : 'default';
 
           if (self.path()) {
             name += '.' + self.path().split('/').pop().split('.')[0];
@@ -1247,7 +1247,7 @@ ${ assist.assistPanel() }
             name = self.name();
           }
         } else if (self.inputFormat() == 'manual') {
-          name = wizard.prefill.target_path ? wizard.prefill.target_path() + '.' : '';
+          name = wizard.prefill.target_path().length > 0 ? wizard.prefill.target_path() + '.' : '';
         }
 
         return name.replace(/ /g, '_').toLowerCase();
@@ -1338,7 +1338,7 @@ ${ assist.assistPanel() }
           return true;
         })
       });
-      if (wizard.prefill.target_type) {
+      if (wizard.prefill.target_type().length > 0) {
         self.outputFormat(wizard.prefill.target_type());
         if (wizard.prefill.target_type() == 'database') {
           vm.currentStep(2);

+ 4 - 1
desktop/libs/indexer/src/indexer/views.py

@@ -85,8 +85,11 @@ HIVE_TYPES = HIVE_PRIMITIVE_TYPES + ("array", "map", "struct")
 
 def importer(request):
   prefill = {
+    'source_type': '',
+    'target_type': '',
+    'target_path': ''
   }
-  
+
   return _importer(request, prefill)