AMBARI-19791 Log Search "Preview" should have a "Select for Copy" button (mgergely)
Change-Id: I99b2b10d83d2f2f4cb88637721bfd32a23668b44 Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c4f59ef7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c4f59ef7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c4f59ef7 Branch: refs/heads/branch-dev-patch-upgrade Commit: c4f59ef71dad456538818f0392c229fd381e62b4 Parents: 8ece8aa Author: Miklos Gergely <[email protected]> Authored: Wed Feb 1 10:49:43 2017 +0100 Committer: Miklos Gergely <[email protected]> Committed: Wed Feb 1 10:49:43 2017 +0100 ---------------------------------------------------------------------- .../webapp/scripts/views/tabs/LogFileView.js | 47 +++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c4f59ef7/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js index 57d4acd..c7e1cba 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js @@ -352,16 +352,16 @@ define(['require', }); }, getIdRowForTableLayout : function(){ - var IdRow = Backgrid.Row.extend({ - render: function() { - IdRow.__super__.render.apply(this, arguments); - if (this.model.has("id")) { - this.$el.attr("data-id", this.model.get('id')); - } - return this; - } - }); - return IdRow; + var IdRow = Backgrid.Row.extend({ + render: function() { + IdRow.__super__.render.apply(this, arguments); + if (this.model.has("id")) { + this.$el.attr("data-id", this.model.get('id')); + } + return this; + } + }); + return IdRow; }, renderTableLikeLogFile: function() { var that = this; @@ -821,6 +821,33 @@ define(['require', click: function() { that.onDialogClosed(); } + }, + { + id: "copyBtn", + text: "Select for Copy", + "class": "btn btn-default", + click: function() { + if ($('.logsContainer-clipboard').length != 0) + return; + + var logElement = $(".logsContainer"); + var logElementRect = logElement[0].getBoundingClientRect(); + logElement.css("display", "none"); + + var text = ''; + logElement.find('div').each(function(){ + text += this.innerText + '\n'; + }); + + var textarea = $('<textarea class="logsContainer-clipboard"></textarea>'); + $(".logsDetail").append(textarea); + textarea + .text(text) + .css('display', 'block') + .width(logElementRect.width) + .height(logElementRect.height) + .select(); + } }] }; var dialog = that.dialog = new JBDialog(opts).render();
