Bläddra i källkod

[editor] Add link to new Hive editor

Romain Rigaux 10 år sedan
förälder
incheckning
35ef96a

+ 2 - 0
desktop/core/src/desktop/models.py

@@ -798,6 +798,8 @@ class Document2(models.Model):
       return reverse('oozie:edit_coordinator') + '?coordinator=' + str(self.id)
     elif self.type == 'oozie-bundle2':
       return reverse('oozie:edit_bundle') + '?bundle=' + str(self.id)
+    elif self.type == 'query':
+      return reverse('notebook:query') + '?editor=' + str(self.id)
     elif self.type == 'notebook':
       return reverse('notebook:notebook') + '?notebook=' + str(self.id)
     elif self.type == 'search-dashboard':

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

@@ -412,6 +412,7 @@ from django.utils.translation import ugettext as _
          <ul role="menu" class="dropdown-menu">
            % if 'beeswax' in apps:
              <li><a href="/${apps['beeswax'].display_name}"><img src="${ static(apps['beeswax'].icon_path) }" class="app-icon"/> ${_('Hive')}</a></li>
+             <li><a href="${ url('notebook:editor_hive') }"><img src="${ static(apps['beeswax'].icon_path) }" class="app-icon"/> ${_('New Hive')}</a></li>
            % endif
            % if 'impala' in apps:
              <li><a href="/${apps['impala'].display_name}"><img src="${ static(apps['impala'].icon_path) }" class="app-icon"/> ${_('Impala')}</a></li>

+ 2 - 1
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -58,7 +58,8 @@ class Notebook(object):
       self.data = json.dumps({
           'name': 'My Notebook',
           'description': '',
-          'snippets': []
+          'snippets': [],
+          'type': 'notebook'
       })
 
   def get_json(self):

+ 1 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -674,6 +674,7 @@
     self.uuid = ko.observable(typeof notebook.uuid != "undefined" && notebook.uuid != null ? notebook.uuid : UUID());
     self.name = ko.observable(typeof notebook.name != "undefined" && notebook.name != null ? notebook.name : 'My Notebook');
     self.description = ko.observable(typeof notebook.description != "undefined" && notebook.description != null ? notebook.description: '');
+    self.type = ko.observable(typeof notebook.type != "undefined" && notebook.type != null ? notebook.type: 'notebook');
     self.snippets = ko.observableArray();
     self.selectedSnippet = ko.observable(vm.availableSnippets().length > 0 ? vm.availableSnippets()[0].type() : 'NO_SNIPPETS');
     self.creatingSessionLocks = ko.observableArray();

+ 1 - 0
desktop/libs/notebook/src/notebook/urls.py

@@ -41,6 +41,7 @@ urlpatterns = patterns('notebook.views',
   url(r'^copy$', 'copy', name='copy'),
 
   url(r'^editor$', 'editor', name='editor'),
+  url(r'^editor/hive$', 'editor_hive', name='editor_hive'),
 )
 
 # APIs

+ 6 - 1
desktop/libs/notebook/src/notebook/views.py

@@ -77,7 +77,8 @@ def editor(request):
   else:
     editor = Notebook()
     data = editor.get_data()
-    data['name'] = 'My SQL query'
+    data['name'] = 'Hive Query'
+    data['type'] = 'query'    
     editor.data = json.dumps(data)
 
   autocomplete_base_url = ''
@@ -95,6 +96,10 @@ def editor(request):
   })
 
 
+def editor_hive(request):
+  return editor(request)
+
+
 def new(request):
   return notebook(request)