Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
d6673b3e
Unverified
Commit
d6673b3e
authored
Aug 17, 2023
by
Licho
Committed by
GitHub
Aug 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor (#2235)
parent
ff1ec5bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
51 deletions
+40
-51
index.tsx
...egCenter/DataSource/components/DataSourceDetail/index.tsx
+31
-39
index.tsx
.../RegCenter/DataSource/components/DataSourceList/index.tsx
+5
-8
BusinessCrud.ts
dinky-web/src/services/BusinessCrud.ts
+4
-4
No files found.
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceDetail/index.tsx
View file @
d6673b3e
...
...
@@ -34,7 +34,6 @@ import {StateType, STUDIO_MODEL} from "@/pages/DataStudio/model";
const
DataSourceDetail
=
(
props
:
any
)
=>
{
const
navigate
=
useNavigate
();
const
{
dataSource
,
backClick
,
dispatch
,
database
:
{
dbData
,
selectDatabaseId
,
expandKeys
,
selectKeys
}}
=
props
;
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
disabled
,
setDisabled
]
=
useState
<
boolean
>
(
true
);
...
...
@@ -87,35 +86,33 @@ const DataSourceDetail = (props : any) => {
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
payload
:
keys
})
if
(
isLeaf
)
{
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
selectDb
.
type
,
id
:
selectDatabaseId
+
schemaName
+
tableName
,
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
"/"
),
label
:
schemaName
+
'.'
+
tableName
,
params
:{
queryParams
:
queryParams
,
tableInfo
:
fullInfo
},
type
:
"metadata"
}
})
}
if
(
isLeaf
)
{
setParams
({
id
:
dataSource
.
id
as
number
,
schemaName
,
tableName
});
setDisabled
(
false
);
/**
* get table columns
*/
setTableInfo
(
fullInfo
);
}
else
{
if
(
!
isLeaf
)
{
clearState
();
return
;
}
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
selectDb
.
type
,
id
:
selectDatabaseId
+
schemaName
+
tableName
,
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
"/"
),
label
:
schemaName
+
'.'
+
tableName
,
params
:
{
queryParams
:
{
id
:
selectDatabaseId
,
schemaName
,
tableName
},
tableInfo
:
fullInfo
},
type
:
"metadata"
}
})
setParams
({
id
:
dataSource
.
id
as
number
,
schemaName
,
tableName
});
setDisabled
(
false
);
// get table columns
setTableInfo
(
fullInfo
);
},
[]);
...
...
@@ -130,13 +127,11 @@ const DataSourceDetail = (props : any) => {
})
}
/**
* render back button and refresh button
* @return {JSX.Element}
*/
const
renderBackButton
=
()
=>
{
return
<>
const
renderBackButton
=
<
DataSourceDetailBackButton
>
<
Space
size=
{
'middle'
}
>
<
Button
size=
{
'middle'
}
icon=
{
<
ReloadOutlined
spin=
{
loading
}
/>
}
type=
"primary"
...
...
@@ -144,14 +139,12 @@ const DataSourceDetail = (props : any) => {
<
Button
size=
{
'middle'
}
icon=
{
<
BackwardOutlined
/>
}
type=
"primary"
onClick=
{
handleBackClick
}
>
{
l
(
'button.back'
)
}
</
Button
>
</
Space
>
</
DataSourceDetailBackButton
>
</>;
};
</
DataSourceDetailBackButton
>;
/**
* render
*/
return
<>
return
(
<
ProCard
loading=
{
loading
}
ghost
gutter=
{
[
16
,
16
]
}
split=
"vertical"
>
<
ProCard
hoverable
bordered
className=
{
'siderTree schemaTree'
}
colSpan=
"16%"
>
{
/* tree */
}
...
...
@@ -162,14 +155,13 @@ const DataSourceDetail = (props : any) => {
<
RightTagsRouter
tableInfo=
{
tableInfo
}
queryParams=
{
params
}
rightButtons=
{
renderBackButton
()
}
rightButtons=
{
renderBackButton
}
tagDisabled=
{
disabled
}
/>
</
ProCard
>
</
ProCard
>
</>;
</
ProCard
>);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
database
:
Studio
.
database
,
}))(
DataSourceDetail
);
;
}))(
DataSourceDetail
);
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceList/index.tsx
View file @
d6673b3e
...
...
@@ -61,20 +61,19 @@ const DataSourceTable = () => {
* set list
*/
const
queryDataSourceList
=
async
()
=>
{
await
queryList
(
API_CONSTANTS
.
DATASOURCE
).
then
(
res
=>
{
setDataSource
(
res
.
data
);
});
const
res
=
await
queryList
(
API_CONSTANTS
.
DATASOURCE
);
setDataSource
(
res
.
data
);
};
/**
* extra callback
* @param callback
*/
const
executeAndCallbackRefresh
=
async
(
callback
:
()
=>
void
)
=>
{
await
setLoading
(
true
);
const
executeAndCallbackRefresh
=
async
(
callback
:
()
=>
Promise
<
void
>
)
=>
{
setLoading
(
true
);
await
callback
();
await
queryDataSourceList
();
await
setLoading
(
false
);
setLoading
(
false
);
};
/**
...
...
@@ -87,7 +86,6 @@ const DataSourceTable = () => {
});
};
/**
* handle delete
* @param id
...
...
@@ -187,7 +185,6 @@ const DataSourceTable = () => {
setDetailPage
(
!
detailPage
);
}
else
{
await
WarningMessage
(
l
(
'rc.ds.enter.error'
));
return
;
}
};
...
...
dinky-web/src/services/BusinessCrud.ts
View file @
d6673b3e
...
...
@@ -99,7 +99,7 @@ export const handleAddOrUpdate = async (url: string, params: any, afterCallBack?
const
{
code
,
msg
}
=
await
addOrUpdateData
(
url
,
{...
params
});
if
(
code
===
RESPONSE_CODE
.
SUCCESS
)
{
await
SuccessMessage
(
msg
);
afterCallBack
&&
afterCallBack
();
afterCallBack
?.
();
}
else
{
await
WarningMessage
(
msg
);
}
...
...
@@ -121,7 +121,7 @@ export const handleRemoveById = async (url: string, id: number, afterCallBack?:
const
{
code
,
msg
}
=
await
removeById
(
url
,
{
id
});
if
(
code
===
RESPONSE_CODE
.
SUCCESS
)
{
await
SuccessMessage
(
msg
);
afterCallBack
&&
afterCallBack
();
afterCallBack
?.
();
}
else
{
await
WarningMessage
(
msg
);
}
...
...
@@ -178,7 +178,7 @@ export const handleOption = async (url: string, title: string, param: any, after
const
result
=
await
postAll
(
url
,
param
);
if
(
result
.
code
===
RESPONSE_CODE
.
SUCCESS
)
{
SuccessMessage
(
result
.
msg
);
afterCallBack
&&
afterCallBack
();
afterCallBack
?.
();
return
result
;
}
else
{
WarningMessage
(
result
.
msg
);
...
...
@@ -275,7 +275,7 @@ export const handlePutDataByParams = async (url: string, title: string, params:
const
{
code
,
msg
}
=
await
putData
(
url
,
{...
params
});
if
(
code
===
RESPONSE_CODE
.
SUCCESS
)
{
await
SuccessMessage
(
msg
);
afterCallBack
&&
afterCallBack
();
afterCallBack
?.
();
return
true
;
}
else
{
await
WarningMessage
(
msg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment