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