You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.7 KiB

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
  1. <urban-filemanager>
  2. <div class="bucket-filemanager">
  3. <div class="file-multi">
  4. <urban-filemanager-actions files={ state.marked }></urban-filemanager-actions>
  5. </div>
  6. <div class="file-table">
  7. <urban-filemanager-parent handleClick={ handleParentClick } if={ state.path.length > 0 }></urban-filemanager-parent>
  8. <template each={ file in state.files }>
  9. <div class="file-table__row">
  10. <div class="file-table__column file-table__column--select" onchange={ (event) => { handleMarked(event, file) } }>
  11. <input type="checkbox" value="true" />
  12. </div>
  13. <div if={ file.is_file } class="file-table__column file-table__column--filename">
  14. { file.filename }
  15. </div>
  16. <div if={ !file.is_file } class="file-table__column file-table__column--filename" onclick={ (event) => { handleDirectoryClick(event, file) } }>
  17. <svg class="icon fill-primary mr-2" aria-hidden="true">
  18. <use xlink:href="/symbol-defs.svg#icon-folder"></use>
  19. </svg>
  20. { file.filename }
  21. </div>
  22. <div if={ file.is_file } class="file-table__column file-table__column--size">
  23. <div class="file-table__inner has-text-right width-100">{ file.meta.size }</div>
  24. </div>
  25. <div if={ file.is_file } class="file-table__column file-table__column--date">
  26. <div class="file-table__inner has-text-right">{ file.meta.updated_at }</div>
  27. </div>
  28. <div class="file-table__column file-table__column--actions">
  29. <div class="file-table__inner has-text-right">
  30. <button type="button" disabled={ true } onclick={ (event) => { handlePreview(event, file) } }>
  31. <svg class="icon fill-success mr-1" aria-hidden="true">
  32. <use xlink:href="/symbol-defs.svg#icon-eye"></use>
  33. </svg>
  34. </button>
  35. <button type="button" onclick={ (event) => { handlePreview(event, file) } }>
  36. <svg class="icon fill-success mr-1" aria-hidden="true">
  37. <use xlink:href="/symbol-defs.svg#icon-download"></use>
  38. </svg>
  39. </button>
  40. <button type="button" onclick={ (event) => { handlePreview(event, file) } }>
  41. <svg class="icon fill-danger mr-1" aria-hidden="true">
  42. <use xlink:href="/symbol-defs.svg#icon-delete"></use>
  43. </svg>
  44. </button>
  45. <button type="button" onclick={ (event) => { handlePreview(event, file) } }>
  46. <svg class="icon fill-grey mr-1" aria-hidden="true">
  47. <use xlink:href="/symbol-defs.svg#icon-build"></use>
  48. </svg>
  49. </button>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. </div>
  55. </div>
  56. <script>
  57. import axios from 'axios'
  58. import File from './file.riot'
  59. import Directory from './directory.riot'
  60. import Parent from './parent.riot'
  61. import Actions from './actions.riot'
  62. riot.register('urban-filemanager-file', File)
  63. riot.register('urban-filemanager-directory', Directory)
  64. riot.register('urban-filemanager-parent', Parent)
  65. riot.register('urban-filemanager-actions', Actions)
  66. export default {
  67. state: {
  68. files: [
  69. ],
  70. path: [
  71. ],
  72. marked: [
  73. ]
  74. },
  75. /**
  76. *
  77. *
  78. * @param {[type]} props [description]
  79. * @param {[type]} state [description]
  80. *
  81. *
  82. */
  83. onBeforeMount(props, state) {
  84. state.files = props.files
  85. },
  86. /**
  87. *
  88. * @param {[type]} event [description]
  89. * @param {[type]} file [description]
  90. *
  91. */
  92. handlePreview(event, file) {
  93. console.log(file)
  94. },
  95. /**
  96. *
  97. *
  98. *
  99. */
  100. handleParentClick(event) {
  101. this.state.path.pop()
  102. this.files()
  103. },
  104. /**
  105. *
  106. *
  107. *
  108. */
  109. handleDirectoryClick(event, file) {
  110. this.state.path.push(file.filename)
  111. this.files()
  112. },
  113. /**
  114. *
  115. *
  116. *
  117. *
  118. */
  119. handleMarked(event, file) {
  120. let exists = false
  121. this.state.marked.forEach((f, index) => {
  122. if (file.filename === f.filename) {
  123. exists = true
  124. }
  125. })
  126. if (exists === false) {
  127. this.state.marked.push(file)
  128. } else {
  129. this.state.marked.splice(this.state.marked.indexOf(file), 1)
  130. }
  131. this.update()
  132. },
  133. /**
  134. *
  135. *
  136. *
  137. */
  138. files() {
  139. axios.get('/api/file/' + this.props.id, {
  140. params: {
  141. path: this.state.path.join('/')
  142. }
  143. }).then((response) => {
  144. this.state.files = response.data.files
  145. this.update()
  146. })
  147. },
  148. }
  149. </script>
  150. </urban-filemanager>