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