Renaming of prompts

Former-commit-id: afa0c349648f9e8fe9eb2dbfd5214454f8dcc048 [formerly 21ea1d1edc1cb396c38a4e9d95778929e66c590f] [formerly d0d88d46de21a489e3e19d239e23147bbf018d16 [formerly e0f3687b26]]
Former-commit-id: 24e6f33d7bcb0f9306f8d4953c7af4de39adff5f [formerly e0ec0773fff43ba2243a8687ae33b373a3fd4e1a]
Former-commit-id: 5f96744de512d3cc6affa99eebb869354f62605b
This commit is contained in:
Henrique Dias
2017-07-03 17:15:47 +01:00
parent 3a085af4bc
commit 009916d954
11 changed files with 133 additions and 84 deletions

View File

@@ -0,0 +1,102 @@
<template>
<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">
<p><strong>Number of files:</strong> {{ req.numFiles }}</p>
<p><strong>Number of directories:</strong> {{ req.numDirs }}</p>
</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>
<button type="submit" @click="$store.commit('showInfo', false)" class="ok">OK</button>
</div>
</div>
</template>
<script>
import {mapState, mapGetters} from 'vuex'
import filesize from 'filesize'
import moment from 'moment'
import api from '@/utils/api'
export default {
name: 'info',
computed: {
...mapState(['req', 'selected']),
...mapGetters(['selectedCount'])
},
methods: {
humanSize: function () {
if (this.selectedCount === 0 || this.req.kind !== 'listing') {
return filesize(this.req.size)
}
var sum = 0
for (let i = 0; i < this.selectedCount; i++) {
sum += this.req.items[this.selected[i]].size
}
return filesize(sum)
},
humanTime: function () {
if (this.selectedCount === 0) {
return moment(this.req.modified).fromNow()
}
return moment(this.req.items[this.selected[0]]).fromNow()
},
name: function () {
if (this.selectedCount === 0) {
return this.req.name
}
return this.req.items[this.selected[0]].name
},
dir: function () {
if (this.selectedCount > 1) {
// Don't show when multiple selected.
return true
}
if (this.selectedCount === 0) {
return this.req.isDir
}
return this.req.items[this.selected[0]].isDir
},
checksum: function (event, hash) {
event.preventDefault()
let link
if (this.selectedCount) {
link = this.req.items[this.selected[0]].url
} else {
link = this.$route.path
}
api.checksum(link, hash)
.then((hash) => {
event.target.innerHTML = hash
})
.catch(error => {
console.log(error)
})
}
}
}
</script>