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: 'vendor',
      label: 'Vendor',
      type: 'object',
      objectType: 'vendor',
      required: true
    },
    {
      name: 'vendor._id',
      label: 'Vendor ID',
      type: 'id',
      objectType: 'vendor',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'moonraker.host',
      label: 'Host',
      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
    }
  ]
}
