ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiw...@apache.org
Subject git commit: AMBARI-6480. Ability to show history of more than 10 background operations.(xiwang)
Date Mon, 14 Jul 2014 23:27:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c5b0e4833 -> f3f4876f7


AMBARI-6480. Ability to show history of more than 10 background operations.(xiwang)


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

Branch: refs/heads/trunk
Commit: f3f4876f7e42162089953c93e15ae12db7264d69
Parents: c5b0e48
Author: Xi Wang <xiwang@apache.org>
Authored: Mon Jul 14 16:14:17 2014 -0700
Committer: Xi Wang <xiwang@apache.org>
Committed: Mon Jul 14 16:26:58 2014 -0700

----------------------------------------------------------------------
 .../global/background_operations_controller.js   | 17 ++++++++++++++---
 ambari-web/app/messages.js                       |  1 +
 ambari-web/app/styles/application.less           | 11 +++++++++++
 .../app/templates/common/host_progress_popup.hbs |  9 ++++++---
 ambari-web/app/utils/ajax/ajax.js                |  2 +-
 ambari-web/app/utils/db.js                       | 19 +++++++++++++++++++
 ambari-web/app/utils/host_progress_popup.js      | 16 ++++++++++++++++
 7 files changed, 68 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index c1d0e78..a52c7ac 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -71,6 +71,7 @@ App.BackgroundOperationsController = Em.Controller.extend({
     });
     return !this.isInitLoading();
   },
