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

Fix task log copy formatting #2733

Merged
merged 1 commit into from
Oct 13, 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
1 change: 1 addition & 0 deletions plugins/_task/_task.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
overflow: auto;
width: 580px;
cursor: text;
user-select: text;
}
.tskconsole img {
width: 100%;
Expand Down
58 changes: 43 additions & 15 deletions plugins/_task/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,33 @@ plugin.fromBackground = function( no )
plugin.onStart(this.foreground);
}

plugin.copyConsoleLog = function() {
const consoleLog = $('#tskcmdlog').text();
plugin.readConsoleLog = function() {
const consoleLog = $('#tskcmdlog')[0].innerText;
if (consoleLog !== "") {
copyToClipboard(consoleLog);
return consoleLog;
} else {
log("Console log is empty.");
log(theUILang.tskLogEmpty);
return;
}
}

plugin.copyConsoleLog = function() {
const consoleLog = plugin.readConsoleLog();
if (!!consoleLog) {
copyToClipboard(consoleLog);
}
}

plugin.saveConsoleLog = function () {
const consoleLog = plugin.readConsoleLog();
if (!!consoleLog) {
const blob = new Blob([consoleLog], {type:"text/plain"});
const fileUrl = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = fileUrl;
link.download = "log.txt";
link.click();
URL.revokeObjectURL(fileUrl); // revoke object url to prevent memory leaks
}
}

Expand Down Expand Up @@ -232,7 +253,9 @@ plugin.setConsoleControls = function(errPresent) {
$("#tskConsole-header").html(theUILang.tskCommandDone);
if ($('#tskcmdlog').text() === "") {
// hide copy log button if log output is empty
$("#tskCopy").hide();
$("#tskCopy, #tskSaveLog").hide();
} else {
$("#tskCopy, #tskSaveLog").show();
};
}
else
Expand Down Expand Up @@ -579,9 +602,16 @@ plugin.onLangLoaded = function() {
),
);
const tskConsoleButtons = $("<div>").attr({id:"tsk_btns"}).addClass("buttons-list").append(
$("<button>").attr({type:"button", id:"tskCopy"})
$("<button>")
.attr({type:"button", id:"tskCopy"})
.on("click", plugin.copyConsoleLog)
.text(theUILang.tskCopy),
.text(theUILang.tskCopy)
.hide(),
$("<button>")
.attr({type:"button", id:"tskSaveLog"})
.on("click", plugin.saveConsoleLog)
.text(theUILang.tskSaveLog)
.hide(),
$("<button>").attr({type:"button", id:"tskBackground"})
.on("click", plugin.toBackground)
.text(theUILang.tskBackground),
Expand All @@ -594,19 +624,17 @@ plugin.onLangLoaded = function() {
true,
);

theDialogManager.setHandler('tskConsole','afterHide',function()
{
if( plugin.foreground.no )
{
if(!plugin.isInBackground())
theDialogManager.setHandler('tskConsole', 'afterHide', function() {
if (plugin.foreground.no) {
if (!plugin.isInBackground())
plugin.shutdown();
else
theWebUI.getTable('tasks').tasksRemovePrim();
}
$("#tskCopy, #tskSaveLog").hide();
});
theDialogManager.setHandler('tskConsole','afterShow',function()
{
if(!plugin.cHeight)
theDialogManager.setHandler('tskConsole', 'afterShow', function() {
if (!plugin.cHeight)
plugin.cHeight = $('#tskcmderrors').parent().height();
});
$(".tskconsole").enableSysMenu();
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnose";
theUILang.tskBackground = "Verstecken";
theUILang.tskCopy = "Kopieren";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Gestartet";
theUILang.tskFinish = "Fertiggestellt";
theUILang.tskElapsed = "Verstrichen";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Διαγνωστικά";
theUILang.tskBackground = "Απόκρυψη";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Εκκίνηση";
theUILang.tskFinish = "Ολοκλήρωση";
theUILang.tskElapsed = "Χρόνος που πέρασε";
Expand Down
4 changes: 3 additions & 1 deletion plugins/_task/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand All @@ -25,4 +27,4 @@
theUILang.tskArg = "Parameter";
theUILang.tskTasks = "Tasks";

thePlugins.get("_task").langLoaded();
thePlugins.get("_task").langLoaded();
2 changes: 2 additions & 0 deletions plugins/_task/lang/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnosticos";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copiar";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostiques";
theUILang.tskBackground = "Cacher";
theUILang.tskCopy = "Copier";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Démarrée";
theUILang.tskFinish = "Terminée";
theUILang.tskElapsed = "Écoulée";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnosztika";
theUILang.tskBackground = "Elrejtés";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Elindult";
theUILang.tskFinish = "Végzett";
theUILang.tskElapsed = "Eltelt";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostiche";
theUILang.tskBackground = "Nascondi";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Avviato";
theUILang.tskFinish = "Terminato";
theUILang.tskElapsed = "Trascorso";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "진단";
theUILang.tskBackground = "숨기기";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "시작됨";
theUILang.tskFinish = "완료됨";
theUILang.tskElapsed = "경과";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/lv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/no.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostikk";
theUILang.tskBackground = "Skjul";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Startet";
theUILang.tskFinish = "Fullført";
theUILang.tskElapsed = "Forløpt";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostyka";
theUILang.tskBackground = "Ukryj";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Rozpoczęty";
theUILang.tskFinish = "Zakończony";
theUILang.tskElapsed = "Upłynęło";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/pt-br.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/pt-pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnóstico";
theUILang.tskBackground = "Ocultar";
theUILang.tskCopy = "Copiar";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Iniciado";
theUILang.tskFinish = "Terminado";
theUILang.tskElapsed = "Decorrido";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Диагностика";
theUILang.tskBackground = "Спрятать";
theUILang.tskCopy = "Копировать";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Старт";
theUILang.tskFinish = "Завершение";
theUILang.tskElapsed = "Затрачено";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/sr.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostik";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Tanılama";
theUILang.tskBackground = "Gizle";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Başlatıldı";
theUILang.tskFinish = "Bitti";
theUILang.tskElapsed = "Geçen";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Діагностика";
theUILang.tskBackground = "Приховати";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Початок";
theUILang.tskFinish = "Завершення";
theUILang.tskElapsed = "Минуло";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/vi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "诊断";
theUILang.tskBackground = "隐藏";
theUILang.tskCopy = "复制";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "已开始";
theUILang.tskFinish = "已完成";
theUILang.tskElapsed = "已用时间";
Expand Down
2 changes: 2 additions & 0 deletions plugins/_task/lang/zh-tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
theUILang.tskErrors = "Diagnostics";
theUILang.tskBackground = "Hide";
theUILang.tskCopy = "Copy";
theUILang.tskLogEmpty = "Console log is empty.";
theUILang.tskSaveLog = "Save Log";
theUILang.tskStart = "Started";
theUILang.tskFinish = "Finished";
theUILang.tskElapsed = "Elapsed";
Expand Down