From b89cf1de07c45db15b4f98b090ad9d0b1bff110f Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 15 Apr 2023 16:05:33 +0800 Subject: [PATCH] Add karma to account items --- object/user.go | 4 +- web/src/UserEditPage.js | 138 +++++++++++++++++++++++++++++++++- web/src/table/AccountTable.js | 11 +++ 3 files changed, 147 insertions(+), 6 deletions(-) diff --git a/object/user.go b/object/user.go index 38cfb374..c2417897 100644 --- a/object/user.go +++ b/object/user.go @@ -48,6 +48,7 @@ type User struct { EmailVerified bool `json:"emailVerified"` Phone string `xorm:"varchar(20) index" json:"phone"` CountryCode string `xorm:"varchar(6)" json:"countryCode"` + Region string `xorm:"varchar(100)" json:"region"` Location string `xorm:"varchar(100)" json:"location"` Address []string `json:"address"` Affiliation string `xorm:"varchar(100)" json:"affiliation"` @@ -57,7 +58,6 @@ type User struct { Homepage string `xorm:"varchar(100)" json:"homepage"` Bio string `xorm:"varchar(100)" json:"bio"` Tag string `xorm:"varchar(100)" json:"tag"` - Region string `xorm:"varchar(100)" json:"region"` Language string `xorm:"varchar(100)" json:"language"` Gender string `xorm:"varchar(100)" json:"gender"` Birthday string `xorm:"varchar(100)" json:"birthday"` @@ -449,7 +449,7 @@ func UpdateUser(id string, user *User, columns []string, isGlobalAdmin bool) boo if len(columns) == 0 { columns = []string{ "owner", "display_name", "avatar", - "location", "address", "country_code", "region", "language", "affiliation", "title", "homepage", "bio", "score", "tag", "signup_application", + "location", "address", "country_code", "region", "language", "affiliation", "title", "homepage", "bio", "tag", "language", "gender", "birthday", "education", "score", "karma", "ranking", "signup_application", "is_admin", "is_global_admin", "is_forbidden", "is_deleted", "hash", "is_default_avatar", "properties", "webauthnCredentials", "managedAccounts", "signin_wrong_times", "last_signin_wrong_time", } diff --git a/web/src/UserEditPage.js b/web/src/UserEditPage.js index 4287dabf..19f00874 100644 --- a/web/src/UserEditPage.js +++ b/web/src/UserEditPage.js @@ -13,7 +13,7 @@ // limitations under the License. import React from "react"; -import {Button, Card, Col, Input, Result, Row, Select, Spin, Switch} from "antd"; +import {Button, Card, Col, Input, InputNumber, Result, Row, Select, Spin, Switch} from "antd"; import * as UserBackend from "./backend/UserBackend"; import * as OrganizationBackend from "./backend/OrganizationBackend"; import * as Setting from "./Setting"; @@ -110,9 +110,9 @@ class UserEditPage extends React.Component { } parseUserField(key, value) { - // if ([].includes(key)) { - // value = Setting.myParseInt(value); - // } + if (["score", "karma", "ranking"].includes(key)) { + value = Setting.myParseInt(value); + } return value; } @@ -360,6 +360,19 @@ class UserEditPage extends React.Component { ); + } else if (accountItem.name === "Address") { + return ( + + + {Setting.getLabel(i18next.t("user:Address"), i18next.t("user:Address - Tooltip"))} : + + + { + this.updateUserField("address", e.target.value); + }} /> + + + ); } else if (accountItem.name === "Affiliation") { return ( (this.state.application === null || this.state.user === null) ? null : ( @@ -379,6 +392,32 @@ class UserEditPage extends React.Component { ); + } else if (accountItem.name === "ID card type") { + return ( + + + {Setting.getLabel(i18next.t("user:ID card type"), i18next.t("user:ID card type - Tooltip"))} : + + + { + this.updateUserField("idCardType", e.target.value); + }} /> + + + ); + } else if (accountItem.name === "ID card") { + return ( + + + {Setting.getLabel(i18next.t("user:ID card"), i18next.t("user:ID card - Tooltip"))} : + + + { + this.updateUserField("idCard", e.target.value); + }} /> + + + ); } else if (accountItem.name === "Homepage") { return ( @@ -431,6 +470,97 @@ class UserEditPage extends React.Component { ); + } else if (accountItem.name === "Language") { + return ( + + + {Setting.getLabel(i18next.t("user:Language"), i18next.t("user:Language - Tooltip"))} : + + + { + this.updateUserField("language", e.target.value); + }} /> + + + ); + } else if (accountItem.name === "Gender") { + return ( + + + {Setting.getLabel(i18next.t("user:Gender"), i18next.t("user:Gender - Tooltip"))} : + + + { + this.updateUserField("gender", e.target.value); + }} /> + + + ); + } else if (accountItem.name === "Birthday") { + return ( + + + {Setting.getLabel(i18next.t("user:Birthday"), i18next.t("user:Birthday - Tooltip"))} : + + + { + this.updateUserField("birthday", e.target.value); + }} /> + + + ); + } else if (accountItem.name === "Education") { + return ( + + + {Setting.getLabel(i18next.t("user:Education"), i18next.t("user:Education - Tooltip"))} : + + + { + this.updateUserField("education", e.target.value); + }} /> + + + ); + } else if (accountItem.name === "Score") { + return ( + + + {Setting.getLabel(i18next.t("user:Score"), i18next.t("user:Score - Tooltip"))} : + + + { + this.updateUserField("score", value); + }} /> + + + ); + } else if (accountItem.name === "Karma") { + return ( + + + {Setting.getLabel(i18next.t("user:Karma"), i18next.t("user:Karma - Tooltip"))} : + + + { + this.updateUserField("karma", value); + }} /> + + + ); + } else if (accountItem.name === "Ranking") { + return ( + + + {Setting.getLabel(i18next.t("user:Ranking"), i18next.t("user:Ranking - Tooltip"))} : + + + { + this.updateUserField("ranking", value); + }} /> + + + ); } else if (accountItem.name === "Signup application") { return ( diff --git a/web/src/table/AccountTable.js b/web/src/table/AccountTable.js index 78be4a0c..1cfea44f 100644 --- a/web/src/table/AccountTable.js +++ b/web/src/table/AccountTable.js @@ -81,16 +81,27 @@ class AccountTable extends React.Component { {name: "Country code", displayName: i18next.t("user:Country code")}, {name: "Country/Region", displayName: i18next.t("user:Country/Region")}, {name: "Location", displayName: i18next.t("user:Location")}, + {name: "Address", displayName: i18next.t("user:Address")}, {name: "Affiliation", displayName: i18next.t("user:Affiliation")}, {name: "Title", displayName: i18next.t("user:Title")}, + {name: "ID card type", displayName: i18next.t("user:ID card type")}, + {name: "ID card", displayName: i18next.t("user:ID card")}, {name: "Homepage", displayName: i18next.t("user:Homepage")}, {name: "Bio", displayName: i18next.t("user:Bio")}, {name: "Tag", displayName: i18next.t("user:Tag")}, + {name: "Language", displayName: i18next.t("user:Language")}, + {name: "Gender", displayName: i18next.t("user:Gender")}, + {name: "Birthday", displayName: i18next.t("user:Birthday")}, + {name: "Education", displayName: i18next.t("user:Education")}, + {name: "Score", displayName: i18next.t("user:Score")}, + {name: "Karma", displayName: i18next.t("user:Karma")}, + {name: "Ranking", displayName: i18next.t("user:Ranking")}, {name: "Signup application", displayName: i18next.t("general:Signup application")}, {name: "Roles", displayName: i18next.t("general:Roles")}, {name: "Permissions", displayName: i18next.t("general:Permissions")}, {name: "3rd-party logins", displayName: i18next.t("user:3rd-party logins")}, {name: "Properties", displayName: i18next.t("user:Properties")}, + {name: "Is online", displayName: i18next.t("user:Is online")}, {name: "Is admin", displayName: i18next.t("user:Is admin")}, {name: "Is global admin", displayName: i18next.t("user:Is global admin")}, {name: "Is forbidden", displayName: i18next.t("user:Is forbidden")},