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.

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