diff --git a/controllers/resource.go b/controllers/resource.go index c6709013..fcfcf7b6 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -361,6 +361,9 @@ func (c *ApiController) UploadResource() { return } + if user.Properties == nil { + user.Properties = map[string]string{} + } user.Properties[tag] = fileUrl user.Properties["isIdCardVerified"] = "false" _, err = object.UpdateUser(user.GetId(), user, []string{"properties"}, false) diff --git a/object/permission_enforcer.go b/object/permission_enforcer.go index 7f1ac6d5..68a41f88 100644 --- a/object/permission_enforcer.go +++ b/object/permission_enforcer.go @@ -309,8 +309,7 @@ func GetAllRoles(userId string) []string { func GetBuiltInModel(modelText string) (model.Model, error) { if modelText == "" { - modelText = ` -[request_definition] + modelText = `[request_definition] r = sub, obj, act [policy_definition] diff --git a/web/src/EnforcerEditPage.js b/web/src/EnforcerEditPage.js index 0d8ab029..a75b9176 100644 --- a/web/src/EnforcerEditPage.js +++ b/web/src/EnforcerEditPage.js @@ -169,7 +169,7 @@ class EnforcerEditPage extends React.Component { { this.updateEnforcerField("adapter", adapter); })} - options={this.state.adapters.map((adapter) => Setting.getOption(adapter.name, `${adapter.owner}/${adapter.name}`)) + options={this.state.adapters.map((adapter) => Setting.getOption(`${adapter.owner}/${adapter.name}`, `${adapter.owner}/${adapter.name}`)) } /> diff --git a/web/src/EnforcerListPage.js b/web/src/EnforcerListPage.js index 478d7a4c..465a6e4e 100644 --- a/web/src/EnforcerListPage.js +++ b/web/src/EnforcerListPage.js @@ -75,7 +75,7 @@ class EnforcerListPage extends BaseListPage { title: i18next.t("general:Name"), dataIndex: "name", key: "name", - width: "150px", + width: "200px", fixed: "left", sorter: true, ...this.getColumnSearchProps("name"), @@ -116,10 +116,42 @@ class EnforcerListPage extends BaseListPage { title: i18next.t("general:Display name"), dataIndex: "displayName", key: "displayName", - width: "200px", + // width: "200px", sorter: true, ...this.getColumnSearchProps("displayName"), }, + { + title: i18next.t("general:Model"), + dataIndex: "model", + key: "model", + width: "250px", + fixed: "left", + sorter: true, + ...this.getColumnSearchProps("name"), + render: (text, record, index) => { + return ( + + {text} + + ); + }, + }, + { + title: i18next.t("general:Adapter"), + dataIndex: "adapter", + key: "adapter", + width: "250px", + fixed: "left", + sorter: true, + ...this.getColumnSearchProps("name"), + render: (text, record, index) => { + return ( + + {text} + + ); + }, + }, { title: i18next.t("general:Is enabled"), dataIndex: "isEnabled", @@ -136,7 +168,7 @@ class EnforcerListPage extends BaseListPage { title: i18next.t("general:Action"), dataIndex: "", key: "op", - width: "170px", + width: "180px", fixed: (Setting.isMobile()) ? "false" : "right", render: (text, record, index) => { return ( diff --git a/web/src/UserEditPage.js b/web/src/UserEditPage.js index a71590f5..ebb0a23a 100644 --- a/web/src/UserEditPage.js +++ b/web/src/UserEditPage.js @@ -570,7 +570,7 @@ class UserEditPage extends React.Component { {name: "ID card back", value: "idCardBack"}, {name: "ID card with person", value: "idCardWithPerson"}, ].map((entry) => { - return this.renderImage(this.state.user.properties[entry.value] || "", this.getIdCardType(entry.name), this.getIdCardText(entry.name), entry.value, disabled); + return this.renderImage(this.state.user.properties === null ? "" : (this.state.user.properties[entry.value] || ""), this.getIdCardType(entry.name), this.getIdCardText(entry.name), entry.value, disabled); }) } @@ -995,11 +995,13 @@ class UserEditPage extends React.Component { { imgUrl ? - - - +
+ + + +
: - +
+
{`Upload ${title}...`}
diff --git a/web/src/account/AccountAvatar.js b/web/src/account/AccountAvatar.js index 23a87dc7..f37f11fa 100644 --- a/web/src/account/AccountAvatar.js +++ b/web/src/account/AccountAvatar.js @@ -17,7 +17,7 @@ import {MetaMaskAvatar} from "react-metamask-avatar"; class AccountAvatar extends React.Component { render() { - const {src, size} = this.props; + const {src, size, width, height} = this.props; // The avatar for Metamask account is directly generated by an algorithm based on the address // src = "metamask:0xC304b2cC0Be8E9ce10fF3Afd34820Ed306A23600"; const matchMetaMask = src.match(/^metamask:(\w+)$/); @@ -27,9 +27,19 @@ class AccountAvatar extends React.Component { ); } - return ( - - ); + if (size !== undefined) { + return ( + + ); + } else if (width === undefined) { + return ( + + ); + } else if (height === undefined) { + return ( + + ); + } } } diff --git a/web/src/table/PoliciyTable.js b/web/src/table/PoliciyTable.js index 402496a8..82c5fac6 100644 --- a/web/src/table/PoliciyTable.js +++ b/web/src/table/PoliciyTable.js @@ -33,11 +33,11 @@ class PolicyTable extends React.Component { } count = 0; - pageSize = 10; + pageSize = 100; getIndex(index) { // Need to be used in all place when modify table. Parameter is the row index in table, need to calculate the index in dataSource. - return index + (this.state.page - 1) * 10; + return index + (this.state.page - 1) * this.pageSize; } UNSAFE_componentWillMount() { @@ -165,7 +165,7 @@ class PolicyTable extends React.Component { renderTable(table) { const columns = [ { - title: "Rule Type", + title: i18next.t("adapter:Rule type"), dataIndex: "Ptype", width: "100px", // render: (text, record, index) => { @@ -270,8 +270,9 @@ class PolicyTable extends React.Component { }, }, { - title: "Option", - key: "option", + title: i18next.t("general:Action"), + dataIndex: "", + key: "op", width: "100px", render: (text, record, index) => { const editable = this.isEditing(index); @@ -304,7 +305,6 @@ class PolicyTable extends React.Component { onChange: (page) => this.setState({ page: page, }), - disabled: this.state.editingIndex !== "" || Setting.builtInObject({owner: this.props.owner, name: this.props.name}), current: this.state.page, }} columns={columns} dataSource={table} rowKey="key" size="middle" bordered