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