diff --git a/api.go b/api.go index 8f0e4c37..ceb5fb0e 100644 --- a/api.go +++ b/api.go @@ -59,8 +59,6 @@ func serveAPI(c *requestContext, w http.ResponseWriter, r *http.Request) (int, e } } - fmt.Println(c.us) - switch router { case "download": return downloadHandler(c, w, r) @@ -524,14 +522,12 @@ func usersPutHandler(c *requestContext, w http.ResponseWriter, r *http.Request) pw, err := hashPassword(u.Password) if err != nil { - fmt.Println(err) return http.StatusInternalServerError, err } c.us.Password = pw err = c.fm.db.UpdateField(&User{ID: c.us.ID}, "Password", pw) if err != nil { - fmt.Println(err) return http.StatusInternalServerError, err } diff --git a/assets/src/components/Editor.vue b/assets/src/components/Editor.vue index b4b08a74..dd1b2a09 100644 --- a/assets/src/components/Editor.vue +++ b/assets/src/components/Editor.vue @@ -1,16 +1,18 @@ diff --git a/assets/src/components/Listing.vue b/assets/src/components/Listing.vue index b8eee257..4e22fcec 100644 --- a/assets/src/components/Listing.vue +++ b/assets/src/components/Listing.vue @@ -172,10 +172,9 @@ export default { buttons.done('upload') this.$store.commit('setReload', true) }) - .catch(e => { + .catch(error => { buttons.done('upload') - // TODO: show error in box - console.log(e) + this.$store.commit('showError', error) }) return false diff --git a/assets/src/components/Main.vue b/assets/src/components/Main.vue index 96f14ec2..fda49a1c 100644 --- a/assets/src/components/Main.vue +++ b/assets/src/components/Main.vue @@ -13,7 +13,7 @@ search - @@ -171,8 +171,6 @@ export default { }, created () { this.fetchData() - // TODO: finish this box - // this.$store.commit('showHover', 'error') }, watch: { '$route': 'fetchData', @@ -184,59 +182,7 @@ export default { mounted () { updateColumnSizes() window.addEventListener('resize', updateColumnSizes) - window.addEventListener('keydown', (event) => { - // Esc! - if (event.keyCode === 27) { - this.$store.commit('closeHovers') - - // Unselect all files and folders. - if (this.req.kind === 'listing') { - let items = document.getElementsByClassName('item') - Array.from(items).forEach(link => { - link.setAttribute('aria-selected', false) - }) - - this.$store.commit('resetSelected') - } - - return - } - - // Del! - if (event.keyCode === 46) { - if (this.showDeleteButton) { - this.$store.commit('showHover', 'delete') - } - } - - // F1! - if (event.keyCode === 112) { - event.preventDefault() - this.$store.commit('showHover', 'help') - } - - // F2! - if (event.keyCode === 113) { - if (this.showRenameButton) { - this.$store.commit('showHover', 'rename') - } - } - - // CTRL + S - if (event.ctrlKey || event.metaKey) { - switch (String.fromCharCode(event.which).toLowerCase()) { - case 's': - event.preventDefault() - - if (this.req.kind !== 'editor') { - window.location = '?download=true' - return - } - - // TODO: save file on editor! - } - } - }) + window.addEventListener('keydown', this.keyEvent) }, methods: { fetchData () { @@ -262,12 +208,61 @@ export default { this.loading = false }) .catch(error => { - // TODO: 404, 403 and 500! console.log(error) this.error = error this.loading = false }) }, + keyEvent (event) { + // Esc! + if (event.keyCode === 27) { + this.$store.commit('closeHovers') + + if (this.req.kind !== 'listing') { + return + } + + // If we're on a listing, unselect all files and folders. + let items = document.getElementsByClassName('item') + Array.from(items).forEach(link => { + link.setAttribute('aria-selected', false) + }) + + this.$store.commit('resetSelected') + } + + // Del! + if (event.keyCode === 46) { + if (this.showDeleteButton && this.req.kind !== 'editor') { + this.$store.commit('showHover', 'delete') + } + } + + // F1! + if (event.keyCode === 112) { + event.preventDefault() + this.$store.commit('showHover', 'help') + } + + // F2! + if (event.keyCode === 113) { + if (this.showRenameButton) { + this.$store.commit('showHover', 'rename') + } + } + + // CTRL + S + if (event.ctrlKey || event.metaKey) { + if (String.fromCharCode(event.which).toLowerCase() === 's') { + event.preventDefault() + + if (this.req.kind !== 'editor') { + document.getElementById('download-button').click() + return + } + } + } + }, openSidebar () { this.$store.commit('showHover', 'sidebar') }, diff --git a/assets/src/components/buttons/Download.vue b/assets/src/components/buttons/Download.vue index cb38638d..d1534be4 100644 --- a/assets/src/components/buttons/Download.vue +++ b/assets/src/components/buttons/Download.vue @@ -1,5 +1,5 @@