Skip to content

Commit 217a466

Browse files
committed
Add copy button for pipeline and job ids
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent c67cf66 commit 217a466

1 file changed

Lines changed: 36 additions & 7 deletions

File tree

vulnerabilities/templates/pipeline_run_details.html

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,18 @@
3939
<h1 class="title">{{ pipeline_name }} Run Log</h1>
4040
<hr>
4141

42-
<div class="box p-4">
42+
<div class="box has-background-info-light is-light p-4">
4343
<div class="columns is-multiline is-vcentered is-mobile is-gapless">
4444
<div class="column is-one-fifth-desktop is-one-quarter-tablet is-half-mobile">
4545
<p class="is-size-7 has-text-weight-semibold">Pipeline ID</p>
46-
<p class="has-text-grey is-size-7 pr-3">{{ run.pipeline.pipeline_id }}</p>
46+
<p class="has-text-grey is-size-7">
47+
{{ run.pipeline.pipeline_id }}
48+
<i class="fa fa-copy has-text-grey"
49+
id="copy-pipeline-id"
50+
style="font-size: 0.60rem; cursor: pointer;"
51+
onclick="copyToClipboard('copy-pipeline-id', '{{ run.pipeline.pipeline_id }}')">
52+
</i>
53+
</p>
4754
</div>
4855
<div class="column is-one-fifth-desktop is-one-quarter-tablet is-half-mobile">
4956
<p class="is-size-7 has-text-weight-semibold">Status</p>
@@ -107,17 +114,24 @@ <h1 class="title">{{ pipeline_name }} Run Log</h1>
107114
</div>
108115
<div class="column is-one-fifth-desktop is-one-quarter-tablet is-half-mobile">
109116
<p class="is-size-7 has-text-weight-semibold">Job ID</p>
110-
<p class="has-text-grey is-size-7">{{ run.run_id }}</p>
117+
<p class="has-text-grey is-size-7">
118+
{{ run.run_id }}
119+
<i class="fa fa-copy has-text-grey"
120+
id="copy-job-id"
121+
style="font-size: 0.60rem; cursor: pointer;"
122+
onclick="copyToClipboard('copy-job-id', '{{ run.run_id }}')">
123+
</i>
124+
</p>
111125
</div>
112126
</div>
113127
</div>
114128

115129
{% if not run.run_end_date and not run.pipeline.live_logging %}
116-
<div class="notification is-info is-light has-text-centered">
130+
<div class="notification has-text-centered" style="background-color: #f8edb2;">
117131
<p class="is-size-6 has-text-grey-dark">
118132
<i class="fa fa-exclamation-triangle mr-1"></i>
119-
Live logging is disabled for this pipeline.
120-
Logs will be available after the pipeline has finished running.
133+
Live streaming of log is disabled for this pipeline.
134+
Log will be available once this pipeline has finished running.
121135
</p>
122136
</div>
123137
{% endif %}
@@ -244,7 +258,22 @@ <h2 class="subtitle mb-2">Log Output</h2>
244258
btn.innerHTML = '<span class="icon is-small"><i class="fa fa-copy"></i></span>';
245259
}, 1500);
246260
})
247-
.catch(err => alert("Copy failed: " + err));
261+
.catch(err => alert("Failed to copy log."));
248262
}
263+
264+
function copyToClipboard(button, text) {
265+
navigator.clipboard.writeText(text)
266+
.then(() => {
267+
const btn = document.getElementById(button);
268+
btn.classList.remove("fa-copy", "has-text-grey");
269+
btn.classList.add("has-text-success", "fa-check");
270+
setTimeout(() => {
271+
btn.classList.remove("fa-check", "has-text-success");
272+
btn.classList.add("has-text-grey", "fa-copy");
273+
}, 1500);
274+
})
275+
.catch(err => alert("Copy to clipboard failed."));
276+
}
277+
249278
</script>
250279
{% endblock %}

0 commit comments

Comments
 (0)