소스 검색

AMBARI-13914. Hard to see/print configuration changes that will be performed as part of an Upgrade (akovalenko)

Aleksandr Kovalenko 9 년 전
부모
커밋
bc4e41d308

+ 32 - 0
ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js

@@ -1486,5 +1486,37 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       self.initDBProperties();
       self.loadUpgradeData(true);
     });
+  },
+
+  /**
+   * Build table from configs list and open new window to show this table
+   * @param configs
+   */
+  openConfigsInNewWindow: function (configs) {
+    var newWindow;
+    var output = '';
+
+    output += '<table style="text-align: left;"><thead><tr>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' +
+        '</tr></thead><tbody>';
+
+    configs.context.forEach(function (config) {
+      output += '<tr>' +
+          '<td>' + config.type + '</td>' +
+          '<td>' + config.name + '</td>' +
+          '<td>' + config.currentValue + '</td>' +
+          '<td>' + config.recommendedValue + '</td>' +
+          '<td>' + config.resultingValue + '</td>' +
+          '</tr>';
+    });
+
+    output += '</tbody></table>';
+    newWindow = window.open();
+    newWindow.document.write(output);
+    newWindow.focus();
   }
 });

+ 1 - 0
ambari-web/app/messages.js

@@ -290,6 +290,7 @@ Em.I18n.translations = {
   'common.timeout.warning.popup.body.after': ' seconds due to inactivity',
   'common.timeout.warning.popup.primary': 'Remain Logged In',
   'common.timeout.warning.popup.secondary': 'Log Out Now',
+  'common.openNewWindow': 'Open in New Window',
 
   'models.alert_instance.tiggered.verbose': "Occurred on {0} <br> Checked on {1}",
   'models.alert_definition.triggered.verbose': "Occurred on {0}",

+ 10 - 1
ambari-web/app/styles/application.less

@@ -6019,7 +6019,7 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox {
       }
       .configs-table {
         table-layout: fixed;
-        font-size: 0.95em;
+        font-size: 0.9em;
         td {
           word-wrap: break-word;
           &.no-value {
@@ -6033,6 +6033,15 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox {
           width: 25%;
         }
       }
+      .configs-table-header {
+        padding-right: 15px;
+      }
+      .configurations-changes-header {
+        display: inline-block;
+      }
+      .open-in-new-window {
+        margin-top: 10px;
+      }
     }
   }
 }

+ 1 - 1
ambari-web/app/templates/common/host_progress_popup.hbs

@@ -195,7 +195,7 @@
         <div class="task-detail-ico-wrap">
           <a title="Click to Copy" {{action "textTrigger" taskInfo target="view"}} class="task-detail-copy"><i
                   class="icon-copy"></i> {{t common.copy}}</a>
-          <a title="Open in New Window" {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i
+          <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i
                   class="icon-external-link"></i> {{t common.open}}</a>
         </div>
         <span class="task-detail-log-rolename">{{view.openedTask.commandDetail}}</span>

+ 9 - 2
ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs

@@ -16,11 +16,14 @@
 * limitations under the License.
 }}
 
-<h4>{{t popup.clusterCheck.Upgrade.configsMerge.title}}</h4>
+<h4 class="configurations-changes-header">{{t popup.clusterCheck.Upgrade.configsMerge.title}}</h4>
+<a {{action openConfigsInNewWindow view.configs target="App.router.mainAdminStackAndUpgradeController"}} {{translateAttr title="common.openNewWindow"}} class="pull-right open-in-new-window" href="#">
+  <i class="icon-external-link"></i> <span id="i18n-34">{{t common.open}}</span>
+</a>
 <div class="alert alert-warning">
   {{t popup.clusterCheck.Upgrade.configsMerge.alert}}
 </div>
-<div class="limited-height-2">
+<div class="configs-table-header">
   <table class="configs-table table table-striped">
     <thead>
     <tr>
@@ -31,6 +34,10 @@
       <th>{{t popup.clusterCheck.Upgrade.configsMerge.resultingValue}}</th>
     </tr>
     </thead>
