fix: edit user password optional
This commit is contained in:
@@ -7,12 +7,18 @@ import Styles from './index.less';
|
|||||||
const DeleteModal = forwardRef((props, ref) => {
|
const DeleteModal = forwardRef((props, ref) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [config, setConfig] = useState<ModalFuncProps & { content: string }>(
|
const [config, setConfig] = useState<
|
||||||
{}
|
ModalFuncProps & { content: string; selection?: boolean; name?: string }
|
||||||
);
|
>({});
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
show: (data: ModalFuncProps & { content: string }) => {
|
show: (
|
||||||
|
data: ModalFuncProps & {
|
||||||
|
content: string;
|
||||||
|
selection?: boolean;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
) => {
|
||||||
setConfig(data);
|
setConfig(data);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
},
|
},
|
||||||
@@ -68,8 +74,15 @@ const DeleteModal = forwardRef((props, ref) => {
|
|||||||
<div className={Styles['content']}>
|
<div className={Styles['content']}>
|
||||||
{config.content &&
|
{config.content &&
|
||||||
intl.formatMessage(
|
intl.formatMessage(
|
||||||
{ id: 'common.delete.confirm' },
|
{
|
||||||
{ type: intl.formatMessage({ id: config.content }) }
|
id: config.selection
|
||||||
|
? 'common.delete.confirm'
|
||||||
|
: 'common.delete.single.confirm'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: intl.formatMessage({ id: config.content }),
|
||||||
|
name: config.name
|
||||||
|
}
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ export function useUpdateChunkedList(options: {
|
|||||||
computedID?: (d: object) => string;
|
computedID?: (d: object) => string;
|
||||||
}) {
|
}) {
|
||||||
const cacheDataListRef = useRef<any[]>(options.dataList || []);
|
const cacheDataListRef = useRef<any[]>(options.dataList || []);
|
||||||
|
const timerRef = useRef<any>(null);
|
||||||
|
|
||||||
|
const debounceUpdateChunckedList = () => {
|
||||||
|
clearTimeout(timerRef.current);
|
||||||
|
timerRef.current = setTimeout(() => {
|
||||||
|
options.setDataList?.([...cacheDataListRef.current]);
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
const updateChunkedList = (
|
const updateChunkedList = (
|
||||||
data: ChunkedCollection,
|
data: ChunkedCollection,
|
||||||
dataList?: { id: string | number }[]
|
dataList?: { id: string | number }[]
|
||||||
@@ -25,7 +33,7 @@ export function useUpdateChunkedList(options: {
|
|||||||
console.log('updateChunkedList=====', {
|
console.log('updateChunkedList=====', {
|
||||||
ids: data?.ids,
|
ids: data?.ids,
|
||||||
type: data?.type,
|
type: data?.type,
|
||||||
collection: data?.collection,
|
collection: data?.collection.length,
|
||||||
dataList: _.map(dataList, (o: any) => o.id)
|
dataList: _.map(dataList, (o: any) => o.id)
|
||||||
});
|
});
|
||||||
let collections = data?.collection || [];
|
let collections = data?.collection || [];
|
||||||
@@ -57,7 +65,7 @@ export function useUpdateChunkedList(options: {
|
|||||||
console.log('create=========', updateIndex, collections);
|
console.log('create=========', updateIndex, collections);
|
||||||
});
|
});
|
||||||
cacheDataListRef.current = [...newDataList, ...cacheDataListRef.current];
|
cacheDataListRef.current = [...newDataList, ...cacheDataListRef.current];
|
||||||
options.setDataList?.([...cacheDataListRef.current]);
|
// options.setDataList?.([...cacheDataListRef.current]);
|
||||||
}
|
}
|
||||||
// DELETE
|
// DELETE
|
||||||
if (data?.type === WatchEventType.DELETE) {
|
if (data?.type === WatchEventType.DELETE) {
|
||||||
@@ -69,7 +77,8 @@ export function useUpdateChunkedList(options: {
|
|||||||
);
|
);
|
||||||
// console.log('updateChunkedList=====delete', updatedList);
|
// console.log('updateChunkedList=====delete', updatedList);
|
||||||
// return updatedList;
|
// return updatedList;
|
||||||
options.setDataList?.([...cacheDataListRef.current]);
|
|
||||||
|
// options.setDataList?.([...cacheDataListRef.current]);
|
||||||
}
|
}
|
||||||
// UPDATE
|
// UPDATE
|
||||||
if (data?.type === WatchEventType.UPDATE) {
|
if (data?.type === WatchEventType.UPDATE) {
|
||||||
@@ -88,8 +97,10 @@ export function useUpdateChunkedList(options: {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('updateChunkedList=====update', cacheDataListRef.current);
|
console.log('updateChunkedList=====update', cacheDataListRef.current);
|
||||||
options.setDataList?.([...cacheDataListRef.current]);
|
// options.setDataList?.([...cacheDataListRef.current]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debounceUpdateChunckedList();
|
||||||
if (options?.callback) {
|
if (options?.callback) {
|
||||||
options?.callback(cacheDataListRef.current);
|
options?.callback(cacheDataListRef.current);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ export default {
|
|||||||
'common.settings.language': 'Language',
|
'common.settings.language': 'Language',
|
||||||
'common.delete.confirm':
|
'common.delete.confirm':
|
||||||
'Are you sure you want to delete the selected {type}?',
|
'Are you sure you want to delete the selected {type}?',
|
||||||
|
'common.delete.single.confirm': 'Are you sure you want to delete {name}?',
|
||||||
'common.filter.name': 'Filter by name',
|
'common.filter.name': 'Filter by name',
|
||||||
'common.form.password': 'Password',
|
'common.form.password': 'Password',
|
||||||
'common.form.username': 'Username',
|
'common.form.username': 'Username',
|
||||||
|
|||||||
@@ -175,7 +175,8 @@ export default {
|
|||||||
'common.table.user': '用户',
|
'common.table.user': '用户',
|
||||||
'common.settings.instructions': '操作指引',
|
'common.settings.instructions': '操作指引',
|
||||||
'common.settings.language': '语言',
|
'common.settings.language': '语言',
|
||||||
'common.delete.confirm': '删除选中的{type}吗?',
|
'common.delete.confirm': '删除选中的{type},确定吗?',
|
||||||
|
'common.delete.single.confirm': '删除 {name},确定吗?',
|
||||||
'common.filter.name': '名称查询',
|
'common.filter.name': '名称查询',
|
||||||
'common.form.password': '密码',
|
'common.form.password': '密码',
|
||||||
'common.form.username': '用户名',
|
'common.form.username': '用户名',
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ export default {
|
|||||||
'playground.params.stop.tips':
|
'playground.params.stop.tips':
|
||||||
'停止序列是一个预定义或用户指定的文本字符串,当这些序列出现时,它会提示 AI 停止生成后续的 token。',
|
'停止序列是一个预定义或用户指定的文本字符串,当这些序列出现时,它会提示 AI 停止生成后续的 token。',
|
||||||
'playground.viewcode.tips':
|
'playground.viewcode.tips':
|
||||||
'{here} 查看 API 密钥。您应该使用环境变量或秘密管理工具将您的密钥暴露给您的应用程序。',
|
'{here} 查看 API 密钥。您应该使用环境变量或密钥管理工具将您的密钥暴露给您的应用程序。',
|
||||||
'playground.viewcode.here': '这里'
|
'playground.viewcode.here': '这里'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const APIKeys: React.FC = () => {
|
|||||||
});
|
});
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const modalRef = useRef<any>(null);
|
const modalRef = useRef<any>(null);
|
||||||
const [dataSource, setDataSource] = useState([]);
|
const [dataSource, setDataSource] = useState<ListItem[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [openAddModal, setOpenAddModal] = useState(false);
|
const [openAddModal, setOpenAddModal] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -100,6 +100,7 @@ const APIKeys: React.FC = () => {
|
|||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'apikeys.table.apikeys',
|
content: 'apikeys.table.apikeys',
|
||||||
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteApisKey(row.id);
|
await deleteApisKey(row.id);
|
||||||
@@ -111,6 +112,7 @@ const APIKeys: React.FC = () => {
|
|||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'apikeys.table.apikeys',
|
content: 'apikeys.table.apikeys',
|
||||||
|
selection: true,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteApisKey);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteApisKey);
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
const handleDelete = async (row: any) => {
|
const handleDelete = async (row: any) => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'models.table.models',
|
content: 'models.table.models',
|
||||||
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await deleteModel(row.id);
|
await deleteModel(row.id);
|
||||||
updateExpandedRowKeys([row.id]);
|
updateExpandedRowKeys([row.id]);
|
||||||
@@ -158,6 +159,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'models.table.models',
|
content: 'models.table.models',
|
||||||
|
selection: true,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteModel);
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
@@ -181,6 +183,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
const handleDeleteInstace = (row: any, list: ModelInstanceListItem[]) => {
|
const handleDeleteInstace = (row: any, list: ModelInstanceListItem[]) => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'models.instances',
|
content: 'models.instances',
|
||||||
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await deleteModelInstance(row.id);
|
await deleteModelInstance(row.id);
|
||||||
if (list.length === 1) {
|
if (list.length === 1) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
|||||||
const systemList = systemMessage
|
const systemList = systemMessage
|
||||||
? [{ role: 'system', content: systemMessage }]
|
? [{ role: 'system', content: systemMessage }]
|
||||||
: [];
|
: [];
|
||||||
const code = `const OpenAI = require("openai");\n\nconst openai = new OpenAI({\n "apiKey": "YOUR_GPUSTACK_API_KEY",\n "baseURL": "${BaseURL}"\n});\n\n\nasync function main(){\nconst params = ${JSON.stringify(
|
const code = `const OpenAI = require("openai");\n\nconst openai = new OpenAI({\n "apiKey": "YOUR_GPUSTACK_API_KEY",\n "baseURL": "${BaseURL}"\n});\n\n\nasync function main(){\n const params = ${JSON.stringify(
|
||||||
{
|
{
|
||||||
...parameters,
|
...parameters,
|
||||||
messages: [
|
messages: [
|
||||||
@@ -85,8 +85,8 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2
|
4
|
||||||
)};\nconst chatCompletion = await openai.chat.completions.create(params);\n console.log(chatCompletion.choices[0]);\n}\nmain();`;
|
)};\nconst chatCompletion = await openai.chat.completions.create(params);\n console.log(chatCompletion.choices[0].message.content);\n}\nmain();`;
|
||||||
setCodeValue(code);
|
setCodeValue(code);
|
||||||
} else if (lang === 'python') {
|
} else if (lang === 'python') {
|
||||||
const formattedParams = _.keys(parameters).reduce(
|
const formattedParams = _.keys(parameters).reduce(
|
||||||
@@ -137,6 +137,9 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
|||||||
minimap: {
|
minimap: {
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
|
hover: {
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
formatOnType: true,
|
formatOnType: true,
|
||||||
formatOnPaste: true,
|
formatOnPaste: true,
|
||||||
|
|||||||
@@ -54,13 +54,6 @@ const Resources: React.FC = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleShowSizeChange = (current: number, size: number) => {
|
|
||||||
setQueryParams({
|
|
||||||
...queryParams,
|
|
||||||
page: current,
|
|
||||||
perPage: size || 10
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePageChange = (page: number, perPage: number | undefined) => {
|
const handlePageChange = (page: number, perPage: number | undefined) => {
|
||||||
console.log(page, perPage);
|
console.log(page, perPage);
|
||||||
@@ -104,6 +97,7 @@ const Resources: React.FC = () => {
|
|||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'worker',
|
content: 'worker',
|
||||||
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteWorker(row.id);
|
await deleteWorker(row.id);
|
||||||
@@ -115,6 +109,7 @@ const Resources: React.FC = () => {
|
|||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'wokers',
|
content: 'wokers',
|
||||||
|
selection: true,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteWorker);
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
name="password"
|
name="password"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: action === PageAction.CREATE,
|
||||||
pattern: PasswordReg,
|
pattern: PasswordReg,
|
||||||
message: intl.formatMessage({ id: 'users.form.rule.password' })
|
message: intl.formatMessage({ id: 'users.form.rule.password' })
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
>
|
>
|
||||||
<SealInput.Password
|
<SealInput.Password
|
||||||
label={intl.formatMessage({ id: 'common.form.password' })}
|
label={intl.formatMessage({ id: 'common.form.password' })}
|
||||||
required
|
required={action === PageAction.CREATE}
|
||||||
></SealInput.Password>
|
></SealInput.Password>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ const Users: React.FC = () => {
|
|||||||
const handleDelete = (row: ListItem) => {
|
const handleDelete = (row: ListItem) => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'users.table.user',
|
content: 'users.table.user',
|
||||||
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
console.log('OK');
|
console.log('OK');
|
||||||
await deleteUser(row.id);
|
await deleteUser(row.id);
|
||||||
@@ -155,6 +156,7 @@ const Users: React.FC = () => {
|
|||||||
const handleDeleteBatch = () => {
|
const handleDeleteBatch = () => {
|
||||||
modalRef.current.show({
|
modalRef.current.show({
|
||||||
content: 'users.table.user',
|
content: 'users.table.user',
|
||||||
|
selection: true,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRowKeys, deleteUser);
|
await handleBatchRequest(rowSelection.selectedRowKeys, deleteUser);
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
|
|||||||
Reference in New Issue
Block a user