AMBARI-18783. Incorrect behaviour of Copy/Open controls for task details (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e719ea44 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e719ea44 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e719ea44 Branch: refs/heads/branch-feature-AMBARI-18634 Commit: e719ea44d190cba118934e8f993cff8a8b8119cb Parents: 753b8d5 Author: Oleg Nechiporenko <[email protected]> Authored: Thu Nov 3 14:38:15 2016 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Nov 3 15:43:10 2016 +0200 ---------------------------------------------------------------------- ambari-web/app/styles/application.less | 8 +- ambari-web/app/styles/log_file_search.less | 4 +- ambari-web/app/styles/modal_popups.less | 1 + .../templates/common/host_progress_popup.hbs | 10 ++- .../app/templates/common/log_file_search.hbs | 2 +- .../common/modal_popups/log_tail_popup.hbs | 12 +-- .../common/modal_popups/logs_popup.hbs | 2 +- .../upgrade_configs_merge_table.hbs | 2 +- .../main/admin/stack_upgrade/upgrade_task.hbs | 4 +- .../main/admin/stack_upgrade/versions.hbs | 2 +- ambari-web/app/templates/main/host/logs.hbs | 2 +- .../wizard/step9/step9HostTasksLogPopup.hbs | 8 +- ambari-web/app/views.js | 1 + .../common/host_progress_popup_body_view.js | 88 ++++++++++---------- .../views/common/modal_popups/log_tail_popup.js | 6 +- .../app/views/common/not-scrollable-textarea.js | 44 ++++++++++ .../views/wizard/step9/hostLogPopupBody_view.js | 42 ++++++---- .../host_progress_popup_body_view_test.js | 2 +- 18 files changed, 153 insertions(+), 87 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index d013173..64b5797 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -2004,15 +2004,19 @@ a:focus { .task-detail-info { .task-detail-log-info { - max-height: 340px; + max-height: 500px; overflow: auto; width: 100%; } .task-detail-log-clipboard { - display: none; + width: 100%; resize: none; overflow: hidden; box-sizing: border-box; + line-height: 14px; + font-size: 11px; + font-family: monospace; + word-break: normal; } .task-top-wrap { http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/styles/log_file_search.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/log_file_search.less b/ambari-web/app/styles/log_file_search.less index 0cbd52c..cf5ef29 100644 --- a/ambari-web/app/styles/log_file_search.less +++ b/ambari-web/app/styles/log_file_search.less @@ -98,7 +98,7 @@ padding-bottom: 400px; text-align: center; - .glyphicon-external-link, + .icon-external-link, .move-to-top, .move-to-bottom { display: block; @@ -113,7 +113,7 @@ line-height: 18px; } - .glyphicon-external-link { + .icon-external-link { margin-top: 5px; font-size: 20px; padding-left: 4px; http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/styles/modal_popups.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/modal_popups.less b/ambari-web/app/styles/modal_popups.less index 5f6a3bc..4c2ba8c 100644 --- a/ambari-web/app/styles/modal_popups.less +++ b/ambari-web/app/styles/modal_popups.less @@ -317,6 +317,7 @@ .task-detail-nav { padding-top: 10px; + padding-bottom: 20px; } .log-tail-content { http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/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 4fb5432..61a6a9d 100644 --- a/ambari-web/app/templates/common/host_progress_popup.hbs +++ b/ambari-web/app/templates/common/host_progress_popup.hbs @@ -203,7 +203,7 @@ <a {{translateAttr title="common.fullLogPopup.clickToCopy"}} {{action "textTrigger" taskInfo target="view"}} class="task-detail-copy"><i class="glyphicon glyphicon-copy"></i> {{t common.copy}}</a> <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i - class="glyphicon glyphicon-external-link"></i> {{t common.open}}</a> + class="glyphicon icon-external-link"></i> {{t common.open}}</a> {{#if App.supports.logSearch}} {{#if view.isLogSearchInstalled}} <a {{action navigateToHostLogs target="view"}} {{bindAttr class="view.isLogsLinkVisible::hidden"}} href="#"> @@ -229,7 +229,11 @@ <div class="task-detail-log-info"> <div class="content-area"> <div class="tab-content"> - <div class="task-detail-log-clipboard-wrap"></div> + <div class="task-detail-log-clipboard-wrap"> + {{#if view.isClipBoardActive}} + {{view App.NotScrollableTextArea class="task-detail-log-clipboard" valueBinding="view.textAreaValue"}} + {{/if}} + </div> <div id="task-log-tab" class="tab-pane active"> <div {{bindAttr class=":task-detail-log-maintext view.isClipBoardActive:hidden"}}> {{#if view.openedTask.isRebalanceHDFSTask }} @@ -265,7 +269,7 @@ <span class="text-bold muted">{{hostLog.fileName}}</span> {{#view App.LogSearchUILinkView linkQueryParamsBinding="hostLog.linkTail" tagName="span"}} <a {{bindAttr href="view.formatedLink" class=":pull-right view.isLodaded::disabled"}} target="_blank"> - <i class="glyphicon glyphicon-external-link"></i> + <i class="icon-external-link"></i> {{t popup.logTail.openInLogSearch}}</a> {{/view}} </p> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/common/log_file_search.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/log_file_search.hbs b/ambari-web/app/templates/common/log_file_search.hbs index 4242e42..008c37a 100644 --- a/ambari-web/app/templates/common/log_file_search.hbs +++ b/ambari-web/app/templates/common/log_file_search.hbs @@ -78,7 +78,7 @@ <div class="context-menu pull-left"> <a href="#" {{action moveTableTop target="view"}} class="move-to-top glyphicon glyphicon-caret-up"></a> <a href="#" {{action moveTableBottom target="view"}} class="move-to-bottom glyphicon glyphicon-caret-down"></a> - <a href="#" {{action navigateToLogUI target="view"}} class="glyphicon glyphicon-external-link"></a> + <a href="#" {{action navigateToLogUI target="view"}} class="icon-external-link"></a> </div> <div class="clearfix"></div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/common/modal_popups/log_tail_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/log_tail_popup.hbs b/ambari-web/app/templates/common/modal_popups/log_tail_popup.hbs index 4014aac..48e5b9d 100644 --- a/ambari-web/app/templates/common/modal_popups/log_tail_popup.hbs +++ b/ambari-web/app/templates/common/modal_popups/log_tail_popup.hbs @@ -26,21 +26,21 @@ {{t common.copy}} </a> <a href="#" {{action openInNewTab target="view"}}> - <i class="glyphicon glyphicon-external-link"></i> + <i class="icon-external-link"></i> {{t common.open}} </a> <a class="open-in-log-search" {{bindAttr href="view.logSearchUrl"}} target="_blank"> - <i class="glyphicon glyphicon-external-link"></i> + <i class="icon-external-link"></i> {{t popup.logTail.openInLogSearch}} </a> </div> </div> <div class="clearfix"></div> </div> -<div class="modal-content"> - <div {{bindAttr class="view.isCopyActive::hidden"}}> - <div class="clipboard-wrap"> - {{view Em.TextArea valueBinding="view.copyContent" classNames="copy-textarea"}} +<div> + <div {{bindAttr class=":task-detail-info view.isCopyActive::hidden"}}> + <div class="clipboard-wrap task-detail-log-info"> + {{view App.NotScrollableTextArea class="task-detail-log-clipboard copy-textarea" valueBinding="view.copyContent"}} </div> </div> <div {{bindAttr class="view.isCopyActive:hidden"}}> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/common/modal_popups/logs_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/logs_popup.hbs b/ambari-web/app/templates/common/modal_popups/logs_popup.hbs index bb62e35..a82096e 100644 --- a/ambari-web/app/templates/common/modal_popups/logs_popup.hbs +++ b/ambari-web/app/templates/common/modal_popups/logs_popup.hbs @@ -21,7 +21,7 @@ <a {{translateAttr title="common.fullLogPopup.clickToCopy"}} {{action "textTrigger" taskInfo target="view"}} class="task-detail-copy"><i class="glyphicon glyphicon-copy"></i> {{t common.copy}}</a> <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i - class="glyphicon glyphicon-external-link"></i> {{t common.open}}</a> + class="icon-external-link"></i> {{t common.open}}</a> </div> <div class="clearfix"></div> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs index 5c285f8..b78ba5a 100644 --- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs +++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_configs_merge_table.hbs @@ -18,7 +18,7 @@ <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="glyphicon glyphicon-external-link"></i> <span id="i18n-34">{{t common.open}}</span> + <i class="icon-external-link"></i> <span>{{t common.open}}</span> </a> <div class="alert alert-warning"> {{t popup.clusterCheck.Upgrade.configsMerge.alert}} http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs index 4c26231..488fe39 100644 --- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs +++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs @@ -38,7 +38,7 @@ <p class="pull-left col-sm-6">{{view.content.output_log}}</p> <div class="manage-controls pull-right col-sm-6"> <a {{translateAttr title="common.openNewWindow"}} {{action openOutLog target="view"}} class="task-detail-open-dialog pull-right"> - <i class="glyphicon glyphicon-external-link"></i> {{t common.open}} + <i class="icon-external-link"></i> {{t common.open}} </a> <a title="Click to Copy" {{action copyOutLog view.content target="view"}} class="task-detail-copy pull-right"> <i class="glyphicon glyphicon-copy"></i> {{t common.copy}} @@ -54,7 +54,7 @@ <p class="pull-left col-sm-6">{{view.content.error_log}}</p> <div class="manage-controls pull-right"> <a {{translateAttr title="common.openNewWindow"}} {{action openErrorLog target="view"}} class="task-detail-open-dialog pull-right"> - <i class="glyphicon glyphicon-external-link"></i> {{t common.open}} + <i class="icon-external-link"></i> {{t common.open}} </a> <a title="Click to Copy" {{action copyErrLog view.content target="view"}} class="task-detail-copy pull-right"> <i class="glyphicon glyphicon-copy"></i> {{t common.copy}} http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs index be88f66..6e45868 100644 --- a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs +++ b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs @@ -19,7 +19,7 @@ <div id="versions-filter-section" class="btn-toolbar"> {{#isAuthorized "AMBARI.MANAGE_STACK_VERSIONS"}} <button class="btn btn-primary" {{action goToVersions target="view"}} id="manage-versions-link"> - <i class="glyphicon glyphicon-external-link"></i> {{t admin.stackVersions.manageVersions}} + <i class="icon-external-link"></i> {{t admin.stackVersions.manageVersions}} </button> {{/isAuthorized}} <div class="btn-group display-inline-block"> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/main/host/logs.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/logs.hbs b/ambari-web/app/templates/main/host/logs.hbs index 6153676..a0b831c 100644 --- a/ambari-web/app/templates/main/host/logs.hbs +++ b/ambari-web/app/templates/main/host/logs.hbs @@ -44,7 +44,7 @@ <a {{action openLogFile row file.filePath target="view.parentView"}} href="#" rel="log-file-name-tooltip" {{bindAttr data-original-title="file.filePath"}}>{{file.fileName}}</a> {{#view App.LogSearchUILinkView linkQueryParamsBinding="file.linkTail" tagName="span"}} <a {{bindAttr href="view.formatedLink"}} target="_blank" rel="log-file-name-tooltip" {{translateAttr title="popup.logTail.openInLogSearch"}} class="pull-right external-link"> - <i class="glyphicon glyphicon-external-link"></i> + <i class="icon-external-link"></i> {{t popup.logTail.openInLogSearch}} </a> {{/view}} http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs b/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs index 6434d97..7e95724 100644 --- a/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs +++ b/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="glyphicon glyphicon-copy"></i> {{t common.copy}}</a> - <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i class="glyphicon glyphicon-external-link"></i> {{t common.open}}</a> + <a {{translateAttr title="common.openNewWindow"}} {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i class="glyphicon icon-external-link"></i> {{t common.open}}</a> </div> <span class="task-detail-log-rolename"> {{view.openedTask.commandDetail}} @@ -77,7 +77,11 @@ {{#if view.isTaskLoaded}} <div class="task-detail-log-info"> <div class="content-area"> - <div class="task-detail-log-clipboard-wrap"></div> + <div class="task-detail-log-clipboard-wrap"> + {{#if view.showClipBoard}} + {{view App.NotScrollableTextArea class="task-detail-log-clipboard" valueBinding="view.formattedLogsForOpenedTask"}} + {{/if}} + </div> <div class="task-detail-log-maintext"> <h5>stderr: <span class="muted">{{view.openedTask.errorLog}} </span></h5> <pre class="stderr">{{view.openedTask.stderr}}</pre> http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index d9a9d6b..d713db1 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -47,6 +47,7 @@ require('views/common/modal_popups/log_tail_popup'); require('views/common/modal_popups/config_validation/config_validation_failed_popup'); require('views/common/modal_popups/config_validation/config_validation_popup'); require('views/common/editable_list'); +require('views/common/not-scrollable-textarea'); require('views/common/host_progress_popup_body_view'); require('views/common/radio_button_view'); require('views/common/rolling_restart_view'); http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/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 375225c..f119c3b 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 @@ -18,7 +18,6 @@ var App = require('app'); var batchUtils = require('utils/batch_scheduled_requests'); -var date = require('utils/date/date'); var fileUtils = require('utils/file_utils'); /** @@ -92,6 +91,9 @@ App.HostProgressPopupBodyView = App.TableView.extend({ */ clipBoardContent: null, + /** + * @type {boolean} + */ isClipBoardActive: false, /** @@ -138,6 +140,17 @@ App.HostProgressPopupBodyView = App.TableView.extend({ }.property('tasks', '[email protected]', '[email protected]', 'openedTaskId'), /** + * stderr and stdout joined together for clipboard + * + * @type {string} + */ + formattedLogsForOpenedTask: function () { + var stderr = this.get('openedTask.stderr'); + var stdout = this.get('openedTask.stdout'); + return 'stderr: \n' + stderr + '\n stdout:\n' + stdout; + }.property('openedTask.stderr', 'openedTask.stdout'), + + /** * @type {object} */ filterMap: { @@ -224,9 +237,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ /** * @type {wrappedHost} */ - currentHost: function () { - return this.get('hosts') && this.get('hosts').findProperty('name', this.get('controller.currentHostName')); - }.property('controller.currentHostName'), + currentHost: Em.computed.findByKey('hosts', 'name', 'controller.currentHostName'), /** * Tasks for current shown host (<code>currentHost</code>) @@ -246,7 +257,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ * @type {string} */ requestScheduleAbortLabel: function () { - return 'ROLLING-RESTART' == this.get('sourceRequestScheduleCommand') ? + return 'ROLLING-RESTART' === this.get('sourceRequestScheduleCommand') ? Em.I18n.t("hostPopup.bgop.abort.rollingRestart"): Em.I18n.t("common.abort"); }.property('sourceRequestScheduleCommand'), @@ -257,7 +268,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ }, willDestroyElement: function () { - if (this.get('controller.dataSourceController.name') == 'highAvailabilityProgressPopupController') { + if (this.get('controller.dataSourceController.name') === 'highAvailabilityProgressPopupController') { this.set('controller.dataSourceController.isTaskPolling', false); } this.unsubscribeResize(); @@ -338,9 +349,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ } }, - currentLevelName: function() { - return this.get('controller.dataSourceController.levelInfo.name'); - }.property('controller.dataSourceController.levelInfo.name'), + currentLevelName: Em.computed.alias('controller.dataSourceController.levelInfo.name'), /** * Preset values on init @@ -472,14 +481,14 @@ App.HostProgressPopupBodyView = App.TableView.extend({ setVisibility: function (filter, obj) { var isEmptyList = true; var filterMap = this.get('filterMap'); - if (filter == "all") { + if (filter === "all") { obj.setEach("isVisible", true); isEmptyList = !obj.length; } else { obj.forEach(function (item) { item.set('isVisible', filterMap[filter].contains(item.status)); - isEmptyList = (isEmptyList) ? !item.get('isVisible') : false; + isEmptyList = isEmptyList ? !item.get('isVisible') : false; }, this) } return isEmptyList; @@ -509,7 +518,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ } this.set('isPaginate', !!isPaginate); - }.observes('[email protected]', '[email protected]', 'parentView.isTaskListHidden', 'parentView.isHostListHidden', 'services.length', '[email protected]'), + }.observes('[email protected]', '[email protected]', 'parentView.isTaskListHidden', 'parentView.isHostListHidden', '[email protected]'), /** * control data uploading, depending on which display level is showed @@ -655,7 +664,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ requestMoreOperations: function () { var BGOController = App.router.get('backgroundOperationsController'); var count = BGOController.get('operationsCount'); - BGOController.set('operationsCount', (count + 10)); + BGOController.set('operationsCount', count + 10); BGOController.requestMostRecent(); }, @@ -724,7 +733,6 @@ App.HostProgressPopupBodyView = App.TableView.extend({ }, /** - /** * Determines if opened task related to service or component. * * @return {boolean} <code>true</code> when relates to service or component @@ -907,7 +915,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ activeHostLog = this.get('hostComponentLogs').findProperty('isActive', true), activeHostLogSelector = activeHostLog ? activeHostLog.get('tabClassNameSelector') + '.active' : false; - if ($(".task-detail-log-clipboard").length) { + if (this.get('isClipBoardActive')) { this.destroyClipBoard(); } if (activeHostLog && $(activeHostLogSelector).length) { @@ -915,7 +923,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ } var newWindow = window.open(); var newDocument = newWindow.document; - newDocument.write($(target).html()); + newDocument.write('<pre>' + this.get('textAreaValue') + '</pre>'); newDocument.close(); }, @@ -928,7 +936,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ toggleTaskLog: function (event) { var taskInfo = event.context; this.set("parentView.isLogWrapHidden", false); - if ($(".task-detail-log-clipboard").length) { + if (this.get('isClipBoardActive')) { this.destroyClipBoard(); } this.set("parentView.isHostListHidden", true); @@ -945,27 +953,22 @@ App.HostProgressPopupBodyView = App.TableView.extend({ * @method textTrigger */ textTrigger: function () { - $(".task-detail-log-clipboard").length ? this.destroyClipBoard() : this.createClipBoard(); + return this.get('isClipBoardActive') ? this.destroyClipBoard() : this.createClipBoard(); }, /** + * @type {string} + */ + textAreaValue: function () { + return this.get('isLogComponentActive') ? this.get('clipBoardContent') : this.get('formattedLogsForOpenedTask'); + }.property('clipBoardContent', 'formattedLogsForOpenedTask', 'isLogComponentActive'), + + /** * Create Clip Board * * @method createClipBoard */ createClipBoard: function () { - var isLogComponentActive = this.get('hostComponentLogs').someProperty('isActive', true), - logElement = isLogComponentActive ? $('.log-component-tab.active .log-tail-content'): $(".task-detail-log-maintext"), - logElementRect = logElement[0].getBoundingClientRect(), - clipBoardContent = this.get('clipBoardContent'); - $(".task-detail-log-clipboard-wrap").html('<textarea class="task-detail-log-clipboard"></textarea>'); - $(".task-detail-log-clipboard") - .html(isLogComponentActive ? this.get('clipBoardContent') : "stderr: \n" + $(".stderr").html() + "\n stdout:\n" + $(".stdout").html()) - .css('display', 'block') - .css('width', logElementRect.width) - .height(isLogComponentActive ? logElement[0].scrollHeight : logElementRect.height) - .select(); - this.set('isClipBoardActive', true); }, @@ -975,13 +978,14 @@ App.HostProgressPopupBodyView = App.TableView.extend({ * @method destroyClipBoard */ destroyClipBoard: function () { - var logElement = this.get('hostComponentLogs').someProperty('isActive', true) ? $('.log-component-tab.active .log-tail-content'): $(".task-detail-log-maintext"); - - $(".task-detail-log-clipboard").remove(); - logElement.css("display", "block"); + var logElement = this.get('isLogComponentActive') ? $('.log-component-tab.active .log-tail-content'): $(".task-detail-log-maintext"); + logElement.css('display', 'block'); this.set('isClipBoardActive', false); }, + /** + * @type {boolean} + */ isLogSearchInstalled: function() { return App.Service.find().someProperty('serviceName', 'LOGSEARCH'); }.property(), @@ -995,9 +999,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ var relationType, componentName, hostName, - logFile, - linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}', - self = this; + linkTailTpl = '?host_name={0}&file_name={1}&component_name={2}'; if (this.get('openedTask.id')) { relationType = this._determineRoleRelation(this.get('openedTask')); @@ -1008,8 +1010,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ .filterProperty('hostComponent.host.hostName', hostName) .filterProperty('hostComponent.componentName', componentName) .reduce(function(acc, item, index) { - var serviceName = item.get('hostComponent.service.serviceName'), - logComponentName = item.get('name'), + var logComponentName = item.get('name'), componentHostName = item.get('hostComponent.host.hostName'); acc.pushObjects(item.get('logFileNames').map(function(logFileName, idx) { var tabClassName = logComponentName + '_' + index + '_' + idx; @@ -1032,13 +1033,16 @@ App.HostProgressPopupBodyView = App.TableView.extend({ }.property('openedTaskId', 'isLevelLoaded'), /** + * @type {boolean} + */ + isLogComponentActive: Em.computed.someBy('hostComponentLogs', 'isActive', true), + + /** * Determines if there are component logs for selected component within 'TASK_DETAILS' level. * * @property {boolean} */ - hostComponentLogsExists: function() { - return this.get('isLogSearchInstalled') && !!this.get('hostComponentLogs.length') && this.get('parentView.isOpen'); - }.property('hostComponentLogs.length', 'isLogSearchInstalled', 'parentView.isOpen'), + hostComponentLogsExists: Em.computed.and('isLogSearchInstalled', 'hostComponentLogs.length', 'parentView.isOpen'), /** * Minimum required content to embed in App.LogTailView. This property observes current active host component log. http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/views/common/modal_popups/log_tail_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/log_tail_popup.js b/ambari-web/app/views/common/modal_popups/log_tail_popup.js index 28609e8..1e6924f 100644 --- a/ambari-web/app/views/common/modal_popups/log_tail_popup.js +++ b/ambari-web/app/views/common/modal_popups/log_tail_popup.js @@ -18,7 +18,6 @@ var App = require('app'); -var dateUtils = require('utils/date/date'); var fileUtils = require('utils/file_utils'); App.showLogTailPopup = function(content) { @@ -54,7 +53,7 @@ App.showLogTailPopup = function(content) { openInNewTab: function() { var newWindow = window.open(); var newDocument = newWindow.document; - newDocument.write($('.log-tail-content.pre-styled').html()); + newDocument.write('<pre>' + this.logsToString() + '</pre>'); newDocument.close(); }, @@ -101,8 +100,7 @@ App.showLogTailPopup = function(content) { this._super(); var newSize = $(window).height() - this.get('resizeDelta') - window.innerHeight*0.08; this.get('parentView').$().find('.copy-textarea').css({ - height: newSize + 'px', - width: '100%' + height: newSize + 'px' }); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/views/common/not-scrollable-textarea.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/not-scrollable-textarea.js b/ambari-web/app/views/common/not-scrollable-textarea.js new file mode 100644 index 0000000..1898714 --- /dev/null +++ b/ambari-web/app/views/common/not-scrollable-textarea.js @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +/** + * Same as Em.TextArea + * Update self height (to avoid scrolling) when value is changed + * + * @type {Em.View} + */ +App.NotScrollableTextArea = Em.TextArea.extend({ + + didInsertElement() { + this.fitHeight(); + this.$().select(); + }, + + fitHeight: function () { + var self = this.$(); + if (self) { + Em.run.next(function () { + self.height(1); + self.height(self[0].scrollHeight); + }); + } + }.observes('value') + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js b/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js index 6374ef6..ae683e0 100644 --- a/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js +++ b/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js @@ -192,10 +192,10 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({ * @method openTaskLogInDialog */ openTaskLogInDialog: function () { - var newwindow = window.open(); - var newdocument = newwindow.document; - newdocument.write($(".task-detail-log-info").html()); - newdocument.close(); + var newWindow = window.open(); + var newDocument = newWindow.document; + newDocument.write('<pre>' + this.get('formattedLogsForOpenedTask') + '<pre>'); + newDocument.close(); }, /** @@ -204,7 +204,16 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({ */ openedTask: function () { return this.get('tasks').findProperty('id', this.get('parentView.c.currentOpenTaskId')) - }.property('parentView.c.currentOpenTaskId', 'tasks.@each'), + }.property('parentView.c.currentOpenTaskId', 'tasks.[]'), + + /** + * @type {string} + */ + formattedLogsForOpenedTask: function () { + var stderr = this.get('openedTask.stderr'); + var stdout = this.get('openedTask.stdout'); + return 'stderr: \n' + stderr + '\n stdout:\n' + stdout; + }.property('openedTask.stderr', 'openedTask.stdout'), /** * Click-handler for toggle task's log view (textarea to box and back) @@ -234,7 +243,7 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({ * @method textTrigger */ textTrigger: function () { - if ($(".task-detail-log-clipboard").length > 0) { + if (this.get('showClipBoard')) { this.destroyClipBoard(); } else { @@ -243,20 +252,17 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({ }, /** + * @type {boolean} + */ + showClipBoard: false, + + /** * Create clipboard with task's log * @method createClipBoard */ createClipBoard: function () { - var log = $(".task-detail-log-maintext"), - logRect = log[0].getBoundingClientRect(); - $(".task-detail-log-clipboard-wrap").html('<textarea class="task-detail-log-clipboard"></textarea>'); - $(".task-detail-log-clipboard") - .html("stderr: \n" + $(".stderr").html() + "\n stdout:\n" + $(".stdout").html()) - .css("display", "block") - .width(logRect.width) - .height(logRect.height) - .select(); - log.css("display", "none") + this.set('showClipBoard', true); + $('.task-detail-log-maintext').css('display', 'none'); }, /** @@ -264,7 +270,7 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({ * @method destroyClipBoard */ destroyClipBoard: function () { - $(".task-detail-log-clipboard").remove(); - $(".task-detail-log-maintext").css("display", "block"); + this.set('showClipBoard', false); + $('.task-detail-log-maintext').css('display', 'block'); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/e719ea44/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 534269b..370f75a 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 @@ -288,7 +288,7 @@ describe('App.HostProgressPopupBodyView', function () { }); it("controller.hosts should be empty", function() { - view.set('controller.hosts', [{}]); + view.set('controller.hosts', [Em.Object.create({})]); view.set('parentView.isOpen', true); expect(view.get('controller.hosts')).to.be.empty; });
