From dd31a7b9a3af167808b04ffe2af3a66af8b17c33 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 31 May 2018 23:15:32 +0200 Subject: nice size functions from bucky :) --- app/client/common/fileList.component.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'app/client/common/fileList.component.js') diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index b3bcd43..7d90045 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -5,13 +5,16 @@ import { Link } from 'react-router-dom'; import moment from 'moment' import * as util from '../util' +const defaultFields = new Set(['date', 'size']) class FileList extends Component { constructor(props){ super() } render(){ const { files, linkFiles, onClick } = this.props + let fields = this.props.fields || defaultFields const fileList = files.map(file => { + const size = util.hush_size(file.size) return (
@@ -20,10 +23,24 @@ class FileList extends Component { : onClick(file)}>{file.name || file.url} }
-
{moment(file.created_at).format("YYYY-MM-DD h:mm a")}
-
{file.size ? ((file.size) / 1024 / 1024).toFixed(1) + ' mb.' : ''}
-
{file.epoch > 0 ? 'epoch ' + file.epoch : ' '}
-
{file.activity || ''} {file.module || ''}
+ {fields.has('date') && +
{moment(file.created_at).format("YYYY-MM-DD")}
+ } + {fields.has('datetime') && +
{moment(file.created_at).format("YYYY-MM-DD h:mm a")}
+ } + {fields.has('size') && +
{size[1]}
+ } + {fields.has('epoch') && +
{file.epoch > 0 ? 'epoch ' + file.epoch : ' '}
+ } + {(fields.has('activity') || fields.has('module')) && +
+ {fields.has('activity') && file.activity} + {fields.has('module') && file.module} +
+ } {this.props.options && this.props.options(file)}
) -- cgit v1.2.3-70-g09d2