mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-09 03:32:56 +00:00

Former-commit-id: e483df4402733b102d11b10436ff74aad11dfa7c [formerly 6d761c2ee838a9766f755b6c54cdc2ca388b5934] [formerly 1365e9e067af021ad0c680bae3af963dc4a90b28 [formerly 889871ec0a1fac26dee1b3152d0f87e2a7af2c65]] Former-commit-id: ba443a90fded4501c0a6872eb293c14b2923c627 [formerly d21c6b9ab41869d2b10aa99853bc5b6931b63d96] Former-commit-id: 7c19b231861797c62dc35c1e8a28f4ceeb8761c7
119 lines
3.8 KiB
Vue
119 lines
3.8 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>{{ $t('prompts.fileInfo') }}</h3>
|
|
|
|
<p v-show="selected.length > 1">{{ $t('prompts.filesSelected', { count: selected.length }) }}</p>
|
|
|
|
<p v-show="selected.length < 2"><strong>{{ $t('prompts.displayName') }}</strong> {{ name() }}</p>
|
|
<p><strong>{{ $t('prompts.size') }}:</strong> <span id="content_length"></span>{{ humanSize() }}</p>
|
|
<p v-show="selected.length < 2"><strong>{{ $t('prompts.lastModified') }}:</strong> {{ humanTime() }}</p>
|
|
|
|
<section v-show="dir() && selected.length === 0">
|
|
<p><strong>{{ $t('prompts.numberFiles') }}:</strong> {{ req.numFiles }}</p>
|
|
<p><strong>{{ $t('prompts.numberDirs') }}:</strong> {{ req.numDirs }}</p>
|
|
</section>
|
|
|
|
<section v-show="!dir()">
|
|
<p><strong>MD5:</strong> <code><a @click="checksum($event, 'md5')">{{ $t('prompts.show') }}</a></code></p>
|
|
<p><strong>SHA1:</strong> <code><a @click="checksum($event, 'sha1')">{{ $t('prompts.show') }}</a></code></p>
|
|
<p><strong>SHA256:</strong> <code><a @click="checksum($event, 'sha256')">{{ $t('prompts.show') }}</a></code></p>
|
|
<p><strong>SHA512:</strong> <code><a @click="checksum($event, 'sha512')">{{ $t('prompts.show') }}</a></code></p>
|
|
</section>
|
|
|
|
<div>
|
|
<button type="submit"
|
|
@click="$store.commit('closeHovers')"
|
|
class="ok"
|
|
:aria-label="$t('buttons.ok')"
|
|
:title="$t('buttons.ok')">{{ $t('buttons.ok') }}</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapState, mapGetters} from 'vuex'
|
|
import filesize from 'filesize'
|
|
import moment from 'moment'
|
|
import * as api from '@/utils/api'
|
|
|
|
export default {
|
|
name: 'info',
|
|
computed: {
|
|
...mapState(['req', 'selected']),
|
|
...mapGetters(['selectedCount'])
|
|
},
|
|
methods: {
|
|
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') {
|
|
return filesize(this.req.size)
|
|
}
|
|
|
|
// Otherwise, sum the sizes of each selected file and returns
|
|
// its human form.
|
|
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 there are no selected files, return the current request
|
|
// modified time.
|
|
if (this.selectedCount === 0) {
|
|
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()
|
|
},
|
|
name: function () {
|
|
// Return the name of the current opened file if there
|
|
// are no selected files.
|
|
if (this.selectedCount === 0) {
|
|
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
|
|
},
|
|
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) {
|
|
// Gets the checksum of the current selected or
|
|
// opened file. Doesn't work for directories.
|
|
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(this.$showError)
|
|
}
|
|
}
|
|
}
|
|
</script>
|