Skip to content

Commit 2aaa997

Browse files
committed
fix: table date display and MariaDB
1 parent 44041dc commit 2aaa997

File tree

12 files changed

+45
-57
lines changed

12 files changed

+45
-57
lines changed
Lines changed: 15 additions & 0 deletions
Loading

client/packages/openblocks-design/src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export { ReactComponent as ToggleButtonCompIcon } from "./icon-toggle-button.svg
217217
export { ReactComponent as GoogleSheetsIcon } from "./icon-query-GoogleSheets.svg";
218218
export { ReactComponent as GraphqlIcon } from "./icon-query-Graphql.svg";
219219
export { ReactComponent as SnowflakeIcon } from "./icon-query-snowflake.svg";
220+
export { ReactComponent as MariaDBIcon } from "./icon-query-MariaDB.svg";
220221
export { ReactComponent as imageEditorIcon } from "./icon-insert-imageEditor.svg";
221222
export { ReactComponent as HomeSettingsIcon } from "./icon-home-settings.svg";
222223
export { ReactComponent as HomeSettingsActiveIcon } from "./icon-home-settings-active.svg";

client/packages/openblocks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"rc-trigger": "^5.3.1",
6262
"react": "^17.0.2",
6363
"react-colorful": "^5.5.1",
64-
"react-documents": "^1.1.2",
64+
"react-documents": "^1.2.1",
6565
"react-dom": "^17.0.2",
6666
"react-draggable": "^4.4.4",
6767
"react-grid-layout": "^1.3.0",

client/packages/openblocks/src/comps/comps/tableComp/column/columnTypeComps/columnDateComp.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ const Wrapper = styled.div`
118118
`;
119119

120120
export function formatDate(date: string, format: string) {
121-
let mom = moment(date, DateParser);
121+
let mom = moment(date);
122122
if (!mom.isValid()) {
123-
mom = moment(0, DateParser);
123+
mom = moment.utc(date, DateParser).local();
124+
if (!mom.isValid()) {
125+
mom = moment(0);
126+
}
124127
}
125128
return mom.isValid() ? mom.format(format) : "";
126129
}

