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.

99 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
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. import Actions from './actions.riot'
  27. riot.register('urban-filemanager-file', File)
  28. riot.register('urban-filemanager-directory', Directory)
  29. riot.register('urban-filemanager-parent', Parent)
  30. export default {
  31. state: {
  32. files: [
  33. ],
  34. path: [
  35. ]
  36. },
  37. onBeforeMount(props, state) {
  38. state.files = props.files
  39. },
  40. handleFileClick() {
  41. },
  42. /**
  43. *
  44. *
  45. * @param {object} event
  46. *
  47. */
  48. handleParentClick(event) {
  49. this.state.path.pop()
  50. this.files()
  51. },
  52. /**
  53. *
  54. *
  55. *
  56. */
  57. handleDirectoryClick(event, file) {
  58. this.state.path.push(file)
  59. this.files()
  60. },
  61. /**
  62. *
  63. *
  64. *
  65. */
  66. files() {
  67. axios.get('/api/file/' + this.props.id, {
  68. params: {
  69. path: this.state.path.join('/')
  70. }
  71. }).then((response) => {
  72. this.state.files = response.data.files
  73. this.update()
  74. })
  75. },
  76. /**
  77. *
  78. *
  79. */
  80. handleMarked() {
  81. console.log('marked')
  82. },
  83. }
  84. </script>
  85. </urban-filemanager>