2
0

Test.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div>
  3. <page-metadata title="Admin | Test" />
  4. <div class="admin-container">
  5. <advanced-table
  6. :column-default="columnDefault"
  7. :columns="columns"
  8. :filters="filters"
  9. data-action="songs.getData"
  10. >
  11. <template #column-thumbnailImage="slotProps">
  12. <img
  13. class="song-thumbnail"
  14. :src="slotProps.item.thumbnail"
  15. onerror="this.src='/assets/notes-transparent.png'"
  16. loading="lazy"
  17. />
  18. </template>
  19. <template #column-thumbnailUrl="slotProps">
  20. <a :href="slotProps.item.thumbnail" target="_blank">
  21. {{ slotProps.item.thumbnail }}
  22. </a>
  23. </template>
  24. <template #column-_id="slotProps">
  25. <span :title="slotProps.item._id">{{
  26. slotProps.item._id
  27. }}</span>
  28. </template>
  29. <template #column-youtubeId="slotProps">
  30. <a
  31. :href="
  32. 'https://www.youtube.com/watch?v=' +
  33. `${slotProps.item.youtubeId}`
  34. "
  35. target="_blank"
  36. >
  37. {{ slotProps.item.youtubeId }}
  38. </a>
  39. </template>
  40. <template #column-title="slotProps">
  41. <span :title="slotProps.item.title">{{
  42. slotProps.item.title
  43. }}</span>
  44. </template>
  45. <template #column-artists="slotProps">
  46. <span :title="slotProps.item.artists.join(', ')">{{
  47. slotProps.item.artists.join(", ")
  48. }}</span>
  49. </template>
  50. <template #column-genres="slotProps">
  51. <span :title="slotProps.item.genres.join(', ')">{{
  52. slotProps.item.genres.join(", ")
  53. }}</span>
  54. </template>
  55. <template #column-requestedBy="slotProps">
  56. <user-id-to-username
  57. :user-id="slotProps.item.requestedBy"
  58. :link="true"
  59. />
  60. </template>
  61. <template #column-actions="slotProps">
  62. <button
  63. class="button is-primary"
  64. @click.prevent="edit(slotProps.item)"
  65. content="Edit Song"
  66. v-tippy
  67. >
  68. <i class="material-icons">edit</i>
  69. </button>
  70. </template>
  71. <!-- <template #bulk-actions="slotProps">
  72. A {{ slotProps.item.length }}
  73. </template>
  74. <template #bulk-actions-right="slotProps">
  75. B {{ slotProps.item.length }}
  76. </template> -->
  77. </advanced-table>
  78. </div>
  79. <edit-song v-if="modals.editSong" song-type="songs" :key="song._id" />
  80. <report v-if="modals.report" />
  81. </div>
  82. </template>
  83. <script>
  84. import { mapState, mapActions } from "vuex";
  85. import { defineAsyncComponent } from "vue";
  86. import AdvancedTable from "@/components/AdvancedTable.vue";
  87. import UserIdToUsername from "@/components/UserIdToUsername.vue";
  88. export default {
  89. components: {
  90. AdvancedTable,
  91. UserIdToUsername,
  92. EditSong: defineAsyncComponent(() =>
  93. import("@/components/modals/EditSong")
  94. ),
  95. Report: defineAsyncComponent(() =>
  96. import("@/components/modals/Report.vue")
  97. )
  98. },
  99. data() {
  100. return {
  101. columnDefault: {
  102. sortable: true,
  103. hidable: true,
  104. defaultVisibility: "shown",
  105. draggable: true,
  106. resizable: true,
  107. pinable: true,
  108. minWidth: 200,
  109. maxWidth: 600
  110. },
  111. columns: [
  112. {
  113. name: "thumbnailImage",
  114. displayName: "Thumb",
  115. properties: ["thumbnail"],
  116. sortable: false,
  117. minWidth: 120,
  118. width: 120,
  119. maxWidth: 120,
  120. resizable: false
  121. },
  122. {
  123. name: "_id",
  124. displayName: "Musare ID",
  125. properties: ["_id"],
  126. sortProperty: "_id",
  127. width: 220
  128. },
  129. {
  130. name: "youtubeId",
  131. displayName: "YouTube ID",
  132. properties: ["youtubeId"],
  133. sortProperty: "youtubeId",
  134. minWidth: 155,
  135. width: 155
  136. },
  137. {
  138. name: "title",
  139. displayName: "Title",
  140. properties: ["title"],
  141. sortProperty: "title"
  142. },
  143. {
  144. name: "artists",
  145. displayName: "Artists",
  146. properties: ["artists"],
  147. sortable: false
  148. },
  149. {
  150. name: "genres",
  151. displayName: "Genres",
  152. properties: ["genres"],
  153. sortable: false
  154. },
  155. {
  156. name: "thumbnailUrl",
  157. displayName: "Thumbnail (URL)",
  158. properties: ["thumbnail"],
  159. sortProperty: "thumbnail",
  160. defaultVisibility: "hidden"
  161. },
  162. {
  163. name: "requestedBy",
  164. displayName: "Requested By",
  165. properties: ["requestedBy"],
  166. sortProperty: "requestedBy",
  167. width: 200
  168. },
  169. {
  170. name: "actions",
  171. displayName: "Actions",
  172. properties: ["_id"],
  173. sortable: false,
  174. hidable: false,
  175. width: 100,
  176. resizable: false
  177. }
  178. ],
  179. filters: [
  180. {
  181. name: "_id",
  182. displayName: "Musare ID",
  183. property: "_id",
  184. filterTypes: ["exact"],
  185. defaultFilterType: "exact"
  186. },
  187. {
  188. name: "youtubeId",
  189. displayName: "YouTube ID",
  190. property: "youtubeId",
  191. filterTypes: ["contains", "exact", "regex"],
  192. defaultFilterType: "contains"
  193. },
  194. {
  195. name: "title",
  196. displayName: "Title",
  197. property: "title",
  198. filterTypes: ["contains", "exact", "regex"],
  199. defaultFilterType: "contains"
  200. },
  201. {
  202. name: "artists",
  203. displayName: "Artists",
  204. property: "artists",
  205. filterTypes: ["contains", "exact", "regex"],
  206. defaultFilterType: "contains"
  207. },
  208. {
  209. name: "genres",
  210. displayName: "Genres",
  211. property: "genres",
  212. filterTypes: ["contains", "exact", "regex"],
  213. defaultFilterType: "contains"
  214. },
  215. {
  216. name: "thumbnail",
  217. displayName: "Thumbnail",
  218. property: "thumbnail",
  219. filterTypes: ["contains", "exact", "regex"],
  220. defaultFilterType: "contains"
  221. },
  222. {
  223. name: "requestedBy",
  224. displayName: "Requested By",
  225. property: "requestedBy",
  226. filterTypes: ["contains", "exact", "regex"],
  227. defaultFilterType: "contains"
  228. }
  229. ]
  230. };
  231. },
  232. computed: {
  233. ...mapState("modalVisibility", {
  234. modals: state => state.modals
  235. }),
  236. ...mapState("modals/editSong", {
  237. song: state => state.song
  238. })
  239. },
  240. mounted() {},
  241. beforeUnmount() {},
  242. methods: {
  243. edit(song) {
  244. this.editSong(song);
  245. this.openModal("editSong");
  246. },
  247. ...mapActions("modals/editSong", ["editSong"]),
  248. ...mapActions("modalVisibility", ["openModal"])
  249. }
  250. };
  251. </script>
  252. <style lang="scss" scoped>
  253. .admin-container {
  254. max-width: 1900px;
  255. margin: 0 auto;
  256. padding: 0 10px;
  257. }
  258. .song-thumbnail {
  259. display: block;
  260. max-width: 50px;
  261. margin: 0 auto;
  262. }
  263. </style>