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 15 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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" @click="searchName()"></i>
  16. <input type="text" placeholder="搜镜像Tag/描述/标签..." v-model="search" @keyup.enter="searchName()">
  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. console.log("res",res.data)
  203. this.totalNumPublic = res.data.count
  204. this.tableDataPublic = res.data.images
  205. this.loadingPublic = false
  206. })
  207. },
  208. getImageListCustom(){
  209. this.loadingCustom = true
  210. this.$axios.get('/explore/images/custom',{
  211. params:this.paramsCustom
  212. }).then((res)=>{
  213. console.log("res",res)
  214. this.totalNumCustom = res.data.count
  215. this.tableDataCustom = res.data.images
  216. this.tableDataCustom.forEach(element => {
  217. this.starCustom.push({id:element.id,})
  218. });
  219. this.loadingCustom = false
  220. })
  221. },
  222. getImageListStar(){
  223. this.loadingStar = true
  224. this.$axios.get('/explore/images/star',{
  225. params:this.paramsStar
  226. }).then((res)=>{
  227. console.log("res",res)
  228. this.totalNumStar = res.data.count
  229. this.tableDataStar = res.data.images
  230. this.loadingStar = false
  231. })
  232. },
  233. searchName(){
  234. if(this.activeName=='first'){
  235. this.paramsPublic.q = this.search
  236. this.paramsPublic.page = 1
  237. this.getImageListPublic()
  238. }
  239. if(this.activeName=='second'){
  240. this.paramsCustom.q = this.search
  241. this.paramsCustom.page = 1
  242. this.getImageListCustom()
  243. }
  244. if(this.activeName=='third'){
  245. this.paramsStar.q = this.search
  246. this.paramsStar.page = 1
  247. this.getImageListStar()
  248. }
  249. },
  250. selectImages(place){
  251. this.imageAddress = place
  252. this.dialogVisible = false
  253. },
  254. },
  255. watch:{
  256. search(val){
  257. if(this.activeName=='first'){
  258. this.paramsPublic.q = val
  259. this.getImageListPublic()
  260. }
  261. if(this.activeName=='second'){
  262. this.paramsCustom.q = val
  263. this.getImageListCustom()
  264. }
  265. if(this.activeName=='third'){
  266. this.paramsStar.q = val
  267. this.getImageListStar()
  268. }
  269. }
  270. },
  271. mounted() {
  272. this.getImageListPublic()
  273. if(location.href.indexOf('benchmark')!==-1 || location.href.indexOf('train-job')!==-1){
  274. this.benchmarkNew = true
  275. }
  276. },
  277. created() {
  278. }
  279. };
  280. </script>
  281. <style scoped>
  282. .header-wrapper {
  283. background-color: #f5f5f6;
  284. padding-top: 15px;
  285. }
  286. .image_text{
  287. padding:25px 0 55px 0 ;
  288. }
  289. #header{
  290. position: relative;
  291. top:-40px;
  292. }
  293. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  294. background-color: #409eff !important;
  295. color: #FFF;
  296. }
  297. /deep/ .el-pagination.is-background .el-pager li.active {
  298. color: #fff;
  299. cursor: default;
  300. background-color: #409eff !important;
  301. }
  302. /deep/ .el-pagination.is-background .el-pager li:hover {
  303. color: #409eff !important;
  304. }
  305. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  306. color: #409eff !important;
  307. }
  308. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  309. background-color: #409eff !important;
  310. color: #FFF;
  311. }
  312. #success{
  313. background-color: #5bb973;
  314. color: white;
  315. }
  316. .text-over{
  317. overflow: hidden;
  318. text-overflow: ellipsis;
  319. vertical-align: middle;
  320. white-space: nowrap;
  321. }
  322. .image_title{
  323. display: inline-block;
  324. width: 80%;
  325. cursor: default;
  326. color: rgb(66, 98, 144);
  327. }
  328. .image_desc{
  329. -webkit-line-clamp: 2;
  330. -webkit-box-orient: vertical;
  331. display: -webkit-box;
  332. text-overflow: ellipsis;
  333. overflow: hidden;
  334. }
  335. .heart-stroke{
  336. stroke: #666;
  337. stroke-width: 2;
  338. fill: #fff
  339. }
  340. .stars_active{
  341. fill: #FA8C16 !important;
  342. stroke:#FA8C16 !important
  343. }
  344. </style>