client/packages/openblocks/src/comps/queries/queryComp/queryPropertyView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export const QueryGeneralPropertyView = (props: {
293293
}}
294294
status={datasourceStatus}
295295
/>
296-
{comp instanceof SQLQuery &&
296+
{children.comp instanceof SQLQuery &&
297297
!NOT_SUPPORT_GUI_SQL_QUERY.includes(children.compType.getView()) && (
298298
<div style={{ width: "104px", marginLeft: "8px", flexShrink: 0 }}>
299299
{/* query comp should not aware of specific queryType */}

client/packages/openblocks/src/comps/queries/sqlQuery/SQLQuery.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ const SQLQueryPropertyView = (props: { comp: InstanceType<typeof SQLQuery> }) =>
196196
: []),
197197
{ label: trans("sqlQuery.update"), value: "UPDATE" },
198198
{ label: trans("sqlQuery.delete"), value: "DELETE" },
199-
{ label: trans("sqlQuery.bulkInsert"), value: "BULK_INSERT" },
199+
...(context?.resourceType !== "oracle"
200+
? [{ label: trans("sqlQuery.bulkInsert"), value: "BULK_INSERT" }]
201+
: []),
200202
{ label: trans("sqlQuery.bulkUpdate"), value: "BULK_UPDATE" },
201203
] as const
202204
}
@@ -251,11 +253,12 @@ export const NOT_SUPPORT_GUI_SQL_QUERY: ResourceType[] = [
251253
"tdengine",
252254
"dameng",
253255
];
254-
export const SUPPORT_UPSERT_SQL_QUERY: ResourceType[] = [
256+
const SUPPORT_UPSERT_SQL_QUERY: ResourceType[] = [
255257
"mysql",
256258
"oceanBase",
257259
"tidb",
258260
"polardbMysql",
259261
"sequoiadbMysql",
260262
"starrocks",
263+
"mariadb",
261264
];

client/packages/openblocks/src/constants/datasourceConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const databasePlugins: Partial<DatasourceType>[] = [
1414
"oracle",
1515
"clickHouse",
1616
"snowflake",
17+
"mariadb",
1718
];
1819

1920
export const apiPluginsForQueryLibrary: Partial<DatasourceType>[] = [

client/packages/openblocks/src/constants/queryConstants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export type DatasourceType =
2828
| "clickHouse"
2929
| "googleSheets"
3030
| "graphql"
31-
| "snowflake";
31+
| "snowflake"
32+
| "mariadb";
3233

3334
export type ResourceType = DatasourceType | "js" | "libraryQuery" | "view";
3435

@@ -50,6 +51,7 @@ export const QueryMap = {
5051
googleSheets: GoogleSheetsQuery,
5152
graphql: GraphqlQuery,
5253
snowflake: SQLQuery,
54+
mariadb: SQLQuery,
5355
};
5456

5557
export const JsPluginQueryMap: Record<string, MultiCompConstructor> = {};

client/packages/openblocks/src/pages/datasource/form/datasourceFormRegistry.tsx

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,8 @@ export const DatasourceFormRegistry: Partial<Record<DatasourceType, DatasourceFo
5555
form: sqlDatasourceForm({ placeholder: "My OceanBase1", port: "2881" }),
5656
whitelist: true,
5757
},
58-
tidb: {
59-
form: sqlDatasourceForm({ placeholder: "My TiDB1", port: "4000" }),
60-
whitelist: true,
61-
},
62-
openGauss: {
63-
form: sqlDatasourceForm({ placeholder: "My OpenGauss1", port: "5432" }),
64-
whitelist: true,
65-
},
66-
gaussdb: {
67-
form: sqlDatasourceForm({ placeholder: "My Gauss1", port: "5432" }),
68-
whitelist: true,
69-
},
70-
dameng: {
71-
form: sqlDatasourceForm({
72-
placeholder: "My DaMeng1",
73-
port: "5236",
74-
supportSSL: false,
75-
supportDatabase: false,
76-
}),
77-
whitelist: true,
78-
},
79-
polardbMysql: {
80-
form: sqlDatasourceForm({ placeholder: "My PolarDB1", port: "3306" }),
81-
whitelist: true,
82-
},
83-
tdengine: {
84-
form: sqlDatasourceForm({
85-
placeholder: "My TDengine1",
86-
port: "6041",
87-
supportPreparedStatement: false,
88-
}),
89-
whitelist: true,
90-
},
91-
sequoiadbMysql: {
92-
form: sqlDatasourceForm({ placeholder: "My SequoiaDB1", port: "3306" }),
93-
whitelist: true,
94-
},
95-
mogdb: {
96-
form: sqlDatasourceForm({ placeholder: "My MogDB1", port: "5432" }),
97-
whitelist: true,
98-
},
99-
starrocks: {
100-
form: sqlDatasourceForm({ placeholder: "My StarRocks1", port: "9030" }),
58+
mariadb: {
59+
form: sqlDatasourceForm({ placeholder: "My MariaDB1", port: "3306" }),
10160
whitelist: true,
10261
},
10362
};

client/packages/openblocks/src/util/bottomResUtils.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import styled from "styled-components";
22
import { ResourceType } from "@openblocks-ee/constants/queryConstants";
33
import {
44
ClickHouseIcon,
5+
DataResponderIcon,
56
DeleteApiIcon,
67
EsIcon,
78
GetApiIcon,
89
GoogleSheetsIcon,
910
GraphqlIcon,
1011
HeadApiIcon,
1112
JSIcon,
13+
MariaDBIcon,
1214
MongoIcon,
1315
MSSQLIcon,
1416
MysqlIcon,
@@ -27,7 +29,6 @@ import {
2729
TempStateIcon,
2830
TraceApiIcon,
2931
TransformerIcon,
30-
DataResponderIcon,
3132
} from "openblocks-design";
3233
import { BottomResTypeEnum } from "types/bottomRes";
3334
import { HttpMethod } from "api/api";
@@ -130,6 +131,8 @@ export const getBottomResIcon = (
130131
return <OpenBlocksQueryIcon />;
131132
case "snowflake":
132133
return <SnowflakeIcon />;
134+
case "mariadb":
135+
return <MariaDBIcon />;
133136
default:
134137
if (defaultIconUrl) {
135138
return getBottomResIconInnerByUrl(type, defaultIconUrl);

client/packages/openblocks/src/util/dateTimeUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import moment from "moment";
33
export const TIME_FORMAT = "HH:mm:ss";
44
export const TIME_12_FORMAT = "HH:mm:ss:a";
55
export const DATE_FORMAT = "YYYY-MM-DD";
6+
export const DATE_FORMAT_EN = "MM/DD/YYYY";
67
export const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
78
export const DATE_TIME_12_FORMAT = "YYYY-MM-DD HH:mm:ss:a";
89
export const TIMESTAMP_FORMAT = "x";
9-
export const DateParser = [DATE_TIME_FORMAT, DATE_TIME_12_FORMAT, DATE_FORMAT, TIMESTAMP_FORMAT];
10+
export const DateParser = [DATE_TIME_FORMAT, DATE_TIME_12_FORMAT, DATE_FORMAT, TIMESTAMP_FORMAT, DATE_FORMAT_EN];
1011
export const TimeParser = [TIME_12_FORMAT, TIME_FORMAT, TIMESTAMP_FORMAT];
1112
export type PickerMode = "date" | "week" | "month" | "quarter" | "year";
1213

client/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14422,7 +14422,7 @@ __metadata:
1442214422
rc-trigger: ^5.3.1
1442314423
react: ^17.0.2
1442414424
react-colorful: ^5.5.1
14425-
react-documents: ^1.1.2
14425+
react-documents: ^1.2.1
1442614426
react-dom: ^17.0.2
1442714427
react-draggable: ^4.4.4
1442814428
react-grid-layout: ^1.3.0
@@ -15959,15 +15959,15 @@ __metadata:
1595915959
languageName: node
1596015960
linkType: hard
1596115961

15962-
"react-documents@npm:^1.1.2":
15963-
version: 1.1.2
15964-
resolution: "react-documents@npm:1.1.2"
15962+
"react-documents@npm:^1.2.1":
15963+
version: 1.2.1
15964+
resolution: "react-documents@npm:1.2.1"
1596515965
dependencies:
1596615966
docviewhelper: ">= 0.0.1"
1596715967
peerDependencies:
1596815968
react: ">=16.8.0"
1596915969
react-dom: ">=16.8.0"
15970-
checksum: ef203f998abda594c5df84ac13d2b6abf5096ebc36558c5450b5a7fe493794a4d25e129029a662cf96650a0a4c650bf33b065929894c664e5970422da74c9051
15970+
checksum: a3f91557d2a05793cacc414208e2e05c37f7f54858ae4dd852aa8c42b4a9e9df3748f2e6cb62b1a153f9ee65271d7b61eb8afc7bf21338ed7ed97e9a4ea85d58
1597115971
languageName: node
1597215972
linkType: hard
1597315973

0 commit comments

Comments
 (0)