- Added a 'list' action to various object models, including AppPassword, AuditLog, Client, and more, to standardize access to list views across the application. - Updated the ObjectModels.js to include a new label for the 'list' action, improving clarity in the permission matrix. - Refactored Sidebar.js to incorporate user profile permissions for sidebar item visibility, enhancing user experience based on access rights. - Introduced utility functions for normalizing paths and filtering sidebar items based on user permissions, streamlining sidebar management. - Improved the overall structure and readability of the Sidebar and ObjectModels components.
301 lines
6.5 KiB
JavaScript
301 lines
6.5 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')
|
|
)
|
|
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: 'page',
|
|
pageName: 'info',
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true
|
|
}
|
|
],
|
|
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
|
|
}
|
|
]
|
|
}
|