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.

index.tmpl 18 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
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <!-- 头部导航栏 -->
  2. {{template "base/head" .}}
  3. <style>
  4. .label_after::after{
  5. margin: -.2em 0 0 .2em;
  6. content: '\00a0';
  7. }
  8. .selectcloudbrain .active.item{
  9. color: #0087f5 !important;
  10. border: 1px solid #0087f5;
  11. margin: -1px;
  12. background: #FFF !important;
  13. }
  14. #deletemodel {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. /* 弹窗 */
  19. #mask {
  20. position: fixed;
  21. top: 0px;
  22. left: 0px;
  23. right: 0px;
  24. bottom: 0px;
  25. filter: alpha(opacity=60);
  26. background-color: #777;
  27. z-index: 1000;
  28. display: none;
  29. opacity: 0.8;
  30. -moz-opacity: 0.5;
  31. padding-top: 100px;
  32. color: #000000
  33. }
  34. #loadingPage {
  35. margin: 200px auto;
  36. width: 50px;
  37. height: 40px;
  38. text-align: center;
  39. font-size: 10px;
  40. display: block;
  41. }
  42. #loadingPage>div {
  43. background-color: green;
  44. height: 100%;
  45. width: 6px;
  46. display: inline-block;
  47. -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
  48. animation: sk-stretchdelay 1.2s infinite ease-in-out;
  49. }
  50. #loadingPage .rect2 {
  51. -webkit-animation-delay: -1.1s;
  52. animation-delay: -1.1s;
  53. }
  54. #loadingPage .rect3 {
  55. -webkit-animation-delay: -1.0s;
  56. animation-delay: -1.0s;
  57. }
  58. #loadingPage .rect4 {
  59. -webkit-animation-delay: -0.9s;
  60. animation-delay: -0.9s;
  61. }
  62. #loadingPage .rect5 {
  63. -webkit-animation-delay: -0.8s;
  64. animation-delay: -0.8s;
  65. }
  66. @-webkit-keyframes sk-stretchdelay {
  67. 0%,
  68. 40%,
  69. 100% {
  70. -webkit-transform: scaleY(0.4)
  71. }
  72. 20% {
  73. -webkit-transform: scaleY(1.0)
  74. }
  75. }
  76. @keyframes sk-stretchdelay {
  77. 0%,
  78. 40%,
  79. 100% {
  80. transform: scaleY(0.4);
  81. -webkit-transform: scaleY(0.4);
  82. }
  83. 20% {
  84. transform: scaleY(1.0);
  85. -webkit-transform: scaleY(1.0);
  86. }
  87. }
  88. /* 消息框 */
  89. .alert {
  90. display: none;
  91. position: fixed;
  92. width: 100%;
  93. z-index: 1001;
  94. padding: 15px;
  95. border: 1px solid transparent;
  96. border-radius: 4px;
  97. text-align: center;
  98. font-weight: bold;
  99. }
  100. .alert-success {
  101. color: #3c763d;
  102. background-color: #dff0d8;
  103. border-color: #d6e9c6;
  104. }
  105. .alert-info {
  106. color: #31708f;
  107. background-color: #d9edf7;
  108. border-color: #bce8f1;
  109. }
  110. .alert-warning {
  111. color: #8a6d3b;
  112. background-color: #fcf8e3;
  113. border-color: #faebcc;
  114. }
  115. .alert-danger {
  116. color: #a94442;
  117. background-color: #f2dede;
  118. border-color: #ebccd1;
  119. }
  120. .pusher {
  121. width: calc(100% - 260px);
  122. box-sizing: border-box;
  123. }
  124. /* 弹窗 (background) */
  125. #imageModal {
  126. display: none;
  127. position: fixed;
  128. z-index: 1;
  129. left: 0;
  130. top: 0;
  131. width: 100%;
  132. height: 100%;
  133. overflow: auto;
  134. background-color: rgb(0, 0, 0);
  135. background-color: rgba(0, 0, 0, 0.4);
  136. }
  137. /* 弹窗内容 */
  138. .modal-content {
  139. background-color: #fefefe;
  140. margin: 15% auto;
  141. padding: 20px;
  142. border: 1px solid #888;
  143. width: 30%;
  144. }
  145. /* 关闭按钮 */
  146. .close {
  147. color: #aaa;
  148. float: right;
  149. font-size: 28px;
  150. font-weight: bold;
  151. }
  152. .close:hover,
  153. .close:focus {
  154. color: black;
  155. text-decoration: none;
  156. cursor: pointer;
  157. }
  158. .dis {
  159. margin-bottom: 20px;
  160. }
  161. .disabled {
  162. cursor: pointer;
  163. pointer-events: none;
  164. }
  165. </style>
  166. <!-- 弹窗 -->
  167. <div id="mask">
  168. <div id="loadingPage">
  169. <div class="rect1"></div>
  170. <div class="rect2"></div>
  171. <div class="rect3"></div>
  172. <div class="rect4"></div>
  173. <div class="rect5"></div>
  174. </div>
  175. </div>
  176. <!-- 提示框 -->
  177. <div class="alert"></div>
  178. <div class="repository release dataset-list view">
  179. {{template "repo/header" .}}
  180. <!-- 列表容器 -->
  181. <div class="ui container">
  182. <!-- 中间云脑和新建任务按钮 -->
  183. <div class="ui three column stack able grid">
  184. <div class="column">
  185. <h2>{{.i18n.Tr "repo.cloudbrain1"}}</h2>
  186. </div>
  187. <div class="column">
  188. </div>
  189. <div class="column right aligned">
  190. {{if .Permission.CanWrite $.UnitTypeCloudBrain}}
  191. <a class="ui green button" href="{{.RepoLink}}/cloudbrain/create">{{.i18n.Tr "repo.cloudbrain.new"}}</a> {{end}}
  192. </div>
  193. </div>
  194. <p>使用鹏城云脑计算资源进行调试,云脑1提供CPU / GPU资源,云脑2提供Ascend NPU资源;调试使用的数据集也需要上传到对应的环境。</p>
  195. <div class="ui blue mini menu selectcloudbrain">
  196. <a class="active item" href="{{.RepoLink}}/cloudbrain">{{svg "octicon-server" 16}} CPU / GPU</a>
  197. <a class="item" href="{{.RepoLink}}/modelarts">{{svg "octicon-server" 16}} Ascend NPU</a>
  198. </div>
  199. <!-- 中下列表展示区 -->
  200. <div class="ui grid">
  201. <div class="row">
  202. <div class="ui sixteen wide column">
  203. <!-- 排序区 -->
  204. <div class="ui sixteen wide column">
  205. <div class="ui two column stackable grid">
  206. <div class="column">
  207. </div>
  208. <!-- <div class="column right aligned">
  209. <div class="ui right dropdown type jump item">
  210. <span class="text">
  211. {{.i18n.Tr "repo.issues.filter_sort"}}<i class="dropdown icon"></i>
  212. </span>
  213. </div>
  214. </div> -->
  215. </div>
  216. </div>
  217. <!-- 任务展示 -->
  218. <div class="dataset list">
  219. {{range .Tasks}}
  220. <div class="ui grid stackable item">
  221. <div class="row">
  222. <!-- 任务名 -->
  223. <div class="four wide column">
  224. <a class="title" href="{{$.Link}}/{{.JobID}}">
  225. <span class="fitted">{{svg "octicon-tasklist" 16}}</span>
  226. <span class="fitted">{{.JobName}}</span>
  227. </a>
  228. </div>
  229. <!--任务状态 -->
  230. <div class="two wide column job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}">
  231. {{.Status}}
  232. </div>
  233. <!-- 任务创建时间 -->
  234. <div class="three wide column">
  235. <span class="ui text center">{{svg "octicon-flame" 16}} {{TimeSinceUnix .CreatedUnix $.Lang}}</span>
  236. </div>
  237. <!-- 评分 -->
  238. <div class="one wide column">
  239. <div class="ui text center clipboard">
  240. <a class="title" onclick="stop(this)" href="{{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}{{$.Link}}/{{.JobID}}/rate{{else}}javascript:void(0);{{end}}" style="{{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}{{else}}color:#CCCCCC{{end}}">
  241. <span class="fitted">评分</span>
  242. </a>
  243. </div>
  244. </div>
  245. <!-- 删除镜像 -->
  246. <div class="one wide column">
  247. <div class="ui text center clipboard">
  248. <form id="delForm-{{.JobID}}" action="{{if ne .Status "STOPPED"}}javascript:void(0){{else}}{{$.Link}}/{{.JobID}}/del{{end}}" method="post">
  249. {{$.CsrfTokenHtml}}
  250. <a class="fitted" onclick="assertDelete(this)" style="{{if ne .Status "STOPPED"}}color:#CCCCCC{{end}}; font-size:16px; font-weight:bold">删除</a>
  251. </form>
  252. </div>
  253. </div>
  254. <!-- 调试 -->
  255. <div class="one wide column">
  256. <div class="ui text center clipboard">
  257. <a class="title" onclick="stop(this)" href="{{if not .CanDebug}}javascript:void(0){{else}}{{$.Link}}/{{.JobID}}/debug{{end}}" style="{{if not .CanDebug}}color:#CCCCCC{{end}}">
  258. <span class="fitted">调试</span>
  259. </a>
  260. </div>
  261. </div>
  262. <!-- 停止 -->
  263. <div class="one wide column">
  264. <div class="ui text center clipboard">
  265. <form id="stopForm-{{.JobID}}" action="{{if eq .Status "STOPPED"}}javascript:void(0){{else}}{{$.Link}}/{{.JobID}}/stop{{end}}" method="post">
  266. {{$.CsrfTokenHtml}}
  267. <a class="fitted" onclick="document.getElementById('stopForm-{{.JobID}}').submit();" style="{{if eq .Status "STOPPED"}}color:#CCCCCC{{end}}; font-size:16px; font-weight:bold">停止</a>
  268. </form>
  269. </div>
  270. </div>
  271. <!-- 模型下载 -->
  272. <div class="two wide column">
  273. <span class="ui text clipboard">
  274. <a class="title" href="{{$.Link}}/{{.JobID}}/models">
  275. <span class="fitted">模型下载</span>
  276. </a>
  277. </span>
  278. </div>
  279. <!-- 接收结果 -->
  280. <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe>
  281. <a class="imageBtn" style="{{if not .CanDebug}}color:#CCCCCC;cursor:pointer;pointer-events:none;{{end}}; font-size:16px; font-weight:bold" value="{{.CanDebug}}">提交镜像</a>
  282. <!-- 镜像列表弹窗 -->
  283. <div id="imageModal" class="modal" style="display: none;">
  284. <div class="modal-content">
  285. <!-- 表格 -->
  286. <div class="ui form">
  287. <form id="commitImageForm" action="{{$.Link}}/{{.JobID}}/commit_image" method="post" target="iframeContent">
  288. {{$.CsrfTokenHtml}}
  289. <div class="row">
  290. <p style="display: inline;">提交任务镜像</p>
  291. <span class="close">&times;</span>
  292. </div>
  293. <div class="ui divider"></div>
  294. <div class="inline required field dis">
  295. <label>镜像标签:</label>
  296. <input name="tag" id="image_tag" tabindex="3" autofocus required maxlength="255" style="width:75%">
  297. </div>
  298. <div class="inline field">
  299. <label class="label_after">镜像描述:</label>
  300. <textarea name="description" rows="8" style="width:75%;margin-left: 0.2em;"></textarea>
  301. </div>
  302. <div class="ui divider"></div>
  303. <div class="inline field">
  304. <label></label>
  305. <button class="ui green button" onclick="showmask()">
  306. {{$.i18n.Tr "repo.cloudbrain.commit_image"}}
  307. </button>
  308. </div>
  309. </form>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. {{end}} {{template "base/paginate" .}}
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. </div>
  324. <!-- 确认模态框 -->
  325. <div id="deletemodel">
  326. <div class="ui basic modal">
  327. <div class="ui icon header">
  328. <i class="trash icon"></i> 删除任务
  329. </div>
  330. <div class="content">
  331. <p>你确认删除该任务么?此任务一旦删除不可恢复。</p>
  332. </div>
  333. <div class="actions">
  334. <div class="ui red basic inverted cancel button">
  335. <i class="remove icon"></i> 取消操作
  336. </div>
  337. <div class="ui green basic inverted ok button">
  338. <i class="checkmark icon"></i> 确定操作
  339. </div>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344. {{template "base/footer" .}}
  345. <script>
  346. // 调试和评分新开窗口
  347. function stop(obj) {
  348. if (obj.style.color != "rgb(204, 204, 204)") {
  349. obj.target = '_blank'
  350. } else {
  351. return
  352. }
  353. }
  354. // 删除时用户确认
  355. function assertDelete(obj) {
  356. if (obj.style.color == "rgb(204, 204, 204)") {
  357. return
  358. } else {
  359. var delId = obj.parentNode.id
  360. flag = 1;
  361. $('.ui.basic.modal')
  362. .modal({
  363. onDeny: function() {
  364. flag = false
  365. },
  366. onApprove: function() {
  367. document.getElementById(delId).submit()
  368. flag = true
  369. },
  370. onHidden: function() {
  371. if (flag == false) {
  372. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  373. }
  374. }
  375. })
  376. .modal('show')
  377. }
  378. }
  379. // 加载任务状态
  380. var timeid = window.setInterval(loadJobStatus, 15000);
  381. function loadJobStatus() {
  382. $(".job-status").each((index, job) => {
  383. const jobID = job.dataset.jobid;
  384. const repoPath = job.dataset.repopath;
  385. if (job.textContent.trim() == 'STOPPED') {
  386. return
  387. }
  388. $.get(`/api/v1/repos/${repoPath}/cloudbrain/${jobID}`, (data) => {
  389. const jobID = data.JobID
  390. const status = data.JobStatus
  391. if (status != job.textContent.trim()) {
  392. //$('#' + jobID).text(status)
  393. //if (status == 'STOPPED') {
  394. window.location.reload()
  395. //}
  396. }
  397. }).fail(function(err) {
  398. console.log(err);
  399. });
  400. });
  401. };
  402. // 获取弹窗
  403. var modal = document.getElementById('imageModal');
  404. // 打开弹窗的按钮对象
  405. var btns = document.getElementsByClassName("imageBtn");
  406. // 获取 <span> 元素,用于关闭弹窗
  407. var spans = document.getElementsByClassName('close');
  408. // 点击按钮打开弹窗
  409. for (i = 0; i < btns.length; i++) {
  410. btns[i].onclick = function() {
  411. modal.style.display = "block";
  412. }
  413. }
  414. // 点击 <span> (x), 关闭弹窗
  415. for (i = 0; i < spans.length; i++) {
  416. spans[i].onclick = function() {
  417. modal.style.display = "none";
  418. }
  419. }
  420. // 在用户点击其他地方时,关闭弹窗
  421. window.onclick = function(event) {
  422. if (event.target == modal) {
  423. modal.style.display = "none";
  424. }
  425. }
  426. // 显示弹窗,弹出相应的信息
  427. function showmask() {
  428. var image_tag = !$('#image_tag').val()
  429. console.log("image_tag",image_tag)
  430. if(image_tag){
  431. return
  432. }
  433. $('#imageModal').css('display', 'none')
  434. $('#mask').css('display', 'block')
  435. $("iframe[name=iframeContent]").on("load", function() {  
  436. var responseText = $("iframe")[0].contentDocument.body.getElementsByTagName("pre")[0].innerHTML; 
  437. var json1 = JSON.parse(responseText)
  438. $('#mask').css('display', 'none')
  439. parent.location.href
  440. if (json1.result_code === "0") {
  441. $('.alert').html('操作成功!').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  442. } else {
  443. $('.alert').html(json1.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(5000).fadeOut();
  444. }
  445. })
  446. }
  447. </script>