You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/02/16 19:30:07 UTC

[02/50] [abbrv] ambari git commit: AMBARI-15009. Log Search: Add link to background operations popup navigate to Host Details Logs tab with pre-set condition (alexantonenko)

AMBARI-15009. Log Search: Add link to background operations popup navigate to Host Details Logs tab with pre-set condition (alexantonenko)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: fdb101bdd78a4d6d2626008dc4a146374283e8f3
Parents: 754d0fa
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Feb 11 12:46:33 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Feb 11 18:17:50 2016 +0200

----------------------------------------------------------------------
 .../main/admin/kerberos/step7_controller.js     | 12 ++--
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/styles/application.less          | 12 ++--
 .../templates/common/host_progress_popup.hbs    |  5 ++
 ambari-web/app/utils/ajax/ajax.js               | 15 ++++
 ambari-web/app/views/application.js             | 22 ++----
 .../common/host_progress_popup_body_view.js     | 75 +++++++++++++++++++-
 .../app/views/common/log_file_search_view.js    |  2 +-
 ambari-web/app/views/common/modal_popup.js      | 27 +++++++
 .../modal_popups/log_file_search_popup.js       | 12 +++-
 .../host_progress_popup_body_view_test.js       | 54 +++++++++++++-
 11 files changed, 204 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/controllers/main/admin/kerberos/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step7_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step7_controller.js
