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 18 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
2 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div>
  3. <div class="ui container" style="width: 100% !important;padding-right: 0;">
  4. <div class="ui grid" style="margin: 0 !important">
  5. <div class="row" style="border: 1px solid #d4d4d5;margin-top:0px;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="$i18n['cloudeBrainMirror']['placeholder']" v-model="search"
  10. @keyup.enter="searchName()">
  11. <button class="ui blue button" @click="searchName()">{{$i18n['cloudeBrainMirror']['search']}}</button>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="ui ten wide column" style="margin: 1rem 0;">
  16. <el-checkbox v-model="checked" style="padding: 0.5rem 1rem;">{{$i18n['cloudeBrainMirror']['platform_recommendations']}}</el-checkbox>
  17. <el-dropdown @command="handleCommand" trigger="click"
  18. style="border: 1px solid rgba(34,36,38,.15);border-radius: 4px;padding: 0.5rem 1rem;">
  19. <span class="el-dropdown-link">
  20. {{dropdownPrivate}}<i class="el-icon-caret-bottom el-icon--right"></i>
  21. </span>
  22. <el-dropdown-menu slot="dropdown">
  23. <el-dropdown-item :command="{label:$i18n['all'],private:''}">{{$i18n['all']}}</el-dropdown-item>
  24. <el-dropdown-item :command="{label:$i18n['cloudeBrainMirror']['public'],private:false}">{{$i18n['cloudeBrainMirror']['public']}}</el-dropdown-item>
  25. <el-dropdown-item :command="{label:$i18n['cloudeBrainMirror']['private'],private:true}">{{$i18n['cloudeBrainMirror']['private']}}</el-dropdown-item>
  26. </el-dropdown-menu>
  27. </el-dropdown>
  28. </div>
  29. <div class="ui six wide column right aligned" style="margin: 1rem 0;">
  30. <a class="ui blue small button" href="/admin/images/commit_image">{{$i18n['cloudeBrainMirror']['create_cloud_brain_mirror']}}</a>
  31. </div>
  32. <div class="ui sixteen wide column" style="padding: 0;overflow-x: auto;">
  33. <el-table :data="tableDataCustom" style="width: 100%;min-width:1700px;" :header-cell-style="tableHeaderStyle">
  34. <el-table-column :label="$i18n['cloudeBrainMirror']['mirror_tag']" min-width="19%" align="left" prop="tag">
  35. <template slot-scope="scope">
  36. <div style="display: flex;align-items: center;">
  37. <a class="text-over image_title" :title="scope.row.tag">{{ scope.row.tag }}</a>
  38. <i class="ri-lock-2-line" style="color: #fa8c16;padding: 0 1rem;"
  39. v-if="scope.row.isPrivate"></i>
  40. <img v-if="scope.row.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  41. </div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column :label="$i18n['cloudeBrainMirror']['mirror_description']" min-width="28%" align="left" prop="description">
  45. <template slot-scope="scope">
  46. <div class="image_desc" :title="scope.row.description">{{ scope.row.description}}
  47. </div>
  48. <div v-if="!!scope.row.topics">
  49. <span v-for="(topic,index) in scope.row.topics"
  50. class="ui repo-topic label topic" style="cursor: default;">{{topic}}</span>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="cloudbrainType" :label="$i18n['cloudeBrainMirror']['available_clusters']" min-width="10%" align="center">
  55. <template slot-scope="scope">
  56. {{scope.row.cloudbrainType | transformType}}
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="isPrivate" :label="$i18n['cloudeBrainMirror']['state']" min-width="8%" align="center">
  60. <template slot-scope="scope">
  61. <span v-if="scope.row.isPrivate" style="color: rgb(250, 140, 22);">{{$i18n['cloudeBrainMirror']['private']}}</span>
  62. <span v-else style="color: rgb(19, 194, 141);">{{$i18n['cloudeBrainMirror']['public']}}</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="creator" :label="$i18n['cloudeBrainMirror']['creator']" min-width="7%" align="center">
  66. <template slot-scope="scope">
  67. <a v-if="scope.row.userName||scope.row.relAvatarLink"
  68. :href="'/' + scope.row.userName" :title="scope.row.userName">
  69. <img :src="scope.row.relAvatarLink" class="ui avatar image">
  70. </a>
  71. <a v-else>
  72. <img class="ui avatar image" title="Ghost" src="/user/avatar/ghost/-1">
  73. </a>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="updatedUnix" :label="$i18n['cloudeBrainMirror']['creation_time']" align="center" min-width="13%">
  77. <template slot-scope="scope">
  78. {{scope.row.updatedUnix | transformTimestamp}}
  79. </template>
  80. </el-table-column>
  81. <el-table-column align="center" min-width="23%" :label="$i18n['cloudeBrainMirror']['operation']">
  82. <template slot-scope="scope">
  83. <div style="display: flex;justify-content: flex-end;align-items: center;">
  84. <div
  85. style="display: flex;align-items: center;cursor: default;;padding: 0 1rem;">
  86. <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke">
  87. <path
  88. 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">
  89. </path>
  90. </svg>
  91. <span
  92. style="line-height: 2;margin-left:0.3rem;">{{scope.row.numStars}}</span>
  93. </div>
  94. <span style="padding: 0 1rem;color: rgb(250, 140, 22);cursor:pointer;"
  95. v-if="scope.row.type==5"
  96. @click="unSetRecommend(scope.$index,scope.row.id)">{{$i18n['cloudeBrainMirror']['cancel_recommendation']}}</span>
  97. <span style="padding: 0 1rem;color: rgb(19, 194, 141);cursor:pointer;"
  98. v-if="scope.row.type!==5 && !scope.row.isPrivate"
  99. @click="setRecommend(scope.$index,scope.row.id)">{{$i18n['cloudeBrainMirror']['set_as_recommended']}}</span>
  100. <span style="padding: 0 1rem;color:#0366d6;cursor:pointer;"
  101. @click="copyUrl(scope.row.place)">{{$i18n['cloudeBrainMirror']['copy_address']}}</span>
  102. <div style="padding-left:1rem;cursor:pointer;">
  103. <el-dropdown size="medium">
  104. <span class="el-dropdown-link">
  105. {{$i18n['cloudeBrainMirror']['more']}}<i class="el-icon-arrow-down el-icon--right"></i>
  106. </span>
  107. <el-dropdown-menu slot="dropdown">
  108. <el-dropdown-item @click.native="eidtImage(scope.row.id)">{{$i18n['cloudeBrainMirror']['edit']}}
  109. </el-dropdown-item>
  110. <el-dropdown-item style="color: red;"
  111. @click.native="deleteImage(scope.row.id)">{{$i18n['cloudeBrainMirror']['delete']}}</el-dropdown-item>
  112. </el-dropdown-menu>
  113. </el-dropdown>
  114. </div>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. </div>
  120. <div class="ui container" style="padding:2rem 0;text-align:center">
  121. <el-pagination background @size-change="handleSizeChangeCustom"
  122. @current-change="handleCurrentChangeCustom" :current-page="currentPageCustom"
  123. :page-size="pageSizeCustom" :page-sizes="[5,15,20]"
  124. layout="total, sizes, prev, pager, next, jumper" :total="totalNumCustom">
  125. </el-pagination>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  134. export default {
  135. components: {
  136. },
  137. data() {
  138. return {
  139. search: '',
  140. dropdownPrivate: '全部',
  141. checked: false,
  142. currentPageCustom: 1,
  143. pageSizeCustom: 15,
  144. totalNumCustom: 0,
  145. paramsCustom: { page: 1, pageSize: 15, q: '', recommend: false },
  146. tableDataCustom: [],
  147. starCustom: [],
  148. loadingCustom: false,
  149. };
  150. },
  151. methods: {
  152. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  153. if (rowIndex === 0) {
  154. return 'background:#f5f5f6;color:#606266'
  155. }
  156. },
  157. handleSizeChangeCustom(val) {
  158. this.paramsCustom.pageSize = val
  159. this.getImageListCustom()
  160. },
  161. handleCurrentChangeCustom(val) {
  162. this.paramsCustom.page = val
  163. this.getImageListCustom()
  164. },
  165. getImageListCustom() {
  166. this.loadingCustom = true
  167. this.$axios.get('/admin/images/data', {
  168. params: this.paramsCustom
  169. }).then((res) => {
  170. this.totalNumCustom = res.data.count
  171. this.tableDataCustom = res.data.images
  172. this.tableDataCustom.forEach(element => {
  173. this.starCustom.push({ id: element.id, })
  174. });
  175. this.loadingCustom = false
  176. })
  177. },
  178. deleteImage(id) {
  179. let flag = 1
  180. let _this = this
  181. $('.ui.basic.modal.images')
  182. .modal({
  183. onDeny: function () {
  184. flag = false
  185. },
  186. onApprove: function () {
  187. _this.$axios.delete('/image/' + id).then((res) => {
  188. _this.getImageListCustom()
  189. })
  190. flag = true
  191. },
  192. onHidden: function () {
  193. if (flag == false) {
  194. $('.alert').html(_this.$i18n['canceled_operation']).removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  195. } else {
  196. $('.alert').html(_this.$i18n['successfully_deleted']).removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  197. }
  198. }
  199. })
  200. .modal('show')
  201. },
  202. eidtImage(id) {
  203. location.href = `/image/${id}/imageAdmin`
  204. },
  205. imageStar(index, id, isStar) {
  206. if (isStar) {
  207. this.$axios.put(`/image/${id}/action/unstar`).then((res) => {
  208. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars - 1
  209. this.tableDataPublic[index].isStar = false
  210. })
  211. } else {
  212. this.$axios.put(`/image/${id}/action/star`).then((res) => {
  213. this.tableDataPublic[index].numStars = this.tableDataPublic[index].numStars + 1
  214. this.tableDataPublic[index].isStar = true
  215. })
  216. }
  217. },
  218. copyUrl(url) {
  219. const cInput = document.createElement('input')
  220. cInput.value = url
  221. document.body.appendChild(cInput)
  222. cInput.select()
  223. document.execCommand('Copy')
  224. cInput.remove()
  225. },
  226. searchName() {
  227. this.paramsCustom.q = this.search
  228. this.paramsCustom.page = 1
  229. this.getImageListCustom()
  230. },
  231. setRecommend(index, id) {
  232. this.$axios.put(`/admin/image/${id}/action/recommend`).then((res) => {
  233. this.tableDataCustom[index].type = 5
  234. })
  235. },
  236. unSetRecommend(index, id) {
  237. this.$axios.put(`/admin/image/${id}/action/unrecommend`).then((res) => {
  238. this.tableDataCustom[index].type = 0
  239. })
  240. },
  241. handleCommand(command) {
  242. this.dropdownPrivate = command.label
  243. this.paramsCustom.private = command.private
  244. this.getImageListCustom()
  245. }
  246. },
  247. filters: {
  248. transformType(val) {
  249. if (val == 0) {
  250. return "GPU"
  251. }
  252. },
  253. transformPravite(val) {
  254. if (val) {
  255. return this.$i18n['cloudeBrainMirror']['private'];
  256. } else {
  257. return this.$i18n['cloudeBrainMirror']['public'];
  258. }
  259. },
  260. transformTimestamp(timestamp) {
  261. const date = new Date(parseInt(timestamp) * 1000);
  262. const Y = date.getFullYear() + '-';
  263. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  264. const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
  265. const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  266. const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  267. const s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()); // 秒
  268. const dateString = Y + M + D + h + m + s;
  269. return dateString;
  270. },
  271. },
  272. watch: {
  273. checked(val) {
  274. this.paramsCustom.page = 1
  275. this.paramsCustom.recommend = val
  276. this.getImageListCustom()
  277. }
  278. },
  279. mounted() {
  280. this.getImageListCustom()
  281. },
  282. created() {
  283. this.$i18n = window.i18n;
  284. this.dropdownPrivate = this.$i18n['all'];
  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. .el-dropdown-menu__item--divided {
  301. border-top: 1px solid blue;
  302. }
  303. .el-table thead {
  304. background-color: #f5f5f6;
  305. }
  306. /deep/ .el-tabs__item:hover {
  307. color: #000;
  308. font-weight: 500;
  309. }
  310. /deep/ .el-tabs__item.is-active {
  311. color: #000;
  312. font-weight: 500;
  313. }
  314. /deep/ .el-tabs__active-bar {
  315. background-color: #000
  316. }
  317. #success {
  318. background-color: #5bb973;
  319. color: white;
  320. }
  321. .text-over {
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. vertical-align: middle;
  325. white-space: nowrap;
  326. }
  327. .image_title {
  328. display: inline-block;
  329. cursor: default;
  330. color: rgb(66, 98, 144);
  331. }
  332. .image_desc {
  333. -webkit-line-clamp: 2;
  334. -webkit-box-orient: vertical;
  335. display: -webkit-box;
  336. text-overflow: ellipsis;
  337. overflow: hidden;
  338. }
  339. .heart-stroke {
  340. stroke: #FA8C16;
  341. stroke-width: 2;
  342. fill: #fff
  343. }
  344. .stars_active {
  345. fill: #FA8C16 !important;
  346. stroke: #FA8C16 !important
  347. }
  348. .header-new-drop {
  349. width: 100%;
  350. }
  351. </style>