2022-02-13 23:39:27 +08:00
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2021-02-13 13:30:51 +08:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
import React from "react";
|
|
|
|
import {Link} from "react-router-dom";
|
2022-07-10 15:45:55 +08:00
|
|
|
import {Button, Popconfirm, Switch, Table, Upload} from "antd";
|
2021-12-31 12:56:19 +08:00
|
|
|
import {UploadOutlined} from "@ant-design/icons";
|
2021-02-13 12:15:19 +08:00
|
|
|
import moment from "moment";
|
|
|
|
import * as Setting from "./Setting";
|
|
|
|
import * as UserBackend from "./backend/UserBackend";
|
2021-02-19 23:23:59 +08:00
|
|
|
import i18next from "i18next";
|
2021-12-25 10:55:10 +08:00
|
|
|
import BaseListPage from "./BaseListPage";
|
2021-02-13 12:15:19 +08:00
|
|
|
|
2021-12-25 10:55:10 +08:00
|
|
|
class UserListPage extends BaseListPage {
|
2021-02-13 12:15:19 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
classes: props,
|
2021-06-19 11:38:24 +08:00
|
|
|
organizationName: props.match.params.organizationName,
|
2021-12-25 10:55:10 +08:00
|
|
|
data: [],
|
|
|
|
pagination: {
|
|
|
|
current: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
},
|
|
|
|
loading: false,
|
2022-07-10 15:45:55 +08:00
|
|
|
searchText: "",
|
|
|
|
searchedColumn: "",
|
2021-02-13 12:15:19 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
newUser() {
|
2021-12-12 18:51:12 +08:00
|
|
|
const randomName = Setting.getRandomName();
|
2021-02-13 12:15:19 +08:00
|
|
|
return {
|
2021-05-30 15:13:43 +08:00
|
|
|
owner: "built-in", // this.props.account.username,
|
2021-11-06 11:32:22 +08:00
|
|
|
name: `user_${randomName}`,
|
2021-02-13 12:15:19 +08:00
|
|
|
createdTime: moment().format(),
|
2021-04-26 19:00:23 +08:00
|
|
|
type: "normal-user",
|
2021-02-15 10:05:14 +08:00
|
|
|
password: "123",
|
2021-11-06 15:52:03 +08:00
|
|
|
passwordSalt: "",
|
2021-11-06 11:32:22 +08:00
|
|
|
displayName: `New User - ${randomName}`,
|
2021-02-13 14:49:31 +08:00
|
|
|
avatar: "https://casbin.org/img/casbin.svg",
|
2021-12-23 21:28:40 +08:00
|
|
|
email: `${randomName}@example.com`,
|
|
|
|
phone: Setting.getRandomNumber(),
|
2021-06-04 20:47:27 +08:00
|
|
|
address: [],
|
2021-02-15 10:05:14 +08:00
|
|
|
affiliation: "Example Inc.",
|
|
|
|
tag: "staff",
|
2021-07-31 16:02:48 +08:00
|
|
|
region: "",
|
2021-02-15 10:05:14 +08:00
|
|
|
isAdmin: false,
|
2021-05-05 23:40:18 +08:00
|
|
|
isGlobalAdmin: false,
|
|
|
|
IsForbidden: false,
|
2021-11-06 15:52:03 +08:00
|
|
|
isDeleted: false,
|
2021-05-30 15:13:43 +08:00
|
|
|
properties: {},
|
2021-12-12 18:51:12 +08:00
|
|
|
signupApplication: "app-built-in",
|
2022-07-10 15:45:55 +08:00
|
|
|
};
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
addUser() {
|
|
|
|
const newUser = this.newUser();
|
|
|
|
UserBackend.addUser(newUser)
|
|
|
|
.then((res) => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.props.history.push({pathname: `/users/${newUser.owner}/${newUser.name}`, mode: "add"});
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
)
|
|
|
|
.catch(error => {
|
|
|
|
Setting.showMessage("error", `User failed to add: ${error}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteUser(i) {
|
2021-12-25 10:55:10 +08:00
|
|
|
UserBackend.deleteUser(this.state.data[i])
|
2021-02-13 12:15:19 +08:00
|
|
|
.then((res) => {
|
2022-07-10 15:45:55 +08:00
|
|
|
Setting.showMessage("success", "User deleted successfully");
|
|
|
|
this.setState({
|
|
|
|
data: Setting.deleteRow(this.state.data, i),
|
|
|
|
pagination: {total: this.state.pagination.total - 1},
|
|
|
|
});
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
)
|
|
|
|
.catch(error => {
|
|
|
|
Setting.showMessage("error", `User failed to delete: ${error}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:56:19 +08:00
|
|
|
uploadFile(info) {
|
2022-07-10 15:45:55 +08:00
|
|
|
const {status, response: res} = info.file;
|
|
|
|
if (status === "done") {
|
|
|
|
if (res.status === "ok") {
|
|
|
|
Setting.showMessage("success", "Users uploaded successfully, refreshing the page");
|
2021-12-31 12:56:19 +08:00
|
|
|
|
2022-07-10 15:45:55 +08:00
|
|
|
const {pagination} = this.state;
|
|
|
|
this.fetch({pagination});
|
2021-12-31 12:56:19 +08:00
|
|
|
} else {
|
|
|
|
Setting.showMessage("error", `Users failed to upload: ${res.msg}`);
|
|
|
|
}
|
2022-07-10 15:45:55 +08:00
|
|
|
} else if (status === "error") {
|
|
|
|
Setting.showMessage("error", "File failed to upload");
|
2021-12-31 12:56:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderUpload() {
|
|
|
|
const props = {
|
2022-07-10 15:45:55 +08:00
|
|
|
name: "file",
|
|
|
|
accept: ".xlsx",
|
|
|
|
method: "post",
|
2021-12-31 12:56:19 +08:00
|
|
|
action: `${Setting.ServerUrl}/api/upload-users`,
|
|
|
|
withCredentials: true,
|
|
|
|
onChange: (info) => {
|
|
|
|
this.uploadFile(info);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Upload {...props}>
|
|
|
|
<Button type="primary" size="small">
|
|
|
|
<UploadOutlined /> {i18next.t("user:Upload (.xlsx)")}
|
|
|
|
</Button>
|
|
|
|
</Upload>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2021-12-31 12:56:19 +08:00
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
renderTable(users) {
|
2021-11-11 14:38:35 +08:00
|
|
|
// transfer country code to name based on selected language
|
|
|
|
var countries = require("i18n-iso-countries");
|
|
|
|
countries.registerLocale(require("i18n-iso-countries/langs/" + i18next.language + ".json"));
|
|
|
|
for (var index in users) {
|
2022-07-10 15:45:55 +08:00
|
|
|
users[index].region = countries.getName(users[index].region, i18next.language, {select: "official"});
|
2021-11-11 14:38:35 +08:00
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
const columns = [
|
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("general:Organization"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "owner",
|
|
|
|
key: "owner",
|
2021-07-23 09:46:01 +08:00
|
|
|
width: (Setting.isMobile()) ? "100px" : "120px",
|
2022-07-10 15:45:55 +08:00
|
|
|
fixed: "left",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("owner"),
|
2021-02-13 12:15:19 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
2021-03-26 21:58:10 +08:00
|
|
|
<Link to={`/organizations/${text}`}>
|
2021-02-13 12:15:19 +08:00
|
|
|
{text}
|
2021-03-26 21:58:10 +08:00
|
|
|
</Link>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
2021-08-07 19:52:01 +08:00
|
|
|
{
|
|
|
|
title: i18next.t("general:Application"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "signupApplication",
|
|
|
|
key: "signupApplication",
|
2021-08-07 19:52:01 +08:00
|
|
|
width: (Setting.isMobile()) ? "100px" : "120px",
|
2022-07-10 15:45:55 +08:00
|
|
|
fixed: "left",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("signupApplication"),
|
2021-08-07 19:52:01 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<Link to={`/applications/${text}`}>
|
|
|
|
{text}
|
|
|
|
</Link>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-08-07 19:52:01 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("general:Name"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "name",
|
|
|
|
key: "name",
|
2021-12-31 09:36:48 +08:00
|
|
|
width: (Setting.isMobile()) ? "80px" : "110px",
|
2022-07-10 15:45:55 +08:00
|
|
|
fixed: "left",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("name"),
|
2021-02-13 12:15:19 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<Link to={`/users/${record.owner}/${text}`}>
|
|
|
|
{text}
|
|
|
|
</Link>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
|
|
|
{
|
2021-04-28 00:13:50 +08:00
|
|
|
title: i18next.t("general:Created time"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "createdTime",
|
|
|
|
key: "createdTime",
|
|
|
|
width: "160px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2021-02-13 12:15:19 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return Setting.getFormattedDate(text);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
|
|
|
{
|
2021-04-28 00:13:50 +08:00
|
|
|
title: i18next.t("general:Display name"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "displayName",
|
|
|
|
key: "displayName",
|
2021-12-29 20:50:49 +08:00
|
|
|
// width: '100px',
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("displayName"),
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
2021-02-13 14:49:31 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("general:Avatar"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "avatar",
|
|
|
|
key: "avatar",
|
|
|
|
width: "80px",
|
2021-02-13 14:49:31 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
2021-03-27 11:38:15 +08:00
|
|
|
<a target="_blank" rel="noreferrer" href={text}>
|
2021-02-13 14:49:31 +08:00
|
|
|
<img src={text} alt={text} width={50} />
|
|
|
|
</a>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 14:49:31 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("general:Email"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "email",
|
|
|
|
key: "email",
|
|
|
|
width: "160px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("email"),
|
2021-02-13 20:13:32 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<a href={`mailto:${text}`}>
|
|
|
|
{text}
|
|
|
|
</a>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
2021-05-01 16:50:47 +08:00
|
|
|
{
|
|
|
|
title: i18next.t("general:Phone"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "phone",
|
|
|
|
key: "phone",
|
|
|
|
width: "120px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("phone"),
|
2021-05-01 16:50:47 +08:00
|
|
|
},
|
2021-02-14 21:21:42 +08:00
|
|
|
// {
|
|
|
|
// title: 'Phone',
|
|
|
|
// dataIndex: 'phone',
|
|
|
|
// key: 'phone',
|
|
|
|
// width: '120px',
|
|
|
|
// sorter: (a, b) => a.phone.localeCompare(b.phone),
|
|
|
|
// },
|
2021-02-14 13:43:55 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("user:Affiliation"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "affiliation",
|
|
|
|
key: "affiliation",
|
|
|
|
width: "140px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("affiliation"),
|
2021-02-14 13:43:55 +08:00
|
|
|
},
|
2021-07-31 16:02:48 +08:00
|
|
|
{
|
|
|
|
title: i18next.t("user:Country/Region"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "region",
|
|
|
|
key: "region",
|
|
|
|
width: "140px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("region"),
|
2021-07-31 16:02:48 +08:00
|
|
|
},
|
2021-02-14 21:21:42 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("user:Tag"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "tag",
|
|
|
|
key: "tag",
|
|
|
|
width: "110px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2022-07-10 15:45:55 +08:00
|
|
|
...this.getColumnSearchProps("tag"),
|
2021-02-14 21:21:42 +08:00
|
|
|
},
|
2021-02-14 13:43:55 +08:00
|
|
|
{
|
2021-04-28 00:13:50 +08:00
|
|
|
title: i18next.t("user:Is admin"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "isAdmin",
|
|
|
|
key: "isAdmin",
|
|
|
|
width: "110px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2021-02-14 13:43:55 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-14 13:43:55 +08:00
|
|
|
},
|
2021-02-15 22:14:19 +08:00
|
|
|
{
|
2021-04-28 00:13:50 +08:00
|
|
|
title: i18next.t("user:Is global admin"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "isGlobalAdmin",
|
|
|
|
key: "isGlobalAdmin",
|
|
|
|
width: "140px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2021-05-02 12:18:28 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-05-02 12:18:28 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: i18next.t("user:Is forbidden"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "isForbidden",
|
|
|
|
key: "isForbidden",
|
|
|
|
width: "110px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2021-02-15 22:14:19 +08:00
|
|
|
render: (text, record, index) => {
|
2021-11-06 15:52:03 +08:00
|
|
|
return (
|
|
|
|
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-11-06 15:52:03 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: i18next.t("user:Is deleted"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "isDeleted",
|
|
|
|
key: "isDeleted",
|
|
|
|
width: "110px",
|
2021-12-25 10:55:10 +08:00
|
|
|
sorter: true,
|
2021-11-06 15:52:03 +08:00
|
|
|
render: (text, record, index) => {
|
2021-02-15 22:14:19 +08:00
|
|
|
return (
|
|
|
|
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-15 22:14:19 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
{
|
2021-02-19 23:23:59 +08:00
|
|
|
title: i18next.t("general:Action"),
|
2022-07-10 15:45:55 +08:00
|
|
|
dataIndex: "",
|
|
|
|
key: "op",
|
|
|
|
width: "190px",
|
2021-07-23 09:46:01 +08:00
|
|
|
fixed: (Setting.isMobile()) ? "false" : "right",
|
2021-02-13 12:15:19 +08:00
|
|
|
render: (text, record, index) => {
|
|
|
|
return (
|
|
|
|
<div>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/users/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
2021-02-13 12:15:19 +08:00
|
|
|
<Popconfirm
|
|
|
|
title={`Sure to delete user: ${record.name} ?`}
|
|
|
|
onConfirm={() => this.deleteUser(index)}
|
|
|
|
>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginBottom: "10px"}} type="danger">{i18next.t("general:Delete")}</Button>
|
2021-02-13 12:15:19 +08:00
|
|
|
</Popconfirm>
|
|
|
|
</div>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2022-08-06 23:54:56 +08:00
|
|
|
},
|
2021-02-13 12:15:19 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-11-06 11:32:22 +08:00
|
|
|
const paginationProps = {
|
2021-12-25 10:55:10 +08:00
|
|
|
total: this.state.pagination.total,
|
2021-11-06 11:32:22 +08:00
|
|
|
showQuickJumper: true,
|
|
|
|
showSizeChanger: true,
|
2021-12-25 10:55:10 +08:00
|
|
|
showTotal: () => i18next.t("general:{total} in total").replace("{total}", this.state.pagination.total),
|
2021-11-06 11:32:22 +08:00
|
|
|
};
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Table scroll={{x: "max-content"}} columns={columns} dataSource={users} rowKey="name" size="middle" bordered pagination={paginationProps}
|
|
|
|
title={() => (
|
|
|
|
<div>
|
|
|
|
{i18next.t("general:Users")}
|
|
|
|
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={this.addUser.bind(this)}>{i18next.t("general:Add")}</Button>
|
|
|
|
{
|
|
|
|
this.renderUpload()
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
loading={this.state.loading}
|
|
|
|
onChange={this.handleTableChange}
|
2021-02-13 12:15:19 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:55:10 +08:00
|
|
|
fetch = (params = {}) => {
|
|
|
|
let field = params.searchedColumn, value = params.searchText;
|
|
|
|
let sortField = params.sortField, sortOrder = params.sortOrder;
|
2022-07-10 15:45:55 +08:00
|
|
|
this.setState({loading: true});
|
2021-12-25 10:55:10 +08:00
|
|
|
if (this.state.organizationName === undefined) {
|
|
|
|
UserBackend.getGlobalUsers(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
|
|
|
.then((res) => {
|
|
|
|
if (res.status === "ok") {
|
|
|
|
this.setState({
|
|
|
|
loading: false,
|
|
|
|
data: res.data,
|
|
|
|
pagination: {
|
|
|
|
...params.pagination,
|
|
|
|
total: res.data2,
|
|
|
|
},
|
|
|
|
searchText: params.searchText,
|
|
|
|
searchedColumn: params.searchedColumn,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
UserBackend.getUsers(this.state.organizationName, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
|
|
|
.then((res) => {
|
|
|
|
if (res.status === "ok") {
|
|
|
|
this.setState({
|
|
|
|
loading: false,
|
|
|
|
data: res.data,
|
|
|
|
pagination: {
|
|
|
|
...params.pagination,
|
|
|
|
total: res.data2,
|
|
|
|
},
|
|
|
|
searchText: params.searchText,
|
|
|
|
searchedColumn: params.searchedColumn,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default UserListPage;
|