All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
172 lines
4.2 KiB
JavaScript
172 lines
4.2 KiB
JavaScript
import DownloadIcon from '../../components/Icons/DownloadIcon'
|
|
import FileIcon from '../../components/Icons/FileIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
|
|
export const File = {
|
|
name: 'file',
|
|
label: 'File',
|
|
prefix: 'FLE',
|
|
icon: FileIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/management/files/info?fileId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/files/info?fileId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/files/info?fileId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/files/info?fileId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'download',
|
|
label: 'Download',
|
|
row: true,
|
|
icon: DownloadIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/files/info?fileId=${_id}&action=download`
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/management/files/info?fileId=${_id}&action=delete`
|
|
}
|
|
],
|
|
url: (id) => `/dashboard/management/files/info?fileId=${id}`,
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'type',
|
|
'size',
|
|
'temp',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: ['name', '_id', 'type', 'temp'],
|
|
sorters: ['name', 'type', 'size', 'createdAt', 'temp'],
|
|
group: ['type'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'file',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'file',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'type',
|
|
label: 'Type',
|
|
type: 'text',
|
|
readOnly: true,
|
|
required: true,
|
|
columnWidth: 190
|
|
},
|
|
{
|
|
name: 'size',
|
|
label: 'Size',
|
|
type: 'number',
|
|
readOnly: true,
|
|
roundNumber: 2,
|
|
required: true,
|
|
suffix: (objectData) => {
|
|
const size = objectData?.size || 0
|
|
if (size === 0) return ' B'
|
|
if (size < 1024) return ' B'
|
|
if (size < 1024 * 1024) return ' KB'
|
|
if (size < 1024 * 1024 * 1024) return ' MB'
|
|
if (size < 1024 * 1024 * 1024 * 1024) return ' GB'
|
|
return ' TB'
|
|
},
|
|
value: (objectData) => {
|
|
const size = objectData?.size || 0
|
|
if (size === 0) return 0
|
|
if (size < 1024) return size
|
|
if (size < 1024 * 1024) return size / 1024
|
|
if (size < 1024 * 1024 * 1024) return size / (1024 * 1024)
|
|
if (size < 1024 * 1024 * 1024 * 1024) return size / (1024 * 1024 * 1024)
|
|
return size / (1024 * 1024 * 1024 * 1024)
|
|
},
|
|
columnWidth: 100
|
|
},
|
|
{
|
|
name: 'metaData',
|
|
label: 'Meta Data',
|
|
columnWidth: 300,
|
|
type: 'data',
|
|
readOnly: true,
|
|
required: false
|
|
}
|
|
]
|
|
}
|