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 32 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  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. .time-show{
  166. font-size: 10px;
  167. margin-top: 0.4rem;
  168. display: inline-block;
  169. }
  170. </style>
  171. <!-- 弹窗 -->
  172. <div id="mask">
  173. <div id="loadingPage">
  174. <div class="rect1"></div>
  175. <div class="rect2"></div>
  176. <div class="rect3"></div>
  177. <div class="rect4"></div>
  178. <div class="rect5"></div>
  179. </div>
  180. </div>
  181. <div class="repository release dataset-list view">
  182. {{template "repo/header" .}}
  183. <!-- {{template "base/alert" .}} -->
  184. <!-- 提示框 -->
  185. <!-- 列表容器 -->
  186. <div class="ui container">
  187. <div class="ui negative message" style="display: none;">
  188. <i class="close icon"></i>
  189. <p></p>
  190. </div>
  191. <div class="ui two column stackable grid">
  192. <div class="column">
  193. <div class="ui blue small menu compact selectcloudbrain">
  194. <a class="active item" href="{{.RepoLink}}/debugjob?debugListType=all">{{$.i18n.Tr "repo.modelarts.notebook"}}</a>
  195. <a class="item" href="{{.RepoLink}}/modelarts/train-job">{{$.i18n.Tr "repo.modelarts.train_job"}}</a>
  196. </div>
  197. </div>
  198. <div class="column right aligned">
  199. <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;">
  200. {{svg "octicon-server" 16}}
  201. <div class="default text" style="color: rgba(0,0,0,.87);"></div>
  202. <i class="dropdown icon"></i>
  203. <div class="menu">
  204. <div class="item" data-value="all">全部</div>
  205. <div class="item" data-value="CPU/GPU">CPU/GPU</div>
  206. <div class="item" data-value="NPU">NPU</div>
  207. </div>
  208. </div>
  209. {{if .Permission.CanWrite $.UnitTypeCloudBrain}}
  210. <a class="ui green button" href="{{.RepoLink}}/cloudbrain/create">{{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}</a>
  211. {{else}}
  212. <a class="ui disabled button">{{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}</a>
  213. {{end}}
  214. </div>
  215. </div>
  216. {{if eq 0 (len .Tasks)}}
  217. <div class="ui placeholder segment bgtask-none">
  218. <div class="ui icon header bgtask-header-pic"></div>
  219. <div class="bgtask-content-header">未创建过调试任务</div>
  220. <div class="bgtask-content">
  221. {{if $.RepoIsEmpty}}
  222. <div class="bgtask-content-txt">代码版本:您还没有初始化代码仓库,请先<a href="{{.RepoLink}}">创建代码版本</a>;</div>
  223. {{end}}
  224. <div class="bgtask-content-txt">运行时长:最长不超过4个小时,超过4个小时将自动停止;</div>
  225. <div class="bgtask-content-txt">数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;</div>
  226. <div class="bgtask-content-txt">使用说明:可以参考启智AI协作平台<a href="https://git.openi.org.cn/zeizei/OpenI_Learning">小白训练营课程。</a></div>
  227. </div>
  228. </div>
  229. {{else}}
  230. <!-- 中下列表展示区 -->
  231. <div class="ui grid">
  232. <div class="row">
  233. <div class="ui sixteen wide column">
  234. <!-- 任务展示 -->
  235. <!-- 表头 -->
  236. <div class="dataset list">
  237. <div class="ui grid stackable" style="background: #f0f0f0;;">
  238. <div class="row">
  239. <div class="four wide column">
  240. <span style="margin:0 6px">{{$.i18n.Tr "repo.cloudbrain_task"}}</span>
  241. </div>
  242. <div class="two wide column text center">
  243. <span style="margin:0 6px">{{$.i18n.Tr "repo.modelarts.status"}}</span>
  244. </div>
  245. <div class="two wide column text center">
  246. <span>{{$.i18n.Tr "repo.modelarts.createtime"}}</span>
  247. </div>
  248. <div class="two wide column text center">
  249. <span>{{$.i18n.Tr "repo.modelarts.computing_resources"}}</span>
  250. </div>
  251. <div class="one wide column text center">
  252. <span>{{$.i18n.Tr "repo.cloudbrain_creator"}}</span>
  253. </div>
  254. <div class="five wide column text center">
  255. <span>{{$.i18n.Tr "repo.cloudbrain_operate"}}</span>
  256. </div>
  257. </div>
  258. </div>
  259. {{range .Tasks}}
  260. <div class="ui grid stackable item">
  261. <div class="row">
  262. <!-- 任务名 -->
  263. <div class="four wide column">
  264. <a class="title" href='{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}' title="{{.JobName}}" style="font-size: 14px;">
  265. <span class="fitted text_over" style="width: 90%;vertical-align: middle;">{{.JobName}}</span>
  266. </a>
  267. </div>
  268. <div class="two wide column text center">
  269. <!--任务状态 -->
  270. <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-resource="{{.ComputeResource}}">
  271. <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>
  272. </span>
  273. </div>
  274. <div class="two wide column text center">
  275. <!-- 任务创建时间 -->
  276. <span style="font-size: 12px;margin-left: 0.4rem;" class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span>
  277. </div>
  278. <div class="two wide column text center">
  279. <!-- 任务计算资源 -->
  280. <span style="font-size: 12px;margin-left: 0.4rem;" class="">{{.ComputeResource}}</span>
  281. </div>
  282. <div class="one wide column text center">
  283. {{if .User.Name}}
  284. <a href="{{AppSubUrl}}/{{.User.Name}}" title="{{.User.Name}}"><img class="ui avatar image" src="{{.User.RelAvatarLink}}"></a>
  285. {{else}}
  286. <a title="Ghost"><img class="ui avatar image" src="{{AppSubUrl}}/user/avatar/Ghost/-1"></a>
  287. {{end}}
  288. </div>
  289. <div class="five wide column text center">
  290. <div class="ui compact buttons">
  291. <!-- {{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}
  292. <a class="ui basic button" href="{{$.Link}}/{{.JobID}}/rate" target="_blank">
  293. 评分
  294. </a>
  295. {{end}} -->
  296. <!-- 调试 -->
  297. <form id="debugAgainForm-{{.JobID}}">
  298. {{$.CsrfTokenHtml}}
  299. {{if .CanDebug}}
  300. {{if eq .Status "RUNNING"}}
  301. <a style="margin: 0 1rem;" id="model-debug-{{.JobID}}" class='ui basic blue button' onclick='debugAgain("{{.JobID}}","{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}/")'>
  302. {{$.i18n.Tr "repo.debug"}}
  303. </a>
  304. {{else}}
  305. <a id="model-debug-{{.JobID}}" class='ui basic {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING"}} disabled {{else}}blue {{end}}button' onclick='debugAgain("{{.JobID}}","{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}/")'>
  306. {{$.i18n.Tr "repo.debug_again"}}
  307. </a>
  308. {{end}}
  309. {{else}}
  310. <a class="ui basic disabled button">
  311. {{$.i18n.Tr "repo.debug_again"}}
  312. </a>
  313. {{end}}
  314. </form>
  315. <!-- 停止 -->
  316. <form id="stopForm-{{.JobID}}" style="margin-left:-1px;">
  317. {{$.CsrfTokenHtml}}
  318. {{if .CanDel}}
  319. {{if eq .ComputeResource "CPU/GPU" }}
  320. <a id="stop-model-debug-{{.JobID}}" class='ui basic {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING"}}disabled {{else}}blue {{end}}button' onclick='stopDebug("{{.JobID}}","{{$.RepoLink}}/cloudbrain/{{.JobID}}/stop")'>
  321. {{$.i18n.Tr "repo.stop"}}
  322. </a>
  323. {{else}}
  324. <a id="stop-model-debug-{{.JobID}}" class='ui basic {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING"}}disabled {{else}}blue {{end}}button' onclick='stopDebug("{{.JobID}}","{{$.RepoLink}}/modelarts/notebook/{{.JobID}}/stop")'>
  325. {{$.i18n.Tr "repo.stop"}}
  326. </a>
  327. {{end}}
  328. {{else}}
  329. <a class="ui basic disabled button">
  330. {{$.i18n.Tr "repo.stop"}}
  331. </a>
  332. {{end}}
  333. </form>
  334. <!-- 删除 -->
  335. <form id="delForm-{{.JobID}}" action="{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}/del" method="post">
  336. <input type="hidden" name="debugListType" value="all">
  337. {{$.CsrfTokenHtml}}
  338. {{if .CanDel}}
  339. <a id="model-delete-{{.JobID}}" class='ui basic {{if eq .Status "STOPPED" "FAILED" "START_FAILED"}}blue {{else}}disabled {{end}}button' onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  340. {{$.i18n.Tr "repo.delete"}}
  341. </a>
  342. {{else}}
  343. <a class="ui basic button disabled" onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  344. {{$.i18n.Tr "repo.delete"}}
  345. </a>
  346. {{end}}
  347. </form>
  348. </div>
  349. <!-- 删除任务 -->
  350. <div class="ui compact buttons" style="{{if eq .ComputeResource "CPU/GPU"}} visibility: visible {{else}} visibility: hidden{{end}}">
  351. <div class="ui dropdown" id="model_more" style="padding: .58928571em 1.125em .58928571em;">
  352. <div class="text">更多</div>
  353. <i class="dropdown icon"></i>
  354. <div class="menu" style="right: auto;">
  355. <div class="item" style="padding: 0 !important;">
  356. <!-- 接收结果 -->
  357. <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe>
  358. {{if .CanDel}}
  359. <a id="model-image-{{.JobID}}" class='imageBtn ui basic {{if ne .Status "RUNNING"}}disabled {{else}}blue {{end}}button'>{{$.i18n.Tr "repo.submit_image"}}</a>
  360. {{else}}
  361. <a class="imageBtn ui basic disabled button">{{$.i18n.Tr "repo.submit_image"}}</a>
  362. {{end}}
  363. </div>
  364. <div class="item" style="padding: 0 !important;">
  365. <!-- 模型下载 -->
  366. {{if .CanDel}}
  367. <a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.JobID}}/models" target="_blank">{{$.i18n.Tr "repo.download"}}</a>
  368. {{else}}
  369. <a class="ui basic disabled button">{{$.i18n.Tr "repo.download"}}</a>
  370. {{end}}
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. </div>
  376. <!-- 镜像列表弹窗 -->
  377. <div id="imageModal" class="modal" style="display: none;">
  378. <div class="modal-content">
  379. <!-- 表格 -->
  380. <div class="ui form">
  381. <form id="commitImageForm" action="{{$.RepoLink}}/cloudbrain/{{.JobID}}/commit_image" method="post" target="iframeContent">
  382. {{$.CsrfTokenHtml}}
  383. <div class="row">
  384. <p style="display: inline;">提交任务镜像</p>
  385. <span class="close">&times;</span>
  386. </div>
  387. <div class="ui divider"></div>
  388. <div class="inline required field dis">
  389. <label>镜像标签:</label>
  390. <input name="tag" id="image_tag" tabindex="3" autofocus required maxlength="254" style="width:75%">
  391. </div>
  392. <div class="inline field">
  393. <label class="label_after">镜像描述:</label>
  394. <textarea name="description" maxlength="254" rows="8" style="width:75%;margin-left: 0.2em;"></textarea>
  395. </div>
  396. <div class="ui divider"></div>
  397. <div class="inline field">
  398. <label></label>
  399. <button class="ui green button" onclick="showmask()">
  400. {{$.i18n.Tr "repo.cloudbrain.commit_image"}}
  401. </button>
  402. </div>
  403. </form>
  404. </div>
  405. </div>
  406. </div>
  407. </div>
  408. </div>
  409. {{end}} {{template "base/paginate" .}}
  410. </div>
  411. </div>
  412. </div>
  413. </div>
  414. {{end}}
  415. </div>
  416. </div>
  417. </div>
  418. </div>
  419. <!-- 确认模态框 -->
  420. <div id="deletemodel">
  421. <div class="ui basic modal">
  422. <div class="ui icon header">
  423. <i class="trash icon"></i> 删除任务
  424. </div>
  425. <div class="content">
  426. <p>你确认删除该任务么?此任务一旦删除不可恢复。</p>
  427. </div>
  428. <div class="actions">
  429. <div class="ui red basic inverted cancel button">
  430. <i class="remove icon"></i> 取消操作
  431. </div>
  432. <div class="ui green basic inverted ok button">
  433. <i class="checkmark icon"></i> 确定操作
  434. </div>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. {{template "base/footer" .}}
  440. <script>
  441. // 调试和评分新开窗口
  442. const {AppSubUrl, StaticUrlPrefix, csrf} = window.config;
  443. let url={{.RepoLink}}
  444. let getParam=getQueryVariable('debugListType')
  445. let dropdownValue = getParam==='all'||getParam==='' ? '全部' : getParam
  446. localStorage.setItem('all',location.href)
  447. function getQueryVariable(variable)
  448. {
  449. let query = window.location.search.substring(1);
  450. let vars = query.split("&");
  451. for (let i=0;i<vars.length;i++) {
  452. let pair = vars[i].split("=");
  453. if(pair[0] == variable){return pair[1];}
  454. }
  455. return(false);
  456. }
  457. function stop(obj) {
  458. if (obj.style.color != "rgb(204, 204, 204)") {
  459. obj.target = '_blank'
  460. } else {
  461. return
  462. }
  463. }
  464. // 删除时用户确认
  465. function assertDelete(obj) {
  466. if (obj.style.color == "rgb(204, 204, 204)") {
  467. return
  468. } else {
  469. var delId = obj.parentNode.id
  470. flag = 1;
  471. $('.ui.basic.modal')
  472. .modal({
  473. onDeny: function() {
  474. flag = false
  475. },
  476. onApprove: function() {
  477. document.getElementById(delId).submit()
  478. flag = true
  479. },
  480. onHidden: function() {
  481. if (flag == false) {
  482. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  483. }
  484. }
  485. })
  486. .modal('show')
  487. }
  488. }
  489. function debugAgain(JobID,debugUrl){
  490. if($('#' + JobID+ '-text').text()==="RUNNING"){
  491. window.open(debugUrl+'debug')
  492. }else{
  493. $.ajax({
  494. type:"POST",
  495. url:debugUrl+'restart',
  496. data:$('#debugAgainForm-'+JobID).serialize(),
  497. success:function(res){
  498. if(res.result_code==="0"){
  499. if(res.job_id!==JobID){
  500. location.reload()
  501. }else{
  502. $('#' + JobID+'-icon').removeClass().addClass(res.status)
  503. $('#' + JobID+ '-text').text(res.status)
  504. $('#model-debug-'+JobID).removeClass('blue').addClass('disabled')
  505. $('#model-delete-'+JobID).removeClass('blue').addClass('disabled')
  506. }
  507. }else{
  508. $(".ui.negative.message").css("display","block")
  509. $(".ui.negative.message p").text(res.error_msg)
  510. setTimeout("$('.message .close').click()",3000)
  511. }
  512. },
  513. error :function(res){
  514. console.log(res)
  515. }
  516. })
  517. }
  518. }
  519. function stopDebug(JobID,stopUrl){
  520. $.ajax({
  521. type:"POST",
  522. url:stopUrl,
  523. data:$('#stopForm-'+JobID).serialize(),
  524. success:function(res){
  525. if(res.result_code==="0"){
  526. $('#' + JobID+'-icon').removeClass().addClass(res.status)
  527. $('#' + JobID+ '-text').text(res.status)
  528. if(res.status==="STOPPED"){
  529. $('#model-debug-'+JobID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0")
  530. $('#model-image-'+JobID).removeClass('blue').addClass('disabled')
  531. $('#stop-model-debug-'+JobID).removeClass('blue').addClass('disabled')
  532. $('#model-delete-'+JobID).removeClass('disabled').addClass('blue')
  533. }
  534. else{
  535. $('#model-debug-'+JobID).removeClass('blue').addClass('disabled')
  536. $('#stop-model-debug-'+JobID).removeClass('blue').addClass('disabled')
  537. }
  538. }else{
  539. $("ui.negative.message").text(res.error_msg)
  540. }
  541. },
  542. error :function(res){
  543. console.log(res)
  544. }
  545. })
  546. }
  547. // 加载任务状态
  548. var timeid = window.setInterval(loadJobStatus, 15000);
  549. $(document).ready(loadJobStatus);
  550. function loadJobStatus() {
  551. $(".job-status").each((index, job) => {
  552. const jobID = job.dataset.jobid;
  553. const repoPath = job.dataset.repopath;
  554. const computeResource = job.dataset.resource
  555. const initArray = ['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED']
  556. if (initArray.includes(job.textContent.trim())) {
  557. return
  558. }
  559. const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain'
  560. $.get(`/api/v1/repos/${repoPath}/${diffResource}/${jobID}`, (data) => {
  561. const jobID = data.JobID
  562. const status = data.JobStatus
  563. if (status != job.textContent.trim()) {
  564. $('#' + jobID+'-icon').removeClass().addClass(status)
  565. $('#' + jobID+ '-text').text(status)
  566. }
  567. if(status==="RUNNING"){
  568. $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem")
  569. $('#model-image-'+jobID).removeClass('disabled').addClass('blue')
  570. }
  571. if(status!=="RUNNING"){
  572. // $('#model-debug-'+jobID).removeClass('blue')
  573. // $('#model-debug-'+jobID).addClass('disabled')
  574. $('#model-image-'+jobID).removeClass('blue').addClass('disabled')
  575. }
  576. if(["CREATING","STOPPING","WAITING","STARTING"].includes(status)){
  577. $('#model-debug-'+jobID).removeClass('blue').addClass('disabled')
  578. }
  579. if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){
  580. $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0")
  581. }
  582. if(["RUNNING","WAITING"].includes(status)){
  583. $('#stop-model-debug-'+jobID).removeClass('disabled').addClass('blue')
  584. }
  585. if(["CREATING","STOPPING","STARTING","STOPPED","FAILED","START_FAILED"].includes(status)){
  586. $('#stop-model-debug-'+jobID).removeClass('blue').addClass('disabled')
  587. }
  588. if(status==="STOPPED" || status==="FAILED"|| status==="START_FAILED"){
  589. $('#model-delete-'+jobID).removeClass('disabled').addClass('blue')
  590. }else{
  591. $('#model-delete-'+jobID).removeClass('blue').addClass('disabled')
  592. }
  593. }).fail(function(err) {
  594. console.log(err);
  595. });
  596. });
  597. };
  598. $(document).ready(function(){
  599. dropdownValue = dropdownValue==="CPU%2FGPU"? 'CPU/GPU' : dropdownValue
  600. $('.default.text').text(dropdownValue)
  601. $('.ui.dropdown')
  602. .dropdown({
  603. action: 'hide',
  604. })
  605. $('.ui.selection.dropdown').dropdown({
  606. onChange:function(value){
  607. location.href = `${url}/debugjob?debugListType=${value}`
  608. }
  609. })
  610. $('.message .close')
  611. .on('click', function() {
  612. $(this)
  613. .closest('.message')
  614. .transition('fade')
  615. })
  616. })
  617. // 获取弹窗
  618. var modal = document.getElementById('imageModal');
  619. // 打开弹窗的按钮对象
  620. var btns = document.getElementsByClassName("imageBtn");
  621. // 获取 <span> 元素,用于关闭弹窗
  622. var spans = document.getElementsByClassName('close');
  623. // 点击按钮打开弹窗
  624. for (i = 0; i < btns.length; i++) {
  625. btns[i].onclick = function() {
  626. modal.style.display = "block";
  627. }
  628. }
  629. // 点击 <span> (x), 关闭弹窗
  630. for (i = 0; i < spans.length; i++) {
  631. spans[i].onclick = function() {
  632. modal.style.display = "none";
  633. }
  634. }
  635. // 在用户点击其他地方时,关闭弹窗
  636. window.onclick = function(event) {
  637. if (event.target == modal) {
  638. modal.style.display = "none";
  639. }
  640. }
  641. // 显示弹窗,弹出相应的信息
  642. function showmask() {
  643. var image_tag = !$('#image_tag').val()
  644. if(image_tag){
  645. return
  646. }
  647. $('#imageModal').css('display', 'none')
  648. $('#mask').css('display', 'block')
  649. $("iframe[name=iframeContent]").on("load", function() {  
  650. var responseText = $("iframe")[0].contentDocument.body.getElementsByTagName("pre")[0].innerHTML; 
  651. var json1 = JSON.parse(responseText)
  652. $('#mask').css('display', 'none')
  653. parent.location.href
  654. if (json1.result_code === "0") {
  655. $('.alert').html('操作成功!').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  656. } else {
  657. $('.alert').html(json1.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(5000).fadeOut();
  658. }
  659. })
  660. }
  661. </script>