.. _custom-tabs: Custom Tabs, Fields, and Filters in Record Index ====================================================== .. seealso:: To create custom fields in the feature vector database, refer to :ref:`custom-metadata`. To add custom tabs and fields to the records of individuals and vehicles, do the following: #. Prepare the list of custom tabs and fields you want to add to the records. #. Open the ``/opt/findface-multi/configs/findface-multi-legacy/findface-multi-legacy.py`` configuration file. .. code:: sudo vi /opt/findface-multi/configs/findface-multi-legacy/findface-multi-legacy.py #. Customize the records of individuals. To do so, uncomment the ``FFSECURITY`` → ``CUSTOM_FIELDS`` → ``human_card`` section and modify the exemplary content, considering the following: * ``'items'``: the list of fields in a record. Describe each field with the following parameters: * ``'name'``: field's internal name, string. * ``'default'``: field's default value. If a default value exceeds ``1e14 - 1`` , use a string data type to specify it, for example, ``"123123.."`` instead of ``123123..``. * ``'label'``: field's label in the web interface (in a record), string. * ``'tab'``: tab that features the field. Tabs are configured separately. * ``'display'``: display format (``form`` or ``list``). It can contain a string or an array: * ``list`` - display in the list of records (string view). * ``form`` - display in the edit form. * ``'description'``: field's description, string. * ``'editable'``: field's :ref:`editability `, boolean. * ``'type'``: field data type, string. Possible values: * ``list``: accepts ``itemsData``. It expects either a list of values or a list of dictionaries containing values. For example: ``['value1', 'value2', 'value3']`` or ``[{id:'1', label: 'value1'}, {'id': '2', 'label': 'value2'}]``. * ``datetime``: primitive data type displayed as a datetime list. * ``date``: primitive data type displayed as a date picker. * ``boolean``: primitive data type displayed as a checkbox. * ``string``: primitive data type ``string``. * ``multiple``: possibility of selecting several items in the list, boolean. * ``'filters'``: the list of search filters associated with the custom fields. Parameters: * ``'name'``: filter's internal name, * ``'label'``: filter's label in the web interface, * ``'field'``: associated field in the format ``[field name]``. * ``'tabs'``: the list of tabs in a record. **Here’s a general example showing all the meta field options:** .. code:: # -- Custom model fields -- # Edit CUSTOM_FIELDS -> `human_card` section to customize human card fields. # Edit CUSTOM_FIELDS -> `car_card` section to customize car card fields. ... # Below is an example with every field type possible. 'CUSTOM_FIELDS': { 'human_card': { 'tabs': [{'name': 'new_tab_1', 'label': 'NewTab_1'}], 'options': { 'list': { 'name': True } }, 'items': [ { 'name': 'string_ed', 'default': '', 'label': 'String_Editable', 'display': ['list', 'form'], 'description': 'String_editable', 'editable': True }, { 'name': 'string_display_form', 'default': 'Only_Form', 'label': 'String_Display_Only_form', 'display': 'form', 'description': 'String_display_form', 'editable': False }, { 'name': 'string_another_tab', 'default': '', 'label': 'String_Another_Tab', 'display': ['list', 'form'], 'tab': 'new_tab_1', 'description': 'String_editable_another_tab' }, { 'name': 'string_ned', 'default': '2.3', 'label': 'String_Not_Editable', 'display': ['list', 'form'], 'description': 'String_not_editable', 'editable': False }, { 'name': 'date', 'default': '', 'label': 'Date', 'display': 'form', 'description': 'Date_field', 'type': 'date', 'editable': True }, { 'name': 'datetime', 'default': '', 'label': 'Datetime', 'display': 'form', 'description': 'Datetime_field', 'type': 'datetime', 'editable': True }, { 'name': 'list_dict', 'default': '', 'label': 'List_Dict_display', 'display': ['form', 'list'], 'description': 'list_dict', 'type': 'list', 'multiple': False, 'itemsData': [ {'id': 'id1_text', 'label': 'label1_text'}, {'id': 'id2_text', 'label': 'label2_text'} ] }, { 'name': 'list', 'default': '', 'label': 'List_Values', 'display': 'form', 'description': 'List_Values', 'type': 'list', 'multiple': False, 'itemsData': ['value1', 'value2', 'value3'] }, { 'name': 'list_mult', 'default': '', 'label': 'list_Multiple', 'display': 'form', 'description': 'List_Multiple', 'type': 'valuelist', 'multiple': True, 'itemsData': ['value1', 'value2', 'value3'] }, { 'name': 'checkbox', 'default': '', 'label': 'Checkbox', 'display': 'form', 'description': 'Checkbox', 'type': 'boolean' } ], 'filters': [ { 'name': 'filter_contains', 'label': 'Filter_Icontains', 'field': 'string_ed__icontains' }, { 'name': 'filter_exact_match', 'label': 'Filter_Exact_match', 'field': 'string_ed' }, { 'name': 'filter_values', 'label': 'ValuesList_filter', 'field': 'list', 'type': 'valuelist', 'itemsData': ['value1', 'value2', 'value3'] }, { 'name': 'filter_values_multiple', 'label': 'ValuesList_filter_Multiple', 'field': 'list_mult', 'type': 'valuelist', 'multiple': True, 'itemsData': ['value1', 'value2', 'value3'] } ] }, 'car_card': {} # same fields are available }, 'camera_meta': { 'items': [ { 'name': 'camera_id', 'default': None, 'label': 'Camera id', 'display': ['list', 'form'], 'description': 'Camera id in custom system' } ], 'filters': [ { 'name': 'camera_id_filter', 'label': 'Camera id filter', 'field': 'camera_id' } ] }, 'face_object': { 'items': [ { 'field_name': 'tag_name_1', 'type': 'string', 'default': 'change_me' }, { 'field_name': 'tag_name_2', 'type': 'uint', 'default': 123 }, { 'field_name': 'tag_name_3', 'type': 'bool', 'default': True } ] } .. _editable_field: .. important:: A custom field's editability also depends on user role permissions. Before you make a custom field editable by specifying ``'editable': True`` in the ``/opt/findface-multi/configs/findface-multi-legacy/findface-multi-legacy.py`` configuration file, make sure a user role has the following permissions enabled: * ``humancard`` (or ``carcard``) → ``View``, ``Change`` * an associated watch list → ``Change`` With these role permissions disabled, all record fields, default and custom, will stay non-editable. Read more in the :ref:`users` section. **Example**: Set up tabs. .. code:: 'CUSTOM_FIELDS': { 'human_card': { 'options': { 'list': { 'name': True } 'tabs': [ {'name': 'new_tab_1', label: 'NewTab_1' } }, 'items': [......] **Example**: Add a custom ``gender`` field with a predefined list of values (``male`` and ``female``) and enable filtering on it. .. code:: FFSECURITY = { 'CUSTOM_FIELDS': { 'human_card': { 'items': [ { # Select only one of the suggested options from the drop-down menu. You cannot add new options using the user int> 'type': 'valuelist', 'name': 'gender', 'label': 'gender', # for ui 'default': '', 'display': ['list', 'form'], 'multiple': False, 'itemsData': ['male', 'female'], } ], 'filters': [ { 'name': 'gender-filter', 'label': 'Card gender filter', # for ui 'field': 'gender', 'type': 'valuelist', 'itemsData': ['male', 'female'] } ] }, 'car_card': {} # same fields structure } } #. Customize the vehicle records. To do so, duplicate the ``human_card`` section content into the ``car_card`` section and modify it by analogy. #. Restart all FindFace Multi containers. .. code:: cd /opt/findface-multi/ sudo docker-compose restart You will see the custom content appear in the records.