Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy button and scroll bars in views #674

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 92 additions & 17 deletions src/main/resources/io/seqera/wave/build-view.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
<html>
<head>
<head>
{{#if build_in_progress}}
<meta http-equiv="refresh" content="5">
{{/if}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Wave container build data">
<title>Wave container build notification</title>
</head>
{{#if build_in_progress}}
<meta http-equiv="refresh" content="5">
{{/if}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Wave container build data">
<title>Wave container build notification</title>
<style>
pre {
white-space: pre-wrap;
overflow-x: auto;
overflow-y: auto;
background-color: #ededed;
padding: 15px;
border-radius: 4px;
margin-bottom: 30px;
max-height: 400px;
max-width: 100%;
word-wrap: break-word;
}
.copy-btn {
position: absolute;
right: 10px;
top: 10px;
background: none;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<svg style="display: none;">
<symbol id="icon-copy" viewBox="0 0 16 16" aria-hidden="true" class="octicon octicon-copy">
<path fill-rule="evenodd" d="M0 1.75A.75.75 0 0 1 .75 1h10.5a.75.75 0 0 1 .75.75V3h-1V2.5H1.5v11h2v1H.75a.75.75 0 0 1-.75-.75zm3.5 2.5A.75.75 0 0 1 4.25 3h10.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.25a.75.75 0 0 1-.75-.75V4.25zm1.5.75v9h9v-9h-9z"></path>
</symbol>
</svg>
<div style="font-family:'-apple-system', BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; padding: 30px; max-width: 800px; margin: 0 auto;">

<div>
Expand Down Expand Up @@ -120,28 +146,54 @@
</table>

<h3>Container file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_containerfile}}</pre>
<div style="position: relative; margin-bottom: 30px;">
<button id="containerFileCopyBtn" class="copy-btn" onclick="copyToClipboard('containerFileData', 'containerFileCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="containerFileData">{{build_containerfile}}</pre>
</div>

{{#if build_condafile}}
<h3>Conda file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_condafile}}</pre>
<div style="position: relative; margin-bottom: 30px;">
<button id="condaFileCopyBtn" class="copy-btn" onclick="copyToClipboard('condaFileData', 'condaFileCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="condaFileData">{{build_condafile}}</pre>
</div>
{{/if}}

{{#if build_success}}
{{#if build_conda_lock_data }}
<h3>Conda lockfile</h3>
<pre style="white-space: pre-wrap; overflow-x: auto; overflow-y: auto; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px; max-height: 400px; max-width: 100%; word-wrap: break-word;">
{{build_conda_lock_data}}
</pre>
<div style="position: relative; margin-bottom: 30px;">
<button id="lockFileCopyBtn" class="copy-btn" onclick="copyToClipboard('lockFileData', 'lockFileCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="lockFileData">{{build_conda_lock_data}}</pre>
</div>
{{/if}}
{{/if}}

{{#if build_log_data}}
<h3>Build logs</h3>
<pre style="white-space: pre-wrap; overflow-x: auto; overflow-y: auto; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_log_data}}</pre>
<div style="position: relative; margin-bottom: 30px;">
<button id="logCopyBtn" class="copy-btn" onclick="copyToClipboard('logData', 'logCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="logData">{{build_log_data}}</pre>
{{#if build_log_truncated}}
<a href="{{build_log_url}}" download>Click here to download the complete build log</a>
{{/if}}
</div>
{{/if}}

<div class="footer" style="clear:both;width:100%;">
Expand All @@ -156,6 +208,29 @@
</div>

</div>

<script>
function copyToClipboard(preId, buttonId) {
const textToCopy = document.getElementById(preId).innerText;
navigator.clipboard.writeText(textToCopy).then(() => {
const copyBtn = document.getElementById(buttonId);
copyBtn.innerHTML = `
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" width="16" data-view-component="true" class="octicon octicon-check">
<path fill-rule="evenodd" d="M13.78 3.22a.75.75 0 0 1 1.06 1.06l-7 7a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 0 1 1.06-1.06L7.25 9.94l6.53-6.72z"></path>
</svg>
<span style="margin-left: 5px;">Copied!</span>
`;

setTimeout(() => {
copyBtn.innerHTML = `
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" width="16" data-view-component="true" class="octicon octicon-copy">
<path fill-rule="evenodd" d="M0 1.75A.75.75 0 0 1 .75 1h10.5a.75.75 0 0 1 .75.75V3h-1V2.5H1.5v11h2v1H.75a.75.75 0 0 1-.75-.75zm3.5 2.5A.75.75 0 0 1 4.25 3h10.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.25a.75.75 0 0 1-.75-.75V4.25zm1.5.75v9h9v-9h-9z"></path>
</svg>
`;
}, 2000);
}).catch(err => {
console.error('Failed to copy text: ', err);
});
}
</script>
</body>
</html>
177 changes: 118 additions & 59 deletions src/main/resources/io/seqera/wave/container-view.hbs
Original file line number Diff line number Diff line change
@@ -1,38 +1,62 @@
<html>
<head>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Wave container request data">
<title>Wave container</title>
</head>
<style>
.table {
width: 100%;
border: 1px solid #dc3545;
border-radius: 5px;
}
.table td {
border: none;
padding-left: 15px;
padding-top: 15px;
padding-bottom: 15px;
}
.button {
color: rgb(207, 34, 46);
text-align: center;
border-color: rgba(31, 35, 40, 0.15);
border-radius: 6px;
border-style: solid;
border-width: 1px;
font-size: 14px;
font-weight: 600;
padding: 5px 16px;
box-shadow: rgba(31, 35, 40, 0.04) 0px 1px 0px 0px, rgba(255, 255, 255, 0.25) 0px 1px 0px 0px inset;
}
</style>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Wave container request data">
<title>Wave container</title>
<style>
.table {
width: 100%;
border: 1px solid #dc3545;
border-radius: 5px;
}
.table td {
border: none;
padding-left: 15px;
padding-top: 15px;
padding-bottom: 15px;
}
.button {
color: rgb(207, 34, 46);
text-align: center;
border-color: rgba(31, 35, 40, 0.15);
border-radius: 6px;
border-style: solid;
border-width: 1px;
font-size: 14px;
font-weight: 600;
padding: 5px 16px;
box-shadow: rgba(31, 35, 40, 0.04) 0px 1px 0px 0px, rgba(255, 255, 255, 0.25) 0px 1px 0px 0px inset;
}
pre {
white-space: pre-wrap;
overflow-x: auto;
overflow-y: auto;
background-color: #ededed;
padding: 15px;
border-radius: 4px;
margin-bottom: 30px;
max-height: 400px;
max-width: 100%;
word-wrap: break-word;
}
.copy-btn {
position: absolute;
right: 10px;
top: 10px;
background: none;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<svg style="display: none;">
<symbol id="icon-copy" viewBox="0 0 16 16" aria-hidden="true" class="octicon octicon-copy">
<path fill-rule="evenodd" d="M0 1.75A.75.75 0 0 1 .75 1h10.5a.75.75 0 0 1 .75.75V3h-1V2.5H1.5v11h2v1H.75a.75.75 0 0 1-.75-.75zm3.5 2.5A.75.75 0 0 1 4.25 3h10.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.25a.75.75 0 0 1-.75-.75V4.25zm1.5.75v9h9v-9h-9z"></path>
</symbol>
</svg>
<div style="font-family:'-apple-system', BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; padding: 30px; max-width: 800px; margin: 0 auto;">

<div>
Expand Down Expand Up @@ -104,11 +128,25 @@

<!-- build info -->
{{#if build_container_file}}
<h3>Docker file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_container_file}}</pre>
<h3>Container file</h3>
<div style="position: relative; margin-bottom: 30px;">
<button id="containerFileCopyBtn" class="copy-btn" onclick="copyToClipboard('containerFileData', 'containerFileCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="containerFileData">{{build_container_file}}</pre>
</div>

<h3>Conda file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_conda_file}}</pre>
<div style="position: relative; margin-bottom: 30px;">
<button id="condaFileCopyBtn" class="copy-btn" onclick="copyToClipboard('condaFileData', 'condaFileCopyBtn')" title="Copy">
<svg width="16" height="16">
<use href="#icon-copy"></use>
</svg>
</button>
<pre id="condaFileData">{{build_conda_file}}</pre>
</div>

<table cellpadding="4" >
<tr>
Expand Down Expand Up @@ -207,30 +245,6 @@
</tr>
</table>
</div>

<script>
function evictFromCache() {
const statusLabel = document.getElementById("statusLabel");
const evictTable = document.getElementById("evictTable");
const evictStatusTable = document.getElementById("evictStatusTable");
fetch("{{server_url}}/container-token/{{request_token}}", {
method: 'DELETE'
}).then(response => {
if (response.ok) {
statusLabel.textContent = "This wave container record has been evicted from cache.";
}else if (response.status === 404) {
statusLabel.textContent = "This wave container record is already evicted from cache.";
}else{
statusLabel.textContent = "Error evicting the wave container record. Please try again later.";
}
}).catch(error => {
statusLabel.textContent = "Error evicting the wave container record. Please try again later.";
});
evictTable.style.display = "none";
evictStatusTable.style.display = "block";
}
</script>

<div class="footer" style="clear:both;width:100%;">
<hr class="footer-hr" style="height:0;overflow:visible;margin-top:30px;border:0;border-top:1px solid #eee;color:#999999;font-size:12px;line-height:18px;margin-bottom:30px;">
<img style="float:right; width: 150px;" src="/assets/seqera-logo.png">
Expand All @@ -243,6 +257,51 @@
</div>

</div>
<script>
function evictFromCache() {
const statusLabel = document.getElementById("statusLabel");
const evictTable = document.getElementById("evictTable");
const evictStatusTable = document.getElementById("evictStatusTable");
fetch("{{server_url}}/container-token/{{request_token}}", {
method: 'DELETE'
}).then(response => {
if (response.ok) {
statusLabel.textContent = "This wave container record has been evicted from cache.";
}else if (response.status === 404) {
statusLabel.textContent = "This wave container record is already evicted from cache.";
}else{
statusLabel.textContent = "Error evicting the wave container record. Please try again later.";
}
}).catch(error => {
statusLabel.textContent = "Error evicting the wave container record. Please try again later.";
});
evictTable.style.display = "none";
evictStatusTable.style.display = "block";
}

function copyToClipboard(preId, buttonId) {
const textToCopy = document.getElementById(preId).innerText;
navigator.clipboard.writeText(textToCopy).then(() => {
const copyBtn = document.getElementById(buttonId);
copyBtn.innerHTML = `
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" width="16" data-view-component="true" class="octicon octicon-check">
<path fill-rule="evenodd" d="M13.78 3.22a.75.75 0 0 1 1.06 1.06l-7 7a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 0 1 1.06-1.06L7.25 9.94l6.53-6.72z"></path>
</svg>
<span style="margin-left: 5px;">Copied!</span>
`;

setTimeout(() => {
copyBtn.innerHTML = `
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" width="16" data-view-component="true" class="octicon octicon-copy">
<path fill-rule="evenodd" d="M0 1.75A.75.75 0 0 1 .75 1h10.5a.75.75 0 0 1 .75.75V3h-1V2.5H1.5v11h2v1H.75a.75.75 0 0 1-.75-.75zm3.5 2.5A.75.75 0 0 1 4.25 3h10.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.25a.75.75 0 0 1-.75-.75V4.25zm1.5.75v9h9v-9h-9z"></path>
</svg>
`;
}, 2000);
}).catch(err => {
console.error('Failed to copy text: ', err);
});
}
</script>

</body>
</html>
Loading