2017-06-28 21:20:28 +00:00
|
|
|
<template>
|
2017-06-30 16:49:05 +00:00
|
|
|
<div class="prompt">
|
|
|
|
<h3>File Information</h3>
|
|
|
|
|
|
|
|
<p v-show="selected.length > 1">{{ selected.length }} files selected.</p>
|
|
|
|
|
|
|
|
<p v-show="selected.length < 2"><strong>Display Name:</strong> {{ name() }}</p>
|
|
|
|
<p><strong>Size:</strong> <span id="content_length"></span>{{ humanSize() }}</p>
|
|
|
|
<p v-show="selected.length < 2"><strong>Last Modified:</strong> {{ humanTime() }}</p>
|
|
|
|
|
|
|
|
<section v-show="dir() && selected.length === 0">
|
2017-07-03 10:04:14 +00:00
|
|
|
<p><strong>Number of files:</strong> {{ req.numFiles }}</p>
|
|
|
|
<p><strong>Number of directories:</strong> {{ req.numDirs }}</p>
|
2017-06-30 16:49:05 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section v-show="!dir()">
|
|
|
|
<p><strong>MD5:</strong> <code><a @click="checksum($event, 'md5')">show</a></code></p>
|
|
|
|
<p><strong>SHA1:</strong> <code><a @click="checksum($event, 'sha1')">show</a></code></p>
|
|
|
|
<p><strong>SHA256:</strong> <code><a @click="checksum($event, 'sha256')">show</a></code></p>
|
|
|
|
<p><strong>SHA512:</strong> <code><a @click="checksum($event, 'sha512')">show</a></code></p>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<div>
|
2017-07-04 16:15:38 +00:00
|
|
|
<button type="submit" @click="$store.commit('closeHovers')" class="ok">OK</button>
|
2017-06-28 21:20:28 +00:00
|
|
|
</div>
|
2017-06-30 16:49:05 +00:00
|
|
|
</div>
|
2017-06-28 21:20:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-06-30 16:49:05 +00:00
|
|
|
import {mapState, mapGetters} from 'vuex'
|
2017-06-28 21:20:28 +00:00
|
|
|
import filesize from 'filesize'
|
|
|
|
import moment from 'moment'
|
2017-07-03 14:19:17 +00:00
|
|
|
import api from '@/utils/api'
|
2017-06-28 21:20:28 +00:00
|
|
|
|
|
|
|
export default {
|
2017-07-03 16:15:47 +00:00
|
|
|
name: 'info',
|
2017-06-30 16:49:05 +00:00
|
|
|
computed: {
|
|
|
|
...mapState(['req', 'selected']),
|
|
|
|
...mapGetters(['selectedCount'])
|
2017-06-28 21:20:28 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
humanSize: function () {
|
2017-07-08 10:30:22 +00:00
|
|
|
// If there are no files selected or this is not a listing
|
|
|
|
// show the human file size of the current request.
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount === 0 || this.req.kind !== 'listing') {
|
2017-07-03 10:04:14 +00:00
|
|
|
return filesize(this.req.size)
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 10:30:22 +00:00
|
|
|
// Otherwise, sum the sizes of each selected file and returns
|
|
|
|
// its human form.
|
2017-06-28 21:20:28 +00:00
|
|
|
var sum = 0
|
|
|
|
|
2017-06-30 16:49:05 +00:00
|
|
|
for (let i = 0; i < this.selectedCount; i++) {
|
2017-07-03 10:04:14 +00:00
|
|
|
sum += this.req.items[this.selected[i]].size
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return filesize(sum)
|
|
|
|
},
|
|
|
|
humanTime: function () {
|
2017-07-08 10:30:22 +00:00
|
|
|
// If there are no selected files, return the current request
|
|
|
|
// modified time.
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount === 0) {
|
2017-07-03 10:04:14 +00:00
|
|
|
return moment(this.req.modified).fromNow()
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 10:30:22 +00:00
|
|
|
// 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.
|
2017-07-03 10:04:14 +00:00
|
|
|
return moment(this.req.items[this.selected[0]]).fromNow()
|
2017-06-28 21:20:28 +00:00
|
|
|
},
|
|
|
|
name: function () {
|
2017-07-08 10:30:22 +00:00
|
|
|
// Return the name of the current opened file if there
|
|
|
|
// are no selected files.
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount === 0) {
|
2017-07-03 10:04:14 +00:00
|
|
|
return this.req.name
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 10:30:22 +00:00
|
|
|
// Otherwise, just return the name of the selected file.
|
|
|
|
// This field won't show when there is more than one
|
|
|
|
// file selected.
|
2017-07-03 10:04:14 +00:00
|
|
|
return this.req.items[this.selected[0]].name
|
2017-06-28 21:20:28 +00:00
|
|
|
},
|
|
|
|
dir: function () {
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount > 1) {
|
2017-06-28 21:20:28 +00:00
|
|
|
// Don't show when multiple selected.
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount === 0) {
|
2017-07-03 10:04:14 +00:00
|
|
|
return this.req.isDir
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 10:04:14 +00:00
|
|
|
return this.req.items[this.selected[0]].isDir
|
2017-06-28 21:20:28 +00:00
|
|
|
},
|
|
|
|
checksum: function (event, hash) {
|
2017-07-08 10:30:22 +00:00
|
|
|
// Gets the checksum of the current selected or
|
|
|
|
// opened file. Doesn't work for directories.
|
2017-06-28 21:20:28 +00:00
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
let link
|
|
|
|
|
2017-06-30 16:49:05 +00:00
|
|
|
if (this.selectedCount) {
|
2017-07-03 10:04:14 +00:00
|
|
|
link = this.req.items[this.selected[0]].url
|
2017-06-28 21:20:28 +00:00
|
|
|
} else {
|
2017-07-03 14:19:17 +00:00
|
|
|
link = this.$route.path
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 14:19:17 +00:00
|
|
|
api.checksum(link, hash)
|
2017-07-08 10:30:22 +00:00
|
|
|
.then((hash) => { event.target.innerHTML = hash })
|
|
|
|
.catch(error => { this.$store.commit('showError', error) })
|
2017-06-28 21:20:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|