DATA - DataViews
A DataView describes a subset of a DataClass to be presented to the users in the Web Interface.
You can define multiple DataViews per DataClass for different type of users.
DataView objects
DataViews are implemented as regular DataClass objects and can thus be managed from the Web UI, REST API, console CLI, import/export, etc.
DataViews
# optional Role definitions to manage DataView authorizations
_role:role_data_view_ro:
displayname: Role data:data_view:ro
subgroups:
- admin_cavaliba
_role:role_data_view_rw:
displayname: Role data:data_view:rw
subgroups:
- admin_cavaliba
_role:role_data_view_admin:
displayname: Role data:data_view:admin
subgroups:
- admin_cavaliba
# DataView definition as a specific DataClass structure
_schema:data_view:
_displayname: Data Views
_is_enabled: yes
_icon: fa-table
_order: 810
_page: Internal
_role_show: role_data_view_ro
_role_access: role_data_view_ro
_role_read: role_data_view_ro
_role_create: role_data_view_rw
_role_update: role_data_view_rw
_role_delete: role_data_view_rw
_role_onoff: role_data_view_rw
_role_import: role_data_view_admin
_role_export: role_data_view_admin
description:
#_action: create_or_update
displayname: Description
order: 100
dataformat: string
dataformat_ext: ""
cardinal_min: 0
cardinal_max: 1
default : ""
# DataClass on which a DataView operates
classname:
displayname: classname
cardinal_min: 0
cardinal_max: 1
order: 110
dataformat: string
# nested YAML structure with columns and operations on columns
content:
displayname: content
cardinal_min: 0
cardinal_max: 1
order: 120
dataformat: text
dataformat_ext: yaml
Content format
The classname attribute defines the DataClass on which the DataView will operate.
The content attribute in the DataView object defines what and how to present the DataClass data. It is a nested YAML structure which lists columns to be displayed and operator to apply on each of these columns.
keyname, displayname and last_update are common attributes to all DataClass. They can be omitted from the DataViews columns. If none is requested , Cavaliba adds keyname by default.
Each entry is the name of a column as it will be displayed.
If the from operator is added to a column entry, it indicates wich DataClass attribute should provide content for that column.
An invalid from value will create an empty value for that column.
the intend use of the column/from combination is to provide nicer column names to users.
Some new operators may be added in the future, like aggregate values or computed values from other columns.
# DataView content attribute
columns:
- keyname
- displayname
- last_update
- city
- zipcode
- my_enumerate_ok_ko
- my_enumerate_ok_ko_na
- my_enumerate_abc
- my_enumerate_abc_multi
- my_enumerate_abcde
- my_enumerate_abcde_multi
- newcol
- ZipAgain:
from: zipcode
- newcol_invalid:
from: non_existent_col
other_operator: tobedone
DataView Example
The follwing YAML snippet create a DataView on the site objects to present some relevant geographical informations.
It says:
- create a user available DataView for the DataClass site objects.
- show a table with the following columns: address, region, …
- some of the columns will have a different name than the underlying DataClass attribute
data_view:site_postal:
#_action: create_or_update
classname: site
is_enabled: true
displayname: MySiteView_postal
description: This View displays Geographical information about sites
content: |
columns:
- Site Name:
from: keyname
- address
- Zip Code
from: zipcode
- Site city:
from: city
- country