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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <div class="inline required field" :class="{ 'unite': benchmarkNew, 'min_title': benchmarkNew}">
  3. <label v-if="benchmarkNew" style="font-weight: normal;">镜像</label>
  4. <label v-else>镜像</label>
  5. <span v-if="benchmarkNew">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  6. <input v-if="benchmarkNew" type="text" name="image" :value="imageAddress" style="width: 48.5%;"
  7. placeholder="选择镜像或输入镜像地址" required>
  8. <input v-else type="text" name="image" :value="imageAddress" placeholder="选择镜像或输入镜像地址" required>
  9. <el-button type="text" @click="dialogVisible = true" icon="el-icon-plus" style="color: #0366d6;">选择镜像
  10. </el-button>
  11. <el-dialog title="选择镜像" :visible.sync="dialogVisible" width="50%">
  12. <div class="ui icon input" style="z-index: 9999;position: absolute;right: 50px;height:30px;">
  13. <i class="search icon" style="cursor: pointer;pointer-events:auto"></i>
  14. <input type="text" placeholder="搜镜像Tag/描述/标签..." v-model="search">
  15. </div>
  16. <el-tabs v-model="activeName" @tab-click="handleClick">
  17. <el-tab-pane label="公开镜像" name="first" v-loading="loadingPublic">
  18. <div style="display: flex;align-items: center;justify-content: space-between;padding: 1rem 0;border-bottom:1px solid #F5F5F5"
  19. v-for="(publicData,index) in tableDataPublic" :key="index">
  20. <div style="width: 90%;">
  21. <div style="display: flex;align-items: center;justify-content: space-between;">
  22. <div style="display: flex;align-items: center;">
  23. <span class="panel_dataset_name text-over"
  24. style="margin-left: 0;">{{publicData.tag}} </span>
  25. <img v-if="publicData.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  26. </div>
  27. <div v-if="!!publicData.topics" class="text-over">
  28. <span v-for="(topic,index) in publicData.topics"
  29. class="ui repo-topic label topic">{{topic}}</span>
  30. </div>
  31. </div>
  32. <div style="margin-top: 8px;display: flex;">
  33. <a v-if="publicData.relAvatarLink||publicData.userName" :title="publicData.userName"
  34. style="cursor: default;">
  35. <img class="ui avatar mini image" style="width: 20px;height: 20px;"
  36. :src="publicData.relAvatarLink">
  37. </a>
  38. <a v-else><img class="ui avatar mini image" title="Ghost" src="/user/avatar/ghost/-1"
  39. style="width: 20px;height: 20px;"></a>
  40. <span class="panel_datset_desc">{{publicData.description}}</span>
  41. </div>
  42. </div>
  43. <div>
  44. <button class="ui primary basic button mini"
  45. @click.stop.prevent="selectImages(publicData.place,publicData.tag)">使用</button>
  46. </div>
  47. </div>
  48. <div class="ui container" style="margin-top:50px;text-align:center">
  49. <el-pagination background @current-change="handleCurrentChangePublic"
  50. :current-page="currentPagePublic" :page-size="pageSizePublic"
  51. layout="total, prev, pager, next" :total="totalNumPublic">
  52. </el-pagination>
  53. </div>
  54. </el-tab-pane>
  55. <el-tab-pane label="我的镜像" name="second" v-loading="loadingCustom">
  56. <div style="display: flex;align-items: center;justify-content: space-between;padding: 1rem 0;border-bottom:1px solid #F5F5F5"
  57. v-for="(customData,index) in tableDataCustom" :key="index">
  58. <div style="width: 90%;">
  59. <div style="display: flex;align-items: center;justify-content: space-between;">
  60. <span class="panel_dataset_name text-over" style="margin-left: 0;">{{customData.tag}}
  61. </span>
  62. <div v-if="!!customData.topics" class="text-over">
  63. <span v-for="(topic,index) in customData.topics"
  64. class="ui repo-topic label topic">{{topic}}</span>
  65. </div>
  66. </div>
  67. <div style="margin-top: 8px;display: flex;">
  68. <a v-if="customData.relAvatarLink||customData.userName" :title="customData.userName"
  69. style="cursor: default;">
  70. <img class="ui avatar mini image" style="width: 20px;height: 20px;"
  71. :src="customData.relAvatarLink">
  72. </a>
  73. <a v-else><img class="ui avatar mini image" title="Ghost" src="/user/avatar/ghost/-1"
  74. style="width: 20px;height: 20px;"></a>
  75. <span class="panel_datset_desc">{{customData.description}}</span>
  76. </div>
  77. </div>
  78. <div>
  79. <button v-if="customData.status===1" class="ui primary basic button mini"
  80. @click.stop.prevent="selectImages(customData.place,customData.tag)">使用</button>
  81. <span v-if="customData.status===0" style="display: flex;align-items: center;">
  82. <i class="CREATING"></i>
  83. <span style="margin-left: 0.4em;font-size: 12px;color: #5A5A5A;">提交中</span>
  84. </span>
  85. <span v-if="customData.status===2" style="display: flex;align-items: center;">
  86. <i class="FAILED"></i>
  87. <el-tooltip class="item" effect="dark" content="检测提交镜像是否大小超过20G!" placement="left">
  88. <span style="margin-left: 0.4em;font-size: 12px;color:red;">提交失败</span>
  89. </el-tooltip>
  90. </span>
  91. </div>
  92. </div>
  93. <div class="ui container" style="margin-top:50px;text-align:center">
  94. <el-pagination background @current-change="handleCurrentChangeCustom"
  95. :current-page="currentPageCustom" :page-size="pageSizeCustom"
  96. layout="total, prev, pager, next" :total="totalNumCustom">
  97. </el-pagination>
  98. </div>
  99. </el-tab-pane>
  100. <el-tab-pane label="我收藏的镜像" name="third">
  101. <div style="display: flex;align-items: center;justify-content: space-between;padding: 1rem 0;border-bottom:1px solid #F5F5F5"
  102. v-for="(starData,index) in tableDataStar" :key="index">
  103. <div style="width: 90%;">
  104. <div style="display: flex;align-items: center;justify-content: space-between;">
  105. <div style="display: flex;align-items: center;">
  106. <span class="panel_dataset_name text-over" style="margin-left: 0;">{{starData.tag}}
  107. </span>
  108. <img v-if="starData.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  109. </div>
  110. <div v-if="!!starData.topics" class="text-over">
  111. <span v-for="(topic,index) in starData.topics"
  112. class="ui repo-topic label topic">{{topic}}</span>
  113. </div>
  114. </div>
  115. <div style="margin-top: 8px;display: flex;">
  116. <a v-if="starData.relAvatarLink||starData.userName" :title="starData.userName"
  117. style="cursor: default;">
  118. <img class="ui avatar mini image" style="width: 20px;height: 20px;"
  119. :src="starData.relAvatarLink">
  120. </a>
  121. <a v-else><img class="ui avatar mini image" title="Ghost" src="/user/avatar/ghost/-1"
  122. style="width: 20px;height: 20px;"></a>
  123. <span class="panel_datset_desc">{{starData.description}}</span>
  124. </div>
  125. </div>
  126. <div>
  127. <button class="ui primary basic button mini"
  128. @click.stop.prevent="selectImages(starData.place,starData.tag)">使用</button>
  129. </div>
  130. </div>
  131. <div class="ui container" style="margin-top:50px;text-align:center">
  132. <el-pagination background @current-change="handleCurrentChangeStar"
  133. :current-page="currentPageStar" :page-size="pageSizeStar" layout="total, prev, pager, next"
  134. :total="totalNumStar">
  135. </el-pagination>
  136. </div>
  137. </el-tab-pane>
  138. </el-tabs>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  144. export default {
  145. components: {
  146. },
  147. data() {
  148. return {
  149. dialogVisible: false,
  150. benchmarkNew: false,
  151. imageAddress: '',
  152. activeName: 'first',
  153. search: '',
  154. checked: false,
  155. currentPagePublic: 1,
  156. pageSizePublic: 5,
  157. totalNumPublic: 0,
  158. paramsPublic: { page: 1, pageSize: 5, q: '', recommend: false },
  159. tableDataPublic: [],
  160. loadingPublic: false,
  161. currentPageCustom: 1,
  162. pageSizeCustom: 5,
  163. totalNumCustom: 0,
  164. paramsCustom: { page: 1, pageSize: 5, q: '' },
  165. tableDataCustom: [],
  166. starCustom: [],
  167. loadingCustom: false,
  168. currentPageStar: 1,
  169. pageSizeStar: 5,
  170. totalNumStar: 0,
  171. paramsStar: { page: 1, pageSize: 5, q: '' },
  172. tableDataStar: [],
  173. loadingStar: false
  174. };
  175. },
  176. methods: {
  177. handleClick(tab, event) {
  178. this.search = ''
  179. if (tab.name == "first") {
  180. this.paramsPublic.q = ''
  181. this.getImageListPublic()
  182. }
  183. if (tab.name == "second") {
  184. this.getImageListCustom()
  185. }
  186. if (tab.name == "third") {
  187. this.getImageListStar()
  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. handleCurrentChangeCustom(val) {
  200. this.paramsCustom.page = val
  201. this.getImageListCustom()
  202. },
  203. handleCurrentChangeStar(val) {
  204. this.paramsStar.page = val
  205. this.getImageListStar()
  206. },
  207. getImageListPublic() {
  208. this.loadingPublic = true
  209. this.$axios.get('/explore/images/public', {
  210. params: this.paramsPublic
  211. }).then((res) => {
  212. this.totalNumPublic = res.data.count
  213. this.tableDataPublic = res.data.images
  214. this.loadingPublic = false
  215. })
  216. },
  217. getImageListCustom() {
  218. this.loadingCustom = true
  219. this.$axios.get('/explore/images/custom', {
  220. params: this.paramsCustom
  221. }).then((res) => {
  222. this.totalNumCustom = res.data.count
  223. this.tableDataCustom = res.data.images
  224. this.tableDataCustom.forEach(element => {
  225. this.starCustom.push({ id: element.id, })
  226. });
  227. this.loadingCustom = false
  228. })
  229. },
  230. getImageListStar() {
  231. this.loadingStar = true
  232. this.$axios.get('/explore/images/star', {
  233. params: this.paramsStar
  234. }).then((res) => {
  235. this.totalNumStar = res.data.count
  236. this.tableDataStar = res.data.images
  237. this.loadingStar = false
  238. })
  239. },
  240. searchName() {
  241. if (this.activeName == 'first') {
  242. this.paramsPublic.q = this.search
  243. this.paramsPublic.page = 1
  244. this.getImageListPublic()
  245. }
  246. if (this.activeName == 'second') {
  247. this.paramsCustom.q = this.search
  248. this.paramsCustom.page = 1
  249. this.getImageListCustom()
  250. }
  251. if (this.activeName == 'third') {
  252. this.paramsStar.q = this.search
  253. this.paramsStar.page = 1
  254. this.getImageListStar()
  255. }
  256. },
  257. selectImages(place) {
  258. this.imageAddress = place
  259. this.dialogVisible = false
  260. },
  261. },
  262. watch: {
  263. search(val) {
  264. if (this.activeName == 'first') {
  265. this.paramsPublic.q = val
  266. this.getImageListPublic()
  267. }
  268. if (this.activeName == 'second') {
  269. this.paramsCustom.q = val
  270. this.getImageListCustom()
  271. }
  272. if (this.activeName == 'third') {
  273. this.paramsStar.q = val
  274. this.getImageListStar()
  275. }
  276. }
  277. },
  278. mounted() {
  279. this.getImageListPublic()
  280. if (location.href.indexOf('benchmark') !== -1 || location.href.indexOf('train-job') !== -1) {
  281. this.benchmarkNew = true
  282. }
  283. },
  284. created() {
  285. }
  286. };
  287. </script>
  288. <style scoped>
  289. .header-wrapper {
  290. background-color: #f5f5f6;
  291. padding-top: 15px;
  292. }
  293. .image_text {
  294. padding: 25px 0 55px 0;
  295. }
  296. #header {
  297. position: relative;
  298. top: -40px;
  299. }
  300. #success {
  301. background-color: #5bb973;
  302. color: white;
  303. }
  304. .text-over {
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. vertical-align: middle;
  308. white-space: nowrap;
  309. }
  310. .image_title {
  311. display: inline-block;
  312. width: 80%;
  313. cursor: default;
  314. color: rgb(66, 98, 144);
  315. }
  316. .image_desc {
  317. -webkit-line-clamp: 2;
  318. -webkit-box-orient: vertical;
  319. display: -webkit-box;
  320. text-overflow: ellipsis;
  321. overflow: hidden;
  322. }
  323. .heart-stroke {
  324. stroke: #666;
  325. stroke-width: 2;
  326. fill: #fff
  327. }
  328. .stars_active {
  329. fill: #FA8C16 !important;
  330. stroke: #FA8C16 !important
  331. }
  332. </style>