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 17 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
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
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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. >{{i18n.image_label}}</label
  11. >
  12. <label v-else>{{i18n.image_label}}</label>
  13. <input
  14. v-if="benchmarkNew"
  15. type="text"
  16. name="image"
  17. :value="imageAddress"
  18. style="width: 48.5%"
  19. :placeholder="i18n.image_select_placeholder"
  20. required
  21. />
  22. <input
  23. v-else
  24. type="text"
  25. name="image"
  26. :value="imageAddress"
  27. :placeholder="i18n.image_select_placeholder"
  28. required
  29. />
  30. <el-button
  31. type="text"
  32. @click="dialogVisible = true"
  33. icon="el-icon-plus"
  34. style="color: #0366d6"
  35. >{{i18n.image_select}}
  36. </el-button>
  37. <el-dialog :title="i18n.image_select" :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="i18n.image_search_placeholder"
  49. v-model="search"
  50. />
  51. </div>
  52. <el-tabs v-model="activeName" @tab-click="handleClick">
  53. <el-tab-pane :label="i18n.image_public" 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. {{i18n.image_use}}
  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="i18n.image_my" 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. {{i18n.image_use}}
  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. >{{i18n.image_commit}}</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="i18n.image_commit_content"
  229. placement="left"
  230. >
  231. <span style="margin-left: 0.4em; font-size: 12px; color: red"
  232. >{{i18n.image_commit_failed}}</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="i18n.image_collected" 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. {{i18n.image_use}}
  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. i18n: {},
  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. if (document.getElementById("ai_image_name")) {
  490. this.imageAddress = document.getElementById("ai_image_name").value;
  491. }
  492. this.getImageListPublic();
  493. if (
  494. location.href.indexOf("train-job") !== -1 ||
  495. location.href.indexOf("inference-job") !== -1 ||
  496. location.href.indexOf("benchmark") !== -1
  497. ) {
  498. this.benchmarkNew = true;
  499. }
  500. if (location.href.indexOf("cloudbrain/benchmark/") !== -1) {
  501. this.benchmark = true;
  502. }
  503. },
  504. created() {
  505. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  506. this.i18n = this.$locale.US;
  507. } else {
  508. this.i18n = this.$locale.CN;
  509. }
  510. },
  511. };
  512. </script>
  513. <style scoped>
  514. .header-wrapper {
  515. background-color: #f5f5f6;
  516. padding-top: 15px;
  517. }
  518. .image_text {
  519. padding: 25px 0 55px 0;
  520. }
  521. #header {
  522. position: relative;
  523. top: -40px;
  524. }
  525. #success {
  526. background-color: #5bb973;
  527. color: white;
  528. }
  529. .text-over {
  530. overflow: hidden;
  531. text-overflow: ellipsis;
  532. vertical-align: middle;
  533. white-space: nowrap;
  534. }
  535. .image_title {
  536. display: inline-block;
  537. width: 80%;
  538. cursor: default;
  539. color: rgb(66, 98, 144);
  540. }
  541. .image_desc {
  542. -webkit-line-clamp: 2;
  543. -webkit-box-orient: vertical;
  544. display: -webkit-box;
  545. text-overflow: ellipsis;
  546. overflow: hidden;
  547. }
  548. .heart-stroke {
  549. stroke: #666;
  550. stroke-width: 2;
  551. fill: #fff;
  552. }
  553. .stars_active {
  554. fill: #fa8c16 !important;
  555. stroke: #fa8c16 !important;
  556. }
  557. </style>