import CRUDBase from '../CRUDBase.js'
import { session } from '../../service/Session.service.js';

class ClientResource extends CRUDBase {
    constructor() {
        super()

        this.endpoint = '/api/v1/radius/clients'
        this.required_fields = ['name']
        this.permission_base = 'v1:radius:clients'

        this.item = 'RADIUS Client'
        this.plural = 'RADIUS Clients'

        this.listing_definition = {
            display: ``,
            columns: [
                {
                    name: 'Client Name',
                    field: 'name',
                },
            ],
            actions: [
                {
                    type: 'resource',
                    position: 'main',
                    action: 'insert',
                    text: 'Create New',
                    color: 'success',
                },
                {
                    type: 'resource',
                    position: 'row',
                    action: 'update',
                    icon: 'fa fa-edit',
                    color: 'primary',
                },
                {
                    type: 'resource',
                    position: 'row',
                    action: 'delete',
                    icon: 'fa fa-times',
                    color: 'danger',
                    confirm: true,
                },
            ],
        }

        this.form_definition = {
            fields: [
                {
                    name: 'Client Name',
                    field: 'name',
                    placeholder: 'Awesome External App',
                    required: true,
                    type: 'text',
                },
                {
                    name: 'Client Secret',
                    field: 'secret',
                    type: 'text',
                    readonly: true,
                    hidden: ['insert'],
                },
            ],
        }
    }
}

const radius_client = new ClientResource()
export { radius_client }
