mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
feat: edit user properties (#1435)
This commit is contained in:
@ -28,11 +28,7 @@ import SamlWidget from "./common/SamlWidget";
|
|||||||
import SelectRegionBox from "./SelectRegionBox";
|
import SelectRegionBox from "./SelectRegionBox";
|
||||||
import WebAuthnCredentialTable from "./WebauthnCredentialTable";
|
import WebAuthnCredentialTable from "./WebauthnCredentialTable";
|
||||||
import ManagedAccountTable from "./ManagedAccountTable";
|
import ManagedAccountTable from "./ManagedAccountTable";
|
||||||
|
import PropertyTable from "./propertyTable";
|
||||||
import {Controlled as CodeMirror} from "react-codemirror2";
|
|
||||||
import "codemirror/lib/codemirror.css";
|
|
||||||
require("codemirror/theme/material-darker.css");
|
|
||||||
require("codemirror/mode/javascript/javascript");
|
|
||||||
|
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
|
|
||||||
@ -490,13 +486,10 @@ class UserEditPage extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<Row style={{marginTop: "20px"}} >
|
<Row style={{marginTop: "20px"}} >
|
||||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
{i18next.t("user:Properties")}:
|
{Setting.getLabel(i18next.t("user:Properties"), i18next.t("user:Properties - Tooltip"))} :
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<CodeMirror
|
<PropertyTable properties={this.state.user.properties} onUpdateTable={(value) => {this.updateUserField("properties", value);}} />
|
||||||
value={JSON.stringify(this.state.user.properties, null, 4)}
|
|
||||||
options={{mode: "javascript", theme: "material-darker"}}
|
|
||||||
/>
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Whether the account is disabled",
|
"Is forbidden - Tooltip": "Whether the account is disabled",
|
||||||
"Is global admin": "Ist globaler Admin",
|
"Is global admin": "Ist globaler Admin",
|
||||||
"Is global admin - Tooltip": "Is the application global administrator",
|
"Is global admin - Tooltip": "Is the application global administrator",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "Link",
|
"Link": "Link",
|
||||||
"Location": "Standort",
|
"Location": "Standort",
|
||||||
"Location - Tooltip": "Standort - Tooltip",
|
"Location - Tooltip": "Standort - Tooltip",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "Passwort setzen",
|
"Password Set": "Passwort setzen",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "Eigenschaften",
|
"Properties": "Eigenschaften",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "Neu erneut eingeben",
|
"Re-enter New": "Neu erneut eingeben",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "Telefon zurücksetzen...",
|
"Reset Phone...": "Telefon zurücksetzen...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "Link aufheben",
|
"Unlink": "Link aufheben",
|
||||||
"Upload (.xlsx)": "Upload (.xlsx)",
|
"Upload (.xlsx)": "Upload (.xlsx)",
|
||||||
"Upload a photo": "Foto hochladen",
|
"Upload a photo": "Foto hochladen",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "Passwort eingeben"
|
"input password": "Passwort eingeben"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Is forbidden - Tooltip",
|
"Is forbidden - Tooltip": "Is forbidden - Tooltip",
|
||||||
"Is global admin": "Is global admin",
|
"Is global admin": "Is global admin",
|
||||||
"Is global admin - Tooltip": "Is global admin - Tooltip",
|
"Is global admin - Tooltip": "Is global admin - Tooltip",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "Link",
|
"Link": "Link",
|
||||||
"Location": "Location",
|
"Location": "Location",
|
||||||
"Location - Tooltip": "Location - Tooltip",
|
"Location - Tooltip": "Location - Tooltip",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "Password Set",
|
"Password Set": "Password Set",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "Properties",
|
"Properties": "Properties",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "Re-enter New",
|
"Re-enter New": "Re-enter New",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "Reset Phone...",
|
"Reset Phone...": "Reset Phone...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "Unlink",
|
"Unlink": "Unlink",
|
||||||
"Upload (.xlsx)": "Upload (.xlsx)",
|
"Upload (.xlsx)": "Upload (.xlsx)",
|
||||||
"Upload a photo": "Upload a photo",
|
"Upload a photo": "Upload a photo",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "input password"
|
"input password": "input password"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Whether the account is disabled",
|
"Is forbidden - Tooltip": "Whether the account is disabled",
|
||||||
"Is global admin": "Est un administrateur global",
|
"Is global admin": "Est un administrateur global",
|
||||||
"Is global admin - Tooltip": "Is the application global administrator",
|
"Is global admin - Tooltip": "Is the application global administrator",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "Lier",
|
"Link": "Lier",
|
||||||
"Location": "Localisation",
|
"Location": "Localisation",
|
||||||
"Location - Tooltip": "Localisation - Infobulle",
|
"Location - Tooltip": "Localisation - Infobulle",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "Mot de passe défini",
|
"Password Set": "Mot de passe défini",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "Propriétés",
|
"Properties": "Propriétés",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "Nouvelle entrée",
|
"Re-enter New": "Nouvelle entrée",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "Réinitialiser le téléphone...",
|
"Reset Phone...": "Réinitialiser le téléphone...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "Délier",
|
"Unlink": "Délier",
|
||||||
"Upload (.xlsx)": "Télécharger (.xlsx)",
|
"Upload (.xlsx)": "Télécharger (.xlsx)",
|
||||||
"Upload a photo": "Télécharger une photo",
|
"Upload a photo": "Télécharger une photo",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "saisir le mot de passe"
|
"input password": "saisir le mot de passe"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Whether the account is disabled",
|
"Is forbidden - Tooltip": "Whether the account is disabled",
|
||||||
"Is global admin": "グローバル管理者",
|
"Is global admin": "グローバル管理者",
|
||||||
"Is global admin - Tooltip": "Is the application global administrator",
|
"Is global admin - Tooltip": "Is the application global administrator",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "リンク",
|
"Link": "リンク",
|
||||||
"Location": "場所",
|
"Location": "場所",
|
||||||
"Location - Tooltip": "場所 → ツールチップ",
|
"Location - Tooltip": "場所 → ツールチップ",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "パスワード設定",
|
"Password Set": "パスワード設定",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "プロパティー",
|
"Properties": "プロパティー",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "新しい入力",
|
"Re-enter New": "新しい入力",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "電話番号をリセット...",
|
"Reset Phone...": "電話番号をリセット...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "リンクを解除",
|
"Unlink": "リンクを解除",
|
||||||
"Upload (.xlsx)": "アップロード (.xlsx)",
|
"Upload (.xlsx)": "アップロード (.xlsx)",
|
||||||
"Upload a photo": "写真をアップロード",
|
"Upload a photo": "写真をアップロード",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "パスワードを入力"
|
"input password": "パスワードを入力"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Whether the account is disabled",
|
"Is forbidden - Tooltip": "Whether the account is disabled",
|
||||||
"Is global admin": "Is global admin",
|
"Is global admin": "Is global admin",
|
||||||
"Is global admin - Tooltip": "Is the application global administrator",
|
"Is global admin - Tooltip": "Is the application global administrator",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "Link",
|
"Link": "Link",
|
||||||
"Location": "Location",
|
"Location": "Location",
|
||||||
"Location - Tooltip": "Location - Tooltip",
|
"Location - Tooltip": "Location - Tooltip",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "Password Set",
|
"Password Set": "Password Set",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "Properties",
|
"Properties": "Properties",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "Re-enter New",
|
"Re-enter New": "Re-enter New",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "Reset Phone...",
|
"Reset Phone...": "Reset Phone...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "Unlink",
|
"Unlink": "Unlink",
|
||||||
"Upload (.xlsx)": "Upload (.xlsx)",
|
"Upload (.xlsx)": "Upload (.xlsx)",
|
||||||
"Upload a photo": "Upload a photo",
|
"Upload a photo": "Upload a photo",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "input password"
|
"input password": "input password"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "Whether the account is disabled",
|
"Is forbidden - Tooltip": "Whether the account is disabled",
|
||||||
"Is global admin": "Глобальный администратор",
|
"Is global admin": "Глобальный администратор",
|
||||||
"Is global admin - Tooltip": "Is the application global administrator",
|
"Is global admin - Tooltip": "Is the application global administrator",
|
||||||
|
"Keys": "Keys",
|
||||||
"Link": "Ссылка",
|
"Link": "Ссылка",
|
||||||
"Location": "Местоположение",
|
"Location": "Местоположение",
|
||||||
"Location - Tooltip": "Расположение - Подсказка",
|
"Location - Tooltip": "Расположение - Подсказка",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "Пароль установлен",
|
"Password Set": "Пароль установлен",
|
||||||
"Please select avatar from resources": "Please select avatar from resources",
|
"Please select avatar from resources": "Please select avatar from resources",
|
||||||
"Properties": "Свойства",
|
"Properties": "Свойства",
|
||||||
|
"Properties - Tooltip": "Properties - Tooltip",
|
||||||
"Re-enter New": "Введите еще раз",
|
"Re-enter New": "Введите еще раз",
|
||||||
"Reset Email...": "Reset Email...",
|
"Reset Email...": "Reset Email...",
|
||||||
"Reset Phone...": "Сбросить телефон...",
|
"Reset Phone...": "Сбросить телефон...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "Отвязать",
|
"Unlink": "Отвязать",
|
||||||
"Upload (.xlsx)": "Загрузить (.xlsx)",
|
"Upload (.xlsx)": "Загрузить (.xlsx)",
|
||||||
"Upload a photo": "Загрузить фото",
|
"Upload a photo": "Загрузить фото",
|
||||||
|
"Values": "Values",
|
||||||
"WebAuthn credentials": "WebAuthn credentials",
|
"WebAuthn credentials": "WebAuthn credentials",
|
||||||
"input password": "пароль для ввода"
|
"input password": "пароль для ввода"
|
||||||
},
|
},
|
||||||
|
@ -726,6 +726,7 @@
|
|||||||
"Is forbidden - Tooltip": "账户是否已被禁用",
|
"Is forbidden - Tooltip": "账户是否已被禁用",
|
||||||
"Is global admin": "是全局管理员",
|
"Is global admin": "是全局管理员",
|
||||||
"Is global admin - Tooltip": "是应用程序管理员",
|
"Is global admin - Tooltip": "是应用程序管理员",
|
||||||
|
"Keys": "键",
|
||||||
"Link": "绑定",
|
"Link": "绑定",
|
||||||
"Location": "城市",
|
"Location": "城市",
|
||||||
"Location - Tooltip": "居住地址所在的城市",
|
"Location - Tooltip": "居住地址所在的城市",
|
||||||
@ -741,6 +742,7 @@
|
|||||||
"Password Set": "密码已设置",
|
"Password Set": "密码已设置",
|
||||||
"Please select avatar from resources": "从资源中选择...",
|
"Please select avatar from resources": "从资源中选择...",
|
||||||
"Properties": "属性",
|
"Properties": "属性",
|
||||||
|
"Properties - Tooltip": "属性",
|
||||||
"Re-enter New": "重复新密码",
|
"Re-enter New": "重复新密码",
|
||||||
"Reset Email...": "重置邮箱...",
|
"Reset Email...": "重置邮箱...",
|
||||||
"Reset Phone...": "重置手机号...",
|
"Reset Phone...": "重置手机号...",
|
||||||
@ -756,6 +758,7 @@
|
|||||||
"Unlink": "解绑",
|
"Unlink": "解绑",
|
||||||
"Upload (.xlsx)": "上传(.xlsx)",
|
"Upload (.xlsx)": "上传(.xlsx)",
|
||||||
"Upload a photo": "上传头像",
|
"Upload a photo": "上传头像",
|
||||||
|
"Values": "值",
|
||||||
"WebAuthn credentials": "WebAuthn凭据",
|
"WebAuthn credentials": "WebAuthn凭据",
|
||||||
"input password": "输入密码"
|
"input password": "输入密码"
|
||||||
},
|
},
|
||||||
|
131
web/src/propertyTable.js
Normal file
131
web/src/propertyTable.js
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
// Copyright 2022 The Casdoor Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import {Button, Input, Table} from "antd";
|
||||||
|
import i18next from "i18next";
|
||||||
|
import {DeleteOutlined} from "@ant-design/icons";
|
||||||
|
import * as Setting from "./Setting";
|
||||||
|
|
||||||
|
class PropertyTable extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
properties: [],
|
||||||
|
count: Object.entries(this.props.properties).length,
|
||||||
|
};
|
||||||
|
// transfer the Object to object[]
|
||||||
|
Object.entries(this.props.properties).map((item, index) => {
|
||||||
|
this.state.properties.push({key: index, name: item[0], value: item[1]});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
page = 1;
|
||||||
|
|
||||||
|
updateTable(table) {
|
||||||
|
this.setState({properties: table});
|
||||||
|
const properties = {};
|
||||||
|
table.map((item) => {
|
||||||
|
properties[item.name] = item.value;
|
||||||
|
});
|
||||||
|
this.props.onUpdateTable(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
addRow(table) {
|
||||||
|
const row = {key: this.state.count, name: "", value: ""};
|
||||||
|
if (table === undefined) {
|
||||||
|
table = [];
|
||||||
|
}
|
||||||
|
table = Setting.addRow(table, row);
|
||||||
|
this.setState({count: this.state.count + 1});
|
||||||
|
this.updateTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteRow(table, index) {
|
||||||
|
table = Setting.deleteRow(table, this.getIndex(index));
|
||||||
|
this.updateTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
getIndex(index) {
|
||||||
|
// Parameter is the row index in table, need to calculate the index in dataSource. 10 is the pageSize.
|
||||||
|
return index + (this.page - 1) * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateField(table, index, key, value) {
|
||||||
|
table[this.getIndex(index)][key] = value;
|
||||||
|
this.updateTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTable(table) {
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: i18next.t("user:Keys"),
|
||||||
|
dataIndex: "name",
|
||||||
|
width: "200px",
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Input value={text} onChange={e => {
|
||||||
|
this.updateField(table, index, "name", e.target.value);
|
||||||
|
}} />
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("user:Values"),
|
||||||
|
dataIndex: "value",
|
||||||
|
width: "200px",
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Input value={text} onChange={e => {
|
||||||
|
this.updateField(table, index, "value", e.target.value);
|
||||||
|
}} />
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("general:Action"),
|
||||||
|
dataIndex: "operation",
|
||||||
|
width: "20px",
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return (
|
||||||
|
<Button icon={<DeleteOutlined />} size="small" onClick={() => this.deleteRow(table, index)} />
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table title={() => (
|
||||||
|
<div>
|
||||||
|
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => this.addRow(table)}>{i18next.t("general:Add")}</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
pagination={{onChange: page => {this.page = page;}}}
|
||||||
|
columns={columns} dataSource={table} rowKey="key" size="middle" bordered
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
{
|
||||||
|
this.renderTable(this.state.properties)
|
||||||
|
}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PropertyTable;
|
Reference in New Issue
Block a user