- Removed the delete action from various components including InvoiceInfo, PaymentInfo, and others to streamline functionality. - Introduced a new DeleteObject component to handle deletion logic in a centralized manner, enhancing code maintainability. - Updated models to utilize the new DeleteObject component for consistent deletion handling across the application. - Simplified ObjectForm by eliminating the previous delete modal, improving component structure and clarity.
308 lines
6.7 KiB
JavaScript
308 lines
6.7 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const HostInfo = lazy(
|
|
() => import('../../components/Dashboard/Management/Hosts/HostInfo')
|
|
)
|
|
const NewHost = lazy(
|
|
() => import('../../components/Dashboard/Management/Hosts/NewHost')
|
|
)
|
|
const HostOTP = lazy(
|
|
() => import('../../components/Dashboard/Management/Hosts/HostOtp')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import HostIcon from '../../components/Icons/HostIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
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'
|
|
import OTPIcon from '../../components/Icons/OTPIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const Host = {
|
|
name: 'host',
|
|
label: 'Host',
|
|
labelPlural: 'Hosts',
|
|
url: '/dashboard/management/hosts',
|
|
prefix: 'HST',
|
|
icon: HostIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Host',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewHost, { defaultValues: objectData, onOk, reset: true })
|
|
}
|
|
},
|
|
{
|
|
name: 'list',
|
|
type: 'page',
|
|
pageName: 'list',
|
|
label: 'List',
|
|
icon: ListIcon
|
|
},
|
|
{
|
|
name: 'info',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon
|
|
},
|
|
{
|
|
name: 'edit',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: XMarkIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: CheckIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
type: 'divider'
|
|
},
|
|
{
|
|
name: 'connect',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
label: 'Connect',
|
|
icon: OTPIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(HostOTP, { id: objectData._id, onOk })
|
|
}
|
|
},
|
|
{
|
|
name: 'delete',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(HostInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'state',
|
|
'tags',
|
|
'connectedAt',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'name',
|
|
'_id',
|
|
'state',
|
|
'tags',
|
|
'connectedAt',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: ['name', 'state', 'connectedAt', 'createdAt', 'updatedAt'],
|
|
group: ['tags'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'host',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'host',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200,
|
|
columnFixed: 'left'
|
|
},
|
|
{
|
|
name: 'connectedAt',
|
|
label: 'Connected At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
objectType: 'host',
|
|
showName: false,
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'online',
|
|
label: 'Online',
|
|
type: 'bool',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'active',
|
|
label: 'Active',
|
|
type: 'bool',
|
|
required: true,
|
|
columnWidth: 125
|
|
},
|
|
|
|
{
|
|
name: 'deviceInfo.os',
|
|
label: 'Operating System',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 220,
|
|
value: (objectData) => {
|
|
if (
|
|
objectData.deviceInfo?.os?.type &&
|
|
objectData.deviceInfo?.os?.release &&
|
|
objectData.deviceInfo?.os?.arch
|
|
) {
|
|
return `${objectData.deviceInfo.os.type} ${objectData.deviceInfo.os.release} (${objectData.deviceInfo.os.arch})`
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: 'deviceInfo.os.hostname',
|
|
label: 'Hostname',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'deviceInfo.cpu.model',
|
|
label: 'CPU Model',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'deviceInfo.cpu',
|
|
label: 'CPU Info',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 150,
|
|
value: (objectData) => {
|
|
if (
|
|
objectData.deviceInfo?.cpu?.cores &&
|
|
objectData.deviceInfo?.cpu?.speedMHz
|
|
) {
|
|
return `Cores: ${objectData.deviceInfo.cpu.cores}, Speed: ${objectData.deviceInfo.cpu.speedMHz} MHz`
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: 'deviceInfo.user.username',
|
|
label: 'User',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 120
|
|
},
|
|
{
|
|
name: 'deviceInfo.user.homedir',
|
|
label: 'User Home',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'deviceInfo.process.nodeVersion',
|
|
label: 'NodeJS Version',
|
|
type: 'text',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'tags',
|
|
label: 'Tags',
|
|
type: 'tags',
|
|
required: false,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'files',
|
|
label: 'Files',
|
|
type: 'objectList',
|
|
objectType: 'file',
|
|
required: false,
|
|
readOnly: true,
|
|
columnWidth: 200,
|
|
showHyperlink: true
|
|
}
|
|
]
|
|
}
|