+  </table>
+</div>
+<div class="limited-height-2">
+  <table class="configs-table table table-striped">
     <tbody>
     {{#each view.configs}}
       <tr>

+ 2 - 2
ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs

@@ -37,7 +37,7 @@
               <a title="Click to Copy" {{action copyOutLog view.content target="view"}} class="task-detail-copy">
                 <i class="icon-copy"></i> {{t common.copy}}
               </a>
-              <a title="Open in New Window" {{action openOutLog target="view"}} class="task-detail-open-dialog">
+              <a {{translateAttr title="common.openNewWindow"}} {{action openOutLog target="view"}} class="task-detail-open-dialog">
                 <i class="icon-external-link"></i> {{t common.open}}
               </a>
             </div>
@@ -53,7 +53,7 @@
               <a title="Click to Copy" {{action copyErrLog view.content target="view"}} class="task-detail-copy">
                 <i class="icon-copy"></i> {{t common.copy}}
               </a>
-              <a title="Open in New Window" {{action openErrorLog target="view"}} class="task-detail-open-dialog">
+              <a {{translateAttr title="common.openNewWindow"}} {{action openErrorLog target="view"}} class="task-detail-open-dialog">
                 <i class="icon-external-link"></i> {{t common.open}}
               </a>
             </div>

+ 1 - 1
ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs

@@ -66,7 +66,7 @@
           <i {{bindAttr class="view.openedTask.status :task-detail-status-ico view.openedTask.icon"}}></i>
           <div class="task-detail-ico-wrap">
             <a title="Click to Copy" {{action "textTrigger" taskInfo target="view"}} class="task-detail-copy"><i class="icon-copy"></i> {{t common.copy}}</a>
-            <a title="Open in New Window" {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i class="icon-external-link"></i> {{t common.open}}</a>
+            <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i class="icon-external-link"></i> {{t common.open}}</a>
           </div>
           <span class="task-detail-log-rolename">
             {{view.openedTask.commandDetail}}

+ 9 - 1
ambari-web/app/views/common/modal_popups/cluster_check_popup.js

@@ -68,6 +68,10 @@ App.showClusterCheckPopup = function (data, header, failTitle, failAlert, warnin
         callback();
       }
       this._super();
+    },
+    didInsertElement: function () {
+      this._super();
+      this.fitHeight();
     }
   });
 };
@@ -124,6 +128,10 @@ App.showPreUpgradeCheckPopup = function (data, header, failTitle, failAlert, war
       if (callback) {
         callback();
       }
+    },
+    didInsertElement: function () {
+      this._super();
+      this.fitHeight();
     }
   });
-};
+};

+ 73 - 4
ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js

@@ -1034,23 +1034,23 @@ describe('App.MainAdminStackAndUpgradeController', function() {
         "stackVersion": '2.3',
         "repositoryVersion": '2.2.1'
       });
-      
+
       var stackVersion = controller.getStackVersionNumber(repo);
       expect(stackVersion).to.equal('2.3');
     });
-    
+
     it("get default stack version number", function(){
       App.set('currentStackVersion', '1.2.3');
       var repo = Em.Object.create({
         "stackVersionType": 'HDP',
         "repositoryVersion": '2.2.1'
       });
-      
+
       var stackVersion = controller.getStackVersionNumber(repo);
       expect(stackVersion).to.equal('1.2.3');
     });
   });
-  
+
   describe("#saveRepoOS()", function() {
     before(function(){
       this.mock = sinon.stub(controller, 'validateRepoVersions');
@@ -1644,4 +1644,73 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
+
+  describe("#openConfigsInNewWindow()", function () {
+
+    var mock = {
+      document: {
+        write: function () {}
+      },
+      focus: function () {}
+    };
+
+    before(function(){
+      sinon.stub(window, 'open', function () {
+        return mock;
+      });
+      sinon.spy(mock.document, 'write');
+      sinon.spy(mock, 'focus');
+    });
+
+    after(function(){
+      window.open.restore();
+    });
+
+    it("should open window and write table to it", function () {
+
+      controller.openConfigsInNewWindow({
+        context: [
+          {
+            type: 'type1',
+            name: 'name1',
+            currentValue: 'currentValue1',
+            recommendedValue: 'recommendedValue1',
+            resultingValue: 'resultingValue1'
+          },
+          {
+            type: 'type2',
+            name: 'name2',
+            currentValue: 'currentValue2',
+            recommendedValue: 'recommendedValue2',
+            resultingValue: 'resultingValue2'
+          }
+        ]
+      });
+
+      expect(window.open.calledOnce).to.be.true;
+      expect(mock.document.write.calledWith('<table style="text-align: left;"><thead><tr>' +
+          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' +
+          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' +
+          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' +
+          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' +
+          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' +
+          '</tr></thead><tbody>' +
+          '<tr>' +
+          '<td>' + 'type1' + '</td>' +
+          '<td>' + 'name1' + '</td>' +
+          '<td>' + 'currentValue1' + '</td>' +
+          '<td>' + 'recommendedValue1' + '</td>' +
+          '<td>' + 'resultingValue1' + '</td>' +
+          '</tr>' +
+          '<tr>' +
+          '<td>' + 'type2' + '</td>' +
+          '<td>' + 'name2' + '</td>' +
+          '<td>' + 'currentValue2' + '</td>' +
+          '<td>' + 'recommendedValue2' + '</td>' +
+          '<td>' + 'resultingValue2' + '</td>' +
+          '</tr></tbody></table>')).to.be.true;
+      expect(mock.focus.calledOnce).to.be.true;
+    });
+  });
+
 });