mirror of
https://github.com/directus/directus.git
synced 2026-01-30 10:48:00 -05:00
Format filesize for display & file info sidebar (#8786)
* format filesize for display & file info sidebar * Use power of 10 Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { defineDisplay } from '@directus/shared/utils';
|
||||
import bytes from 'bytes';
|
||||
import formatFilesize from '@/utils/format-filesize';
|
||||
|
||||
export default defineDisplay({
|
||||
id: 'filesize',
|
||||
name: '$t:displays.filesize.filesize',
|
||||
description: '$t:displays.filesize.description',
|
||||
icon: 'description',
|
||||
component: ({ value }: { value: number }) => bytes(value, { decimalPlaces: 0 }),
|
||||
component: ({ value }: { value: number }) => formatFilesize(value),
|
||||
options: [],
|
||||
types: ['integer'],
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, ref, watch } from 'vue';
|
||||
import readableMimeType from '@/utils/readable-mime-type';
|
||||
import bytes from 'bytes';
|
||||
import formatFilesize from '@/utils/format-filesize';
|
||||
import localizedFormat from '@/utils/localized-format';
|
||||
import api, { addTokenToURL } from '@/api';
|
||||
import { getRootPath } from '@/utils/get-root-path';
|
||||
@@ -154,7 +154,7 @@ export default defineComponent({
|
||||
if (!props.file) return null;
|
||||
if (!props.file.filesize) return null;
|
||||
|
||||
return bytes(props.file.filesize, { decimalPlaces: 2, unitSeparator: ' ' }); // { locale: locale.value.split('-')[0] }
|
||||
return formatFilesize(props.file.filesize); // { locale: locale.value.split('-')[0] }
|
||||
});
|
||||
|
||||
const { creationDate, modificationDate } = useDates();
|
||||
|
||||
Reference in New Issue
Block a user