From e9743b14c2fb597487836e8446a3d14281a45eba Mon Sep 17 00:00:00 2001 From: Arne Schauf Date: Sat, 3 Mar 2018 12:17:42 +0100 Subject: fix stuff that broke on upgrade --- src/pages/UploadDetail.vue | 16 ++++++++-------- src/pages/UploadList.vue | 41 ++++++++++++++++++++++++----------------- src/plugins/prettyBytes.js | 25 +++++++++++++++++++++++++ src/plugins/vueMoment.js | 5 +++++ 4 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 src/plugins/prettyBytes.js create mode 100644 src/plugins/vueMoment.js (limited to 'src') diff --git a/src/pages/UploadDetail.vue b/src/pages/UploadDetail.vue index d742a4a..956e324 100644 --- a/src/pages/UploadDetail.vue +++ b/src/pages/UploadDetail.vue @@ -9,7 +9,7 @@ by {{ upload.author.username }} updated {{ upload.updatedAt | moment("from") }} - + {{ upload.title }} @@ -38,7 +38,7 @@ Voting - + @@ -53,18 +53,18 @@ Dependencies - + Dependencies - + No dependencies
-
{{ d.title }} @@ -76,14 +76,14 @@ File downloads - + File downloads - + No files
Other data - + diff --git a/src/pages/UploadList.vue b/src/pages/UploadList.vue index a8a731c..da297ba 100644 --- a/src/pages/UploadList.vue +++ b/src/pages/UploadList.vue @@ -5,28 +5,29 @@

Available Mods

- - + + + {{ props.value.sum }} +
@@ -38,13 +39,9 @@ import { Dialog, } from 'quasar' - import Truncate from 'vue-truncate-collapsed' import moment from 'moment' export default { - components: { - Truncate, - }, computed: { showList () { return this.$route.name === 'upload-list' @@ -71,12 +68,22 @@ rowHeight: '60px', }, tableColumns: [ - {label: 'Title', field: 'title', width: '100px'}, - {label: 'Description', field: 'description', width: '500px'}, - {label: 'Author', field: 'author', width: '100px', format: el => el.username}, - {label: 'Voting', field: 'voting', width: '100px'}, - {label: 'Last update', field: 'updatedAt', width: '100px', format: el => moment(el).from()}, - {label: 'Actions', field: 'action', width: '200px'}, + {name: 'title', label: 'Title', field: 'title'}, + { + name: 'description', + label: 'Description', + field: 'description', + format: el => typeof el === 'string' && el.length > 150 ? el.slice(0, 150) + '...' : el, + }, + {name: 'author', label: 'Author', field: row => row.author.username}, + {name: 'voting', label: 'Voting', field: 'voting'}, + { + name: 'updatedAt', + label: 'Last update', + field: 'updatedAt', + format: el => moment(el).from(), + }, + {name: 'action', label: 'Actions', field: 'action'}, ], } }, diff --git a/src/plugins/prettyBytes.js b/src/plugins/prettyBytes.js new file mode 100644 index 0000000..ebfb72d --- /dev/null +++ b/src/plugins/prettyBytes.js @@ -0,0 +1,25 @@ +export default ({ Vue }) => { + Vue.filter('prettyBytes', function (value) { + const UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + + if (!Number.isFinite(value)) { + throw new TypeError(`Expected a finite number, got ${typeof value}: ${value}`) + } + + const neg = value < 0 + + if (neg) { + value = -value + } + + if (value < 1) { + return (neg ? '-' : '') + value + ' B' + } + + const exponent = Math.min(Math.floor(Math.log10(value) / 3), UNITS.length - 1) + const numStr = Number((value / Math.pow(1000, exponent)).toPrecision(3)) + const unit = UNITS[exponent] + + return (neg ? '-' : '') + numStr + ' ' + unit + }) +} diff --git a/src/plugins/vueMoment.js b/src/plugins/vueMoment.js new file mode 100644 index 0000000..dd8ebfb --- /dev/null +++ b/src/plugins/vueMoment.js @@ -0,0 +1,5 @@ +import VueMoment from 'vue-moment' + +export default ({ Vue }) => { + Vue.use(VueMoment) +} -- cgit v1.2.3-54-g00ecf