| @@ -113,26 +113,24 @@ | |||
| </div> | |||
| </div> | |||
| <div class="ui bottom attached tab segment" data-tab="logs"> | |||
| <!-- <form class="ui form" action="{{.RepoLink}}/modelarts/train-job" method="get"> --> | |||
| <div class="ui message" style="display: none;"> | |||
| <div class="header"> | |||
| </div> | |||
| </div> | |||
| <div class="ui top attached segment" style="background: #f0f0f0;"> | |||
| <div class="center aligned"> | |||
| <label>{{$.i18n.Tr "repo.modelarts.log"}}:</label> | |||
| <!-- <span class="fitted file_name">{{.log_file_name}}</span> | |||
| <span class="fitted start_line">{{.log.StartLine}}</span> | |||
| <span class="fitted end_line"></span> --> | |||
| <span class="fitted file_name">{{.log_file_name}}</span> | |||
| <input type="hidden" name="file_name" value={{.log_file_name}}> | |||
| <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=""> --> | |||
| <input type="hidden" name="start_line" value={{.log.StartLine}}> | |||
| <input type="hidden" name="end_line" value={{.log.EndLine}}> | |||
| </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> --> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -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('<pre>' + data.Content + '</pre>') | |||
| } | |||
| }).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('<pre>' + data.Content + '/pre') | |||
| } | |||
| }).fail(function(err) { | |||