Selaa lähdekoodia

AMBARI-5766. View: Files need to preserve navigation when showing an error. (jaimin)

Jaimin Jetly 11 vuotta sitten
vanhempi
commit
6ef7e33d6d

+ 3 - 0
contrib/views/files/src/main/resources/ui/app/controllers/files.js

@@ -148,3 +148,6 @@ App.FilesController = Ember.ArrayController.extend({
   }.property('arrangedContent')
   }.property('arrangedContent')
 });
 });
 
 
+App.FilesAlertController = Em.ObjectController.extend({
+  content:null
+});

+ 1 - 0
contrib/views/files/src/main/resources/ui/app/initialize.js

@@ -34,6 +34,7 @@ require('templates/util/deletePopover');
 require('templates/util/uploader');
 require('templates/util/uploader');
 require('templates/util/contextMenu');
 require('templates/util/contextMenu');
 require('templates/util/deleteBulk');
 require('templates/util/deleteBulk');
+require('templates/util/errorRow');
 
 
 //////////////////////////////////
 //////////////////////////////////
 // Models
 // Models

+ 40 - 1
contrib/views/files/src/main/resources/ui/app/routes/file.js

@@ -25,16 +25,55 @@ App.FilesRoute = Em.Route.extend({
     }
     }
   },
   },
   actions:{
   actions:{
+    error:function (error,transition,e) {
+      if (this.router._lookupActiveView('files')) {
+        this.controllerFor('filesAlert').set('content',error);
+        this.render('files.alert',{
+          into:'files',
+          outlet:'error',
+          controller:'filesAlert'
+        });
+      } else {
+        return true;
+      };
+    },
     dirUp: function () {
     dirUp: function () {
       var currentPath = this.controllerFor('files').get('path');
       var currentPath = this.controllerFor('files').get('path');
       var upDir = currentPath.replace(currentPath.substr(currentPath.lastIndexOf('/')), '');
       var upDir = currentPath.replace(currentPath.substr(currentPath.lastIndexOf('/')), '');
       var target = upDir || '/';
       var target = upDir || '/';
       return this.transitionTo('files',{queryParams: {path: target}});
       return this.transitionTo('files',{queryParams: {path: target}});
+    },
+    willTransition:function (argument) {
+      this.send('removeAlert');
+    },
+    removeAlert:function () {
+      this.disconnectOutlet({
+        outlet: 'error',
+        parentView: 'files'
+      });
     }
     }
   },
   },
   model:function (params) {
   model:function (params) {
-    this.store.unloadAll('file');
     var path = (Em.isEmpty(params.path))?'/':params.path;
     var path = (Em.isEmpty(params.path))?'/':params.path;
     return this.store.listdir(path);
     return this.store.listdir(path);
+  },
+  afterModel:function (model) {
+    var self = this;
+    var model = model;
+    this.store.filter('file',function(file) {
+      if (!model.contains(file)) {
+        return true;
+      };
+    }).then(function (files) {
+      files.forEach(function (file) {
+        file.store.unloadRecord(file);
+      })
+    });
+  },
+  setupController:function (controller,model,transition) {
+    controller.set('model', model);
+  },
+  renderTemplate:function (q,w,e) {
+    this.render('files');
   }
   }
 });
 });

+ 12 - 0
contrib/views/files/src/main/resources/ui/app/styles/application.less

@@ -122,6 +122,18 @@
       }
       }
     }
     }
     tbody {
     tbody {
+      .error-row{
+        td {
+          padding: 0;
+          border: 0;
+          & > div {
+            border-top: 1px solid #DDDDDD;
+            padding: 8px;
+            color: #a94442;
+            word-break: break-word;
+          }
+        }
+      }
       .btn-delete {
       .btn-delete {
         .popover-content{
         .popover-content{
           width: 80px;
           width: 80px;

+ 5 - 0
contrib/views/files/src/main/resources/ui/app/templates/files.hbs

@@ -129,6 +129,11 @@
           <strong> .. </strong>
           <strong> .. </strong>
         </td>
         </td>
       </tr>
       </tr>
+      <tr class="error-row">
+        <td colspan="7" class="danger">
+          {{outlet error}}
+        </td>
+      </tr>
       {{#unless hideMoving}}
       {{#unless hideMoving}}
       {{#if movingFile}}
       {{#if movingFile}}
         <tr class="isMoving">
         <tr class="isMoving">

+ 24 - 0
contrib/views/files/src/main/resources/ui/app/templates/util/errorRow.hbs

@@ -0,0 +1,24 @@
+{{!
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF 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.
+}}
+
+<div class="text-center">
+  <button {{action 'removeAlert'}} type="button" class="close" aria-hidden="true">&times;</button>
+  <strong>{{content.status}} </strong> {{content.statusText}}  
+</div>
+  
+

+ 4 - 0
contrib/views/files/src/main/resources/ui/app/views/file.js

@@ -209,3 +209,7 @@ App.FilesView = Em.View.extend({
       });
       });
     }.observes('controller.hideMoving')
     }.observes('controller.hideMoving')
 });
 });
+
+App.FilesAlertView = Em.View.extend({
+  templateName:'util/errorRow'
+});

+ 1 - 1
contrib/views/files/src/main/resources/ui/config.coffee

@@ -43,7 +43,7 @@ exports.config =
     addSourceURLs: true
     addSourceURLs: true
 
 
   paths:
   paths:
-    public: '/usr/lib/ambari-server/web/files'
+    public: '/usr/lib/ambari-server/web/views-debug/FILES/FILES_1/'
 
 
   overrides:
   overrides:
     production:
     production: