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