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 11 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 class="half-table">
  82. <span class="model_header_text">基本信息</span>
  83. <table class="tableStyle" style="margin-top:20px;">
  84. <tbody>
  85. <tr>
  86. <td class="ti-text-form-label text-width80">模型名称</td>
  87. <td class="ti-text-form-content word-elipsis"><span id="ModelName" title=""></span></td>
  88. </tr>
  89. <tr>
  90. <td class="ti-text-form-label text-width80">版本</td>
  91. <td class="ti-text-form-content word-elipsis"><span id="Version" title=""></span></td>
  92. </tr>
  93. <tr>
  94. <td class="ti-text-form-label text-width80">标签</td>
  95. <td class="ti-text-form-content">
  96. <div id="Label">
  97. </div>
  98. </td>
  99. </tr>
  100. <tr>
  101. <td class="ti-text-form-label text-width80">大小</td>
  102. <td class="ti-text-form-content word-elipsis"><span id="Size" title=""></span></td>
  103. </tr>
  104. <tr>
  105. <td class="ti-text-form-label text-width80">创建时间</td>
  106. <td class="ti-text-form-content word-elipsis"><span id="CreateTime" title=""></span></td>
  107. </tr>
  108. <tr>
  109. <td class="ti-text-form-label text-width80">模型描述</td>
  110. <td class="ti-text-form-content" ><div id="edit-td" style="display:flex"><span id="Description" title="" class="iword-elipsis"></span><i id="edit-pencil" data-id="" data-desc="" class="pencil alternate icon" style="cursor:pointer;vertical-align: top;" id="editor" onclick="editorFn(this)"></div></td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. </div>
  115. <div class="half-table">
  116. <span class="model_header_text">模型精度</span>
  117. <table class="tableStyle" style="margin-top:20px;">
  118. <tbody>
  119. <tr>
  120. <td class="ti-text-form-label text-width80">准确率</td>
  121. <td class="ti-text-form-content word-elipsis"><span id="Accuracy" title=""></span></td>
  122. </tr>
  123. <tr>
  124. <td class="ti-text-form-label text-width80">F1</td>
  125. <td class="ti-text-form-content word-elipsis"><span id="F1" title=""></span></td>
  126. </tr>
  127. <tr>
  128. <td class="ti-text-form-label text-width80">精确率</td>
  129. <td class="ti-text-form-content word-elipsis"><span id="Precision" title=""></span></td>
  130. </tr>
  131. <tr>
  132. <td class="ti-text-form-label text-width80">召回率</td>
  133. <td class="ti-text-form-content word-elipsis"><span id="Recall" title=""></span></td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. </div>
  138. <div style="clear: both;"></div>
  139. </div>
  140. </div>
  141. </div>
  142. {{template "base/footer" .}}
  143. <script>
  144. let url = location.href.split('show_model')[0]
  145. let ID = location.search.split('?name=').pop()
  146. $(document).ready(loadInfo);
  147. function changeInfo(version){
  148. $.get(`${url}show_model_info_api?name=${ID}`,(data)=>{
  149. let versionData = data.filter((item)=>{
  150. return item.Version === version
  151. })
  152. let returnArray = []
  153. returnArray = transObj(versionData)
  154. let [initObj,initModelAcc,id] = returnArray
  155. renderInfo(initObj,initModelAcc,id)
  156. })
  157. }
  158. function loadInfo(){
  159. $.get(`${url}show_model_info_api?name=${ID}`,(data)=>{
  160. let html = ''
  161. for (let i=0;i<data.length;i++){
  162. if(!data[i].IsCanOper){
  163. $("#edit-pencil").css("display","none")
  164. }
  165. html += `<option value="${data[i].Version}">${data[i].Version}</option>`
  166. }
  167. $('#dropdown').append(html)
  168. let returnArray = []
  169. returnArray = transObj(data)
  170. let [initObj,initModelAcc,id] = returnArray
  171. renderInfo(initObj,initModelAcc,id)
  172. })
  173. }
  174. function transObj(data){
  175. let {ID,Name,Version,Label,Size,Description,CreatedUnix,Accuracy} = data[0]
  176. let modelAcc = JSON.parse(Accuracy)
  177. let size = tranSize(Size)
  178. let time = transTime(CreatedUnix)
  179. let initObj = {
  180. ModelName:Name || '--',
  181. Version:Version,
  182. Label:Label || '--',
  183. Size:size,
  184. CreateTime:time,
  185. Description:Description || '--',
  186. }
  187. let initModelAcc = {
  188. Accuracy: modelAcc.Accuracy || '--',
  189. F1: modelAcc.F1 || '--',
  190. Precision:modelAcc.Precision || '--',
  191. Recall: modelAcc.Recall || '--'
  192. }
  193. return [initObj,initModelAcc,ID]
  194. }
  195. function transTime(time){
  196. let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  197. let Y = date.getFullYear() + '-';
  198. let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
  199. let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  200. let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  201. let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  202. let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  203. return Y+M+D+h+m+s;
  204. }
  205. function tranSize(value){
  206. if(null==value||value==''){
  207. return "0 Bytes";
  208. }
  209. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  210. var index=0;
  211. var srcsize = parseFloat(value);
  212. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  213. var size =srcsize/Math.pow(1024,index);
  214. size=size.toFixed(2);//保留的小数位数
  215. return size+unitArr[index];
  216. }
  217. function editorFn(context){
  218. let id= context.dataset.id
  219. let text = context.dataset.desc
  220. $('#edit-td').replaceWith("<div id='edit-div' style='width:80%;display: inline-block;'><textarea id='textarea-value' value='' rows='3' maxlength='255' style='width:80%;' id='edit-text'>"+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>");
  221. }
  222. function editorCancel(text,id){
  223. $('#edit-div').replaceWith(`<div id="edit-td" style="display:flex;"><span id="Description" title="${text}" class="iword-elipsis">${text}</span><i id="edit-pencil" data-id="${id}" data-desc="${text}" class="pencil alternate icon" style="cursor:pointer;vertical-align: top;" id="editor" onclick="editorFn(this)"></div>`)
  224. }
  225. function editorSure(text,id){
  226. let description=$('#textarea-value').val()
  227. let data = {
  228. ID:id,
  229. Description:description
  230. }
  231. $.ajax({
  232. url:`${url}modify_model`,
  233. type:'PUT',
  234. data:data
  235. }).done((res)=>{
  236. $('#edit-div').replaceWith(`<div id="edit-td" style="display:flex;"><span id="Description" title="${description}" class="iword-elipsis">${description}</span><i id="edit-pencil" data-id="${id}" data-desc="${description}" class="pencil alternate icon" style="cursor:pointer;vertical-align: top;" id="editor" onclick="editorFn(this)"></div>`)
  237. })
  238. }
  239. function renderInfo(obj,accObj,id){
  240. for(let key in obj){
  241. if(key==="Description"){
  242. $(`#${key}`).text(obj[key])
  243. $(`#${key}`).attr("title",obj[key])
  244. $('#edit-pencil').attr("data-id",id)
  245. $('#edit-pencil').attr("data-desc",obj[key])
  246. }
  247. else if(key==="Label"){
  248. $('#Label').empty()
  249. if(obj[key]==='--'){
  250. $('#Label').text(obj[key])
  251. }else{
  252. let labelArray = obj[key].trim().split(' ')
  253. let html=''
  254. for(let i=0;i<labelArray.length;i++){
  255. html += `<a class="ui label">${labelArray[i]}</a>`
  256. }
  257. $('#Label').append(html)
  258. }
  259. }
  260. else{
  261. $(`#${key}`).text(obj[key])
  262. $(`#${key}`).attr("title",obj[key])
  263. }
  264. }
  265. for(let key in accObj){
  266. $(`#${key}`).text(accObj[key])
  267. $(`#${key}`).attr("title",accObj[key])
  268. }
  269. }
  270. </script>