mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
Add GetPermissionsBySubmitter()
This commit is contained in:
@ -385,13 +385,17 @@ class App extends Component {
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
);
|
||||
res.push(
|
||||
<Menu.Item key="/permissions">
|
||||
<Link to="/permissions">
|
||||
{i18next.t("general:Permissions")}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
);
|
||||
}
|
||||
|
||||
res.push(
|
||||
<Menu.Item key="/permissions">
|
||||
<Link to="/permissions">
|
||||
{i18next.t("general:Permissions")}
|
||||
</Link>
|
||||
</Menu.Item>
|
||||
);
|
||||
|
||||
if (Setting.isAdminUser(this.state.account)) {
|
||||
res.push(
|
||||
<Menu.Item key="/models">
|
||||
<Link to="/models">
|
||||
|
@ -22,6 +22,7 @@ import i18next from "i18next";
|
||||
import * as RoleBackend from "./backend/RoleBackend";
|
||||
import * as ModelBackend from "./backend/ModelBackend";
|
||||
import * as ApplicationBackend from "./backend/ApplicationBackend";
|
||||
import moment from "moment/moment";
|
||||
|
||||
const {Option} = Select;
|
||||
|
||||
@ -297,6 +298,63 @@ class PermissionEditPage extends React.Component {
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("permission:Submitter"), i18next.t("permission:Submitter - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input disabled={true} value={this.state.permission.submitter} onChange={e => {
|
||||
this.updatePermissionField("submitter", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("permission:Approver"), i18next.t("permission:Approver - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input disabled={true} value={this.state.permission.approver} onChange={e => {
|
||||
this.updatePermissionField("approver", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("permission:Approve time"), i18next.t("permission:Approve time - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input disabled={true} value={Setting.getFormattedDate(this.state.permission.approveTime)} onChange={e => {
|
||||
this.updatePermissionField("approveTime", e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{marginTop: "20px"}} >
|
||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{Setting.getLabel(i18next.t("permission:State"), i18next.t("permission:State - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select disabled={!Setting.isLocalAdminUser(this.props.account)} virtual={false} style={{width: "100%"}} value={this.state.permission.state} onChange={(value => {
|
||||
if (this.state.permission.state !== value) {
|
||||
if (value === "Approved") {
|
||||
this.updatePermissionField("approver", this.props.account.name);
|
||||
this.updatePermissionField("approveTime", moment().format());
|
||||
} else {
|
||||
this.updatePermissionField("approver", "");
|
||||
this.updatePermissionField("approveTime", "");
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePermissionField("state", value);
|
||||
})}>
|
||||
{
|
||||
[
|
||||
{id: "Approved", name: "Approved"},
|
||||
{id: "Pending", name: "Pending"},
|
||||
].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
|
||||
}
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ class PermissionListPage extends BaseListPage {
|
||||
newPermission() {
|
||||
const randomName = Setting.getRandomName();
|
||||
return {
|
||||
owner: "built-in",
|
||||
owner: this.props.account.owner,
|
||||
name: `permission_${randomName}`,
|
||||
createdTime: moment().format(),
|
||||
displayName: `New Permission - ${randomName}`,
|
||||
users: [],
|
||||
users: [this.props.account.name],
|
||||
roles: [],
|
||||
domains: [],
|
||||
resourceType: "Application",
|
||||
@ -37,6 +37,10 @@ class PermissionListPage extends BaseListPage {
|
||||
actions: ["Read"],
|
||||
effect: "Allow",
|
||||
isEnabled: true,
|
||||
submitter: this.props.account.name,
|
||||
approver: "",
|
||||
approveTime: "",
|
||||
state: "Pending",
|
||||
};
|
||||
}
|
||||
|
||||
@ -44,6 +48,10 @@ class PermissionListPage extends BaseListPage {
|
||||
const newPermission = this.newPermission();
|
||||
PermissionBackend.addPermission(newPermission)
|
||||
.then((res) => {
|
||||
if (res.msg !== "") {
|
||||
Setting.showMessage("error", res.msg);
|
||||
return;
|
||||
}
|
||||
this.props.history.push({pathname: `/permissions/${newPermission.owner}/${newPermission.name}`, mode: "add"});
|
||||
}
|
||||
)
|
||||
@ -260,7 +268,9 @@ class PermissionListPage extends BaseListPage {
|
||||
value = params.type;
|
||||
}
|
||||
this.setState({loading: true});
|
||||
PermissionBackend.getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
||||
|
||||
const getPermissions = Setting.isAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter;
|
||||
getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
this.setState({
|
||||
|
@ -373,6 +373,13 @@ export function isAdminUser(account) {
|
||||
return account.owner === "built-in" || account.isGlobalAdmin === true;
|
||||
}
|
||||
|
||||
export function isLocalAdminUser(account) {
|
||||
if (account === undefined || account === null) {
|
||||
return false;
|
||||
}
|
||||
return account.isAdmin === true || isAdminUser(account);
|
||||
}
|
||||
|
||||
export function deepCopy(obj) {
|
||||
return Object.assign({}, obj);
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ export function getPermissions(owner, page = "", pageSize = "", field = "", valu
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function getPermissionsBySubmitter() {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-permissions-by-submitter`, {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
export function getPermission(owner, name) {
|
||||
return fetch(`${Setting.ServerUrl}/api/get-permission?id=${owner}/${encodeURIComponent(name)}`, {
|
||||
method: "GET",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "Aktionen",
|
||||
"Actions - Tooltip": "Aktionen - Tooltip",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "Berechtigung bearbeiten",
|
||||
"Effect": "Effekt",
|
||||
"Effect - Tooltip": "Effekt - Tooltip",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "Ressourcentyp",
|
||||
"Resource type - Tooltip": "Ressourcentyp - Tooltip",
|
||||
"Resources": "Ressourcen",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "Rolle bearbeiten",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "Unterrollen",
|
||||
"Sub roles - Tooltip": "Unterrollen - Tooltip",
|
||||
"Sub users": "Unternutzer",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "Actions",
|
||||
"Actions - Tooltip": "Actions - Tooltip",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "Edit Permission",
|
||||
"Effect": "Effect",
|
||||
"Effect - Tooltip": "Effect - Tooltip",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "Resource type",
|
||||
"Resource type - Tooltip": "Resource type - Tooltip",
|
||||
"Resources": "Resources",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "Edit Role",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "Sub roles",
|
||||
"Sub roles - Tooltip": "Sub roles - Tooltip",
|
||||
"Sub users": "Sub users",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "Actions",
|
||||
"Actions - Tooltip": "Actions - Info-bulle",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "Autorisation d'édition",
|
||||
"Effect": "Effet",
|
||||
"Effect - Tooltip": "Effet - Infobulle",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "Type de ressource",
|
||||
"Resource type - Tooltip": "Type de ressource - infobulle",
|
||||
"Resources": "Ressource",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "Modifier le rôle",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "Sous-rôles",
|
||||
"Sub roles - Tooltip": "Sous-rôles - infobulle",
|
||||
"Sub users": "Sous-utilisateurs",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "アクション",
|
||||
"Actions - Tooltip": "アクション → ツールチップ",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "権限を編集",
|
||||
"Effect": "効果",
|
||||
"Effect - Tooltip": "エフェクト - ツールチップ",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "リソースタイプ",
|
||||
"Resource type - Tooltip": "リソースタイプ - ツールチップ",
|
||||
"Resources": "リソース",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "役割を編集",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "サブロール",
|
||||
"Sub roles - Tooltip": "Sub roles - Tooltip",
|
||||
"Sub users": "サブユーザー",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "Actions",
|
||||
"Actions - Tooltip": "Actions - Tooltip",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "Edit Permission",
|
||||
"Effect": "Effect",
|
||||
"Effect - Tooltip": "Effect - Tooltip",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "Resource type",
|
||||
"Resource type - Tooltip": "Resource type - Tooltip",
|
||||
"Resources": "Resources",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "Edit Role",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "Sub roles",
|
||||
"Sub roles - Tooltip": "Sub roles - Tooltip",
|
||||
"Sub users": "Sub users",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "Действия",
|
||||
"Actions - Tooltip": "Действия - Подсказка",
|
||||
"Approve time": "Approve time",
|
||||
"Approve time - Tooltip": "Approve time - Tooltip",
|
||||
"Approver": "Approver",
|
||||
"Approver - Tooltip": "Approver - Tooltip",
|
||||
"Edit Permission": "Изменить права доступа",
|
||||
"Effect": "Эффект",
|
||||
"Effect - Tooltip": "Эффект - Подсказка",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "Тип ресурса",
|
||||
"Resource type - Tooltip": "Тип ресурса - Подсказка",
|
||||
"Resources": "Ресурсы",
|
||||
"Resources - Tooltip": "Resources - Tooltip"
|
||||
"Resources - Tooltip": "Resources - Tooltip",
|
||||
"State": "State",
|
||||
"State - Tooltip": "State - Tooltip",
|
||||
"Submitter": "Submitter",
|
||||
"Submitter - Tooltip": "Submitter - Tooltip"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "Alipay",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "Изменить роль",
|
||||
"New Role": "New Role",
|
||||
"Sub domains": "Sub domains",
|
||||
"Sub domains - Tooltip": "Sub domains - Tooltip",
|
||||
"Sub roles": "Суб роли",
|
||||
"Sub roles - Tooltip": "Суб роли - Tooltip",
|
||||
"Sub users": "Субпользователи",
|
||||
|
@ -343,6 +343,10 @@
|
||||
"permission": {
|
||||
"Actions": "动作",
|
||||
"Actions - Tooltip": "授权的动作",
|
||||
"Approve time": "审批时间",
|
||||
"Approve time - Tooltip": "该授权被审批通过的时间",
|
||||
"Approver": "审批者",
|
||||
"Approver - Tooltip": "审批通过该授权的人",
|
||||
"Edit Permission": "编辑权限",
|
||||
"Effect": "效果",
|
||||
"Effect - Tooltip": "允许还是拒绝",
|
||||
@ -350,7 +354,11 @@
|
||||
"Resource type": "资源类型",
|
||||
"Resource type - Tooltip": "授权资源的类型",
|
||||
"Resources": "资源",
|
||||
"Resources - Tooltip": "被授权的资源"
|
||||
"Resources - Tooltip": "被授权的资源",
|
||||
"State": "审批状态",
|
||||
"State - Tooltip": "该授权现在的状态",
|
||||
"Submitter": "申请者",
|
||||
"Submitter - Tooltip": "申请该授权的人"
|
||||
},
|
||||
"product": {
|
||||
"Alipay": "支付宝",
|
||||
@ -519,6 +527,8 @@
|
||||
"role": {
|
||||
"Edit Role": "编辑角色",
|
||||
"New Role": "添加角色",
|
||||
"Sub domains": "包含域",
|
||||
"Sub domains - Tooltip": "当前角色所包含的子域",
|
||||
"Sub roles": "包含角色",
|
||||
"Sub roles - Tooltip": "当前角色所包含的子角色",
|
||||
"Sub users": "包含用户",
|
||||
|
Reference in New Issue
Block a user