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 21 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. {{template "base/alert" .}}
  179. <!-- 中间云脑和新建任务按钮 -->
  180. <div class="ui two column stackable grid ">
  181. <div class="column">
  182. <div class="ui blue small menu compact selectcloudbrain">
  183. <a class="active item" href="{{.RepoLink}}/modelarts/notebook">{{$.i18n.Tr "repo.modelarts.notebook"}}</a>
  184. <a class="item" href="{{.RepoLink}}/modelarts/train-job">{{$.i18n.Tr "repo.modelarts.train_job"}}</a>
  185. </div>
  186. </div>
  187. <div class="column right aligned">
  188. <div class="ui selection dropdown" style="min-width: 10em;min-height:2.6em;border-radius: .28571429rem;margin-right: 1em;padding: .67em 3.2em .7em 1em;">
  189. {{svg "octicon-server" 16}}
  190. <div class="default text" style="color: rgba(0,0,0,.87);"> Ascend NPU</div>
  191. <i class="dropdown icon"></i>
  192. <div class="menu">
  193. <a class="item" href="{{.RepoLink}}/cloudbrain" data-value="11">CPU / GPU</a>
  194. <a class="item" href="{{.RepoLink}}/modelarts/notebook" data-value="22">Ascend NPU</a>
  195. </div>
  196. </div>
  197. {{if .Permission.CanWrite $.UnitTypeCloudBrain}}
  198. <a class="ui green button" href="{{.RepoLink}}/modelarts/notebook/create">{{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}</a>{{end}}
  199. </div>
  200. </div>
  201. <!-- 中下列表展示区 -->
  202. <div class="ui grid">
  203. <div class="row">
  204. <div class="ui sixteen wide column">
  205. <!-- 排序区 -->
  206. <!-- <div class="ui sixteen wide column">
  207. <div class="ui two column stackable grid">
  208. <div class="column">
  209. </div>
  210. <div class="column right aligned">
  211. <div class="ui right dropdown type jump item">
  212. <span class="text">
  213. {{.i18n.Tr "repo.issues.filter_sort"}}<i class="dropdown icon"></i>
  214. </span>
  215. </div>
  216. </div>
  217. </div>
  218. </div> -->
  219. <!-- 任务展示 -->
  220. <div class="dataset list">
  221. <!-- 表头 -->
  222. <div class="ui grid stackable" style="background: #f0f0f0;;">
  223. <div class="row">
  224. <div class="six wide column">
  225. <span style="margin:0 6px">{{$.i18n.Tr "repo.cloudbrain_task"}}</span>
  226. </div>
  227. <div class="three wide column">
  228. <span>{{$.i18n.Tr "repo.cloudbrain_status_createtime"}}</span>
  229. </div>
  230. <div class="two wide column text center">
  231. <span>{{$.i18n.Tr "repo.cloudbrain_creator"}}</span>
  232. </div>
  233. <div class="five wide column text center">
  234. <span style="margin-left: 5rem;">{{$.i18n.Tr "repo.cloudbrain_operate"}}</span>
  235. </div>
  236. </div>
  237. </div>
  238. {{range .Tasks}}
  239. <div class="ui grid stackable item">
  240. <div class="row">
  241. <!-- 任务名 -->
  242. <div class="six wide column">
  243. <a class="title" href="{{$.Link}}/{{.JobID}}" title="{{.JobName}}" style="font-size: 15px;">
  244. <span class="fitted" style="vertical-align: middle;">{{svg "octicon-tasklist" 16}}</span>
  245. <span class="fitted" style="width: 90%;vertical-align: middle;margin-left: 0.4rem;">{{.JobName}}</span>
  246. </a>
  247. </div>
  248. <div class="three wide column">
  249. <!--任务状态 -->
  250. <!-- <span class="ui compact button job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}">
  251. {{.Status}}
  252. </span> -->
  253. <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}">
  254. <span><i id="{{.JobID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.JobID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span>
  255. </span>
  256. <!-- 任务创建时间 -->
  257. <span style="font-size: 12px;margin-left: 0.4rem;" class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span>
  258. </div>
  259. <div class="two wide column text center">
  260. {{if .User.Name}}
  261. <a href="{{AppSubUrl}}/{{.User.Name}}" title="{{.User.Name}}"><img class="ui avatar image" src="{{.User.RelAvatarLink}}"></a>
  262. {{else}}
  263. <a title="Ghost"><img class="ui avatar image" src="{{AppSubUrl}}/user/avatar/Ghost/-1"></a>
  264. {{end}}
  265. </div>
  266. <div class="five wide column text right">
  267. <div class="ui compact buttons">
  268. <!-- <a class="ui basic blue button" href="{{$.Link}}/{{.JobID}}">
  269. 查看
  270. </a> -->
  271. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  272. <a id="model-debug-{{.JobID}}" style="margin-right: 2rem;" class="ui basic {{if not .CanDebug}}disabled {{else}}blue {{end}}button" href="{{$.Link}}/{{.JobID}}/debug" target="_blank">
  273. {{$.i18n.Tr "repo.debug"}}
  274. </a>
  275. {{else}}
  276. <a style="margin-right: 2rem;" class="ui basic disabled button" href="{{$.Link}}/{{.JobID}}/debug" target="_blank">
  277. {{$.i18n.Tr "repo.debug"}}
  278. </a>
  279. {{end}}
  280. <form id="stopForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/stop" method="post" style="margin-left:-1px;">
  281. {{$.CsrfTokenHtml}}
  282. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  283. <a id="stop-model-debug-{{.JobID}}" style="margin-right: 2rem;" class="ui basic {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "WAITING" "STARTING"}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
  284. {{$.i18n.Tr "repo.stop"}}
  285. </a>
  286. {{else}}
  287. <a style="margin-right: 2rem;" class="ui basic disabled button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
  288. {{$.i18n.Tr "repo.stop"}}
  289. </a>
  290. {{end}}
  291. </form>
  292. </div>
  293. <!-- <div class="ui compact buttons" style="margin-right:10px;"> -->
  294. <!-- 模型下载 -->
  295. <!-- <a class="ui basic blue button" href="{{$.Link}}/{{.JobID}}/models" target="_blank">
  296. 模型下载
  297. </a> -->
  298. <!-- 接收结果 -->
  299. <!-- <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe>
  300. <a class="imageBtn ui basic {{if not .CanDebug}}disabled {{else}}blue {{end}}button" value="{{.CanDebug}}">提交镜像</a> -->
  301. <!-- </div> -->
  302. <!-- 删除任务 -->
  303. <form class="ui compact buttons" id="delForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/del" method="post">
  304. {{$.CsrfTokenHtml}}
  305. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  306. <a id="model-delete-{{.JobID}}" class="ui compact {{if eq .Status "RUNNING" "CREATING" "WAITING" "STARTING" "STOPPING" }}disabled {{else}}red {{end}}button" onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  307. {{$.i18n.Tr "repo.delete"}}
  308. </a>
  309. {{else}}
  310. <a class="ui compact disabled button" onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  311. {{$.i18n.Tr "repo.delete"}}
  312. </a>
  313. {{end}}
  314. </form>
  315. </div>
  316. </div>
  317. </div>
  318. {{end}} {{template "base/paginate" .}}
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. <!-- 确认模态框 -->
  328. <div id="deletemodel">
  329. <div class="ui basic modal">
  330. <div class="ui icon header">
  331. <i class="trash icon"></i> 删除任务
  332. </div>
  333. <div class="content">
  334. <p>你确认删除该任务么?此任务一旦删除不可恢复。</p>
  335. </div>
  336. <div class="actions">
  337. <div class="ui red basic inverted cancel button">
  338. <i class="remove icon"></i> 取消操作
  339. </div>
  340. <div class="ui green basic inverted ok button">
  341. <i class="checkmark icon"></i> 确定操作
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. </div>
  347. {{template "base/footer" .}}
  348. <script>
  349. // 调试和评分新开窗口
  350. function stop(obj) {
  351. if (obj.style.color != "rgb(204, 204, 204)") {
  352. obj.target = '_blank'
  353. } else {
  354. return
  355. }
  356. }
  357. // 删除时用户确认
  358. function assertDelete(obj) {
  359. if (obj.style.color == "rgb(204, 204, 204)") {
  360. return
  361. } else {
  362. var delId = obj.parentNode.id
  363. flag = 1;
  364. $('.ui.basic.modal')
  365. .modal({
  366. onDeny: function() {
  367. flag = false
  368. },
  369. onApprove: function() {
  370. document.getElementById(delId).submit()
  371. flag = true
  372. },
  373. onHidden: function() {
  374. if (flag == false) {
  375. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  376. }
  377. }
  378. })
  379. .modal('show')
  380. }
  381. }
  382. // 加载任务状态
  383. var timeid = window.setInterval(loadJobStatus, 15000);
  384. $(document).ready(loadJobStatus);
  385. function loadJobStatus() {
  386. $(".job-status").each((index, job) => {
  387. const jobID = job.dataset.jobid;
  388. const repoPath = job.dataset.repopath;
  389. if (job.textContent.trim() == 'STOPPED' || job.textContent.trim() == 'START_FAILED' || job.textContent.trim() == 'CREATE_FAILED') {
  390. return
  391. }
  392. $.get(`/api/v1/repos/${repoPath}/modelarts/notebook/${jobID}`, (data) => {
  393. const jobID = data.JobID
  394. const status = data.JobStatus
  395. if (status != job.textContent.trim()) {
  396. $('#' + jobID+'-icon').removeClass().addClass(status)
  397. $('#' + jobID+ '-text').text(status)
  398. //if (status == 'STOPPED') {
  399. // window.location.reload()
  400. //}
  401. }
  402. if(status==="RUNNING"){
  403. $('#model-debug-'+jobID).removeClass('disabled')
  404. $('#model-debug-'+jobID).addClass('blue')
  405. }
  406. if(status!=="RUNNING"){
  407. $('#model-debug-'+jobID).removeClass('blue')
  408. $('#model-debug-'+jobID).addClass('disabled')
  409. }
  410. if(status!=="STOPPED" || status!=="FAILED"){
  411. // $('#stop-model-debug-'+jobID).removeClass('disabled')
  412. // $('#stop-model-debug-'+jobID).addClass('blue')
  413. // $('#model-delete-'+jobID).removeClass('red')
  414. // $('#model-delete-'+jobID).addClass('disabled')
  415. }
  416. if(status=="STOPPED" || status=="FAILED" ){
  417. $('#stop-model-debug-'+jobID).removeClass('blue')
  418. $('#stop-model-debug-'+jobID).addClass('disabled')
  419. $('#model-delete-'+jobID).removeClass('disabled')
  420. $('#model-delete-'+jobID).addClass('red')
  421. }
  422. if(status=="START_FAILED"){
  423. $('#stop-model-debug-'+jobID).removeClass('blue')
  424. $('#stop-model-debug-'+jobID).addClass('disabled')
  425. $('#model-delete-'+jobID).removeClass('disabled')
  426. $('#model-delete-'+jobID).addClass('red')
  427. }
  428. }).fail(function(err) {
  429. console.log(err);
  430. });
  431. });
  432. };
  433. // 获取弹窗
  434. var modal = document.getElementById('imageModal');
  435. // 打开弹窗的按钮对象
  436. var btns = document.getElementsByClassName("imageBtn");
  437. // 获取 <span> 元素,用于关闭弹窗
  438. var spans = document.getElementsByClassName('close');
  439. // 点击按钮打开弹窗
  440. for (i = 0; i < btns.length; i++) {
  441. btns[i].onclick = function() {
  442. modal.style.display = "block";
  443. }
  444. }
  445. // 点击 <span> (x), 关闭弹窗
  446. for (i = 0; i < spans.length; i++) {
  447. spans[i].onclick = function() {
  448. modal.style.display = "none";
  449. }
  450. }
  451. // 在用户点击其他地方时,关闭弹窗
  452. window.onclick = function(event) {
  453. if (event.target == modal) {
  454. modal.style.display = "none";
  455. }
  456. }
  457. // 显示弹窗,弹出相应的信息
  458. function showmask() {
  459. $('#imageModal').css('display', 'none')
  460. $('#mask').css('display', 'block')
  461. $("iframe[name=iframeContent]").on("load", function() {  
  462. var responseText = $("iframe")[0].contentDocument.body.getElementsByTagName("pre")[0].innerHTML; 
  463. var json1 = JSON.parse(responseText)
  464. $('#mask').css('display', 'none')
  465. parent.location.href
  466. if (json1.result_code === "0") {
  467. $('.alert').html('操作成功!').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  468. } else {
  469. $('.alert').html(json1.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(5000).fadeOut();
  470. }
  471. })
  472. }
  473. </script>