Skip to content

Commit

Permalink
Merge pull request #3 from medyagh/copy_logs
Browse files Browse the repository at this point in the history
Add Copy To Clipboard button
  • Loading branch information
medyagh authored Apr 7, 2020
2 parents 8a449f3 + e229541 commit 74e7edc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/report/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package report

// Version is gopogh version
const Version = "v0.1.3"
const Version = "v0.1.17"

// Build includes commit sha date
var Build string
Expand Down
30 changes: 25 additions & 5 deletions pkg/template/report3.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,19 @@ <h2 class="mdl-card__title-text">Test {{$resultType}} ({{ len $results }}/{{ $.T
<div class="mdl-grid ">
<input size="23" id="{{$resultType}}searchbox{{$i}}" class="search_box" type="text" placeholder="🔍 search... ">
<a id="pl_{{$resultType}}_{{$r.TestName}}" href="#{{$resultType}}_{{ $r.TestName }}"><i class="fa fa-link fa-2x"></i></a>
<button id="button1" onclick="CopyToClipboard('{{$resultType}}_{{$r.TestName}}_content')"><i class="fa fa-2tx fa-clipboard">Copy To Clipboard</i></button>
</div>

<div id="{{$resultType}}testcontent{{ $i }}" class="content">
{{range $r.Events}}
<pre>{{ .Output }}</pre>
{{end}}
</div>

<div id="{{$resultType}}_{{$r.TestName}}_content">
<div id="{{$resultType}}testcontent{{ $i }}" class="content">
{{range $r.Events}}
<pre>{{ .Output }}</pre>
{{end}}
</div>
</div>
</div>
</div>
{{end}}
</div>
</div>
Expand All @@ -184,6 +188,22 @@ <h2 class="mdl-card__title-text">Test {{$resultType}} ({{ len $results }}/{{ $.T
<div class="mdl-snackbar__text">Copied to clipboard</div>
</div>
</div>
<script type="text/javascript">
function CopyToClipboard(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
alert("Test logs was copied to clipboard.")
}
}
</script>
<script type="text/javascript">
var headers = document.querySelectorAll('.test-section-header');

Expand Down

0 comments on commit 74e7edc

Please sign in to comment.