+
   /**
    * indicate whether data for current level has already been loaded or not
    * @return {Boolean}
@@ -89,10 +90,13 @@ App.BackgroundOperationsController = Em.Controller.extend({
    */
   getQueryParams: function () {
     var levelInfo = this.get('levelInfo');
+    var count = App.db.getBGOOperationsCount();
     var result = {
       name: 'background_operations.get_most_recent',
       successCallback: 'callBackForMostRecent',
-      data: {}
+      data: {
+        'operationsCount': count
+      }
     };
     if (levelInfo.get('name') === 'TASK_DETAILS' && !App.testMode) {
       result.name = 'background_operations.get_by_task';
@@ -176,13 +180,16 @@ App.BackgroundOperationsController = Em.Controller.extend({
   callBackForMostRecent: function (data) {
     var runningServices = 0;
     var currentRequestIds = [];
-
+    var countIssued = App.db.getBGOOperationsCount();
+    var countGot = data.itemTotal;
+   
     data.items.forEach(function (request) {
       var rq = this.get("services").findProperty('id', request.Requests.id);
       var isRunning = this.isRequestRunning(request);
       var requestParams = this.parseRequestContext(request.Requests.request_context);
       this.assignScheduleId(request, requestParams);
       currentRequestIds.push(request.Requests.id);
+
       if (rq) {
         rq.set('progress', Math.ceil(request.Requests.progress_percent));
         rq.set('status', request.Requests.request_status);
@@ -207,16 +214,20 @@ App.BackgroundOperationsController = Em.Controller.extend({
           contextCommand: requestParams.contextCommand
         });
         this.get("services").unshift(rq);
+        //To sort DESC by request id
+        this.set("services", this.get("services").sort( function(a,b) { return b.get('id')
- a.get('id'); })) ;
       }
       runningServices += ~~isRunning;
     }, this);
     this.removeOldRequests(currentRequestIds);
     this.set("allOperationsCount", runningServices);
+    this.set('isShowMoreAvailable', countGot >= countIssued);
     this.set('serviceTimestamp', App.dateTime());
   },
+  isShowMoreAvailable: null,
   /**
    * remove old requests
-   * as API returns 10 latest request, the requests that absent in response should be removed
+   * as API returns 10, or  20 , or 30 ...etc latest request, the requests that absent in
response should be removed
    * @param currentRequestIds
    */
   removeOldRequests: function (currentRequestIds) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 85c893a..214870f 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -246,6 +246,7 @@ Em.I18n.translations = {
   'hostPopup.status.category.aborted':'Aborted ({0})',
   'hostPopup.status.category.timedout':'Timedout ({0})',
   'hostPopup.header.postFix':' Background Operations Running',
+  'hostPopup.serviceInfo.showMore':'Show more...',
   'hostPopup.bgop.sourceRequestSchedule.running': 'Future operations of this batch request
can be aborted',
   'hostPopup.bgop.sourceRequestSchedule.aborted': 'Future operations of this batch request
have been aborted',
   'hostPopup.bgop.abort.rollingRestart': 'Abort Rolling Restart',

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 70ced0e..e09711a 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -1877,6 +1877,17 @@ width:100%;
       text-align: left;
     }
   }
+  #service-info{
+    .show-more {
+      width: 98.8%;
+      min-height: 20px;
+      cursor: pointer;
+      border-top: 1px solid #CCC;
+      text-align: center;
+      padding: 10px 10px 10px 0px;
+      font-size: 16px;
+    }
+  }
   #host-info, #service-info{
     overflow: auto;
     max-height: 340px;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/templates/common/host_progress_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/host_progress_popup.hbs b/ambari-web/app/templates/common/host_progress_popup.hbs
index 33fde90..26dcc6f 100644
--- a/ambari-web/app/templates/common/host_progress_popup.hbs
+++ b/ambari-web/app/templates/common/host_progress_popup.hbs
@@ -19,7 +19,7 @@
 <div class="host-component-popup-wrap">
 
     {{#if view.parentView.isLoaded}}
-    <!-- SERVICES --->
+    {{!-- SERVICES --}}
 
     <div {{bindAttr class="view.isServiceListHidden:hidden :task-list-main-warp"}}>
       <div class="task-top-wrap">
@@ -62,11 +62,14 @@
             </div>
           {{/each}}
         {{/if}}
+        {{#if view.isShowMore}}
+            <div class="show-more" {{action requestMoreOperations}}><a href="#">{{t
hostPopup.serviceInfo.showMore}}</a></div>
+        {{/if}}
       </div>
     </div>
 
 
-  <!-- HOSTS --->
+  {{!-- HOSTS ---}}
 
   <div {{bindAttr class="view.isHostListHidden:hidden :task-list-main-warp"}}>
     <div class="task-top-wrap">
@@ -134,7 +137,7 @@
   </div>
 
 
-  <!-- TASKS --->
+  {{!-- TASKS ---}}
 
   <div {{bindAttr class="view.isTaskListHidden:hidden :task-list-main-warp"}}>
     <div class="task-top-wrap">

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 73b66d5..8139e15 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -221,7 +221,7 @@ var urls = {
     'mock': '/data/alerts/HDP2/host_alerts.json'
   },
   'background_operations.get_most_recent': {
-    'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
+    'real': '/clusters/{clusterName}/requests?to=end&page_size={operationsCount}&fields=Requests',
     'mock': '/data/background_operations/list_on_start.json',
     'testInProduction': true
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index b77ee1a..b39c5f2 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -167,6 +167,16 @@ App.db.setAuthenticated = function (authenticated) {
   console.log('Now present value of authentication is: ' + App.db.data.app.authenticated);
 };
 
+App.db.setBGOOperationsCount = function(count) {
+  console.log('TRACE: Entering db:setBGOOperationsCount function');
+  App.db.data = localStorage.getObject('ambari');
+  if (!App.db.data.app.BGOOperationsCount) {
+    App.db.data.app.BGOOperationsCount = 10;
+  }
+  App.db.data.app.BGOOperationsCount = count;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.setFilterConditions = function(name, filterConditions) {
   console.log('TRACE: Entering db:setFilterConditions function');
   App.db.data = localStorage.getObject('ambari');
@@ -551,6 +561,15 @@ App.db.getAuthenticated = function () {
   return App.db.data.app.authenticated;
 };
 
+App.db.getBGOOperationsCount = function () {
+  console.log('Trace: Entering db:getBGOOperationsCount function');
+  App.db.data = localStorage.getObject('ambari');
+  if (App.db.data.app.BGOOperationsCount) {
+    return App.db.data.app.BGOOperationsCount;
+  }
+  return 10;
+};
+
 App.db.getFilterConditions = function(name) {
   console.log('TRACE: Entering db:getFilterConditions function');
   App.db.data = localStorage.getObject('ambari');

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3f4876f/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index 3c63965..56ca788 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -789,6 +789,22 @@ App.HostPopup = Em.Object.create({
         },
 
         /**
+         * Onclick handler for Show more ..
+         */
+        requestMoreOperations: function () {
+          var count = App.db.getBGOOperationsCount();
+          App.db.setBGOOperationsCount(count + 10);
+          App.router.get('backgroundOperationsController').requestMostRecent();
+        },
+
+        setShowMoreAvailable: function () {
+          if (this.get('parentView.isOpen')) {
+            this.set('isShowMore', App.router.get("backgroundOperationsController.isShowMoreAvailable"));
+          }
+        }.observes('parentView.isOpen', 'App.router.backgroundOperationsController.isShowMoreAvailable'),
+        isShowMore: true,
+
+        /**
          * Onclick handler for selected Service
          * @param {Object} event
          */


Mime
View raw message