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