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.

97 lines
2.3 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
  1. <urban-filemanager>
  2. <div class="bucket-filemanager">
  3. <div class="file-table">
  4. <urban-filemanager-parent handleClick={ handleParentClick } if={ state.path.length > 0 }></urban-filemanager-parent>
  5. <template each={ file in state.files }>
  6. <urban-filemanager-file
  7. if={ file.is_file }
  8. file={ file }
  9. handleClick={ handleFileClick }
  10. handleMarked={ handleMarked }
  11. ></urban-filemanager-file>
  12. <urban-filemanager-directory
  13. if={ !file.is_file }
  14. file={ file }
  15. handleClick={ handleDirectoryClick }
  16. handleMarked={ handleMarked }
  17. ></urban-filemanager-directory>
  18. </template>
  19. </div>
  20. </div>
  21. <script>
  22. import axios from 'axios'
  23. import File from './file.riot'
  24. import Directory from './directory.riot'
  25. import Parent from './parent.riot'
  26. riot.register('urban-filemanager-file', File)
  27. riot.register('urban-filemanager-directory', Directory)
  28. riot.register('urban-filemanager-parent', Parent)
  29. export default {
  30. state: {
  31. files: [
  32. ],
  33. path: [
  34. ]
  35. },
  36. onBeforeMount(props, state) {
  37. state.files = props.files
  38. },
  39. handleFileClick() {
  40. },
  41. /**
  42. *
  43. *
  44. * @param {object} event
  45. *
  46. */
  47. handleParentClick(event) {
  48. this.state.path.pop()
  49. this.files()
  50. },
  51. /**
  52. *
  53. *
  54. *
  55. */
  56. handleDirectoryClick(event, file) {
  57. this.state.path.push(file)
  58. this.files()
  59. },
  60. /**
  61. *
  62. *
  63. */
  64. files() {
  65. axios.get('/api/file/' + this.props.id, {
  66. params: {
  67. path: this.state.path.join('/')
  68. }
  69. }).then((response) => {
  70. this.state.files = response.data.files
  71. this.update()
  72. })
  73. },
  74. /**
  75. *
  76. *
  77. */
  78. handleMarked() {
  79. console.log('marked')
  80. },
  81. }
  82. </script>
  83. </urban-filemanager>