Browse Source

scroll

tags/v1.21.12.1
Gitea 4 years ago
parent
commit
68ceb59357
2 changed files with 60 additions and 18 deletions
  1. +1
    -1
      templates/repo/modelarts/trainjob/index.tmpl
  2. +59
    -17
      templates/repo/modelarts/trainjob/show.tmpl

+ 1
- 1
templates/repo/modelarts/trainjob/index.tmpl View File

@@ -214,7 +214,7 @@
const jobID = data.JobID
const status = data.JobStatus
$('#' + jobID).text(status)
// console.log(data)
// console.log(data)
}).fail(function(err) {
console.log(err);
});


+ 59
- 17
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -113,24 +113,26 @@
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="logs">
<form class="ui form" action="{{$.Link}}/log" method="get">
<!-- <form class="ui form" action="{{.RepoLink}}/modelarts/train-job" method="get"> -->
<div class="ui top attached segment" style="background: #f0f0f0;">
<div class="center aligned">
<span class="fitted end_line">{{.JobID}}</span>
<label>{{$.i18n.Tr "repo.modelarts.log"}}:</label>
<span class="fitted file_name">{{.log_file_name}}</span>
<!-- <span class="fitted file_name">{{.log_file_name}}</span>
<span class="fitted start_line">{{.log.StartLine}}</span>
<span class="fitted end_line">{{.log.EndLine}}</span>
<span class="fitted end_line"></span> -->
<input type="hidden" name="file_name" value={{.log_file_name}}>
<input type="hidden" name="base_line" value="">
<input type="hidden" name="order" value="">
<input type="hidden" name="start_line" value={{.log.StartLine}}>
<input type="hidden" name="end_line" value={{.log.EndLine}}>
<input type="hidden" name="lines" value={{.log.Lines}}>
<!-- <input type="hidden" name="order" value=""> -->
</div>
</div>
<div class="ui attached segment log" style="height: 300px !important; overflow: auto;">
<pre>{{.log.Content}}</pre>
<div class="ui centered inline loader"></div>
</div>
</form>
<!-- </form> -->
</div>
</div>
</div>
@@ -145,23 +147,63 @@
$('.menu .item').tab()
$('.ui.style.accordion').accordion();

var repoPath
var jobID
var userName
var file_name
var end_line
var lines
var start_line
$(document).ready(function(){
var url = window.location.href;
var urlArr = url.split('/')
userName = urlArr.slice(-5)[0]
repoPath = urlArr.slice(-4)[0]
jobID = urlArr.slice(-1)[0]
file_name = $('input[name=file_name]').val()
end_line = $('input[name=end_line]').val()
lines = $('input[name=lines]').val()
start_line = $('input[name=start_line]').val()
})
$(".log").scroll(function () {
var scrollTop = $(this)[0].scrollTop; // 滚动条Y轴的滚动距离
var scrollHeight = $(this)[0].scrollHeight; // 文档高度
var divHeight = $(this).height(); // 可视区高度

var start_line = $('.fitted.start_line').text()
var end_line = $('.fitted.end_line').text()

if(scrollTop + divHeight + 50 >= scrollHeight){
$('input[name=base_line]').val(end_line)
$('input[name=order]').val("asc")
$('.ui.form').submit()
$('.loader').addClass('active')
console.log(end_line)
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?file_name=${file_name}&end_line=${end_line}&order=asc`, (data) => {
if (data.lines == 0){
alert("到底啦")
}else{
$('.loader').removeClass('active')
$('.log').append(data.Content)
end_line = data.EndLine
lines = data.lines
console.log(data)
}
}).fail(function(err) {
console.log(err);
});
// $('.ui.form').submit()
}
if(scrollTop == 0){
$('input[name=base_line]').val(start_line)
$('input[name=order]').val("desc")
$('.ui.form').submit()
$('.loader').addClass('active')
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?file_name=${file_name}&start_line=${start_line}&order=desc`, (data) => {
if (data.lines == 0){
alert("到顶啦")
}else{
$('.loader').removeClass('active')
$('.log').append(data.Content)
start_line = data.StartLine //如果变动就改变所对应的值
lines = data.lines
$(".log").prepend('<pre>' + data.Content + '/pre')
}
}).fail(function(err) {
console.log(err);
});
}
})
</script>

Loading…
Cancel
Save