import PrinterIcon from '../../components/Icons/PrinterIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import PlayCircleIcon from '../../components/Icons/PlayCircleIcon'

export const Printer = {
  name: 'printer',
  label: 'Printer',
  prefix: 'PRN',
  icon: PrinterIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) => `/dashboard/production/printers/info?printerId=${_id}`
    },

    {
      name: 'reload',
      label: 'Reload',
      icon: ReloadIcon,
      url: (_id) =>
        `/dashboard/production/printers/info?printerId=${_id}&action=reload`
    },
    {
      name: 'control',
      label: 'Control',
      row: true,
      icon: PlayCircleIcon,
      url: (_id) => `/dashboard/production/printers/control?printerId=${_id}`
    },
    {
      name: 'edit',
      label: 'Edit',
      row: true,
      icon: EditIcon,
      url: (_id) =>
        `/dashboard/production/printers/info?printerId=${_id}&action=edit`
    }
  ],
  columns: ['name', '_id', 'state', 'tags', 'connectedAt'],
  filters: ['name', '_id', 'state', 'tags'],
  sorters: ['name', 'state', 'connectedAt'],
  group: ['tags'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      objectType: 'printer',
      showCopy: true
    },
    {
      name: 'connectedAt',
      label: 'Connected At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'name',
      label: 'Name',
      required: true,
      type: 'text',
      columnWidth: 200,
      columnFixed: 'left'
    },
    {
      name: 'state',
      label: 'Status',
      type: 'state',
      objectType: 'printer',
      showName: false,
      readOnly: true
    },
    {
      name: 'active',
      label: 'Active',
      type: 'bool',
      required: true
    },
    {
      name: 'online',
      label: 'Online',
      type: 'bool',
      readOnly: true
    },
    {
      name: 'vendor',
      label: 'Vendor',
      type: 'object',
      objectType: 'vendor',
      required: false
    },
    {
      name: 'vendor._id',
      label: 'Vendor ID',
      type: 'id',
      objectType: 'vendor',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'host',
      label: 'Host',
      type: 'object',
      objectType: 'host',
      required: true
    },
    {
      name: 'host._id',
      label: 'Host ID',
      type: 'id',
      objectType: 'host',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'moonraker.host',
      label: 'Hostname',
      type: 'text',
      required: true
    },
    {
      name: 'moonraker.port',
      label: 'Port',
      type: 'number',
      required: true
    },
    {
      name: 'moonraker.apiKey',
      label: 'API Key',
      type: 'secret',
      reveal: true,
      required: false
    },
    {
      name: 'moonraker.protocol',
      label: 'Protocol',
      type: 'wsprotocol',
      required: true
    },
    {
      name: 'tags',
      label: 'Tags',
      type: 'tags',
      required: false
    },
    {
      name: 'firmware',
      label: 'Firmware Version',
      type: 'text',
      required: false,
      readOnly: true
    },
    {
      name: 'currentFilamentStock',
      label: 'Filament Stock',
      type: 'object',
      objectType: 'filamentStock',
      required: false
    },
    {
      name: 'currentFilamentStock._id',
      label: 'Filament Stock ID',
      type: 'id',
      objectType: 'filamentStock',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'currentJob',
      label: 'Current Job',
      type: 'object',
      objectType: 'job',
      required: false
    },
    {
      name: 'currentJob._id',
      label: 'Current Job ID',
      type: 'id',
      objectType: 'job',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'currentSubJob',
      label: 'Current Sub Job',
      type: 'object',
      objectType: 'subJob',
      required: false
    },
    {
      name: 'currentSubJob._id',
      label: 'Current Sub Job ID',
      type: 'id',
      objectType: 'subJob',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'alerts',
      label: 'Alerts',
      type: 'alerts',
      required: false
    }
  ]
}
