ソースを参照

AMBARI-2899. NameNode HA Wizard: implement progress popup for tasks on progress pages. (Antonenko Alexander via yusaku)

Yusaku Sako 11 年 前
コミット
1d93addee9

+ 37 - 3
ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js

@@ -27,6 +27,7 @@ App.HighAvailabilityProgressPageController = Em.Controller.extend({
   currentTaskId: null,
   POLL_INTERVAL: 4000,
   isSubmitDisabled: true,
+  serviceTimestamp: null,
 
   loadStep: function () {
     this.clearStep();
@@ -48,17 +49,41 @@ App.HighAvailabilityProgressPageController = Em.Controller.extend({
         status: 'PENDING',
         id: i,
         command: commands[i],
-        showRetry: false
+        showRetry: false,        
+        name: Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.task' + i + '.title'),
+        displayName: Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.task' + i + '.title'),
+        progress: 0,
+        isRunning: false,
+        hosts: []
       }));
     }
   },
 
+  services: function(){
+    return this.get('tasks');
+  }.property('tasks'),
+
   loadTasks: function () {
     //load and set tasks statuses form server
   },
 
   setTaskStatus: function (taskId, status) {
-    this.get('tasks').findProperty('id', taskId).set('status', status)
+    this.get('tasks').findProperty('id', taskId).set('status', status);
+  },
+
+  setTaskLogs: function (taskId, tasks) {
+    var hosts = [];
+    tasks.forEach(function (task) {
+      hosts.push(
+       {
+          name: task.Tasks.host_name,
+          publicName: task.Tasks.host_name,
+          logTasks: [task]
+        }
+      );
+    });
+    this.get('tasks').findProperty('id', taskId).set('hosts', hosts);
+    this.set('serviceTimestamp', new Date().getTime());
   },
 
   showRetry: function (taskId) {
@@ -212,18 +237,27 @@ App.HighAvailabilityProgressPageController = Em.Controller.extend({
       if (!tasks.someProperty('Tasks.status', 'PENDING') && !tasks.someProperty('Tasks.status', 'QUEUED') && !tasks.someProperty('Tasks.status', 'IN_PROGRESS')) {
         if (tasks.someProperty('Tasks.status', 'FAILED')) {
           this.setTaskStatus(currentTaskId, 'FAILED');
+          this.showRetry(currentTaskId);
         } else {
           this.setTaskStatus(currentTaskId, 'COMPLETED');
         }
         this.set('currentRequestIds', []);
       } else {
-        var progress = Math.round((tasks.filterProperty('Tasks.status', 'COMPLETED').length + tasks.filterProperty('Tasks.status', 'IN_PROGRESS').length / 2) / tasks.length * 100);
+        var actionsPerHost = tasks.length;
+        var completedActions = tasks.filterProperty('Tasks.status', 'COMPLETED').length
+          + tasks.filterProperty('Tasks.status', 'FAILED').length
+          + tasks.filterProperty('Tasks.status', 'ABORTED').length
+          + tasks.filterProperty('Tasks.status', 'TIMEDOUT').length;
+        var queuedActions = tasks.filterProperty('Tasks.status', 'QUEUED').length;
+        var inProgressActions = tasks.filterProperty('Tasks.status', 'IN_PROGRESS').length;
+        var progress = Math.ceil(((queuedActions * 0.09) + (inProgressActions * 0.35) + completedActions ) / actionsPerHost * 100);
         this.get('tasks').findProperty('id', currentTaskId).set('progress', progress);
         this.setTaskStatus(currentTaskId, 'IN_PROGRESS');
         window.setTimeout(function () {
           self.doPolling()
         }, self.POLL_INTERVAL);
       }
+      this.setTaskLogs(currentTaskId, tasks);
       this.set('logs', []);
     }
   },

+ 18 - 6
ambari-web/app/styles/application.less

@@ -452,16 +452,28 @@ h1 {
       i {
         font-size: 20px;
       }
+      .not-active-link{
+        text-decoration: none;
+        pointer-events: none;
+        color: black;
+        cursor: default;
+      }
+      .active-link{
+        pointer-events: auto;
+        color: #0088cc;
+        cursor: pointer;
+      }
+      .retry {
+        cursor: pointer;
+        margin-left: 15px;
+        i {
+          font-size: 14px;
+        }
+      }
     }
     .row {
       margin-left: 0;
     }
-    .retry {
-      margin-left: 15px;
-      i {
-        font-size: 14px;
-      }
-    }
   }
 }
 

+ 1 - 1
ambari-web/app/templates/main/admin/highAvailability/progress.hbs

@@ -23,7 +23,7 @@
   {{#view view.taskView contentBinding="task"}}
   <div class="item">
     <i {{bindAttr class="view.icon view.iconColor"}}></i>
-    <a href="javascript:void(0)">{{task.title}}</a>
+    <a {{bindAttr class="view.linkClass"}} {{action "hostsLogPopup" task target="view"}} >{{task.title}}</a>
     {{#if task.showRetry}}
     <a {{action retryTask target="controller"}} class="btn btn-primary retry">
       <i class="icon-repeat icon-white"></i>

+ 16 - 1
ambari-web/app/views/main/admin/highAvailability/progress_view.js

@@ -30,6 +30,7 @@ App.HighAvailabilityProgressPageView = Em.View.extend({
   taskView: Em.View.extend({
     icon: '',
     iconColor: '',
+    linkClass: '',
 
     didInsertElement: function () {
       this.onStatus();
@@ -40,6 +41,7 @@ App.HighAvailabilityProgressPageView = Em.View.extend({
     }.property('content.progress'),
 
     onStatus: function () {
+      this.set('linkClass', 'active-link');
       if (this.get('content.status') === 'IN_PROGRESS') {
         this.set('icon', 'icon-cog');
         this.set('iconColor', 'text-info');
@@ -52,11 +54,24 @@ App.HighAvailabilityProgressPageView = Em.View.extend({
       } else {
         this.set('icon', 'icon-cog');
         this.set('iconColor', '');
+        this.set('linkClass', 'not-active-link');
       }
     }.observes('content.status'),
 
     showProgressBar: function () {
       return this.get('content.status') === "IN_PROGRESS";
-    }.property('content.status')
+    }.property('content.status'),
+
+    /**
+     * open popup with list of hosts, that associated to service
+     * @param event
+     */
+    hostsLogPopup: function(event){
+      if(event.contexts[0].linkClass != "not-active-link"){
+        var serviceName = event.contexts[0].title;
+        var controller = this.get("controller");
+        App.HostPopup.initPopup(serviceName, controller);
+      }
+    }
   })
 });