From 68ceb59357f6d8f1d4de169ff24dc424b4d869ac Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 9 Apr 2021 08:59:54 +0800 Subject: [PATCH] scroll --- templates/repo/modelarts/trainjob/index.tmpl | 2 +- templates/repo/modelarts/trainjob/show.tmpl | 76 +++++++++++++++----- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index 09407a855..4834d7a97 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -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); }); diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index 2477cdab4..00aeb0dd2 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -113,24 +113,26 @@
-
+
- {{.JobID}} - {{.log_file_name}} + - - + + + +
{{.log.Content}}
+
-
+
@@ -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('
' + data.Content + '/pre')
+                }
+            }).fail(function(err) {
+                console.log(err);
+            });
         }
     })
 
\ No newline at end of file