import { DateField } from '@dvn/core/doldurma/src/fields/date';
import { DateDataType } from '@dvn/core/doldurma/src/fields/date/date';
import { DataTransferField } from '@dvn/core/doldurma/src/fields/query-include/data-transfer-field';
import { ViewPlacement } from '@dvn/core/models/app-config';
import { Comparison } from '@dvn/core/models/filter';
import { TableListViewConfig } from '@dvn/core/models/table-list-view-config';
import { AppViewType } from '@dvn/core/models/view-config';
import { dataConfigs } from '../data-configs';
import { spaces } from '../spaces';
import * as detailViewErrorLog from './detail-view-error-log';
export const ID = 'table-list-view-error-logs-anonymous';
export const viewConfig = TableListViewConfig.decode({
  _id: ID,
  type: AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Anonymous Error Logs',
  space: spaces['mentornity'],
  table: dataConfigs['errorlogs'],
  query: {
    fields: [
      new DataTransferField('res'),
      new DataTransferField('command'),
      new DataTransferField('status'),
      new DataTransferField('message'),
      new DataTransferField('createdAt'),
      new DataTransferField('status'),
    ],
    filter: {
      filters: [
        {
          comparison: Comparison.Eq,
          id: 'user._id',
          value: '',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: TableListViewConfig.decode({
    main: {
      actions: [
        {
          ui: {
            name: 'expand',
            buttonType: 'icon-button',
            iconName: 'uil uil-expand-alt',
            view: 'flat'
          },
          data: {
            type: 'navigation',
            direction: 'forward',
            placement: ViewPlacement.SideModal,
            viewId: detailViewErrorLog.ID,
            params: {
              conversionConfig: {
                'item._id': 'id',
              }
            }
          }
        },
      ],
      fields: [
        {
          fieldId: 'createdAt',
          fieldDisplay: new DateField('createdAt', 'Creation Date').setDateFormat('DD.MM.YYYY HH:mm').setDataType(DateDataType.Unix),
        },
        {
          fieldId: 'status',
        },
        {
          fieldId: 'message',
        },
        {
          fieldId: 'res',
        },
      ],
      columns: {
        createdAt: {
          width: 150,
        },
        status: {
          width: 100,
        },
      },
    },
  }),
});
