Advertisement
claukiller

Untitled

Jun 1st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. <template>
  2. <div class="height-0100 width-0100">
  3. <div class="height-0100 display-f position-r">
  4. <div class="padding-t-60 display-f width-0100">
  5. <div class="display-f flex-direction-c height-0100 width-0100 margin-t-40">
  6. <!-- contenido con tablas [docs] -->
  7. <div class="overflow-a height-0100 bg-color-w-0100">
  8. <table class="js-table-main display responsive no-wrap stickyThead width-0100 js-datatable-docs">
  9. <thead class="width-0100 bg-color-thead">
  10. <tr class="bg-color-thead height-50">
  11. <th class="width-20 padding-16-im"></th>
  12. <th class="fablet tablet desktop">Nombre</th>
  13. <th class="tablet desktop">Tamaño</th>
  14. <th class="fablet tablet desktop">Modificación</th>
  15. <th>Opciones</th>
  16. </tr>
  17. </thead>
  18. <tbody>
  19. <tr class="hover-link cursor-p border-b-1 border-solid border-color-b-005 height-50 vertical-align-m bg-color-n" :key="file.path" v-for="file of list">
  20. <td class="width-20 padding-16-im vertical-align-tb"></td>
  21. <td class="opacity-050 padding-l-10 ellipsis">
  22. <span v-if="file.extension != '' ">
  23. <a :href="file.webViewLink">{{file.filename}}.{{file.extension}} </a>
  24. </span>
  25. <span v-else>
  26. <a :href="file.webViewLink">{{file.filename}}</a>
  27. </span>
  28. </td>
  29. <td class="opacity-050 padding-l-10 ellipsis">
  30. <a :href="file.webViewLink">{{convertToMbs(file.size)}} MB</a>
  31. </td>
  32. <td class="opacity-050 padding-l-10 ellipsis">
  33. <a :href="file.webViewLink">{{ file.modifiedTime | moment('LLLL') }}</a>
  34. </td>
  35. <td class="opacity-050 padding-l-10 ellipsis">
  36. <button @click="visible =! visible"> : </button>
  37. <transition v-if ="visible">
  38. <div v-show="visible" class="border-radius-modal sh-modal bg-color-w-0100 position-a zindex-10 right-30 zindex-15 dropdown__content margin-t-3">
  39. <nav class="position-r padding-t-16 padding-b-16 padding-r-10 padding-l-10">
  40. <ul>
  41. <li>
  42. <button v-on:click='downloadFile(file)'>Descargar</button>
  43. </li>
  44. <li>
  45. <button v-on:click='deleteFile(file)'>Eliminar</button>
  46. </li>
  47. </ul>
  48. </nav>
  49. </div>
  50. </transition>
  51. </td>
  52.  
  53. </tr>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <!-- end contenido con tablas [docs] -->
  62. </template>
  63.  
  64. <script>
  65. import ApiClient from '@/api/ApiClient'
  66. export default {
  67. data () {
  68. return {list: [], visible: false}
  69. },
  70. created () {
  71. ApiClient.getClientApi().get('/list')
  72. .then(response => {
  73. this.list = response.data
  74. })
  75. },
  76. methods: {
  77. convertToMbs (bytes) {
  78. return ((bytes / 1024) / 1024).toFixed(2)
  79. },
  80. downloadFile (file) {
  81. var path = file.path
  82. var filename = file.filename + '.' + file.extension
  83. var mimetype = file.mimetype
  84.  
  85. ApiClient.getClientApi().post('/get', {path, filename, mimetype}, {responseType: 'blob'})
  86. .then(response => {
  87. let blob = new Blob([response.data], { type: mimetype })
  88. let link = document.createElement('a')
  89. link.href = window.URL.createObjectURL(blob)
  90. link.download = filename
  91. link.click()
  92. })
  93. },
  94. deleteFile (file) {
  95. var path = file.path
  96. ApiClient.getClientApi().get('/delete/' + path)
  97. .then(response => {
  98. console.log(response)
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104.  
  105. <!-- Add "scoped" attribute to limit CSS to this component only -->
  106. <style scoped lang="scss">
  107. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement