From 634f5b360ba48679bb76e3e9e80bb71ac3d2893b Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 9 Apr 2021 12:22:35 +0800 Subject: [PATCH] complate scroll --- templates/repo/modelarts/trainjob/show.tmpl | 73 +++++++++------------ 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index 00aeb0dd2..fa4e739e0 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -113,26 +113,24 @@
- +
- - + {{.log_file_name}} - - - - + +
{{.log.Content}}
-
- + +
@@ -147,58 +145,51 @@ $('.menu .item').tab() $('.ui.style.accordion').accordion(); - var repoPath - var jobID var userName - var file_name - var end_line - var lines - var start_line + var repoPath + var jobID $(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 scrollTop = $(this)[0].scrollTop; // 滚动距离 var scrollHeight = $(this)[0].scrollHeight; // 文档高度 var divHeight = $(this).height(); // 可视区高度 - - if(scrollTop + divHeight + 50 >= scrollHeight){ - $('.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) => { + var file_name = $('input[name=file_name]').val() + + if(parseInt(scrollTop) + divHeight + 29 == scrollHeight){ + var end_line = $('input[name=end_line]').val() + $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?file_name=${file_name}&base_line=${end_line}&order=asc`, (data) => { if (data.lines == 0){ - alert("到底啦") + $('.header').text('您已翻阅至日志底部') + $('.message').css('display', 'block') + setTimeout(function(){ + $('.message').css('display', 'none') + }, 1000) }else{ - $('.loader').removeClass('active') - $('.log').append(data.Content) - end_line = data.EndLine - lines = data.lines - console.log(data) + $('input[name=end_line]').val(data.EndLine) + $('.log').append('
' + data.Content  + '
') } }).fail(function(err) { console.log(err); }); - // $('.ui.form').submit() } if(scrollTop == 0){ - $('.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) => { + var start_line = $('input[name=start_line]').val() + $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?file_name=${file_name}&base_line=${start_line}&order=desc`, (data) => { if (data.lines == 0){ - alert("到顶啦") + $('.header').text('您已翻阅至日志底部') + $('.message').css('display', 'block') + setTimeout(function(){ + $('.message').css('display', 'none') + }, 1000) }else{ - $('.loader').removeClass('active') - $('.log').append(data.Content) - start_line = data.StartLine //如果变动就改变所对应的值 - lines = data.lines + $('input[name=start_line]').val(data.StartLine) //如果变动就改变所对应的值 $(".log").prepend('
' + data.Content + '/pre')
                 }
             }).fail(function(err) {