index 71e94ca..2a4fb90 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step7_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step7_controller.js
@@ -48,13 +48,13 @@ App.KerberosWizardStep7Controller = App.KerberosProgressPageController.extend({
       }
     };
     if (isRetry) {
-      // on retry we have to unkerberize cluster
-      this.unkerberizeCluster().always(function() {
-        // clear current request object before start of kerberize process
-        self.set('request', kerberizeRequest);
-        self.clearStage();
-        self.loadStep();
+      // on retry send force update
+      self.set('request', {
+        name: 'KERBERIZE_CLUSTER',
+        ajaxName: 'admin.kerberize.cluster.force'
       });
+      self.clearStage();
+      self.loadStep();
     } else {
       this.set('request', kerberizeRequest);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 59877a5..909f55c 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -313,6 +313,7 @@ Em.I18n.translations = {
   'common.keywords': 'Keywods',
   'common.levels': 'Levels',
   'common.extension': 'Extension',
+  'common.logs': 'Logs',
 
   'models.alert_instance.tiggered.verbose': "Occurred on {0} <br> Checked on {1}",
   'models.alert_definition.triggered.verbose': "Occurred on {0}",

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 57b7e76..4e2b5d1 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -1861,13 +1861,13 @@ a:focus {
       float: right;
       a {
         cursor: pointer;
-      }
-      .task-detail-copy {
-        margin-right: 12px;
         float: left;
-      }
-      .task-detail-open-dialog {
-        float: right;
+        margin-right: 12px;
+
+        &:last-child {
+          margin-right: 0;
+          float: right;
+        }
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/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 00f2e08..fe330f7 100644
--- a/ambari-web/app/templates/common/host_progress_popup.hbs
+++ b/ambari-web/app/templates/common/host_progress_popup.hbs
@@ -195,6 +195,11 @@
         <div class="task-detail-ico-wrap">
           <a {{translateAttr title="common.fullLogPopup.clickToCopy"}} {{action "textTrigger" taskInfo target="view"}} class="task-detail-copy"><i
                   class="icon-copy"></i> {{t common.copy}}</a>
+          {{#if App.supports.logSearch}}
+            <a {{action navigateToHostLogs target="view"}} {{bindAttr class="view.isLogsLinkVisible::hidden"}} href="#">
+              <i class="icon-file"></i> {{t common.logs}}
+            </a>
+          {{/if}}
           <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i
                   class="icon-external-link"></i> {{t common.open}}</a>
         </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/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 ce6a196..f2174f3 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1477,6 +1477,21 @@ var urls = {
     }
   },
 
+  'admin.kerberize.cluster.force': {
+    'type': 'PUT',
+    'real': '/clusters/{clusterName}?force_toggle_kerberos=true',
+    'mock': '/data/wizard/kerberos/kerberize_cluster.json',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          Clusters: {
+            security_type: "KERBEROS"
+          }
+        })
+      }
+    }
+  },
+
   'admin.unkerberize.cluster.skip': {
     'type': 'PUT',
     'real': '/clusters/{clusterName}?manage_kerberos_identities=false',

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/views/application.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/application.js b/ambari-web/app/views/application.js
index 8a83144..2a8ea00 100644
--- a/ambari-web/app/views/application.js
+++ b/ambari-web/app/views/application.js
@@ -26,28 +26,16 @@ App.ApplicationView = Em.View.extend({
     // on 'Enter' pressed, trigger modal window primary button if primary button is enabled(green)
     // on 'Esc' pressed, close the modal
     $(document).keydown(function(event){
-      if (event.which == 13 || event.keyCode == 13 ) {
-        var primaryButton = $(document).find('#modal > .modal-footer > .btn-success').last();
-        if ((!$("*:focus").is("textarea")) && primaryButton.length > 0 && primaryButton.attr('disabled') != 'disabled') {
-          event.preventDefault();
-          event.stopPropagation();
-          primaryButton.click();
-          return false;
-        }
+      if (event.which === 13 || event.keyCode === 13 ) {
+        $('#modal').trigger('enter-key-pressed');
       }
       return true;
     });
     $(document).keyup(function(event){
-      if (event.which == 27 || event.keyCode == 27) {
-        var closeButton = $(document).find('#modal > .modal-header > .close').last();
-        if (closeButton.length > 0) {
-          event.preventDefault();
-          event.stopPropagation();
-          closeButton.click();
-          return false;
-        }
+      if (event.which === 27 || event.keyCode === 27) {
+        $('#modal').trigger('escape-key-pressed');
       }
       return true;
     });
   }
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/views/common/host_progress_popup_body_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/host_progress_popup_body_view.js b/ambari-web/app/views/common/host_progress_popup_body_view.js
index cdabc5e..197551f 100644
--- a/ambari-web/app/views/common/host_progress_popup_body_view.js
+++ b/ambari-web/app/views/common/host_progress_popup_body_view.js
@@ -21,6 +21,12 @@ var batchUtils = require('utils/batch_scheduled_requests');
 var date = require('utils/date/date');
 
 /**
+ * @typedef {object} TaskRelationObject
+ * @property {string} type relation type 'service', 'component'
+ * @property {string} [value] optional value of relation e.g. name of component or service
+ */
+
+/**
  * Option for "filter by state" dropdown
  * @typedef {object} progressPopupCategoryObject
  * @property {string} value "all|pending|in progress|failed|completed|aborted|timedout"
@@ -576,6 +582,73 @@ App.HostProgressPopupBodyView = App.TableView.extend({
   },
 
   /**
+   * Navigate to host details logs tab with preset filter.
+   */
+  navigateToHostLogs: function() {
+    var relationType = this._determineRoleRelation(this.get('openedTask')),
+        hostModel = App.Host.find().findProperty('id', this.get('currentHost.name')),
+        queryParams = [],
+        model;
+
+    if (relationType.type === 'component') {
+      model = App.StackServiceComponent.find().findProperty('componentName', relationType.value);
+      queryParams.push('service_name=' + model.get('serviceName'));
+      queryParams.push('component_name=' + relationType.value);
+    }
+    if (relationType.type === 'service') {
+      queryParams.push('service_name=' + relationType.value);
+    }
+    App.router.transitionTo('main.hosts.hostDetails.logs', hostModel, { query: '?' + queryParams.join('&') });
+    if (this.get('parentView') && typeof this.get('parentView').onClose === 'function') this.get('parentView').onClose();
+  },
+
+  /**
+  /**
+  * Determines if opened task related to service or component.
+  *
+  * @return {boolean} <code>true</code> when relates to service or component
+  */
+  isLogsLinkVisible: function() {
+    if (!this.get('openedTask') || !this.get('openedTask.id')) return false;
+    return !!this._determineRoleRelation(this.get('openedTask'));
+  }.property('openedTask'),
+
+  /**
+   * @param  {wrappedTask} taskInfo
+   * @return {boolean|TaskRelationObject}
+   */
+  _determineRoleRelation: function(taskInfo) {
+    var foundComponentName,
+        foundServiceName,
+        componentNames = App.StackServiceComponent.find().mapProperty('componentName'),
+        serviceNames = App.StackService.find().mapProperty('serviceName'),
+        taskLog = this.get('currentHost.logTasks').findProperty('Tasks.id', Em.get(taskInfo, 'id')) || {},
+        role = Em.getWithDefault(taskLog, 'Tasks.role', false),
+        eqlFn = function(compare) {
+          return function(item) {
+            return item === compare;
+          };
+        };
+
+    if (!role) {
+      return false;
+    }
+    // component service check
+    if (role.endsWith('_SERVICE_CHECK')) {
+      role = role.replace('_SERVICE_CHECK', '');
+    }
+    foundComponentName = componentNames.filter(eqlFn(role))[0];
+    foundServiceName = serviceNames.filter(eqlFn(role))[0];
+    if (foundComponentName || foundServiceName) {
+      return {
+        type: foundComponentName ? 'component' : 'service',
+        value: foundComponentName || foundServiceName
+      }
+    }
+    return false;
+  },
+
+  /**
    * @type {boolean}
    */
   isRequestSchedule: function () {
@@ -745,4 +818,4 @@ App.HostProgressPopupBodyView = App.TableView.extend({
     $(".task-detail-log-maintext").css("display", "block");
   }
 
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/views/common/log_file_search_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/log_file_search_view.js b/ambari-web/app/views/common/log_file_search_view.js
index c242ec8..6d402d1 100644
--- a/ambari-web/app/views/common/log_file_search_view.js
+++ b/ambari-web/app/views/common/log_file_search_view.js
@@ -128,7 +128,7 @@ App.LogFileSearchView = Em.View.extend(App.InfiniteScrollMixin, {
   /**
   * Make request and get content with applied filters.
   */
-  fetchContent: function(params) {
+  fetchContent: function() {
     console.debug('Make Request with params:', this.serializeFilters());
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index 3402e80..f016fcf 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -65,6 +65,9 @@ App.ModalPopup = Ember.View.extend({
   showCloseButton: true,
 
   didInsertElement: function () {
+    this.$().find('#modal')
+      .on('enter-key-pressed', this.enterKeyPressed.bind(this))
+      .on('escape-key-pressed', this.escapeKeyPressed.bind(this));
     if (this.autoHeight && !$.mocho) {
       var block = this.$().find('#modal > .modal-body').first();
       if(block.offset()) {
@@ -76,6 +79,30 @@ App.ModalPopup = Ember.View.extend({
     this.focusElement(firstInputElement);
   },
 
+  willDestroyElement: function() {
+    this.$().find('#modal').off('enter-key-pressed').off('escape-key-pressed');
+  },
+
+  escapeKeyPressed: function() {
+    var closeButton = this.$().find('.modal-header > .close').last();
+    if (closeButton.length > 0) {
+      event.preventDefault();
+      event.stopPropagation();
+      closeButton.click();
+      return false;
+    }
+  },
+
+  enterKeyPressed: function() {
+    var primaryButton = this.$().find('.modal-footer > .btn-success').last();
+    if ((!$("*:focus").is("textarea")) && primaryButton.length > 0 && primaryButton.attr('disabled') !== 'disabled') {
+      event.preventDefault();
+      event.stopPropagation();
+      primaryButton.click();
+      return false;
+    }
+  },
+
   /**
    * If popup is opened from another popup it should be displayed above
    * @method fitZIndex

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/app/views/common/modal_popups/log_file_search_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/log_file_search_popup.js b/ambari-web/app/views/common/modal_popups/log_file_search_popup.js
index 4730a19..4e2032b 100644
--- a/ambari-web/app/views/common/modal_popups/log_file_search_popup.js
+++ b/ambari-web/app/views/common/modal_popups/log_file_search_popup.js
@@ -21,6 +21,16 @@ var App = require('app');
 App.LogFileSearchPopup = function(header) {
   return App.ModalPopup.show({
     classNames: ['modal-full-width', 'sixty-percent-width-modal', 'log-file-search-popup'],
-    bodyClass: App.LogFileSearchView.extend({})
+    header: header,
+    bodyView: null,
+    bodyClass: App.LogFileSearchView.extend({
+      didInsertElement: function() {
+        this.set('parentView.bodyView', this);
+        this._super();
+      }
+    }),
+    enterKeyPressed: function() {
+      this.get('bodyView').fetchContent();
+    }
   });
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/fdb101bd/ambari-web/test/views/common/host_progress_popup_body_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/host_progress_popup_body_view_test.js b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
index 8642d9b..a14cb26 100644
--- a/ambari-web/test/views/common/host_progress_popup_body_view_test.js
+++ b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
@@ -55,4 +55,56 @@ describe('App.HostProgressPopupBodyView', function () {
 
   });
 
-});
\ No newline at end of file
+  describe('_determineRoleRelation', function() {
+    var cases;
+
+    beforeEach(function() {
+      sinon.stub(App.StackServiceComponent, 'find').returns([{componentName: 'DATANODE'}])
+      sinon.stub(App.StackService, 'find').returns([{serviceName: 'HDFS'}])
+    });
+
+    afterEach(function() {
+      App.StackServiceComponent.find.restore();
+      App.StackService.find.restore();
+    });
+
+    cases = [
+      {
+        task: { role: 'HDFS_SERVICE_CHECK'},
+        m: 'Role is HDFS_SERVICE_CHECK',
+        e: {
+          type: 'service',
+          value: 'HDFS'
+        }
+      },
+      {
+        task: { role: 'DATANODE'},
+        m: 'Role is DATANODE',
+        e: {
+          type: 'component',
+          value: 'DATANODE'
+        }
+      },
+      {
+        task: { role: 'UNDEFINED'},
+        m: 'Role is UNDEFINED',
+        e: false
+      }
+    ];
+
+    cases.forEach(function(test) {
+      it(test.m, function() {
+        view.reopen({
+          currentHost: Em.Object.create({
+            logTasks: [
+              { Tasks: { id: 1, role: test.task.role }}
+            ]
+          })
+        });
+
+        var ret = view._determineRoleRelation(Em.Object.create({ id: 1 }));
+        expect(ret).to.be.eql(test.e);
+      });
+    });
+  });
+});