Comments and bugfixes
parent
063cd4f5ed
commit
5eab62e0aa
|
@ -28,11 +28,13 @@ export default {
|
||||||
this.closeHovers()
|
this.closeHovers()
|
||||||
buttons.loading('delete')
|
buttons.loading('delete')
|
||||||
|
|
||||||
|
// If we are not on a listing, delete the current
|
||||||
|
// opened file.
|
||||||
if (this.req.kind !== 'listing') {
|
if (this.req.kind !== 'listing') {
|
||||||
api.delete(this.$route.path)
|
api.delete(this.$route.path)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
buttons.done('delete')
|
buttons.done('delete')
|
||||||
this.$router.push({path: url.removeLastDir(this.$route.path) + '/'})
|
this.$router.push({ path: url.removeLastDir(this.$route.path) + '/' })
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
buttons.done('delete')
|
buttons.done('delete')
|
||||||
|
@ -47,6 +49,8 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the promises array and fill it with
|
||||||
|
// the delete request for every selected file.
|
||||||
let promises = []
|
let promises = []
|
||||||
|
|
||||||
for (let index of this.selected) {
|
for (let index of this.selected) {
|
||||||
|
@ -55,13 +59,12 @@ export default {
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$store.commit('setReload', true)
|
|
||||||
buttons.done('delete')
|
buttons.done('delete')
|
||||||
|
this.$store.commit('setReload', true)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error)
|
|
||||||
this.$store.commit('setReload', true)
|
|
||||||
buttons.done('delete')
|
buttons.done('delete')
|
||||||
|
this.$store.commit('setReload', true)
|
||||||
this.$store.commit('showError', error)
|
this.$store.commit('showError', error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,14 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
humanSize: function () {
|
humanSize: function () {
|
||||||
|
// If there are no files selected or this is not a listing
|
||||||
|
// show the human file size of the current request.
|
||||||
if (this.selectedCount === 0 || this.req.kind !== 'listing') {
|
if (this.selectedCount === 0 || this.req.kind !== 'listing') {
|
||||||
return filesize(this.req.size)
|
return filesize(this.req.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, sum the sizes of each selected file and returns
|
||||||
|
// its human form.
|
||||||
var sum = 0
|
var sum = 0
|
||||||
|
|
||||||
for (let i = 0; i < this.selectedCount; i++) {
|
for (let i = 0; i < this.selectedCount; i++) {
|
||||||
|
@ -53,17 +57,27 @@ export default {
|
||||||
return filesize(sum)
|
return filesize(sum)
|
||||||
},
|
},
|
||||||
humanTime: function () {
|
humanTime: function () {
|
||||||
|
// If there are no selected files, return the current request
|
||||||
|
// modified time.
|
||||||
if (this.selectedCount === 0) {
|
if (this.selectedCount === 0) {
|
||||||
return moment(this.req.modified).fromNow()
|
return moment(this.req.modified).fromNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise return the modified time of the first item
|
||||||
|
// that is selected since this should not appear when
|
||||||
|
// there is more than one file selected.
|
||||||
return moment(this.req.items[this.selected[0]]).fromNow()
|
return moment(this.req.items[this.selected[0]]).fromNow()
|
||||||
},
|
},
|
||||||
name: function () {
|
name: function () {
|
||||||
|
// Return the name of the current opened file if there
|
||||||
|
// are no selected files.
|
||||||
if (this.selectedCount === 0) {
|
if (this.selectedCount === 0) {
|
||||||
return this.req.name
|
return this.req.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, just return the name of the selected file.
|
||||||
|
// This field won't show when there is more than one
|
||||||
|
// file selected.
|
||||||
return this.req.items[this.selected[0]].name
|
return this.req.items[this.selected[0]].name
|
||||||
},
|
},
|
||||||
dir: function () {
|
dir: function () {
|
||||||
|
@ -79,6 +93,8 @@ export default {
|
||||||
return this.req.items[this.selected[0]].isDir
|
return this.req.items[this.selected[0]].isDir
|
||||||
},
|
},
|
||||||
checksum: function (event, hash) {
|
checksum: function (event, hash) {
|
||||||
|
// Gets the checksum of the current selected or
|
||||||
|
// opened file. Doesn't work for directories.
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let link
|
let link
|
||||||
|
@ -90,12 +106,8 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
api.checksum(link, hash)
|
api.checksum(link, hash)
|
||||||
.then((hash) => {
|
.then((hash) => { event.target.innerHTML = hash })
|
||||||
event.target.innerHTML = hash
|
.catch(error => { this.$store.commit('showError', error) })
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.log(error)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (this.new === '') return
|
if (this.new === '') return
|
||||||
|
|
||||||
|
// Build the path of the new directory.
|
||||||
let uri = this.$route.path
|
let uri = this.$route.path
|
||||||
if (this.$store.state.req.kind !== 'listing') {
|
if (this.$store.state.req.kind !== 'listing') {
|
||||||
uri = url.removeLastDir(uri) + '/'
|
uri = url.removeLastDir(uri) + '/'
|
||||||
|
@ -35,13 +36,10 @@ export default {
|
||||||
uri = uri.replace('//', '/')
|
uri = uri.replace('//', '/')
|
||||||
|
|
||||||
api.post(uri)
|
api.post(uri)
|
||||||
.then(() => {
|
.then(() => { this.$router.push({ path: uri }) })
|
||||||
this.$router.push({ path: uri })
|
.catch(error => { this.$store.commit('showError', error) })
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$store.commit('showError', error)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Close the prompt
|
||||||
this.$store.commit('closeHovers')
|
this.$store.commit('closeHovers')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (this.new === '') return
|
if (this.new === '') return
|
||||||
|
|
||||||
|
// Build the path of the new file.
|
||||||
let uri = this.$route.path
|
let uri = this.$route.path
|
||||||
if (this.$store.state.req.kind !== 'listing') {
|
if (this.$store.state.req.kind !== 'listing') {
|
||||||
uri = url.removeLastDir(uri) + '/'
|
uri = url.removeLastDir(uri) + '/'
|
||||||
|
@ -34,14 +35,12 @@ export default {
|
||||||
uri += this.name
|
uri += this.name
|
||||||
uri = uri.replace('//', '/')
|
uri = uri.replace('//', '/')
|
||||||
|
|
||||||
|
// Create the new file.
|
||||||
api.post(uri)
|
api.post(uri)
|
||||||
.then(() => {
|
.then(() => { this.$router.push({ path: uri }) })
|
||||||
this.$router.push({ path: uri })
|
.catch(error => { this.$store.commit('showError', error) })
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$store.commit('showError', error)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Close the prompt.
|
||||||
this.$store.commit('closeHovers')
|
this.$store.commit('closeHovers')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ export default {
|
||||||
this.$store.commit('closeHovers')
|
this.$store.commit('closeHovers')
|
||||||
},
|
},
|
||||||
oldName: function () {
|
oldName: function () {
|
||||||
|
// Get the current name of the file we are editing.
|
||||||
if (this.req.kind !== 'listing') {
|
if (this.req.kind !== 'listing') {
|
||||||
return this.req.name
|
return this.req.name
|
||||||
}
|
}
|
||||||
|
@ -58,14 +59,12 @@ export default {
|
||||||
this.$router.push({ path: newLink })
|
this.$router.push({ path: newLink })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO: keep selected after reload?
|
|
||||||
this.$store.commit('setReload', true)
|
this.$store.commit('setReload', true)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$store.commit('showError', error)
|
this.$store.commit('showError', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.$store.commit('closeHovers')
|
this.$store.commit('closeHovers')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue