Commit b1c883f2 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

nicer duration and file size formats

* add filesize npm package
* add prettyNanoseconds mixin function
parent dbf60c32
......@@ -5087,10 +5087,9 @@
}
},
"filesize": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
"integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==",
"dev": true
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-4.1.2.tgz",
"integrity": "sha512-iSWteWtfNcrWQTkQw8ble2bnonSl7YJImsn9OZKpE2E4IHhXI78eASpDYUljXZZdYj36QsEKjOs/CsiDqmKMJw=="
},
"fill-range": {
"version": "4.0.0",
......@@ -11188,6 +11187,12 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
"integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
"dev": true
},
"filesize": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
"integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==",
"dev": true
}
}
},
......
......@@ -10,6 +10,7 @@
"dependencies": {
"axios": "^0.18.0",
"bootstrap-vue": "^2.0.0-rc.19",
"filesize": "^4.1.2",
"oidc-client": "^1.7.1",
"vue": "^2.6.10",
"vue-router": "^3.0.6"
......
......@@ -72,6 +72,8 @@
<script>
import axios from 'axios'
import filesize from 'filesize'
import prettyDate from '../mixins/prettyDate'
export default {
data () {
......@@ -93,6 +95,7 @@ export default {
}
}
},
mixins: [ prettyDate ],
computed: {
filesTable: function (){
var arr = []
......@@ -102,8 +105,8 @@ export default {
artist: this.files[i].metadata.artist,
album:this.files[i].metadata.album,
title: this.files[i].metadata.title,
duration: this.files[i].duration,
size: this.files[i].size,
duration: this.prettyNanoseconds(this.files[i].duration),
size: filesize(this.files[i].size),
updated: this.files[i].updated,
actions: '...'
})
......@@ -157,7 +160,7 @@ export default {
}).catch(error => {
alert('There was an error fetching files from tank: ' + error)
})
var uri = process.env.VUE_APP_API_TANK + 'shows/' + slug + '/playlists'
uri = process.env.VUE_APP_API_TANK + 'shows/' + slug + '/playlists'
axios.get(uri, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
......
......@@ -68,6 +68,13 @@ export default {
duration += 'sec'
}
return duration
},
prettyNanoseconds: function(ns) {
var sec_total = ns / 1000 / 1000 / 1000
var hours = Math.floor(sec_total / 3600)
var minutes = Math.floor((sec_total - (hours * 3600)) / 60)
var seconds = Math.floor((sec_total - (hours * 3600) - (minutes * 60)) * 10) / 10
return hours + ':' + leadingZero(minutes) + ':' + leadingZero(seconds)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment