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.

adminImages.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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div >
  3. <div class="ui container" style="width: 80%;">
  4. <div class="ui grid">
  5. <div class="row" style="border: 1px solid #d4d4d5;margin-top: 15px;padding-top: 0;">
  6. <div class="ui attached segment">
  7. <div class="ui form ignore-dirty">
  8. <div class="ui fluid action input">
  9. <input type="text" placeholder="搜镜像Tag/描述/标签..." v-model="search" @keyup.enter="searchName()">
  10. <button class="ui blue button" @click="searchName()">搜索</button>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="ui ten wide column" style="margin: 1rem 0;">
  15. <el-checkbox v-model="checked" style="padding: 0.5rem 1rem;">仅显示平台推荐</el-checkbox>
  16. <el-dropdown @command="handleCommand" trigger="click" style="border: 1px solid rgba(34,36,38,.15);border-radius: 4px;padding: 0.5rem 1rem;">
  17. <span class="el-dropdown-link">
  18. {{dropdownPrivate}}<i class="el-icon-caret-bottom el-icon--right"></i>
  19. </span>
  20. <el-dropdown-menu slot="dropdown">
  21. <el-dropdown-item :command="{label:'全部',private:''}">全部</el-dropdown-item>
  22. <el-dropdown-item :command="{label:'公开',private:false}">公开</el-dropdown-item>
  23. <el-dropdown-item :command="{label:'私有',private:true}">私有</el-dropdown-item>
  24. </el-dropdown-menu>
  25. </el-dropdown>
  26. </div>
  27. <div class="ui six wide column right aligned" style="margin: 1rem 0;">
  28. <a class="ui blue small button" href="/admin/images/commit_image">创建云脑镜像</a>
  29. </div>
  30. <div class="ui sixteen wide column" style="padding: 0;">
  31. <el-table
  32. :data="tableDataCustom"
  33. style="width: 100%"
  34. :header-cell-style="tableHeaderStyle"
  35. >
  36. <el-table-column
  37. label="镜像Tag"
  38. min-width="19%"
  39. align="left"
  40. prop="tag"
  41. >
  42. <template slot-scope="scope">
  43. <div style="display: flex;align-items: center;">
  44. <a class="text-over image_title" :title="scope.row.tag">{{ scope.row.tag }}</a>
  45. <i class="ri-lock-2-line" style="color: #fa8c16;padding: 0 1rem;" v-if="scope.row.isPrivate"></i>
  46. <img v-if="scope.row.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  47. </div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. label="镜像描述"
  52. min-width="28%"
  53. align="left"
  54. prop="description"
  55. >
  56. <template slot-scope="scope">
  57. <div class="image_desc" :title="scope.row.description">{{ scope.row.description}}</div>
  58. <div v-if="!!scope.row.topics">
  59. <span v-for="(topic,index) in scope.row.topics" class="ui repo-topic label topic" style="cursor: default;">{{topic}}</span>
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="cloudbrainType"
  65. label="可用集群"
  66. min-width="10%"
  67. align="center"
  68. >
  69. <template slot-scope="scope">
  70. {{scope.row.cloudbrainType | transformType}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="isPrivate"
  75. label="状态"
  76. min-width="8%"
  77. align="center"
  78. >
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.isPrivate" style="color: rgb(250, 140, 22);">私有</span>
  81. <span v-else style="color: rgb(19, 194, 141);">公开</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. prop="creator"
  86. label="创建者"
  87. min-width="7%"
  88. align="center"
  89. >
  90. <template slot-scope="scope">
  91. <a :href="'/' + scope.row.userName" :title="scope.row.userName">
  92. <img :src="scope.row.relAvatarLink" class="ui avatar image">
  93. </a>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. prop="createdUnix"
  98. label="创建时间"
  99. align="center"
  100. min-width="13%"
  101. >
  102. <template slot-scope="scope">
  103. {{scope.row.createdUnix | transformTimestamp}}
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. align="center"
  108. min-width="23%"
  109. label="操作"
  110. >
  111. <template slot-scope="scope">
  112. <div style="display: flex;justify-content: flex-end;align-items: center;">
  113. <div style="display: flex;align-items: center;cursor: default;;padding: 0 1rem;">
  114. <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke"><path d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"></path></svg>
  115. <span style="line-height: 2;margin-left:0.3rem;">{{scope.row.numStars}}</span>
  116. </div>
  117. <span style="padding: 0 1rem;color: rgb(250, 140, 22);cursor:pointer;" v-if="scope.row.type==5" @click="unSetRecommend(scope.$index,scope.row.id)">取消推荐</span>
  118. <span style="padding: 0 1rem;color: rgb(19, 194, 141);cursor:pointer;" v-if="scope.row.type!==5 && !scope.row.isPrivate" @click="setRecommend(scope.$index,scope.row.id)">设为推荐</span>
  119. <span style="padding: 0 1rem;color:#0366d6;cursor:pointer;" @click="copyUrl(scope.row.place)">复制地址</span>
  120. <div style="padding-left:1rem;cursor:pointer;">
  121. <el-dropdown size="medium">
  122. <span class="el-dropdown-link">
  123. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  124. </span>
  125. <el-dropdown-menu slot="dropdown">
  126. <el-dropdown-item @click.native="eidtImage(scope.row.id)">编辑</el-dropdown-item>
  127. <el-dropdown-item style="color: red;" @click.native="deleteImage(scope.row.id)">删除</el-dropdown-item>
  128. </el-dropdown-menu>
  129. </el-dropdown>
  130. </div>
  131. </div>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. </div>
  136. <div class="ui container" style="padding:2rem 0;text-align:center">
  137. <el-pagination
  138. background
  139. @size-change="handleSizeChangeCustom"
  140. @current-change="handleCurrentChangeCustom"
  141. :current-page="currentPageCustom"
  142. :page-size="pageSizeCustom"
  143. :page-sizes="[5,15,20]"
  144. layout="total, sizes, prev, pager, next, jumper"
  145. :total="totalNumCustom">
  146. </el-pagination>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  155. export default {
  156. components: {
  157. },
  158. data() {
  159. return {
  160. search:'',
  161. dropdownPrivate:'全部',
  162. checked:false,
  163. currentPageCustom:1,
  164. pageSizeCustom:15,
  165. totalNumCustom:0,
  166. paramsCustom:{page:1,pageSize:15,q:'',recommend:false},
  167. tableDataCustom: [],
  168. starCustom:[],
  169. loadingCustom:false,
  170. };
  171. },
  172. methods: {
  173. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  174. if(rowIndex===0){
  175. return 'background:#f5f5f6;color:#606266'
  176. }
  177. },
  178. handleSizeChangeCustom(val){
  179. this.paramsCustom.pageSize = val
  180. this.getImageListCustom()
  181. },
  182. handleCurrentChangeCustom(val){
  183. this.paramsCustom.page = val
  184. this.getImageListCustom()
  185. },
  186. getImageListCustom(){
  187. this.loadingCustom = true
  188. this.$axios.get('/admin/images/data',{
  189. params:this.paramsCustom
  190. }).then((res)=>{
  191. this.totalNumCustom = res.data.count
  192. this.tableDataCustom = res.data.images
  193. this.tableDataCustom.forEach(element => {
  194. this.starCustom.push({id:element.id,})
  195. });
  196. this.loadingCustom = false
  197. })
  198. },
  199. deleteImage(id){
  200. let flag=1
  201. let _this = this
  202. $('.ui.basic.modal.images')
  203. .modal({
  204. onDeny: function() {
  205. flag = false
  206. },
  207. onApprove: function() {
  208. _this.$axios.delete('/image/'+id).then((res)=>{
  209. _this.getImageListCustom()
  210. })
  211. flag = true
  212. },
  213. onHidden: function() {
  214. if (flag == false) {
  215. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  216. }else{
  217. $('.alert').html('删除成功').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  218. }
  219. }
  220. })
  221. .modal('show')
  222. },
  223. eidtImage(id){
  224. location.href = `/image/${id}/imageAdmin`
  225. },
  226. imageStar(index,id,isStar){
  227. if(isStar){
  228. this.$axios.put(`/image/${id}/action/unstar`).then((res)=>{
  229. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars - 1
  230. this.tableDataPublic[index].isStar = false
  231. })
  232. }else{
  233. this.$axios.put(`/image/${id}/action/star`).then((res)=>{
  234. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars + 1
  235. this.tableDataPublic[index].isStar = true
  236. })
  237. }
  238. },
  239. copyUrl(url){
  240. const cInput = document.createElement('input')
  241. cInput.value = url
  242. document.body.appendChild(cInput)
  243. cInput.select()
  244. document.execCommand('Copy')
  245. cInput.remove()
  246. },
  247. searchName(){
  248. this.paramsCustom.q = this.search
  249. this.paramsCustom.page = 1
  250. this.getImageListCustom()
  251. },
  252. setRecommend(index,id){
  253. this.$axios.put(`/admin/image/${id}/action/recommend`).then((res)=>{
  254. this.tableDataCustom[index].type = 5
  255. })
  256. },
  257. unSetRecommend(index,id){
  258. this.$axios.put(`/admin/image/${id}/action/unrecommend`).then((res)=>{
  259. this.tableDataCustom[index].type = 0
  260. })
  261. },
  262. handleCommand(command){
  263. this.dropdownPrivate = command.label
  264. this.paramsCustom.private = command.private
  265. this.getImageListCustom()
  266. }
  267. },
  268. filters:{
  269. transformType(val){
  270. if(val==0){
  271. return "GPU"
  272. }
  273. },
  274. transformPravite(val){
  275. if(val){
  276. return "私有"
  277. }else{
  278. return "公开"
  279. }
  280. },
  281. transformTimestamp(timestamp){
  282. const date = new Date(parseInt(timestamp) * 1000);
  283. const Y = date.getFullYear() + '-';
  284. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  285. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  286. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  287. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()) + ':' ;
  288. const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  289. const dateString = Y + M + D + h + m + s;
  290. return dateString;
  291. },
  292. },
  293. watch:{
  294. checked(val){
  295. this.paramsCustom.page = 1
  296. this.paramsCustom.recommend = val
  297. this.getImageListCustom()
  298. }
  299. },
  300. mounted() {
  301. this.getImageListCustom()
  302. },
  303. created() {
  304. }
  305. };
  306. </script>
  307. <style scoped>
  308. .header-wrapper {
  309. background-color: #f5f5f6;
  310. padding-top: 15px;
  311. }
  312. .image_text{
  313. padding:25px 0 55px 0 ;
  314. }
  315. #header{
  316. position: relative;
  317. top:-40px;
  318. }
  319. .el-dropdown-menu__item--divided{
  320. border-top: 1px solid blue;
  321. }
  322. .el-table thead{
  323. background-color: #f5f5f6;
  324. }
  325. /deep/ .el-tabs__item:hover{
  326. color: #000;
  327. font-weight: 500;
  328. }
  329. /deep/ .el-tabs__item.is-active {
  330. color: #000;
  331. font-weight: 500;
  332. }
  333. /deep/ .el-tabs__active-bar{
  334. background-color:#000
  335. }
  336. #success{
  337. background-color: #5bb973;
  338. color: white;
  339. }
  340. .text-over{
  341. overflow: hidden;
  342. text-overflow: ellipsis;
  343. vertical-align: middle;
  344. white-space: nowrap;
  345. }
  346. .image_title{
  347. display: inline-block;
  348. cursor: default;
  349. color: rgb(66, 98, 144);
  350. }
  351. .image_desc{
  352. -webkit-line-clamp: 2;
  353. -webkit-box-orient: vertical;
  354. display: -webkit-box;
  355. text-overflow: ellipsis;
  356. overflow: hidden;
  357. }
  358. .heart-stroke{
  359. stroke: #FA8C16;
  360. stroke-width: 2;
  361. fill: #fff
  362. }
  363. .stars_active{
  364. fill: #FA8C16 !important;
  365. stroke:#FA8C16 !important
  366. }
  367. .header-new-drop{
  368. width: 100%;
  369. }
  370. </style>