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 8.0 kB

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