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.

selectImages.vue 16 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <template>
  2. <div
  3. class="inline required field"
  4. :class="{ min_title: benchmarkNew, unite: benchmark }"
  5. >
  6. <label
  7. v-if="benchmarkNew"
  8. class="label-fix-width"
  9. style="font-weight: normal"
  10. >镜像</label
  11. >
  12. <label v-else>镜像</label>
  13. <span v-if="benchmark">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  14. <input
  15. v-if="benchmarkNew"
  16. type="text"
  17. name="image"
  18. :value="imageAddress"
  19. style="width: 48.5%"
  20. placeholder="选择镜像或输入镜像地址"
  21. required
  22. />
  23. <input
  24. v-else
  25. type="text"
  26. name="image"
  27. :value="imageAddress"
  28. placeholder="选择镜像或输入镜像地址"
  29. required
  30. />
  31. <el-button
  32. type="text"
  33. @click="dialogVisible = true"
  34. icon="el-icon-plus"
  35. style="color: #0366d6"
  36. >选择镜像
  37. </el-button>
  38. <el-dialog title="选择镜像" :visible.sync="dialogVisible" width="50%">
  39. <div
  40. class="ui icon input"
  41. style="z-index: 9999; position: absolute; right: 50px; height: 30px"
  42. >
  43. <i
  44. class="search icon"
  45. style="cursor: pointer; pointer-events: auto"
  46. ></i>
  47. <input
  48. type="text"
  49. placeholder="搜镜像Tag/描述/标签..."
  50. v-model="search"
  51. />
  52. </div>
  53. <el-tabs v-model="activeName" @tab-click="handleClick">
  54. <el-tab-pane label="公开镜像" name="first" v-loading="loadingPublic">
  55. <div
  56. style="
  57. display: flex;
  58. align-items: center;
  59. justify-content: space-between;
  60. padding: 1rem 0;
  61. border-bottom: 1px solid #f5f5f5;
  62. "
  63. v-for="(publicData, index) in tableDataPublic"
  64. :key="index"
  65. >
  66. <div style="width: 90%">
  67. <div
  68. style="
  69. display: flex;
  70. align-items: center;
  71. justify-content: space-between;
  72. "
  73. >
  74. <div style="display: flex; align-items: center">
  75. <span
  76. class="panel_dataset_name text-over"
  77. style="margin-left: 0"
  78. >{{ publicData.tag }}
  79. </span>
  80. <img
  81. v-if="publicData.type == 5"
  82. src="/img/jian.svg"
  83. style="margin-left: 0.5rem"
  84. />
  85. </div>
  86. <div v-if="!!publicData.topics" class="text-over">
  87. <span
  88. v-for="(topic, index) in publicData.topics"
  89. class="ui repo-topic label topic"
  90. >{{ topic }}</span
  91. >
  92. </div>
  93. </div>
  94. <div style="margin-top: 8px; display: flex">
  95. <a
  96. v-if="publicData.relAvatarLink || publicData.userName"
  97. :title="publicData.userName"
  98. style="cursor: default"
  99. >
  100. <img
  101. class="ui avatar mini image"
  102. style="width: 20px; height: 20px"
  103. :src="publicData.relAvatarLink"
  104. />
  105. </a>
  106. <a v-else
  107. ><img
  108. class="ui avatar mini image"
  109. title="Ghost"
  110. src="/user/avatar/ghost/-1"
  111. style="width: 20px; height: 20px"
  112. /></a>
  113. <span class="panel_datset_desc">{{
  114. publicData.description
  115. }}</span>
  116. </div>
  117. </div>
  118. <div>
  119. <button
  120. class="ui primary basic button mini"
  121. @click.stop.prevent="
  122. selectImages(publicData.place, publicData.tag)
  123. "
  124. >
  125. 使用
  126. </button>
  127. </div>
  128. </div>
  129. <div
  130. class="ui container"
  131. style="margin-top: 50px; text-align: center"
  132. >
  133. <el-pagination
  134. background
  135. @current-change="handleCurrentChangePublic"
  136. :current-page="currentPagePublic"
  137. :page-size="pageSizePublic"
  138. layout="total, prev, pager, next"
  139. :total="totalNumPublic"
  140. >
  141. </el-pagination>
  142. </div>
  143. </el-tab-pane>
  144. <el-tab-pane label="我的镜像" name="second" v-loading="loadingCustom">
  145. <div
  146. style="
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. padding: 1rem 0;
  151. border-bottom: 1px solid #f5f5f5;
  152. "
  153. v-for="(customData, index) in tableDataCustom"
  154. :key="index"
  155. >
  156. <div style="width: 90%">
  157. <div
  158. style="
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. "
  163. >
  164. <span
  165. class="panel_dataset_name text-over"
  166. style="margin-left: 0"
  167. >{{ customData.tag }}
  168. </span>
  169. <div v-if="!!customData.topics" class="text-over">
  170. <span
  171. v-for="(topic, index) in customData.topics"
  172. class="ui repo-topic label topic"
  173. >{{ topic }}</span
  174. >
  175. </div>
  176. </div>
  177. <div style="margin-top: 8px; display: flex">
  178. <a
  179. v-if="customData.relAvatarLink || customData.userName"
  180. :title="customData.userName"
  181. style="cursor: default"
  182. >
  183. <img
  184. class="ui avatar mini image"
  185. style="width: 20px; height: 20px"
  186. :src="customData.relAvatarLink"
  187. />
  188. </a>
  189. <a v-else
  190. ><img
  191. class="ui avatar mini image"
  192. title="Ghost"
  193. src="/user/avatar/ghost/-1"
  194. style="width: 20px; height: 20px"
  195. /></a>
  196. <span class="panel_datset_desc">{{
  197. customData.description
  198. }}</span>
  199. </div>
  200. </div>
  201. <div>
  202. <button
  203. v-if="customData.status === 1"
  204. class="ui primary basic button mini"
  205. @click.stop.prevent="
  206. selectImages(customData.place, customData.tag)
  207. "
  208. >
  209. 使用
  210. </button>
  211. <span
  212. v-if="customData.status === 0"
  213. style="display: flex; align-items: center"
  214. >
  215. <i class="CREATING"></i>
  216. <span
  217. style="margin-left: 0.4em; font-size: 12px; color: #5a5a5a"
  218. >提交中</span
  219. >
  220. </span>
  221. <span
  222. v-if="customData.status === 2"
  223. style="display: flex; align-items: center"
  224. >
  225. <i class="FAILED"></i>
  226. <el-tooltip
  227. class="item"
  228. effect="dark"
  229. content="检测提交镜像是否大小超过20G!"
  230. placement="left"
  231. >
  232. <span style="margin-left: 0.4em; font-size: 12px; color: red"
  233. >提交失败</span
  234. >
  235. </el-tooltip>
  236. </span>
  237. </div>
  238. </div>
  239. <div
  240. class="ui container"
  241. style="margin-top: 50px; text-align: center"
  242. >
  243. <el-pagination
  244. background
  245. @current-change="handleCurrentChangeCustom"
  246. :current-page="currentPageCustom"
  247. :page-size="pageSizeCustom"
  248. layout="total, prev, pager, next"
  249. :total="totalNumCustom"
  250. >
  251. </el-pagination>
  252. </div>
  253. </el-tab-pane>
  254. <el-tab-pane label="我收藏的镜像" name="third">
  255. <div
  256. style="
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. padding: 1rem 0;
  261. border-bottom: 1px solid #f5f5f5;
  262. "
  263. v-for="(starData, index) in tableDataStar"
  264. :key="index"
  265. >
  266. <div style="width: 90%">
  267. <div
  268. style="
  269. display: flex;
  270. align-items: center;
  271. justify-content: space-between;
  272. "
  273. >
  274. <div style="display: flex; align-items: center">
  275. <span
  276. class="panel_dataset_name text-over"
  277. style="margin-left: 0"
  278. >{{ starData.tag }}
  279. </span>
  280. <img
  281. v-if="starData.type == 5"
  282. src="/img/jian.svg"
  283. style="margin-left: 0.5rem"
  284. />
  285. </div>
  286. <div v-if="!!starData.topics" class="text-over">
  287. <span
  288. v-for="(topic, index) in starData.topics"
  289. class="ui repo-topic label topic"
  290. >{{ topic }}</span
  291. >
  292. </div>
  293. </div>
  294. <div style="margin-top: 8px; display: flex">
  295. <a
  296. v-if="starData.relAvatarLink || starData.userName"
  297. :title="starData.userName"
  298. style="cursor: default"
  299. >
  300. <img
  301. class="ui avatar mini image"
  302. style="width: 20px; height: 20px"
  303. :src="starData.relAvatarLink"
  304. />
  305. </a>
  306. <a v-else
  307. ><img
  308. class="ui avatar mini image"
  309. title="Ghost"
  310. src="/user/avatar/ghost/-1"
  311. style="width: 20px; height: 20px"
  312. /></a>
  313. <span class="panel_datset_desc">{{
  314. starData.description
  315. }}</span>
  316. </div>
  317. </div>
  318. <div>
  319. <button
  320. class="ui primary basic button mini"
  321. @click.stop.prevent="selectImages(starData.place, starData.tag)"
  322. >
  323. 使用
  324. </button>
  325. </div>
  326. </div>
  327. <div
  328. class="ui container"
  329. style="margin-top: 50px; text-align: center"
  330. >
  331. <el-pagination
  332. background
  333. @current-change="handleCurrentChangeStar"
  334. :current-page="currentPageStar"
  335. :page-size="pageSizeStar"
  336. layout="total, prev, pager, next"
  337. :total="totalNumStar"
  338. >
  339. </el-pagination>
  340. </div>
  341. </el-tab-pane>
  342. </el-tabs>
  343. </el-dialog>
  344. </div>
  345. </template>
  346. <script>
  347. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  348. export default {
  349. components: {},
  350. data() {
  351. return {
  352. dialogVisible: false,
  353. benchmarkNew: false,
  354. benchmark: false,
  355. imageAddress: "",
  356. activeName: "first",
  357. search: "",
  358. checked: false,
  359. currentPagePublic: 1,
  360. pageSizePublic: 5,
  361. totalNumPublic: 0,
  362. paramsPublic: { page: 1, pageSize: 5, q: "", recommend: false },
  363. tableDataPublic: [],
  364. loadingPublic: false,
  365. currentPageCustom: 1,
  366. pageSizeCustom: 5,
  367. totalNumCustom: 0,
  368. paramsCustom: { page: 1, pageSize: 5, q: "" },
  369. tableDataCustom: [],
  370. starCustom: [],
  371. loadingCustom: false,
  372. currentPageStar: 1,
  373. pageSizeStar: 5,
  374. totalNumStar: 0,
  375. paramsStar: { page: 1, pageSize: 5, q: "" },
  376. tableDataStar: [],
  377. loadingStar: false,
  378. };
  379. },
  380. methods: {
  381. handleClick(tab, event) {
  382. this.search = "";
  383. if (tab.name == "first") {
  384. this.paramsPublic.q = "";
  385. this.getImageListPublic();
  386. }
  387. if (tab.name == "second") {
  388. this.getImageListCustom();
  389. }
  390. if (tab.name == "third") {
  391. this.getImageListStar();
  392. }
  393. },
  394. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  395. if (rowIndex === 0) {
  396. return "background:#f5f5f6;color:#606266";
  397. }
  398. },
  399. handleCurrentChangePublic(val) {
  400. this.paramsPublic.page = val;
  401. this.getImageListPublic();
  402. },
  403. handleCurrentChangeCustom(val) {
  404. this.paramsCustom.page = val;
  405. this.getImageListCustom();
  406. },
  407. handleCurrentChangeStar(val) {
  408. this.paramsStar.page = val;
  409. this.getImageListStar();
  410. },
  411. getImageListPublic() {
  412. this.loadingPublic = true;
  413. this.$axios
  414. .get("/explore/images/public", {
  415. params: this.paramsPublic,
  416. })
  417. .then((res) => {
  418. this.totalNumPublic = res.data.count;
  419. this.tableDataPublic = res.data.images;
  420. this.loadingPublic = false;
  421. });
  422. },
  423. getImageListCustom() {
  424. this.loadingCustom = true;
  425. this.$axios
  426. .get("/explore/images/custom", {
  427. params: this.paramsCustom,
  428. })
  429. .then((res) => {
  430. this.totalNumCustom = res.data.count;
  431. this.tableDataCustom = res.data.images;
  432. this.tableDataCustom.forEach((element) => {
  433. this.starCustom.push({ id: element.id });
  434. });
  435. this.loadingCustom = false;
  436. });
  437. },
  438. getImageListStar() {
  439. this.loadingStar = true;
  440. this.$axios
  441. .get("/explore/images/star", {
  442. params: this.paramsStar,
  443. })
  444. .then((res) => {
  445. this.totalNumStar = res.data.count;
  446. this.tableDataStar = res.data.images;
  447. this.loadingStar = false;
  448. });
  449. },
  450. searchName() {
  451. if (this.activeName == "first") {
  452. this.paramsPublic.q = this.search;
  453. this.paramsPublic.page = 1;
  454. this.getImageListPublic();
  455. }
  456. if (this.activeName == "second") {
  457. this.paramsCustom.q = this.search;
  458. this.paramsCustom.page = 1;
  459. this.getImageListCustom();
  460. }
  461. if (this.activeName == "third") {
  462. this.paramsStar.q = this.search;
  463. this.paramsStar.page = 1;
  464. this.getImageListStar();
  465. }
  466. },
  467. selectImages(place) {
  468. this.imageAddress = place;
  469. this.dialogVisible = false;
  470. },
  471. },
  472. watch: {
  473. search(val) {
  474. if (this.activeName == "first") {
  475. this.paramsPublic.q = val;
  476. this.getImageListPublic();
  477. }
  478. if (this.activeName == "second") {
  479. this.paramsCustom.q = val;
  480. this.getImageListCustom();
  481. }
  482. if (this.activeName == "third") {
  483. this.paramsStar.q = val;
  484. this.getImageListStar();
  485. }
  486. },
  487. },
  488. mounted() {
  489. this.getImageListPublic();
  490. if (
  491. location.href.indexOf("train-job") !== -1 ||
  492. location.href.indexOf("benchmark") !== -1
  493. ) {
  494. this.benchmarkNew = true;
  495. }
  496. if (location.href.indexOf("cloudbrain/benchmark/") !== -1) {
  497. this.benchmark = true;
  498. }
  499. },
  500. created() {},
  501. };
  502. </script>
  503. <style scoped>
  504. .header-wrapper {
  505. background-color: #f5f5f6;
  506. padding-top: 15px;
  507. }
  508. .image_text {
  509. padding: 25px 0 55px 0;
  510. }
  511. #header {
  512. position: relative;
  513. top: -40px;
  514. }
  515. #success {
  516. background-color: #5bb973;
  517. color: white;
  518. }
  519. .text-over {
  520. overflow: hidden;
  521. text-overflow: ellipsis;
  522. vertical-align: middle;
  523. white-space: nowrap;
  524. }
  525. .image_title {
  526. display: inline-block;
  527. width: 80%;
  528. cursor: default;
  529. color: rgb(66, 98, 144);
  530. }
  531. .image_desc {
  532. -webkit-line-clamp: 2;
  533. -webkit-box-orient: vertical;
  534. display: -webkit-box;
  535. text-overflow: ellipsis;
  536. overflow: hidden;
  537. }
  538. .heart-stroke {
  539. stroke: #666;
  540. stroke-width: 2;
  541. fill: #fff;
  542. }
  543. .stars_active {
  544. fill: #fa8c16 !important;
  545. stroke: #fa8c16 !important;
  546. }
  547. </style>