You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/12/31 13:40:25 UTC

ambari git commit: AMBARI-8953 Views: Files, reduce UI memory consumption (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk aaf84e3ac -> 536901a5d


AMBARI-8953 Views: Files, reduce UI memory consumption (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/536901a5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/536901a5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/536901a5

Branch: refs/heads/trunk
Commit: 536901a5d8f90320cc0548ff22e5d814e6f4d7e2
Parents: aaf84e3
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Dec 30 13:58:56 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Dec 31 14:39:57 2014 +0200

----------------------------------------------------------------------
 .../ui/app/components/popoverDelete.js          | 20 +++++++++++++++++++
 .../ui/app/components/toggleContext.js          |  5 +++--
 .../resources/ui/app/controllers/chmodModal.js  |  3 ++-
 .../src/main/resources/ui/app/routes/file.js    | 21 ++++++++++----------
 .../resources/ui/app/styles/application.less    |  8 ++++----
 .../resources/ui/app/templates/util/fileRow.hbs |  4 +---
 .../src/main/resources/ui/app/views/file.js     |  4 ++++
 7 files changed, 45 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js b/contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js
index 7926abc..2bd6fba 100644
--- a/contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js
+++ b/contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js
@@ -18,6 +18,26 @@
 
 var App = require('app');
 
+Em.BsPopoverComponent.reopen({
+  willClearRender:function () {
+    var triggers = this.triggers.split(' ');
+
+      for (var i = triggers.length; i--;) {
+          var trigger = triggers[i];
+
+          if (trigger == 'click') {
+              this.$element.off('click');
+          } else if (trigger != 'manual') {
+              var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focus';
+              var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur';
+
+              this.$element.off(eventIn);
+              this.$element.off(eventOut);
+          }
+      }
+  }
+});
+
 App.PopoverDeleteComponent = Em.Component.extend({
   popover:Em.computed.alias('childViews.firstObject'),
   layoutName:'components/deletePopover',

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/components/toggleContext.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/components/toggleContext.js b/contrib/views/files/src/main/resources/ui/app/components/toggleContext.js
index 68e4b80..65735ba 100644
--- a/contrib/views/files/src/main/resources/ui/app/components/toggleContext.js
+++ b/contrib/views/files/src/main/resources/ui/app/components/toggleContext.js
@@ -50,7 +50,8 @@ App.ToggleContextComponent = Em.Component.extend({
     }
   },
   willClearRender:function () {
-    this.$().parents('.file-row').off('click');
-    this.$().parents('.file-row').off('.context.data-api').removeData('context');
+    var fileRow = this.$().parents('tr');
+    fileRow.off('click');
+    fileRow.data('context').destroy();
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js b/contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js
index 88a437f..a7170f7 100644
--- a/contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js
+++ b/contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js
@@ -43,6 +43,7 @@ App.ChmodModalController = Em.ObjectController.extend({
   otrW:_permissionsProp(8, 'w').property('permissions'),
   otrE:_permissionsProp(9, 'x').property('permissions'),
   replaceAt:function (index,p) {
-    return this.get('permissions').substr(0, index) + p + perm.substr(index + p.length);;
+    var perm = this.get('permissions');
+    return perm.substr(0, index) + p + perm.substr(index + p.length);
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/routes/file.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/routes/file.js b/contrib/views/files/src/main/resources/ui/app/routes/file.js
index e99fc77..e233ea9 100644
--- a/contrib/views/files/src/main/resources/ui/app/routes/file.js
+++ b/contrib/views/files/src/main/resources/ui/app/routes/file.js
@@ -86,17 +86,18 @@ App.FilesRoute = Em.Route.extend({
   },
   model:function (params) {
     var path = (Em.isEmpty(params.path))?'/':params.path;
-    return this.store.listdir(path);
+    var model = this.store.listdir(path);
+    this.set('prevModel',model);
+    return model;
   },
-  afterModel:function (model) {
-    this.store.filter('file',function(file) {
-      if (!model.contains(file)) {
-        return true;
-      }
-    }).then(function (files) {
-      files.forEach(function (file) {
-        file.store.unloadRecord(file);
+  prevModel:null,
+  beforeModel:function () {
+    if (this.get('prevModel.isPending')) {
+      this.get('prevModel').then(function (files) {
+        files.forEach(function (file) {
+          file.store.unloadRecord(file);
+        });
       });
-    });
+    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/styles/application.less
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/styles/application.less b/contrib/views/files/src/main/resources/ui/app/styles/application.less
index 74bcecb..6f858dd 100644
--- a/contrib/views/files/src/main/resources/ui/app/styles/application.less
+++ b/contrib/views/files/src/main/resources/ui/app/styles/application.less
@@ -157,9 +157,9 @@
       }
       .fa-spin {
         -webkit-animation: spin 0.7s infinite linear;
-        -moz-animation: spin 2s infinite linear;
-        -o-animation: spin 2s infinite linear;
-        animation: spin 2s infinite linear;
+        -moz-animation: spin 0.7s infinite linear;
+        -o-animation: spin 0.7s infinite linear;
+        animation: spin 0.7s infinite linear;
       }
       .chmod-row {
         &:hover > td {
@@ -381,4 +381,4 @@
 .modal-backdrop.in {
   filter: alpha(opacity=0);
   opacity: 0;
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs b/contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs
index 24e0aeb..197b3d6 100644
--- a/contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs
+++ b/contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs
@@ -16,7 +16,6 @@
    limitations under the License.
 }}
 
-<tr {{bind-attr class=":file-row isMoving:isMoving"}}>
   <td>
     {{#if content.isDirectory}}
     <i class="fa fa-folder"></i>
@@ -69,7 +68,7 @@
         <li>{{popover-delete confirm="deleteFile"}}</li>
       </ul>
     {{/unless}}
-    </td>
+  </td>
   <td>
   {{#if isMoving}}
     <a href="#" {{action 'moveFile' 'cancel' target="parentController" }} data-toggle="tooltip" data-placement="bottom" title="Cancel moving"> <i class="fa fa-times fa-lg"></i></a>
@@ -78,4 +77,3 @@
   {{/if}}
   {{toggle-context}}
   </td>
-</tr>

http://git-wip-us.apache.org/repos/asf/ambari/blob/536901a5/contrib/views/files/src/main/resources/ui/app/views/file.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/views/file.js b/contrib/views/files/src/main/resources/ui/app/views/file.js
index 2a74426..c0404a8 100644
--- a/contrib/views/files/src/main/resources/ui/app/views/file.js
+++ b/contrib/views/files/src/main/resources/ui/app/views/file.js
@@ -23,6 +23,10 @@ Em.CloakedView.reopen({
   classNameBindings:['_containedView.controller.isMoving:isMoving']
 });
 
+Ember.CloakedView.reopen({
+  cloak:Em.K
+});
+
 App.FileView = Em.View.extend({
   templateName: 'util/fileRow',
   tagName:'tr'