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

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