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.vue 15 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="新建Notebook调试任务"
  5. :visible.sync="dialogVisible"
  6. width="50%"
  7. :close-on-click-modal="false"
  8. @closed="handleClose"
  9. >
  10. <div class="wrapper">
  11. <div
  12. class="three-resource-type"
  13. :class="{ active: selectIndex == 0 }"
  14. @click="selectResource(0,'waitCountGpu')"
  15. >
  16. <div class="resource-child-node">
  17. <div class="resource-type-icon background-C">
  18. <span class="text">C</span>
  19. </div>
  20. <div class="resource-type-detail">
  21. <div class="detail-title"><span>CPU 环境</span></div>
  22. <div class="detail-spec">
  23. <span>{{cpuSpec}}</span>
  24. </div>
  25. <div class="detail-spec">
  26. <span>镜像:{{notebookInfo.imageCpuDescription}}</span>
  27. </div>
  28. </div>
  29. <div class="resource-select">
  30. <i v-if="selectIndex===0" :class="{'slide-in-bottom': !slideActive && !initSelect }" class="ri-checkbox-circle-line green"></i>
  31. <i
  32. class="ri-checkbox-blank-circle-line gray"
  33. :class="{'fade-out':selectIndex===0}"
  34. ></i>
  35. </div>
  36. </div>
  37. </div>
  38. <div
  39. class="three-resource-type"
  40. :class="{ active: selectIndex == 1 }"
  41. @click="selectResource(1,'waitCountGpu')"
  42. >
  43. <div class="resource-child-node">
  44. <div class="resource-type-icon background-G">
  45. <span class="text">G</span>
  46. </div>
  47. <div class="resource-type-detail">
  48. <div class="detail-title"><span>GPU 环境</span></div>
  49. <div class="detail-spec">
  50. <span>{{gpuSpec}}</span>
  51. </div>
  52. <div class="detail-spec">
  53. <span>镜像:{{notebookInfo.imageGpuDescription}}</span>
  54. </div>
  55. </div>
  56. <div class="resource-select">
  57. <i v-if="selectIndex===1 && !initSelect" :class="[slideActive && !initSelect ?'slide-in-top':'slide-in-bottom']" class="ri-checkbox-circle-line green"></i>
  58. <i v-if="selectIndex===1 && initSelect" class="ri-checkbox-circle-line green"></i>
  59. <i
  60. class="ri-checkbox-blank-circle-line gray"
  61. :class="{'fade-out':selectIndex===1}"
  62. ></i>
  63. </div>
  64. </div>
  65. </div>
  66. <div
  67. class="three-resource-type"
  68. :class="{ active: selectIndex == 2 }"
  69. @click="selectResource(2,'waitCountNpu')"
  70. >
  71. <div class="resource-child-node">
  72. <div class="resource-type-icon background-N">
  73. <span class="text">N</span>
  74. </div>
  75. <div class="resource-type-detail">
  76. <div class="detail-title"><span>NPU 环境</span></div>
  77. <div class="detail-spec">
  78. <span>{{npuSpec}}</span>
  79. </div>
  80. <div class="detail-spec">
  81. <span>镜像:{{notebookInfo.imageCpuDescription}}</span>
  82. </div>
  83. </div>
  84. <div class="resource-select">
  85. <i v-if="selectIndex===2" :class="{'slide-in-top': slideActive && !initSelect}" class="ri-checkbox-circle-line green"></i>
  86. <i
  87. class="ri-checkbox-blank-circle-line gray"
  88. :class="{'fade-out':selectIndex===2}"
  89. ></i>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="resource-footer">
  94. <div class="resource-operate" v-if="selectIndex==0">
  95. <button v-if="btnStatus[0]===0" class="ui green small button" @click="createTask(0)"></i>新建任务1</button>
  96. <button v-else-if="btnStatus[0]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
  97. <button v-else>aaaa</button>
  98. <span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
  99. </div>
  100. <div class="resource-operate" v-if="selectIndex==1">
  101. <button v-if="btnStatus[1]===0" class="ui green small button" @click="createTask(1)"></i>新建任务2</button>
  102. <button v-else-if="btnStatus[1]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
  103. <button v-else>aaaa</button>
  104. <span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
  105. </div>
  106. <div class="resource-operate" v-if="selectIndex==2">
  107. <button v-if="btnStatus[2]===0" class="ui green small button" @click="createTask(2)"></i>新建任务3</button>
  108. <button v-else-if="btnStatus[2]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
  109. <div v-else>
  110. <button class="ui small button" style="background-color: #1684fc;">调试</button>
  111. <button class="ui small button">停止</button>
  112. </div>
  113. <span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
  114. </div>
  115. </div>
  116. </div>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script>
  121. import { getFileNotebook,createNotebook,getCb1Notebook,getCb2Notebook } from "~/apis/modules/notobook";
  122. let timerCb1,timerCb2
  123. export default {
  124. data() {
  125. return {
  126. dialogVisible: false,
  127. selectIndex: 0,
  128. slideActive:true,
  129. initSelect:true,
  130. notebookInfo:{specCpu:{acc_cards_num:0},specGpu:{acc_cards_num:0},specNpu:{acc_cards_num:0}},
  131. waitCount:0,
  132. fileInfo:{
  133. file:'',
  134. branch_name:'',
  135. owner_name:'',
  136. project_name:'',
  137. },
  138. btnStatus:{0:0,1:0,2:0},
  139. firtstStatus:0,
  140. secondStatus:0,
  141. thirdStatus:0,
  142. };
  143. },
  144. methods: {
  145. handleClose(done) {
  146. console.log("close")
  147. this.initSelect = true
  148. },
  149. selectResource(index,type) {
  150. if(index==this.selectIndex){
  151. return
  152. }
  153. if(index>this.selectIndex){
  154. this.slideActive = true
  155. }else{
  156. this.slideActive = false
  157. }
  158. this.selectIndex = index;
  159. this.initSelect = false
  160. this.waitCount += this.notebookInfo[type] +1
  161. },
  162. getNotebookInfo(){
  163. getFileNotebook().then((res)=>{
  164. console.log(res)
  165. if(res.data.code==0){
  166. this.notebookInfo = res.data
  167. this.waitCount = res.data.waitCountGpu
  168. }else{
  169. console.log(res.data.message)
  170. }
  171. }).catch((err)=>{
  172. console.log(err)
  173. })
  174. },
  175. getCb1NotebookInfo(path,id){
  176. getCb1Notebook(path,id).then((res)=>{
  177. console.log(res)
  178. })
  179. },
  180. getCb2NotebookInfo(path,id){
  181. getCb2Notebook(path,id).then((res)=>{
  182. console.log(res)
  183. })
  184. },
  185. createTask(index){
  186. this.btnStatus[index]=1
  187. const data = {type:index,...this.fileInfo}
  188. let repoPath = `repos/${this.fileInfo.owner_name}/${this.fileInfo.project_name}`
  189. createNotebook(data).then((res)=>{
  190. console.log("=========",res)
  191. if(res.data.code===0 && res.status===200){
  192. // this.btnStatus[index]=2
  193. if(index===2){
  194. console.log("index",index)
  195. timerCb2 = setInterval(() => {
  196. setTimeout(this.getCb2NotebookInfo(repoPath,res.data.message), 0)
  197. }, 3000)
  198. }else{
  199. timerCb1 = setInterval(() => {
  200. setTimeout(this.getCb1NotebookInfo(repoPath,res.data.message), 0)
  201. }, 3000)
  202. }
  203. }else if(res.data.code===1 && res.status===403){
  204. this.btnStatus[index]=0
  205. }else{
  206. this.btnStatus[index]=0
  207. }
  208. }).catch((err)=>{
  209. this.btnStatus[index]=0
  210. console.log(err)
  211. })
  212. }
  213. },
  214. computed: {
  215. cpuSpec(){
  216. return `规格:GPU: ${this.notebookInfo.specCpu.acc_cards_num}*${this.notebookInfo.specCpu.acc_card_type},
  217. CPU: ${this.notebookInfo.specCpu.cpu_cores}, 显存: ${this.notebookInfo.specCpu.gpu_mem_gi_b}GB,
  218. 内存: ${this.notebookInfo.specCpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specCpu.share_mem_gi_b}GB`
  219. },
  220. npuSpec(){
  221. return `规格:NPU: ${this.notebookInfo.specNpu.acc_cards_num}*${this.notebookInfo.specNpu.acc_card_type},
  222. CPU: ${this.notebookInfo.specNpu.cpu_cores}, 显存: ${this.notebookInfo.specNpu.gpu_mem_gi_b}GB,
  223. 内存: ${this.notebookInfo.specNpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specNpu.share_mem_gi_b}GB`
  224. },
  225. gpuSpec(){
  226. return `规格:NPU: ${this.notebookInfo.specGpu.acc_cards_num}*${this.notebookInfo.specGpu.acc_card_type},
  227. CPU: ${this.notebookInfo.specGpu.cpu_cores}, 显存: ${this.notebookInfo.specGpu.gpu_mem_gi_b}GB,
  228. 内存: ${this.notebookInfo.specGpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specGpu.share_mem_gi_b}GB`
  229. }
  230. },
  231. beforeDestroy() {
  232. clearInterval(timerCb1)
  233. clearInterval(timerCb2)
  234. },
  235. mounted() {
  236. this.getNotebookInfo()
  237. // this.dialogVisible = true
  238. console.log("-----------aaaaa--");
  239. const selfData = document.querySelector('#__vue-self-data')
  240. this.fileInfo.file = selfData.getAttribute('data-file')
  241. this.fileInfo.branch_name = selfData.getAttribute('data-branch')
  242. this.fileInfo.owner_name = selfData.getAttribute('data-owner')
  243. this.fileInfo.project_name = selfData.getAttribute('data-project')
  244. console.log(this.fileInfo)
  245. let that = this;
  246. document
  247. .querySelector("#notebook-debug")
  248. .addEventListener("click", function () {
  249. that.dialogVisible = true;
  250. });
  251. },
  252. };
  253. </script>
  254. <style scoped lang="less">
  255. /deep/ .el-dialog__header {
  256. text-align: left;
  257. height: 45px;
  258. background: rgb(240, 240, 240);
  259. border-radius: 5px 5px 0px 0px;
  260. border-bottom: 1px solid rgb(212, 212, 213);
  261. padding: 0 15px;
  262. display: flex;
  263. align-items: center;
  264. font-weight: 500;
  265. font-size: 16px;
  266. color: rgb(16, 16, 16);
  267. font-family: Roboto;
  268. .el-dialog__title {
  269. font-weight: 600;
  270. font-size: 15px;
  271. color: rgb(16, 16, 16);
  272. }
  273. .el-dialog__headerbtn {
  274. top: 15px;
  275. right: 15px;
  276. }
  277. }
  278. /deep/ .el-dialog__body {
  279. padding: 55px 15px 0 15px;
  280. }
  281. .wrapper {
  282. width: 100%;
  283. .active {
  284. background: linear-gradient(
  285. 269.2deg,
  286. rgba(183, 247, 255, 0.5) 0%,
  287. rgba(233, 233, 255, 0) 78.67%
  288. );
  289. border-radius: 5px 5px 0px 0px;
  290. }
  291. .three-resource-type {
  292. width: 70%;
  293. margin: 0 auto;
  294. display: flex;
  295. border-top: 1px solid rgba(16, 16, 16, 0.1);
  296. cursor: pointer;
  297. &:first-child {
  298. border: none;
  299. }
  300. .resource-child-node {
  301. display: flex;
  302. align-items: center;
  303. width: 100%;
  304. height: 115px;
  305. .resource-type-icon {
  306. width: 50px;
  307. height: 50px;
  308. line-height: 20px;
  309. border-radius: 25px;
  310. text-align: center;
  311. display: flex;
  312. align-items: center;
  313. justify-content: center;
  314. .text {
  315. font-size: 26px;
  316. color: rgba(251, 251, 251, 1);
  317. font-family: ZKXiaoWeiLogo-regular;
  318. }
  319. }
  320. .background-C {
  321. background: linear-gradient(
  322. 134.2deg,
  323. rgba(130, 209, 246, 1) 0%,
  324. rgba(41, 182, 244, 1) 51.94%,
  325. rgba(0, 137, 205, 1) 102.83%
  326. );
  327. }
  328. .background-N {
  329. background: linear-gradient(
  330. 151.47deg,
  331. rgba(123, 50, 178, 1) 20.02%,
  332. rgba(64, 26, 93, 1) 100%
  333. );
  334. }
  335. .background-G {
  336. background: linear-gradient(
  337. -25.25deg,
  338. rgba(254, 86, 77, 1) 9.3%,
  339. rgba(251, 155, 54, 1) 38.86%,
  340. rgba(249, 202, 38, 1) 67.95%
  341. );
  342. }
  343. }
  344. .resource-type-detail {
  345. margin-left: 23px;
  346. .detail-title {
  347. font-family: SourceHanSansSC;
  348. font-weight: 500;
  349. font-size: 16px;
  350. color: rgb(16, 16, 16);
  351. font-style: normal;
  352. letter-spacing: 0px;
  353. line-height: 32px;
  354. text-decoration: none;
  355. }
  356. .detail-spec {
  357. font-family: SourceHanSansSC;
  358. font-weight: 400;
  359. font-size: 14px;
  360. color: rgba(136, 136, 136, 1);
  361. font-style: normal;
  362. letter-spacing: 0px;
  363. line-height: 24px;
  364. text-decoration: none;
  365. }
  366. }
  367. .resource-select {
  368. margin-left: auto;
  369. margin-right: 20px;
  370. font-size: 20px;
  371. height: 100%;
  372. display: flex;
  373. align-items: center;
  374. .green {
  375. color: green;
  376. }
  377. .gray {
  378. color: rgba(16, 16, 16, 0.1);
  379. }
  380. }
  381. }
  382. .resource-footer {
  383. margin-top: 40px;
  384. border-top: 1px solid rgba(16, 16, 16, 0.1);
  385. height: 71px;
  386. display: flex;
  387. align-items: center;
  388. .resource-operate {
  389. display: flex;
  390. align-items: center;
  391. }
  392. }
  393. .slide-in-top {
  394. -webkit-animation: slide-in-top 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  395. animation: slide-in-top 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  396. }
  397. .slide-in-bottom {
  398. -webkit-animation: slide-in-bottom 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  399. animation: slide-in-bottom 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  400. }
  401. .fade-out {
  402. -webkit-animation: fade-in 1.2s cubic-bezier(0.39, 0.575, 0.565, 1) both;
  403. animation: fade-in 1.2s cubic-bezier(0.39, 0.575, 0.565, 1) both;
  404. position: absolute
  405. }
  406. @-webkit-keyframes slide-in-top {
  407. 0% {
  408. -webkit-transform: translateY(-50px);
  409. transform: translateY(-50px);
  410. opacity: 0;
  411. }
  412. 100% {
  413. -webkit-transform: translateY(0);
  414. transform: translateY(0);
  415. opacity: 1;
  416. }
  417. }
  418. @keyframes slide-in-top {
  419. 0% {
  420. -webkit-transform: translateY(-50px);
  421. transform: translateY(-50px);
  422. opacity: 0;
  423. }
  424. 100% {
  425. -webkit-transform: translateY(0);
  426. transform: translateY(0);
  427. opacity: 1;
  428. }
  429. }
  430. @-webkit-keyframes slide-in-bottom {
  431. 0% {
  432. -webkit-transform: translateY(50px);
  433. transform: translateY(50px);
  434. opacity: 0;
  435. }
  436. 100% {
  437. -webkit-transform: translateY(0);
  438. transform: translateY(0);
  439. opacity: 1;
  440. }
  441. }
  442. @keyframes slide-in-bottom {
  443. 0% {
  444. -webkit-transform: translateY(50px);
  445. transform: translateY(50px);
  446. opacity: 0;
  447. }
  448. 100% {
  449. -webkit-transform: translateY(0);
  450. transform: translateY(0);
  451. opacity: 1;
  452. }
  453. }
  454. @-webkit-keyframes fade-in {
  455. 0% {
  456. opacity: 1;
  457. }
  458. 100% {
  459. opacity: 0;
  460. }
  461. }
  462. @keyframes fade-in {
  463. 0% {
  464. opacity: 1;
  465. }
  466. 100% {
  467. opacity: 0;
  468. }
  469. }
  470. }
  471. </style>