Skip to content

Commit

Permalink
Add copying job log to clipboard and add saving job log to file
Browse files Browse the repository at this point in the history
  • Loading branch information
ganiuszka committed Dec 27, 2023
1 parent 61d3fd2 commit 110422b
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 4 deletions.
Binary file modified Web/Lang/en/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5131,3 +5131,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/fr/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5142,3 +5142,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/ja/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/ja/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5205,3 +5205,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/ko/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/ko/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5147,3 +5147,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/pl/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/pl/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5142,3 +5142,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/pt/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/pt/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5142,3 +5142,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
Binary file modified Web/Lang/ru/messages.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions Web/Lang/ru/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5141,3 +5141,9 @@ msgstr "Log"

msgid "Latest"
msgstr "Latest"

msgid "Copy to clipboard"
msgstr "Copy to clipboard"

msgid "Save log in file"
msgstr "Save log in file"
2 changes: 1 addition & 1 deletion Web/Portlets/JobLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function loadJobLog($sender, $param)
$log = implode(PHP_EOL, $log);
$this->getPage()->getCallbackClient()->callClientFunction(
'oJobLogWindow.set_log',
[$log]
[$log, $joblog]
);
}

Expand Down
32 changes: 29 additions & 3 deletions Web/Portlets/JobLog.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div id="job_log_window" class="w3-modal">
<div class="w3-modal-content w3-animate-top w3-card-4">
<header class="w3-container w3-green">
<i id="job_log_clipboard_copy" class="fa-solid fa-copy fa-fw w3-xxlarge w3-right w3-margin-top pointer w3-animate-opacity" style="margin-right: 48px;" title="<%[ Copy to clipboard ]%>" onclick="oJobLogWindow.copy_to_clipboard();"></i>
<i id="job_log_clipboard_copied"class="fa-solid fa-check fa-fw w3-xxlarge w3-right w3-margin-top w3-animate-opacity" style="margin-right: 48px; display: none;"></i>
<i id="job_log_save_file" class="fa-solid fa-download w3-xxlarge w3-right w3-margin-top pointer w3-animate-opacity" style="margin-right: 16px;" title="<%[ Save log in file ]%>" onclick="oJobLogWindow.save_file();"></i>
<span onclick="oJobLogWindow.show_window(false);" class="w3-button w3-display-topright">&times;</span>
<h2><%[ Job log ]%> - <span id="job_log_jobname"></span></h2>
</header>
Expand All @@ -15,13 +18,17 @@
<script>
var oJobLogWindow = {
jobid: 0,
jobname: '',
log_raw: '',
refresh: false,
refresh_interval: 5000,
ids: {
win: 'job_log_window',
content: 'job_log_content',
out: 'job_log_output',
name: 'job_log_jobname'
name: 'job_log_jobname',
clipboard_copy: 'job_log_clipboard_copy',
clipboard_copied: 'job_log_clipboard_copied',
},
open_window: function(jobid, jobname, refresh) {
this.clear_log();
Expand All @@ -31,6 +38,7 @@ var oJobLogWindow = {
jname.textContent = jobname;
}
this.jobid = jobid;
this.jobname = jobname;
this.get_log();
this.show_window(true);
},
Expand All @@ -47,7 +55,8 @@ var oJobLogWindow = {
cb.setCallbackParameter(this.jobid);
cb.dispatch();
},
set_log: function(log, force_stop) {
set_log: function(log, log_raw, force_stop) {
oJobLogWindow.log_raw = log_raw;
const is_bottom = oJobLogWindow.is_scroll_bottom();
const out = document.getElementById(oJobLogWindow.ids.out);
out.innerHTML = log;
Expand All @@ -59,7 +68,7 @@ var oJobLogWindow = {
}
},
clear_log: function() {
this.set_log('', true);
this.set_log('', '', true);
},
set_scroll_bottom: function() {
const container = document.getElementById(this.ids.content);
Expand All @@ -68,6 +77,23 @@ var oJobLogWindow = {
is_scroll_bottom: function() {
const container = document.getElementById(this.ids.content);
return (container.scrollTop === (container.scrollHeight - container.offsetHeight));
},
copy_to_clipboard: function() {
const copy = document.getElementById(this.ids.clipboard_copy);
const copied = document.getElementById(this.ids.clipboard_copied);
const log = this.log_raw.join("\n");
copy_to_clipboard(log);
copy.style.display = 'none';
copied.style.display = 'inline-block';
setTimeout(() => {
copied.style.display = 'none';
copy.style.display = 'inline-block';
}, 1300);
},
save_file: function() {
const log = this.log_raw.join("\n");
const filename = '%jobid_%jobname_job_log.txt'.replace('%jobid', this.jobid).replace('%jobname', this.jobname);
save_file(log, filename, 'text/plain');
}
}
</script>

0 comments on commit 110422b

Please sign in to comment.