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