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.

selectGrampusImages.vue 7.8 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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div
  3. class="inline required field"
  4. :class="{ unite: benchmarkNew, min_title: benchmarkNew }"
  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
  38. :title="i18n.image_select"
  39. :visible.sync="dialogVisible"
  40. width="50%"
  41. >
  42. <div
  43. class="ui icon input"
  44. style="z-index: 9999; position: absolute; right: 50px; height: 30px"
  45. >
  46. <i
  47. class="search icon"
  48. style="cursor: pointer; pointer-events: auto"
  49. ></i>
  50. <input
  51. type="text"
  52. :placeholder="i18n.image_search_placeholder"
  53. v-model="search"
  54. />
  55. </div>
  56. <el-tabs v-model="activeName" @tab-click="handleClick">
  57. <el-tab-pane
  58. :label="i18n.image_public"
  59. name="first"
  60. v-loading="loadingPublic"
  61. >
  62. <div
  63. style="
  64. display: flex;
  65. align-items: center;
  66. justify-content: space-between;
  67. padding: 1rem 0;
  68. border-bottom: 1px solid #f5f5f5;
  69. "
  70. v-for="(publicData, index) in tableDataPublic"
  71. :key="index"
  72. >
  73. <div style="width: 90%">
  74. <div
  75. style="
  76. display: flex;
  77. align-items: center;
  78. justify-content: space-between;
  79. "
  80. >
  81. <div style="display: flex; align-items: center">
  82. <span
  83. class="panel_dataset_name text-over"
  84. style="margin-left: 0"
  85. >{{ publicData.tag }}
  86. </span>
  87. <img
  88. v-if="publicData.type == 5"
  89. src="/img/jian.svg"
  90. style="margin-left: 0.5rem"
  91. />
  92. </div>
  93. <div v-if="!!publicData.topics" class="text-over">
  94. <span
  95. v-for="(topic, index) in publicData.topics"
  96. class="ui repo-topic label topic"
  97. >{{ topic }}</span
  98. >
  99. </div>
  100. </div>
  101. <div style="margin-top: 8px; display: flex">
  102. <a
  103. v-if="publicData.relAvatarLink || publicData.userName"
  104. :title="publicData.userName"
  105. style="cursor: default"
  106. >
  107. <img
  108. class="ui avatar mini image"
  109. style="width: 20px; height: 20px"
  110. :src="publicData.relAvatarLink"
  111. />
  112. </a>
  113. <a v-else
  114. ><img
  115. class="ui avatar mini image"
  116. title="Ghost"
  117. src="/user/avatar/ghost/-1"
  118. style="width: 20px; height: 20px"
  119. /></a>
  120. <span class="panel_datset_desc">{{
  121. publicData.description
  122. }}</span>
  123. </div>
  124. </div>
  125. <div>
  126. <button
  127. class="ui primary basic button mini"
  128. @click.stop.prevent="
  129. selectImages(publicData.place, publicData.tag)
  130. "
  131. >
  132. {{ i18n.image_use }}
  133. </button>
  134. </div>
  135. </div>
  136. <div
  137. class="ui container"
  138. style="margin-top: 50px; text-align: center"
  139. >
  140. <el-pagination
  141. background
  142. @current-change="handleCurrentChangePublic"
  143. :current-page="currentPagePublic"
  144. :page-size="pageSizePublic"
  145. layout="total, prev, pager, next"
  146. :total="totalNumPublic"
  147. >
  148. </el-pagination>
  149. </div>
  150. </el-tab-pane>
  151. </el-tabs>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  157. export default {
  158. components: {},
  159. data() {
  160. return {
  161. dialogVisible: false,
  162. benchmarkNew: false,
  163. imageAddress: "",
  164. activeName: "first",
  165. search: "",
  166. checked: false,
  167. currentPagePublic: 1,
  168. pageSizePublic: 5,
  169. totalNumPublic: 0,
  170. paramsPublic: {
  171. page: 1,
  172. pageSize: 5,
  173. q: "",
  174. recommend: false,
  175. cloudbrainType: 2,
  176. },
  177. tableDataPublic: [],
  178. loadingPublic: false,
  179. i18n: {},
  180. };
  181. },
  182. methods: {
  183. handleClick(tab, event) {
  184. this.search = "";
  185. if (tab.name == "first") {
  186. this.paramsPublic.q = "";
  187. this.getImageListPublic();
  188. }
  189. },
  190. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  191. if (rowIndex === 0) {
  192. return "background:#f5f5f6;color:#606266";
  193. }
  194. },
  195. handleCurrentChangePublic(val) {
  196. this.paramsPublic.page = val;
  197. this.getImageListPublic();
  198. },
  199. getImageListPublic() {
  200. this.loadingPublic = true;
  201. this.$axios
  202. .get("/explore/images/public", {
  203. params: this.paramsPublic,
  204. })
  205. .then((res) => {
  206. this.totalNumPublic = res.data.count;
  207. this.tableDataPublic = res.data.images;
  208. this.loadingPublic = false;
  209. });
  210. },
  211. searchName() {
  212. if (this.activeName == "first") {
  213. this.paramsPublic.q = this.search;
  214. this.paramsPublic.page = 1;
  215. this.getImageListPublic();
  216. }
  217. },
  218. selectImages(place) {
  219. this.imageAddress = place;
  220. this.dialogVisible = false;
  221. },
  222. },
  223. watch: {
  224. search(val) {
  225. if (this.activeName == "first") {
  226. this.paramsPublic.q = val;
  227. this.getImageListPublic();
  228. }
  229. },
  230. },
  231. mounted() {
  232. if (document.getElementById("ai_image_name")) {
  233. this.imageAddress = document.getElementById("ai_image_name").value;
  234. }
  235. this.getImageListPublic();
  236. if (
  237. location.href.indexOf("benchmark") !== -1 ||
  238. location.href.indexOf("train-job") !== -1 ||
  239. location.href.indexOf("modelsafety") !== -1
  240. ) {
  241. this.benchmarkNew = true;
  242. }
  243. },
  244. created() {
  245. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  246. this.i18n = this.$locale.US;
  247. } else {
  248. this.i18n = this.$locale.CN;
  249. }
  250. },
  251. };
  252. </script>
  253. <style scoped>
  254. .header-wrapper {
  255. background-color: #f5f5f6;
  256. padding-top: 15px;
  257. }
  258. .image_text {
  259. padding: 25px 0 55px 0;
  260. }
  261. #header {
  262. position: relative;
  263. top: -40px;
  264. }
  265. #success {
  266. background-color: #5bb973;
  267. color: white;
  268. }
  269. .text-over {
  270. overflow: hidden;
  271. text-overflow: ellipsis;
  272. vertical-align: middle;
  273. white-space: nowrap;
  274. }
  275. .image_title {
  276. display: inline-block;
  277. width: 80%;
  278. cursor: default;
  279. color: rgb(66, 98, 144);
  280. }
  281. .image_desc {
  282. -webkit-line-clamp: 2;
  283. -webkit-box-orient: vertical;
  284. display: -webkit-box;
  285. text-overflow: ellipsis;
  286. overflow: hidden;
  287. }
  288. .heart-stroke {
  289. stroke: #666;
  290. stroke-width: 2;
  291. fill: #fff;
  292. }
  293. .stars_active {
  294. fill: #fa8c16 !important;
  295. stroke: #fa8c16 !important;
  296. }
  297. </style>