fix: audit logs loads error

This commit is contained in:
sealday 2024-03-15 18:33:28 +08:00
parent d8590a6a95
commit 227e2dbf47
2 changed files with 179 additions and 87 deletions

109
main.mjs Normal file
View File

@ -0,0 +1,109 @@
const data = {
uid: '3jiixjqak8v',
collection: 'records',
measures: [
{
field: ['items', 'count'],
aggregation: 'sum',
alias: 'items.count',
},
],
dimensions: [
{
field: ['items', 'product_id'],
},
{
field: ['movement'],
},
],
filter: {
$and: [
{
date: {
$dateBetween: [new Date('2024-02-29T16:00:00.000Z'), new Date('2024-03-31T15:59:59.999Z')],
},
},
],
},
orders: [],
};
// const result = await fetch("https://shcx.daoyoucloud.com/api/charts:query", {
// "headers": {
// "accept": "application/json, text/plain, */*",
// "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
// "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjQsImlhdCI6MTcxMDMxNDA2MywiZXhwIjoxNzEwOTE4ODYzfQ.aLc66wn-egDk_VOoackTph0kghLAquqp-Hdr1qN9gdU",
// "content-type": "application/json",
// "sec-ch-ua": "\"Chromium\";v=\"122\", \"Not(A:Brand\";v=\"24\", \"Microsoft Edge\";v=\"122\"",
// "sec-ch-ua-mobile": "?0",
// "sec-ch-ua-platform": "\"macOS\"",
// "sec-fetch-dest": "empty",
// "sec-fetch-mode": "cors",
// "sec-fetch-site": "same-origin",
// "x-authenticator": "basic",
// "x-hostname": "shcx.daoyoucloud.com",
// "x-locale": "zh-CN",
// "x-role": "admin",
// "x-timezone": "+08:00",
// "x-with-acl-meta": "true",
// "Referer": "https://shcx.daoyoucloud.com/admin/sujj53fixe7?",
// "Referrer-Policy": "strict-origin-when-cross-origin"
// },
// "body": JSON.stringify(data),
// "method": "POST"
// });
// {
// "uid": "9bismho25ro",
// "collection": "view_record_items",
// "measures": Array[5],
// "dimensions": Array[3],
// "filter": {
// "$and": [
// {
// "$and": [
// {
// "record": {
// "date": {
// "$dateBetween": [
// "2024-02-29T16:00:00.000Z",
// "2024-03-31T15:59:59.999Z"
// ]
// }
// }
// }
// ]
// }
// ]
// },
// "orders": [
// ]
// }
const result = await fetch('http://127.0.0.1:15000/api/charts:query', {
headers: {
accept: 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
authorization:
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjQsImlhdCI6MTcxMDQyNDM2NywiZXhwIjoxNzExMDI5MTY3fQ.6XqA8aTAHwkr9UDRjPgQey2c3_pwxfJZJ8gdDn4NxJc',
'content-type': 'application/json',
'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-authenticator': 'basic',
'x-hostname': '127.0.0.1',
'x-locale': 'zh-CN',
'x-role': 'root',
'x-timezone': '+08:00',
'x-with-acl-meta': 'true',
Referer: 'http://127.0.0.1:15000/admin/dihuq9gj0cl',
'Referrer-Policy': 'strict-origin-when-cross-origin',
},
body: JSON.stringify(data),
method: 'POST',
});
console.log(await result.json());

View File

@ -1,8 +1,77 @@
import { ActionInitializer } from '@nocobase/client'; import { ActionInitializer } from '@nocobase/client';
import React from 'react'; import React from 'react';
import { tval } from '../locale'; import { tval } from '../locale';
import { uid } from '@nocobase/utils/client';
export const AuditLogsViewActionInitializer = () => { export const AuditLogsViewActionInitializer = () => {
const changes = {
type: 'string',
'x-component': 'AssociationField',
'x-decorator': 'FormItem',
'x-collection-field': 'auditLogs.changes',
'x-read-pretty': true,
'x-component-props': {
multiple: true,
fieldNames: {
value: 'id',
label: 'id',
},
mode: 'SubTable',
},
properties: {
block: {
type: 'void',
'x-component': 'AssociationField.SubTable',
properties: {
[uid()]: {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
field: {
'x-collection-field': 'auditChanges.field',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
[uid()]: {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
before: {
'x-collection-field': 'auditChanges.before',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
[uid()]: {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
after: {
'x-collection-field': 'auditChanges.after',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
},
},
},
};
const schema = { const schema = {
type: 'void', type: 'void',
title: tval('View'), title: tval('View'),
@ -228,93 +297,7 @@ export const AuditLogsViewActionInitializer = () => {
type: 'void', type: 'void',
'x-component': 'Grid.Col', 'x-component': 'Grid.Col',
properties: { properties: {
changes: { changes,
type: 'void',
'x-component': 'TableField',
'x-decorator': 'FormItem',
'x-collection-field': 'auditLogs.changes',
'x-component-props': {},
properties: {
block: {
type: 'void',
'x-decorator': 'TableFieldProvider',
'x-acl-action': 'auditChanges:list',
'x-decorator-props': {
collection: 'auditChanges',
association: 'auditLogs.changes',
resource: 'auditLogs.changes',
action: 'list',
params: {
paginate: false,
},
showIndex: true,
dragSort: false,
},
properties: {
actions: {
type: 'void',
'x-component': 'TableField.ActionBar',
'x-component-props': {},
},
changes: {
type: 'array',
'x-component': 'TableV2',
'x-component-props': {
rowSelection: false,
useProps: '{{ useTableFieldProps }}',
},
properties: {
'5uvv96u9ict': {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
field: {
'x-collection-field': 'auditChanges.field',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
h7a4tgt11gd: {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
before: {
'x-collection-field': 'auditChanges.before',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
m275z8rglzx: {
type: 'void',
'x-decorator': 'TableV2.Column.Decorator',
'x-component': 'TableV2.Column',
properties: {
after: {
'x-collection-field': 'auditChanges.after',
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-component-props': {
ellipsis: true,
},
},
},
},
},
},
},
},
},
},
}, },
}, },
}, },