This commit is contained in:
2022-01-03 19:25:10 +00:00
parent 1d7908667b
commit 059d4a97f2
2 changed files with 34 additions and 10 deletions

View File

@@ -80,6 +80,25 @@ export default {
logSelected: function() {
this.getDataFromApi();
},
downloadLog() {
const vm = this;
if (!vm.selectedLog) {
return;
}
try {
const href = window.$gz.api.genericDownloadUrl(
"log-file/download/" + vm.selectedLog
);
if (window.open(href, "DownloadLog") == null) {
throw new Error(
"Unable to download, your browser rejected navigating to download url."
);
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, this);
// window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed"));
}
},
async getDataFromApi() {
const vm = this;
if (!vm.selectedLog) {
@@ -138,6 +157,12 @@ function generateMenu(vm) {
surface: false,
key: FORM_KEY + ":copylog",
vm: vm
},
{
title: "Download",
icon: "$ayiFileDownload",
key: FORM_KEY + ":download",
vm: vm
}
]
};
@@ -158,6 +183,9 @@ function clickHandler(menuItem) {
//put the log info on the clipboard:
window.$gz.util.copyToClipboard("SERVER LOG\n" + m.vm.log);
break;
case "download":
m.vm.downloadLog();
break;
default:
window.$gz.eventBus.$emit(
"notify-warning",
@@ -180,7 +208,11 @@ async function initForm(vm) {
// Ensures UI translated text is available
//
async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations(["OpsTestJob", "Log"]);
await window.$gz.translation.cacheTranslations([
"OpsTestJob",
"Log",
"Download"
]);
}
//////////////////////