From 8746f2b306ab504730134481c3352b3565f30c70 Mon Sep 17 00:00:00 2001 From: jnywong Date: Fri, 5 Dec 2025 15:09:44 +0000 Subject: [PATCH 1/3] Add button to copy error message --- nbgitpuller/static/js/gitsyncview.js | 18 ++++++++++++++---- nbgitpuller/static/js/index.js | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/nbgitpuller/static/js/gitsyncview.js b/nbgitpuller/static/js/gitsyncview.js index da65052..8c77f36 100644 --- a/nbgitpuller/static/js/gitsyncview.js +++ b/nbgitpuller/static/js/gitsyncview.js @@ -4,7 +4,7 @@ import { FitAddon } from 'xterm-addon-fit'; import { WebLinksAddon } from 'xterm-addon-web-links'; export class GitSyncView{ - constructor(termSelector, progressSelector, termToggleSelector, recoverySelector) { + constructor(termSelector, progressSelector, termToggleSelector, containerErrorSelector, copyErrorSelector) { // Class that encapsulates view rendering as much as possible this.term = new Terminal({ convertEol: true @@ -18,7 +18,8 @@ export class GitSyncView{ this.termToggle = document.querySelector(termToggleSelector); this.termElement = document.querySelector(termSelector); - this.recovery = document.querySelector(recoverySelector); + this.containerError = document.querySelector(containerErrorSelector); + this.copyError = document.querySelector(copyErrorSelector); this.termToggle.onclick = () => this.setTerminalVisibility(!this.visible) } @@ -64,9 +65,18 @@ export class GitSyncView{ } } - setRecoveryLink(isError) { + setContainerError(isError, errorText='') { if (isError) { - this.recovery.classList.toggle('hidden', !visible); + this.containerError.classList.toggle('hidden', !this.visible); + } + const button = this.copyError; + button.onclick = async () => { + try { + await navigator.clipboard.writeText(errorText); + button.innerHTML = 'Error message copied!'; + } catch (err) { + console.error('Failed to copy error text: ', err); + } } } } diff --git a/nbgitpuller/static/js/index.js b/nbgitpuller/static/js/index.js index b9e5cfc..25d88ef 100644 --- a/nbgitpuller/static/js/index.js +++ b/nbgitpuller/static/js/index.js @@ -29,7 +29,8 @@ const gsv = new GitSyncView( '#status-details', '#status-panel-title', '#status-panel-toggle', - '#recovery-link' + '#container-error', + '#copy-error-button', ); gs.addHandler('syncing', function(data) { @@ -46,11 +47,11 @@ gs.addHandler('error', function(data) { gsv.setProgressValue(100); gsv.setProgressText('Error: ' + data.message); gsv.setProgressError(true); - gsv.setRecoveryLink(true); gsv.setTerminalVisibility(true); if (data.output) { gsv.term.write(data.output); } + gsv.setContainerError(true, data.output); }); gs.start(); From 24cedca3cfe3eb05c1bd2558bbf2b0041685c36b Mon Sep 17 00:00:00 2001 From: jnywong Date: Fri, 5 Dec 2025 15:09:54 +0000 Subject: [PATCH 2/3] Add button to html --- nbgitpuller/templates/status.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/nbgitpuller/templates/status.html b/nbgitpuller/templates/status.html index 56f9b15..cb3dfdc 100644 --- a/nbgitpuller/templates/status.html +++ b/nbgitpuller/templates/status.html @@ -12,7 +12,7 @@ {% endblock %} {% block site %} -
+
@@ -30,8 +30,15 @@
- {% endblock %} @@ -74,5 +81,12 @@ width: 100%; color: black; } + +#container-error { + margin-right: 0px; + padding-left: 0px; + padding-right: 30px; +} + {% endblock %} From 55ea4b72f3644fd117332a46283be96a425a7335 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 8 Dec 2025 11:38:45 +0000 Subject: [PATCH 3/3] Copy additional useful info --- nbgitpuller/static/js/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nbgitpuller/static/js/index.js b/nbgitpuller/static/js/index.js index 25d88ef..7132f4a 100644 --- a/nbgitpuller/static/js/index.js +++ b/nbgitpuller/static/js/index.js @@ -49,9 +49,13 @@ gs.addHandler('error', function(data) { gsv.setProgressError(true); gsv.setTerminalVisibility(true); if (data.output) { - gsv.term.write(data.output); + const errorText= `Repository: ${gs.repo}\nBranch: ${gs.branch}\nRedirect URL: ${gs.redirectUrl}\n\n${data.output}\n`; + gsv.term.write(errorText); + gsv.setContainerError( + true, + errorText + ); } - gsv.setContainerError(true, data.output); }); gs.start();