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

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