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

HUE-6091 [core] Changed dashboards to follow the is_embeddable format

Enrico Berti 8 жил өмнө
parent
commit
56220f5

+ 0 - 2
apps/search/src/search/urls.py

@@ -28,10 +28,8 @@ urlpatterns = patterns('search.views',
 urlpatterns += patterns('dashboard.views',
   url(r'^$', 'index', name='index'),
   url(r'^m$', 'index_m', name='index_m'),
-  url(r'^embeddable$', 'index_embeddable', name='index_embeddable'),
   url(r'^save$', 'save', name='save'),
   url(r'^new_search', 'new_search', name='new_search'),
-  url(r'^embeddable/new_search', 'new_search_embeddable', name='new_search_embeddable'),
   url(r'^browse/(?P<name>.+)', 'browse', name='browse'),
   url(r'^browse_m/(?P<name>.+)', 'browse_m', name='browse_m'),
 

+ 5 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -518,7 +518,7 @@ ${ assist.assistPanel() }
         editor: '/notebook/editor?is_embeddable=true',
         notebook: '/notebook/notebook?is_embeddable=true',
         metastore: '/metastore/tables/?is_embeddable=true',
-        dashboard: '/dashboard/embeddable/new_search',
+        dashboard: '/dashboard/new_search?is_embeddable=true',
         oozie_workflow: '/oozie/editor/workflow/new/?is_embeddable=true',
         oozie_coordinator: '/oozie/editor/coordinator/new/?is_embeddable=true',
         oozie_bundle: '/oozie/editor/bundle/new/?is_embeddable=true',
@@ -915,6 +915,10 @@ ${ assist.assistPanel() }
           self.currentApp('home');
         });
 
+        page('/dashboard/new_search', function(ctx){
+          self.currentApp('dashboard');
+        });
+
         page('/', function(ctx){
           self.currentApp('editor');
         });

+ 5 - 2
desktop/libs/dashboard/src/dashboard/templates/search.mako

@@ -24,12 +24,15 @@ from desktop import conf
 <%namespace name="common_search" file="common_search.mako" />
 <%namespace name="notebookKoComponents" file="/common_notebook_ko_components.mako" />
 
+%if not is_embeddable:
 ${ commonheader(_('Dashboard'), "dashboard", user, request, "80px") | n,unicode }
-
 ${ notebookKoComponents.downloadSnippetResults() }
+%endif
 
 <div id="searchComponents">
-${ common_search.page_structure() }
+${ common_search.page_structure(is_embeddable) }
 </div>
 
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
+%endif

+ 0 - 28
desktop/libs/dashboard/src/dashboard/templates/search_embeddable.mako

@@ -1,28 +0,0 @@
-## Licensed to Cloudera, Inc. under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  Cloudera, Inc. licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License.  You may obtain a copy of the License at
-##
-##     http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-
-<%!
-from django.utils.translation import ugettext as _
-
-from desktop.views import commonheader, commonfooter, _ko
-from desktop import conf
-%>
-
-<%namespace name="common_search" file="common_search.mako" />
-
-<div id="searchComponents">
-${ common_search.page_structure(is_embeddable=True) }
-</div>

+ 0 - 2
desktop/libs/dashboard/src/dashboard/urls.py

@@ -20,10 +20,8 @@ from django.conf.urls import patterns, url
 urlpatterns = patterns('dashboard.views',
   url(r'^$', 'index', name='index'),
   url(r'^m$', 'index_m', name='index_m'),
-  url(r'^embeddable$', 'index_embeddable', name='index_embeddable'),
   url(r'^save$', 'save', name='save'),
   url(r'^new_search', 'new_search', name='new_search'),
-  url(r'^embeddable/new_search', 'new_search_embeddable', name='new_search_embeddable'),
   url(r'^browse/(?P<name>.+)', 'browse', name='browse'),
   url(r'^browse_m/(?P<name>.+)', 'browse_m', name='browse_m'),
 

+ 5 - 15
desktop/libs/dashboard/src/dashboard/views.py

@@ -51,7 +51,7 @@ DEFAULT_LAYOUT = [
 ]
 
 
-def index(request, is_mobile=False, is_embeddable=False):
+def index(request, is_mobile=False):
   hue_collections = DashboardController(request.user).get_search_collections()
   collection_id = request.GET.get('collection')
 
@@ -79,8 +79,6 @@ def index(request, is_mobile=False, is_embeddable=False):
   template = 'search.mako'
   if is_mobile:
     template = 'search_m.mako'
-  if is_embeddable:
-    template = 'search_embeddable.mako'
 
   return render(template, request, {
     'collection': collection,
@@ -93,16 +91,14 @@ def index(request, is_mobile=False, is_embeddable=False):
     }),
     'is_owner': collection_doc.doc.get().can_write(request.user),
     'can_edit_index': can_edit_index(request.user),
+    'is_embeddable': request.GET.get('is_embeddable', False),
     'mobile': is_mobile,
   })
 
 def index_m(request):
   return index(request, True)
 
-def index_embeddable(request):
-  return index(request, False, True)
-
-def new_search(request, is_embeddable=False):
+def new_search(request):
   engine = request.GET.get('engine', 'solr')
   collections = get_engine(request.user, engine).datasets()
   if not collections:
@@ -111,10 +107,6 @@ def new_search(request, is_embeddable=False):
   collection = Collection2(user=request.user, name=collections[0], engine=engine)
   query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}
 
-  template = 'search.mako'
-  if is_embeddable:
-    template = 'search_embeddable.mako'
-
   if request.GET.get('format', 'plain') == 'json':
     return JsonResponse({
       'collection': collection.get_props(request.user),
@@ -127,7 +119,7 @@ def new_search(request, is_embeddable=False):
        }
      })
   else:
-    return render(template, request, {
+    return render('search.mako', request, {
       'collection': collection,
       'query': query,
       'initial': json.dumps({
@@ -137,12 +129,10 @@ def new_search(request, is_embeddable=False):
           'engines': get_engines(request.user)
        }),
       'is_owner': True,
+      'is_embeddable': request.GET.get('is_embeddable', False),
       'can_edit_index': can_edit_index(request.user)
     })
 
-def new_search_embeddable(request):
-  return new_search(request, True)
-
 def browse(request, name, is_mobile=False):
   engine = request.GET.get('engine', 'solr')
   collections = get_engine(request.user, engine).datasets()