Kaynağa Gözat

HUE-6091 [core] 404 error page

Enrico Berti 8 yıl önce
ebeveyn
işleme
1ad414c46e

+ 1 - 0
Gruntfile.js

@@ -37,6 +37,7 @@ module.exports = function(grunt) {
           'desktop/core/src/desktop/static/desktop/css/hue.css': 'desktop/core/src/desktop/static/desktop/less/hue.less',
           'desktop/core/src/desktop/static/desktop/css/hue3-extra.css': 'desktop/core/src/desktop/static/desktop/less/hue3-extra.less',
           'desktop/core/src/desktop/static/desktop/css/login.css': 'desktop/core/src/desktop/static/desktop/less/login.less',
+          'desktop/core/src/desktop/static/desktop/css/httperrors.css': 'desktop/core/src/desktop/static/desktop/less/httperrors.less',
           'apps/metastore/src/metastore/static/metastore/css/metastore.css': 'apps/metastore/src/metastore/static/metastore/less/metastore.less',
           'desktop/libs/notebook/src/notebook/static/notebook/css/notebook.css': 'desktop/libs/notebook/src/notebook/static/notebook/less/notebook.less',
           'desktop/libs/notebook/src/notebook/static/notebook/css/notebook-layout.css': 'desktop/libs/notebook/src/notebook/static/notebook/less/notebook-layout.less',

+ 15 - 37
desktop/core/src/desktop/static/desktop/css/httperrors.css

@@ -1,39 +1,17 @@
-/*
- 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
+/*!
+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
+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.
-*/
-
-body {
-  background-color: #EEE;
-  padding-top: 100px;
-}
-
-.error-code {
-  margin: 0;
-  padding-bottom: 30px;
-  color: #CCC;
-  text-align: center;
-  font-weight: 200;
-  font-size: 150px;
-  line-height: 150px;
-}
-
-.error-box {
-  padding: 20px 35px 20px;
-  margin-bottom: 50px;
-  background: #fff;
-  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
-}
+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.
+ */#httperror .error-code{margin:0;padding-bottom:30px;color:#CCC;text-align:center;font-weight:200;font-size:150px;line-height:150px}#httperror .error-box{padding:20px 35px 20px;margin-bottom:50px}

+ 34 - 0
desktop/core/src/desktop/static/desktop/less/httperrors.less

@@ -0,0 +1,34 @@
+/*
+ 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.
+*/
+
+#httperror {
+  .error-code {
+    margin: 0;
+    padding-bottom: 30px;
+    color: #CCC;
+    text-align: center;
+    font-weight: 200;
+    font-size: 150px;
+    line-height: 150px;
+  }
+
+  .error-box {
+    padding: 20px 35px 20px;
+    margin-bottom: 50px;
+  }
+}

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

@@ -22,7 +22,7 @@ ${ commonheader(_('403 - Access forbidden'), "", user, request) | n,unicode }
 
 <link rel="stylesheet" href="${ static('desktop/css/httperrors.css') }">
 
-<div class="container-fluid">
+<div id="httperror" class="container-fluid">
   <div class="row-fluid">
     <div class="span12 center">
       <div class="error-code">403</div>

+ 1 - 1
desktop/core/src/desktop/templates/403_csrf.mako

@@ -22,7 +22,7 @@ ${ commonheader(_('403 - CSRF error'), "", user, request) | n,unicode }
 
 <link rel="stylesheet" href="${ static('desktop/css/httperrors.css') }">
 
-<div class="container-fluid">
+<div id="httperror" class="container-fluid">
   <div class="row-fluid">
     <div class="span12 center">
       <div class="error-code">403</div>

+ 11 - 2
desktop/core/src/desktop/templates/404.mako

@@ -17,11 +17,14 @@
 from desktop.views import commonheader, commonfooter
 from django.utils.translation import ugettext as _
 %>
+
+%if not is_embeddable:
 ${ commonheader(_('404 - Page not found'), "", user, request) | n,unicode }
+%endif
 
 <link rel="stylesheet" href="${ static('desktop/css/httperrors.css') }">
 
-<div class="container-fluid">
+<div id="httperror" class="container-fluid">
   <div class="row-fluid">
     <div class="span12 center">
       <div class="error-code">404</div>
@@ -31,11 +34,17 @@ ${ commonheader(_('404 - Page not found'), "", user, request) | n,unicode }
     <div class="span6 offset3 center error-box">
       <h1>${_('Page not found.')}</h1>
 
-      <p>${_("We're sorry, but the requested page could not be found:")} <code>${uri}</code></p>
+      <p>${_("We're sorry, but the requested page could not be found")}
+        %if uri:
+        <code>${uri}</code>
+        %endif
+      </p>
       <br/>
       <a href="/home">${ _('Go to My documents') }</a>
     </div>
   </div>
 </div>
 
+%if not is_embeddable:
 ${ commonfooter(request, messages) | n,unicode }
+%endif

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

@@ -25,7 +25,7 @@ ${ commonheader(_('500 - Server error'), "", user, request) | n,unicode }
 
 <link rel="stylesheet" href="${ static('desktop/css/httperrors.css') }">
 
-<div class="container-fluid">
+<div id="httperror" class="container-fluid">
   <div class="row-fluid">
     <div class="span12 center">
       <div class="error-code">500</div>

+ 3 - 2
desktop/core/src/desktop/templates/hue.mako

@@ -351,6 +351,7 @@ ${ hueIcons.symbols() }
       <div id="embeddable_admin_wizard" class="embeddable"></div>
       <div id="embeddable_logs" class="embeddable"></div>
       <div id="embeddable_dump_config" class="embeddable"></div>
+      <div id="embeddable_404" class="embeddable"></div>
     </div>
 
     <div id="rightResizer" class="resizer" data-bind="visible: rightAssistVisible() && rightAssistAvailable(), splitFlexDraggable : {
@@ -512,6 +513,7 @@ ${ assist.assistPanel() }
     var onePageViewModel = (function () {
 
       var EMBEDDABLE_PAGE_URLS = {
+        404: '/404',
         editor: '/editor',
         notebook: '/notebook',
         metastore: '/metastore/tables/',
@@ -920,8 +922,7 @@ ${ assist.assistPanel() }
 
         page('*', function(ctx){
           console.error('Route not found', ctx);
-          // force to editor
-          page('/editor');
+          self.loadApp('404');
         });
 
         page();

+ 1 - 0
desktop/core/src/desktop/urls.py

@@ -95,6 +95,7 @@ dynamic_patterns += patterns('desktop.views',
   (r'^assist_m', 'assist_m'),
   # Hue 4
   (r'^hue.*/$', 'hue'),
+  (r'^404$', 'not_found'),
 
   # KO components, change to doc?name=ko_editor or similar
   (r'^ko_editor', 'ko_editor'),

+ 5 - 0
desktop/core/src/desktop/views.py

@@ -130,6 +130,11 @@ def home2(request, is_embeddable=False):
 def home_embeddable(request):
   return home2(request, True)
 
+def not_found(request):
+  return render('404.mako', request, {
+    'is_embeddable': request.GET.get('is_embeddable', False)
+  })
+
 
 @access_log_level(logging.WARN)
 def log_view(request):