mirror of
https://github.com/directus/directus.git
synced 2026-02-12 03:15:00 -05:00
Add sort/limit to metric
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
<div class="field half-right">
|
||||
<p class="type-label">{{ $t('name') }}</p>
|
||||
<v-input v-model="edits.name" :disabled="edits.show_header !== true" />
|
||||
<v-input :nullable="false" v-model="edits.name" :disabled="edits.show_header !== true" />
|
||||
</div>
|
||||
|
||||
<div class="field half-left">
|
||||
|
||||
@@ -17,20 +17,6 @@ export default definePanel({
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'field',
|
||||
type: 'string',
|
||||
name: '$t:panels.metric.field',
|
||||
meta: {
|
||||
interface: 'system-field',
|
||||
options: {
|
||||
collectionField: 'collection',
|
||||
typeAllowList: ['integer', 'bigInteger', 'float', 'decimal'],
|
||||
allowPrimaryKey: true,
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'function',
|
||||
type: 'string',
|
||||
@@ -64,15 +50,66 @@ export default definePanel({
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'field',
|
||||
type: 'string',
|
||||
name: '$t:panels.metric.field',
|
||||
meta: {
|
||||
interface: 'system-field',
|
||||
options: {
|
||||
collectionField: 'collection',
|
||||
typeAllowList: ['integer', 'bigInteger', 'float', 'decimal'],
|
||||
allowPrimaryKey: true,
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'limit',
|
||||
type: 'integer',
|
||||
name: '$t:limit',
|
||||
schema: {
|
||||
default_value: 100,
|
||||
},
|
||||
meta: {
|
||||
interface: 'input',
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'sortField',
|
||||
type: 'string',
|
||||
name: '$t:sort_field',
|
||||
meta: {
|
||||
interface: 'system-field',
|
||||
options: {
|
||||
collectionField: 'collection',
|
||||
allowPrimaryKey: true,
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'sortDirection',
|
||||
type: 'string',
|
||||
name: '$t:sort_direction',
|
||||
meta: {
|
||||
interface: 'select-dropdown',
|
||||
options: {
|
||||
choices: [
|
||||
{
|
||||
text: '$t:sort_asc',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
text: '$t:sort_desc',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'filter',
|
||||
type: 'json',
|
||||
|
||||
@@ -44,6 +44,8 @@ export default defineComponent({
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const sort =
|
||||
props.options.sortField && `${props.options.sortDirection === 'desc' ? '-' : ''}${props.options.sortField}`;
|
||||
const res = await api.get(`/items/${props.options.collection}`, {
|
||||
params: {
|
||||
aggregate: {
|
||||
@@ -52,6 +54,8 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
filter: props.options.filter,
|
||||
sort: sort,
|
||||
limit: props.options.limit ?? 100,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user