You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

showinfo.tmpl 7.5 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. {{template "base/head" .}}
  2. <div class="repository">
  3. {{template "repo/header" .}}
  4. <style>
  5. .model_header_text{
  6. font-size: 14px;
  7. color: #101010;
  8. font-weight: bold;
  9. }
  10. .ti_form{
  11. text-align: left;
  12. max-width: 100%;
  13. vertical-align: middle;
  14. }
  15. .ti-text-form-label {
  16. padding-bottom: 20px;
  17. padding-right: 20px;
  18. color: #8a8e99;
  19. font-size: 14px;
  20. white-space: nowrap !important;
  21. width: 80px;
  22. line-height: 30px;
  23. }
  24. .ti-text-form-content {
  25. line-height: 30px;
  26. padding-bottom: 20px;
  27. width: 100%;
  28. }
  29. .change-version{
  30. min-width: auto !important;
  31. border: 1px solid rgba(187, 187, 187, 100) !important;
  32. border-radius: .38571429rem !important;
  33. margin-left: 1.5em;
  34. }
  35. .word-elipsis{
  36. overflow: hidden;
  37. text-overflow: ellipsis;
  38. white-space: nowrap;
  39. }
  40. .half-table{
  41. width: 50%;
  42. float: left;
  43. }
  44. .text-width80 {
  45. width: 100px;
  46. line-height: 30px;
  47. }
  48. .tableStyle{
  49. width:100%;
  50. table-layout: fixed;
  51. }
  52. .iword-elipsis{
  53. display: inline-block;
  54. width: 80%;
  55. overflow: hidden;
  56. text-overflow: ellipsis;
  57. white-space: nowrap;
  58. }
  59. </style>
  60. <div class="ui container">
  61. <h4 class="ui header" id="vertical-segment">
  62. <!-- <a href="javascript:window.history.back();"><i class="arrow left icon"></i>返回</a> -->
  63. <div class="ui breadcrumb">
  64. <a class="section" href="{{$.RepoLink}}/modelmanage/show_model">
  65. 模型管理
  66. </a>
  67. <div class="divider"> / </div>
  68. <div class="active section">{{.name}}</div>
  69. </div>
  70. <select class="ui dropdown tiny change-version" id="dropdown" onchange="changeInfo(this.value)">
  71. </select>
  72. </h4>
  73. <div id="showInfo" style="border:1px solid #e2e2e2;padding: 20px 60px;margin-top:24px">
  74. </div>
  75. </div>
  76. </div>
  77. {{template "base/footer" .}}
  78. <script>
  79. let url = location.href.split('show_model')[0]
  80. let ID = location.search.split('?name=').pop()
  81. console.log("-----------",ID)
  82. $(document).ready(loadInfo);
  83. function changeInfo(version){
  84. $.get(`${url}show_model_info_api?name=${ID}`,(data)=>{
  85. let versionData = data.filter((item)=>{
  86. return item.Version === version
  87. })
  88. let initObj = transObj(versionData)[0]
  89. let initModelAcc = transObj(versionData)[1]
  90. let id= transObj(data)[2]
  91. console.log("=======",initObj,initModelAcc)
  92. $('#showInfo').empty()
  93. renderInfo(initObj,initModelAcc,id)
  94. })
  95. }
  96. function loadInfo(){
  97. $.get(`${url}show_model_info_api?name=${ID}`,(data)=>{
  98. let html = ''
  99. for (let i=0;i<data.length;i++){
  100. html += `<option value="${data[i].Version}">${data[i].Version}</option>`
  101. }
  102. $('#dropdown').append(html)
  103. let initObj = transObj(data)[0]
  104. let initModelAcc = transObj(data)[1]
  105. let id= transObj(data)[2]
  106. renderInfo(initObj,initModelAcc,id)
  107. })
  108. }
  109. function transObj(data){
  110. let {ID,Name,Version,Label,Size,Description,CreatedUnix,Accuracy} = data[0]
  111. let modelAcc = JSON.parse(Accuracy)
  112. let size = tranSize(Size)
  113. let time = transTime(CreatedUnix)
  114. let initObj = {
  115. ModelName:Name || '--',
  116. Version:Version,
  117. Label:Label || '--',
  118. Size:size,
  119. CreateTime:time,
  120. Description:Description || '--',
  121. }
  122. let initModelAcc = {
  123. Accuracy: modelAcc.Accuracy || '--',
  124. F1: modelAcc.F1 || '--',
  125. Precision:modelAcc.Precision || '--',
  126. Recall: modelAcc.Recall || '--'
  127. }
  128. return [initObj,initModelAcc,ID]
  129. }
  130. function transTime(time){
  131. let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  132. let Y = date.getFullYear() + '-';
  133. let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
  134. let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  135. let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  136. let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  137. let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  138. return Y+M+D+h+m+s;
  139. }
  140. function tranSize(value){
  141. if(null==value||value==''){
  142. return "0 Bytes";
  143. }
  144. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  145. var index=0;
  146. var srcsize = parseFloat(value);
  147. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  148. var size =srcsize/Math.pow(1024,index);
  149. size=size.toFixed(2);//保留的小数位数
  150. return size+unitArr[index];
  151. }
  152. function editorFn(text,id){
  153. console.log("----",text,id)
  154. $('#edit-td').replaceWith("<div id='edit-div' style='width:80%;display: inline-block;'><textarea id='textarea-value' rows='3' maxlength='255' style='width:80%;' id='edit-text'></textarea><i class='check icon' onclick='editorSure(\"" + text + "\",\"" + id + "\")'></i><i class='times icon' onclick='editorCancel(\"" + text + "\")'></i></div>");
  155. }
  156. function editorCancel(text){
  157. $('#edit-div').replaceWith('<span id="edit-td" class="iword-elipsis">'+text+'</span>')
  158. }
  159. function editorSure(text,id){
  160. console.log("-------text,id",id)
  161. let description=$('#textarea-value').val()
  162. let data = {
  163. ID:id,
  164. Description:description
  165. }
  166. // $.put(`${url}show_model_info_api?name=${ID}`,(data)={
  167. // })
  168. $.ajax({
  169. url:`${url}modify_model`,
  170. type:'PUT',
  171. data:data
  172. }).done((res)=>{console.log(res)})
  173. }
  174. function renderInfo(obj,accObj,id){
  175. let html = ''
  176. html += '<div class="half-table">'
  177. html += '<span class="model_header_text">基本信息</span>'
  178. html += '<table class="tableStyle" style="margin-top:20px;">'
  179. html += '<tbody>'
  180. for(let key in obj){
  181. html += '<tr style="font-size: 12px;">'
  182. html += `<td class="ti-text-form-label text-width80">${key}</td>`
  183. if(key==="Description"){
  184. let description = obj[key]
  185. html += '<td class="ti-text-form-content" ><span id="edit-td" class="iword-elipsis">'+description+'</span><i class="pencil alternate icon" style="cursor:pointer;vertical-align: top;" id="editor" onclick="editorFn(\'' + description + '\',\'' + id + '\')"></td>'
  186. // html += '<td class="ti-text-form-content iword-elipsis"><i class="pencil alternate icon" style="cursor:pointer" id="editor" onclick="editorFn()"></i></td>'
  187. }else{
  188. html += `<td class="ti-text-form-content word-elipsis">${obj[key]}</td>`
  189. }
  190. html += '</tr>'
  191. }
  192. html += '</tbody>'
  193. html += '</table>'
  194. html += '</div>'
  195. html += '<div class="half-table">'
  196. html += '<span class="model_header_text">模型精度</span>'
  197. html += '<table class="tableStyle" style="margin-top:20px;">'
  198. html += '<tbody>'
  199. for(let key in accObj){
  200. html += '<tr style="font-size: 12px;">'
  201. html += `<td class="ti-text-form-label text-width80">${key}</td>`
  202. html += `<td class="ti-text-form-content">${accObj[key]}</td>`
  203. html += '</tr>'
  204. }
  205. html += '</tbody>'
  206. html += '</table>'
  207. html += '</div>'
  208. html += '<div style="clear: both;"></div>'
  209. $('#showInfo').append(html)
  210. }
  211. </script>