@nocobase/plugin-data-visualization
Advanced tools
Comparing version 1.0.0-alpha.17 to 1.0.1-alpha.1
@@ -41,2 +41,3 @@ /** | ||
getTranslatedTitle: (title: string) => string; | ||
parseFilter: (filterValue: any) => Promise<any>; | ||
}; | ||
@@ -43,0 +44,0 @@ export declare const useFilterVariable: () => { |
@@ -9,2 +9,17 @@ /** | ||
*/ | ||
import { ISchema } from '@formily/react'; | ||
export declare const useGeneralVariableOptions: (schema: ISchema, operator?: { | ||
value: string; | ||
}) => (import("@nocobase/client/es/schema-settings/VariableInput/type").Option | { | ||
label: string; | ||
value: string; | ||
key: string; | ||
disabled: boolean; | ||
children: { | ||
key: string; | ||
value: string; | ||
label: string; | ||
disabled: boolean; | ||
}[]; | ||
})[]; | ||
export declare const useVariableOptions: () => ({ | ||
@@ -11,0 +26,0 @@ label: string; |
@@ -11,3 +11,3 @@ /** | ||
module.exports = { | ||
"@nocobase/client": "1.0.0-alpha.17", | ||
"@nocobase/client": "1.0.1-alpha.1", | ||
"dayjs": "1.11.10", | ||
@@ -17,4 +17,4 @@ "@formily/react": "2.3.0", | ||
"lodash": "4.17.21", | ||
"@nocobase/cache": "1.0.0-alpha.17", | ||
"@nocobase/server": "1.0.0-alpha.17", | ||
"@nocobase/cache": "1.0.1-alpha.1", | ||
"@nocobase/server": "1.0.1-alpha.1", | ||
"react": "18.2.0", | ||
@@ -27,7 +27,7 @@ "@ant-design/icons": "5.2.6", | ||
"@formily/core": "2.3.0", | ||
"@nocobase/utils": "1.0.0-alpha.17", | ||
"@nocobase/utils": "1.0.1-alpha.1", | ||
"react-i18next": "11.18.6", | ||
"sequelize": "6.35.2", | ||
"@nocobase/actions": "1.0.0-alpha.17", | ||
"@nocobase/database": "1.0.0-alpha.17" | ||
"@nocobase/actions": "1.0.1-alpha.1", | ||
"@nocobase/database": "1.0.1-alpha.1" | ||
}; |
@@ -1,1 +0,1 @@ | ||
{"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-05-27T06:55:35.915Z"} | ||
{"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-06-07T14:02:20.577Z"} |
@@ -14,5 +14,5 @@ /** | ||
export declare const parseFieldAndAssociations: (ctx: Context, next: Next) => Promise<void>; | ||
export declare const parseVariables: (ctx: Context, next: Next) => Promise<any>; | ||
export declare const parseVariables: (ctx: Context, next: Next) => Promise<void>; | ||
export declare const cacheMiddleware: (ctx: Context, next: Next) => Promise<void>; | ||
export declare const checkPermission: (ctx: Context, next: Next) => Promise<any>; | ||
export declare const query: (ctx: Context, next: Next) => Promise<void>; |
@@ -52,3 +52,3 @@ /** | ||
var import_koa_compose = __toESM(require("koa-compose")); | ||
var import_utils = require("@nocobase/utils"); | ||
var import_server = require("@nocobase/server"); | ||
const getDB = (ctx, dataSource) => { | ||
@@ -234,48 +234,7 @@ const ds = ctx.app.dataSourceManager.dataSources.get(dataSource); | ||
const { filter } = ctx.action.params.values; | ||
if (!filter) { | ||
return next(); | ||
} | ||
const isNumeric = (str) => { | ||
if (typeof str === "number") | ||
return true; | ||
if (typeof str != "string") | ||
return false; | ||
return !isNaN(str) && !isNaN(parseFloat(str)); | ||
}; | ||
const getUser = () => { | ||
return async ({ fields }) => { | ||
var _a, _b; | ||
const userFields = fields.filter((f) => f && ctx.db.getFieldByPath("users." + f)); | ||
(_a = ctx.logger) == null ? void 0 : _a.info("parse filter variables", { userFields, method: "parseVariables" }); | ||
if (!ctx.state.currentUser) { | ||
return; | ||
} | ||
if (!userFields.length) { | ||
return; | ||
} | ||
const user = await ctx.db.getRepository("users").findOne({ | ||
filterByTk: ctx.state.currentUser.id, | ||
fields: userFields | ||
}); | ||
(_b = ctx.logger) == null ? void 0 : _b.info("parse filter variables", { | ||
$user: user == null ? void 0 : user.toJSON(), | ||
method: "parseVariables" | ||
}); | ||
return user; | ||
}; | ||
}; | ||
ctx.action.params.values.filter = await (0, import_utils.parseFilter)(filter, { | ||
timezone: ctx.get("x-timezone"), | ||
now: (/* @__PURE__ */ new Date()).toISOString(), | ||
getField: (path) => { | ||
const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join("."); | ||
const { resourceName } = ctx.action; | ||
return ctx.db.getFieldByPath(`${resourceName}.${fieldPath}`); | ||
}, | ||
vars: { | ||
$nDate: (0, import_utils.getDateVars)(), | ||
$user: getUser() | ||
} | ||
ctx.action.params.filter = filter; | ||
await import_server.middlewares.parseVariables(ctx, async () => { | ||
ctx.action.params.values.filter = ctx.action.params.filter; | ||
await next(); | ||
}); | ||
await next(); | ||
}; | ||
@@ -282,0 +241,0 @@ const cacheMiddleware = async (ctx, next) => { |
{ | ||
"name": "@nocobase/plugin-data-visualization", | ||
"version": "1.0.0-alpha.17", | ||
"version": "1.0.1-alpha.1", | ||
"displayName": "Data visualization", | ||
@@ -36,3 +36,3 @@ "displayName.zh-CN": "数据可视化", | ||
}, | ||
"gitHead": "a38719a9d25efc14e06e979209ff5085e049aca7", | ||
"gitHead": "d24aa16987a4068f857ae073fcce18f3cb490660", | ||
"keywords": [ | ||
@@ -39,0 +39,0 @@ "Blocks" |
Sorry, the diff of this file is too big to display
1469476
7807