|
|
@@ -21,11 +21,14 @@ export default async function initCloudrainSow() { |
|
|
|
} |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
function escapeHTML(a){ |
|
|
|
a = "" + a; |
|
|
|
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");; |
|
|
|
} |
|
|
|
function timeFormat(date) { |
|
|
|
return `${date.getFullYear()}-${paddingZeros(date.getMonth() + 1, 2)}-${paddingZeros(date.getDate(), 2)} ${paddingZeros(date.getHours(), 2)}:${paddingZeros(date.getMinutes(), 2)}:${paddingZeros(date.getSeconds(), 2)}`; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function logScroll(version_name, repoPath, ID, max = "", lines = 60) { |
|
|
|
let container = document.querySelector(`#log${max}${version_name}`); |
|
|
|
let scrollTop = container.scrollTop; |
|
|
@@ -70,7 +73,7 @@ export default async function initCloudrainSow() { |
|
|
|
$(`#log${version_name} input[name=end_line${max}]`).val( |
|
|
|
data.EndLine |
|
|
|
); |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + data.Content); |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + escapeHTML(data.Content)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -114,7 +117,7 @@ export default async function initCloudrainSow() { |
|
|
|
$(`#log${version_name} input[name=start_line${max}]`).val( |
|
|
|
data.StartLine |
|
|
|
); //如果变动就改变所对应的值 |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + data.Content); |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + escapeHTML(data.Content)); |
|
|
|
} |
|
|
|
} |
|
|
|
).fail(function (err) { |
|
|
@@ -176,7 +179,7 @@ export default async function initCloudrainSow() { |
|
|
|
$(`#log${version_name} input[name=start_line${max}]`).val( |
|
|
|
data.StartLine |
|
|
|
); |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + data.Content); |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + escapeHTML(data.Content)); |
|
|
|
if (data.Lines == 0) { |
|
|
|
if (max) { |
|
|
|
$("body").toast({ |
|
|
@@ -218,7 +221,7 @@ export default async function initCloudrainSow() { |
|
|
|
$(`#log${version_name} input[name=start_line${max}]`).val( |
|
|
|
data.StartLine |
|
|
|
); |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + data.Content); |
|
|
|
$(`#log${max}${version_name}`).prepend("<pre>" + escapeHTML(data.Content)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -287,7 +290,7 @@ export default async function initCloudrainSow() { |
|
|
|
$(`#log${version_name} input[name=start_line${max}]`).val( |
|
|
|
data.StartLine |
|
|
|
); |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + (data.Content||'')); |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + (escapeHTML(data.Content)||'')); |
|
|
|
$.get( |
|
|
|
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=${data.EndLine}&lines=${lines}&order=desc`, |
|
|
|
(data) => { |
|
|
@@ -320,7 +323,7 @@ export default async function initCloudrainSow() { |
|
|
|
data.EndLine |
|
|
|
); |
|
|
|
} |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + data.Content); |
|
|
|
$(`#log${max}${version_name}`).append("<pre>" + escapeHTML(data.Content)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -374,11 +377,10 @@ export default async function initCloudrainSow() { |
|
|
|
let html = ""; |
|
|
|
if (jsonObj != null){ |
|
|
|
let podEventArray = jsonObj['JobEvents']; |
|
|
|
console.log("podEventArray",podEventArray) |
|
|
|
if(podEventArray != null){ |
|
|
|
for(var i=0; i < podEventArray.length;i++){ |
|
|
|
for(let i=0; i < podEventArray.length;i++){ |
|
|
|
if (podEventArray[i]["reason"] != "") { |
|
|
|
let time = new Date(podEventArray[i]["timestamp"]) |
|
|
|
let time = podEventArray[i]["timestamp"]&&new Date(podEventArray[i]["timestamp"]) |
|
|
|
html += `<p><b>[${podEventArray[i]["reason"]}]</b> <span>${time.toLocaleString()}</span></p>` |
|
|
|
html += `<p>${podEventArray[i]["message"]}</p>`; |
|
|
|
} |
|
|
@@ -472,7 +474,7 @@ export default async function initCloudrainSow() { |
|
|
|
(data) => { |
|
|
|
$("input[name=end_line]").val(data.EndLine); |
|
|
|
$("input[name=start_line]").val(data.StartLine); |
|
|
|
$(`#log_file${version_name}`).text(data.Content); |
|
|
|
$(`#log_file${version_name}`).text(escapeHTML(data.Content)); |
|
|
|
document.getElementById("mask").style.display = "none"; |
|
|
|
} |
|
|
|
).fail(function (err) { |
|
|
@@ -531,6 +533,317 @@ export default async function initCloudrainSow() { |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
}); |
|
|
|
let initShowExportDataset = true |
|
|
|
let initShowNoDataset = true |
|
|
|
let canExportDataset = true |
|
|
|
let fileList = [] |
|
|
|
let timer = null |
|
|
|
let last_version = '' |
|
|
|
let datasetID = '' |
|
|
|
$('.ui.accordion .export-dataset').on('click', function (e) { |
|
|
|
const version_name = this.dataset.version; |
|
|
|
const jobId = this.dataset.jobid; |
|
|
|
const repoPath = this.dataset.repopath; |
|
|
|
const Fileurl = `${repoPath}/getmodelfile` |
|
|
|
const dataUrl = `${repoPath}/getcurrentdataset` |
|
|
|
const exportUrl = `${repoPath}/export_exist_dataset` |
|
|
|
const getProgressUrl = `${repoPath}/getprogress` |
|
|
|
|
|
|
|
if (!initShowExportDataset && last_version===version_name) { |
|
|
|
if (initShowNoDataset) { |
|
|
|
$(".ui.export_dataset.modal").modal({ |
|
|
|
onShow: function () { |
|
|
|
$('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) |
|
|
|
$(".ui.export_dataset.modal .cancel").on('click', function () { |
|
|
|
$(".ui.export_dataset.modal").modal('hide') |
|
|
|
}) |
|
|
|
}, |
|
|
|
onHide: function (params) { |
|
|
|
$('.ui.modal.export_dataset #container').off("click") |
|
|
|
$('#export-dataset-select').off("click") |
|
|
|
$('#export-dataset-type').off("click") |
|
|
|
$('.ui.export_dataset.modal .error.message').text('').hide() |
|
|
|
}, |
|
|
|
onApprove: function () { |
|
|
|
const modelFileSelectEle = $(".ui.export_dataset.modal #export-dataset-file .items").find('.file_item') |
|
|
|
if (modelFileSelectEle.length !== 0 && canExportDataset) { |
|
|
|
modelFileSelectEle.each(function (index) { |
|
|
|
fileList.push($(this).attr('data-index')) |
|
|
|
}) |
|
|
|
const type = Number($('.ui.modal.export_dataset input[name="type"]').val()) |
|
|
|
const csrf = $('.ui.modal.export_dataset input[name="_csrf"]').val() |
|
|
|
const desc = $('.ui.modal.export_dataset textarea[name="description"]').val() //,description:desc |
|
|
|
let params = { _csrf: csrf, jobId: jobId, versionName: version_name, datasetId: datasetID, modelSelectedFile: fileList.join(';'), type: type,description:desc } |
|
|
|
postExportDataset(exportUrl, params, getProgressUrl) |
|
|
|
} else { |
|
|
|
$('.ui.export_dataset.modal .error.message').text(`${i18n['exportDataset']['please_select_file']}`).show() |
|
|
|
} |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}).modal('show').modal('setting', 'closable', false) |
|
|
|
} else { |
|
|
|
$(".ui.no_export_dataset.modal").modal({ |
|
|
|
onShow: function () { |
|
|
|
$('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) |
|
|
|
}, |
|
|
|
}).modal("show") |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
$(`.ui.accordion #${version_name}-export-dataset .export-popup`).show() |
|
|
|
$('.ui.export_dataset.modal .error.message').text('').hide() |
|
|
|
$.get(dataUrl, (data) => { |
|
|
|
initShowExportDataset = false |
|
|
|
last_version = version_name |
|
|
|
if (data.code === 0) { |
|
|
|
datasetID = data.dataset.ID |
|
|
|
getModelFileList(Fileurl, version_name, jobId) |
|
|
|
getInitEXportDataset(getProgressUrl,data.dataset.ID,jobId,version_name) |
|
|
|
$(".ui.export_dataset.modal").modal({ |
|
|
|
onApprove: function () { |
|
|
|
const modelFileSelectEle = $(".ui.export_dataset.modal #export-dataset-file .items").find('.file_item') |
|
|
|
if (modelFileSelectEle.length !== 0 && canExportDataset) { |
|
|
|
modelFileSelectEle.each(function (index) { |
|
|
|
fileList.push($(this).attr('data-index')) |
|
|
|
}) |
|
|
|
const type = Number($('.ui.modal.export_dataset input[name="type"]').val()) |
|
|
|
const csrf = $('.ui.modal.export_dataset input[name="_csrf"]').val() |
|
|
|
const desc = $('.ui.modal.export_dataset textarea[name="description"]').val() //,description:desc |
|
|
|
let params = { _csrf: csrf, jobId: jobId, versionName: version_name, datasetId: data.dataset.ID, modelSelectedFile: fileList.join(';'), type: type, description: desc } |
|
|
|
postExportDataset(exportUrl, params, getProgressUrl) |
|
|
|
} else { |
|
|
|
$('.ui.export_dataset.modal .error.message').text(`${i18n['exportDataset']['please_select_file']}`).show() |
|
|
|
} |
|
|
|
return false; |
|
|
|
}, |
|
|
|
onShow: function () { |
|
|
|
$(`.ui.accordion #${version_name}-export-dataset .export-popup`).hide() |
|
|
|
$('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) |
|
|
|
}, |
|
|
|
onHide: function () { |
|
|
|
$('.ui.modal.export_dataset #container').off("click") |
|
|
|
$('#export-dataset-select').off("click") |
|
|
|
$('#export-dataset-type').off("click") |
|
|
|
$('.ui.export_dataset.modal .error.message').text('').hide() |
|
|
|
} |
|
|
|
}) |
|
|
|
.modal("show") |
|
|
|
.modal('setting', 'closable', false) |
|
|
|
} else { |
|
|
|
$(".ui.no_export_dataset.modal").modal({ |
|
|
|
onShow: function () { |
|
|
|
$(`.ui.accordion #${version_name}-export-dataset .export-popup`).hide() |
|
|
|
$('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) |
|
|
|
}, |
|
|
|
}).modal("show") |
|
|
|
initShowNoDataset = false |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
$('#export-dataset-select').on('click', function () { |
|
|
|
$(this).find('#model-file-wrap').show() |
|
|
|
}) |
|
|
|
$('#model-file-export').on('click','.delete.icon', function () { |
|
|
|
let fileEle = $(this).siblings('span').text() |
|
|
|
$(this).parent().remove() |
|
|
|
const $parentCheckbox = $('#model-file-result').find(`input[name="${fileEle}"]`).parent() |
|
|
|
$parentCheckbox.checkbox('set unchecked') |
|
|
|
}) |
|
|
|
$('.ui.modal.export_dataset #container').on('click', function (e) { |
|
|
|
if ($(e.target).closest('#model-file-wrap').length === 0 && $(e.target).closest('#export-dataset-select').length !== 1) { |
|
|
|
$(this).find('#model-file-wrap').hide() |
|
|
|
} |
|
|
|
}) |
|
|
|
$('#export-dataset-type').on('click', function (e,arg1) { |
|
|
|
document.querySelectorAll('#export-dataset-type a').forEach((item) => { |
|
|
|
item.classList.remove('active') |
|
|
|
}) |
|
|
|
if (arg1) { |
|
|
|
$('#export-dataset-type a')[arg1].classList.add('active') |
|
|
|
document.querySelector('input[name="type"]').value=arg1 |
|
|
|
} else { |
|
|
|
e.target.classList.add('active') |
|
|
|
document.querySelector('input[name="type"]').value=e.target.dataset.type |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
e.stopPropagation(); |
|
|
|
}) |
|
|
|
function getInitEXportDataset(getProgressUrl, datasetId, jobId,version_name) { |
|
|
|
let setIntervalFlag = false |
|
|
|
$('.ui.modal.export_dataset #model-file-export').empty() |
|
|
|
$.get(getProgressUrl, { progressId: `${datasetId}_${jobId}_${version_name}` }, (data) => { |
|
|
|
const result = data && JSON.parse(data) |
|
|
|
if (Object.keys(result).length > 0) { |
|
|
|
canExportDataset = false |
|
|
|
let fileInitList = Object.keys(result).filter((item) => item !== '##type##') |
|
|
|
$($('#export-dataset-type')).trigger('click',`${result['##type##']}`) |
|
|
|
|
|
|
|
fileInitList.forEach((item) => { |
|
|
|
if (result[item] === -1) { |
|
|
|
let itemHtml = `<div data-index="${item}" class="file_item"> |
|
|
|
<span class="nowrap" style="width:80%" title="${item}">${item}</span> |
|
|
|
<div class="file_error"><i class="ri-close-circle-line failed"></i><span>${i18n['exportDataset']['export_failed']}</span></div> |
|
|
|
</div>` |
|
|
|
$('.ui.modal.export_dataset #model-file-export').append(itemHtml) |
|
|
|
} |
|
|
|
if (result[item] === -2) { |
|
|
|
let itemHtml = `<div data-index="${item}" class="file_item"> |
|
|
|
<span class="nowrap" style="width:80%" title="${item}">${item}</span> |
|
|
|
<div class="file_error""> |
|
|
|
<i class="ri-close-circle-line failed"></i> |
|
|
|
<span>${i18n['exportDataset']['export_failed']}</span> |
|
|
|
<span data-tooltip="${i18n['exportDataset']['export_has_same_file']}" data-inverted="" data-variation="tiny"> |
|
|
|
<i class="ri-question-fill question"></i> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div>` |
|
|
|
$('.ui.modal.export_dataset #model-file-export').append(itemHtml) |
|
|
|
} |
|
|
|
if (result[item] === 100) { |
|
|
|
let itemHtml = `<div data-index="${item}" class="file_item"> |
|
|
|
<span class="nowrap" style="width:80%" title="${item}">${item}</span> |
|
|
|
<div class="file_success""> |
|
|
|
<i class="ri-checkbox-circle-line success" style="vertical-align: middle;"></i> |
|
|
|
<span>${i18n['exportDataset']['export_success']}</span> |
|
|
|
</div> |
|
|
|
</div>` |
|
|
|
$('.ui.modal.export_dataset #model-file-export').append(itemHtml) |
|
|
|
} |
|
|
|
if (result[item] === 0) { |
|
|
|
let itemHtml = `<div data-index="${item}" class="file_item"> |
|
|
|
<span class="nowrap" style="width:80%" title="${item}">${item}</span> |
|
|
|
<div class="file_wait""><i class="ri-loader-2-line waiting spin"></i><span>${i18n['exportDataset']['exporting']}</span></div> |
|
|
|
</div>` |
|
|
|
$('.ui.modal.export_dataset #model-file-export').append(itemHtml) |
|
|
|
setIntervalFlag = true |
|
|
|
} |
|
|
|
}) |
|
|
|
if (setIntervalFlag) { |
|
|
|
timer && clearInterval(timer) |
|
|
|
timer = setIntervalImmediately(getProgress, 5000, getProgressUrl, `${datasetId}_${jobId}`) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
function getModelFileList(Fileurl,version_name,jobId) { |
|
|
|
$.get(Fileurl, { versionName: version_name, jobId: jobId }, (data) => { |
|
|
|
$('.ui.modal.export_dataset #model-file-result').empty() |
|
|
|
let html = '' |
|
|
|
if (data.code === 0 && data.files.length !== 0) { |
|
|
|
let dataFileList = data.files.sort((a, b) => { |
|
|
|
return a.FileName.localeCompare(b.FileName) |
|
|
|
}) |
|
|
|
dataFileList.forEach(element => { |
|
|
|
html += `<div class="item"> |
|
|
|
<div class="ui child checkbox"> |
|
|
|
<input type="checkbox" name="${element.FileName}"> |
|
|
|
<label>${element.FileName}</label> |
|
|
|
</div> |
|
|
|
</div>` |
|
|
|
}); |
|
|
|
$('.ui.modal.export_dataset #model-file-result').append(html) |
|
|
|
$('#model-file-result.list .child.checkbox').checkbox({ |
|
|
|
onChecked: function () { |
|
|
|
$('.ui.export_dataset.modal .error.message').text('').hide() |
|
|
|
if (!canExportDataset) { |
|
|
|
$('.ui.modal.export_dataset #model-file-export').empty() |
|
|
|
canExportDataset = true |
|
|
|
} |
|
|
|
let itemHtml = '' |
|
|
|
let fileName = $(this).attr('name') |
|
|
|
itemHtml += `<div data-index="${fileName}" class="file_item"> |
|
|
|
<span class="nowrap" style="width:80%" title="${fileName}">${fileName}</span> |
|
|
|
<i class="delete icon" style="cursor:pointer"></i> |
|
|
|
</div>` |
|
|
|
$('.ui.modal.export_dataset #model-file-export').append(itemHtml) |
|
|
|
|
|
|
|
}, |
|
|
|
onUnchecked: function() { |
|
|
|
let fileName = $(this).attr('name') |
|
|
|
$('.ui.modal.export_dataset #model-file-export').find(`div[data-index="${fileName}"]`).remove() |
|
|
|
|
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
}).fail(function (err) { |
|
|
|
console.log(err); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
function getProgress(getProgressUrl,progressId) { |
|
|
|
const $statusEle = $('#model-file-export .file_item').find('div') |
|
|
|
let fileLength = $statusEle.length |
|
|
|
let count = 0 |
|
|
|
$.get(getProgressUrl, { progressId: progressId }, (data) => { |
|
|
|
const result = data && JSON.parse(data) |
|
|
|
let sortResult = Object.keys(result).sort((a,b) => { |
|
|
|
return fileList.indexOf(a)-fileList.indexOf(b) |
|
|
|
}) |
|
|
|
let filterResult = sortResult.filter((item) => item !== '##type##') |
|
|
|
filterResult.forEach((item, index) => { |
|
|
|
console.log(item) |
|
|
|
if (result[item] === -1) { |
|
|
|
|
|
|
|
if (!$($statusEle[index]).hasClass('file_error')) { |
|
|
|
$($statusEle[index]).replaceWith(`<div class="file_error"><i class="ri-close-circle-line failed"></i><span>${i18n['exportDataset']['export_failed']}</span></div>`) |
|
|
|
} |
|
|
|
count++ |
|
|
|
} |
|
|
|
if (result[item] === -2) { |
|
|
|
if (!$($statusEle[index]).hasClass('file_error')) { |
|
|
|
$($statusEle[index]).replaceWith(`<div class="file_error""><i class="ri-close-circle-line failed"></i><span>${i18n['exportDataset']['export_failed']}</span><span data-tooltip="${i18n['exportDataset']['export_has_same_file']}" data-inverted="" data-variation="tiny"><i class="ri-question-fill question"></i></span></div>`) |
|
|
|
} |
|
|
|
count++ |
|
|
|
} |
|
|
|
if (result[item] === 100 ) { |
|
|
|
if (!$($statusEle[index]).hasClass('file_success')) { |
|
|
|
$($statusEle[index]).replaceWith(`<div class="file_success""><i class="ri-checkbox-circle-line success" style="vertical-align: middle;"></i><span>${i18n['exportDataset']['export_success']}</span></div>`) |
|
|
|
} |
|
|
|
count++ |
|
|
|
} |
|
|
|
console.log("count:",count) |
|
|
|
if (count === fileLength) { |
|
|
|
$(".ui.export_dataset.modal").modal('refresh') |
|
|
|
timer && clearInterval(timer) |
|
|
|
$('#export-dataset-select').on('click', function () { |
|
|
|
$(this).find('#model-file-wrap').show() |
|
|
|
}) |
|
|
|
$('.ui.modal.export_dataset .ui.approve').removeClass('disabled') |
|
|
|
fileList = [] |
|
|
|
canExportDataset = false |
|
|
|
$('#model-file-result.list .child.checkbox.checked').each(function () { |
|
|
|
$(this).checkbox('set unchecked') |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
function postExportDataset(url, params, getProgressUrl) { |
|
|
|
$.post(url, params, (data) => { |
|
|
|
if (data.code === '0') { |
|
|
|
$('#model-file-export .delete.icon').each(function () { |
|
|
|
$(this).replaceWith(`<div class="file_wait""><i class="ri-loader-2-line waiting spin"></i><span>${i18n['exportDataset']['exporting']}</span></div>`) |
|
|
|
}) |
|
|
|
$('.ui.modal.export_dataset .ui.approve').addClass('disabled') |
|
|
|
$('#export-dataset-select').off("click") |
|
|
|
// $('.ui.modal.export_dataset').off("click") |
|
|
|
getProgress(getProgressUrl,data.progressId) |
|
|
|
|
|
|
|
timer && clearInterval(timer) |
|
|
|
timer = setIntervalImmediately(getProgress,5000,getProgressUrl,data.progressId) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
function setIntervalImmediately(func, interval,...args) { |
|
|
|
func(...args) |
|
|
|
return setInterval(func,interval,...args) |
|
|
|
}; |
|
|
|
// $('.ui.pointing.secondary.menu .item:eq(0)').click(function(e) { |
|
|
|
// const self = $(this); |
|
|
|
// setTimeout(function() { |
|
|
|