+ {
+ this.state.task !== null ? this.renderTask() : null
+ }
+
+
+
+
+ );
+ }
+}
+
+export default TaskEditPage;
diff --git a/web/src/TaskListPage.js b/web/src/TaskListPage.js
new file mode 100644
index 0000000..d4951ba
--- /dev/null
+++ b/web/src/TaskListPage.js
@@ -0,0 +1,197 @@
+// Copyright 2023 The casbin 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 {Link} from "react-router-dom";
+import {Button, Popconfirm, Table} from "antd";
+import moment from "moment";
+import * as Setting from "./Setting";
+import * as TaskBackend from "./backend/TaskBackend";
+import i18next from "i18next";
+
+class TaskListPage extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ classes: props,
+ tasks: null,
+ };
+ }
+
+ UNSAFE_componentWillMount() {
+ this.getTasks();
+ }
+
+ getTasks() {
+ TaskBackend.getTasks(this.props.account.name)
+ .then((res) => {
+ if (res.status === "ok") {
+ this.setState({
+ tasks: res.data,
+ });
+ } else {
+ Setting.showMessage("error", `Failed to get tasks: ${res.msg}`);
+ }
+ });
+ }
+
+ newTask() {
+ const randomName = Setting.getRandomName();
+ return {
+ owner: this.props.account.name,
+ name: `task_${randomName}`,
+ createdTime: moment().format(),
+ displayName: `New Task - ${randomName}`,
+ provider: "provider_openai",
+ application: "Docs-Polish",
+ path: "F:/github_repos/casdoor-website",
+ };
+ }
+
+ addTask() {
+ const newTask = this.newTask();
+ TaskBackend.addTask(newTask)
+ .then((res) => {
+ if (res.status === "ok") {
+ Setting.showMessage("success", "Task added successfully");
+ this.setState({
+ tasks: Setting.prependRow(this.state.tasks, newTask),
+ });
+ } else {
+ Setting.showMessage("error", `Failed to add task: ${res.msg}`);
+ }
+ })
+ .catch(error => {
+ Setting.showMessage("error", `Task failed to add: ${error}`);
+ });
+ }
+
+ deleteTask(i) {
+ TaskBackend.deleteTask(this.state.tasks[i])
+ .then((res) => {
+ if (res.status === "ok") {
+ Setting.showMessage("success", "Task deleted successfully");
+ this.setState({
+ tasks: Setting.deleteRow(this.state.tasks, i),
+ });
+ } else {
+ Setting.showMessage("error", `Task failed to delete: ${res.msg}`);
+ }
+ })
+ .catch(error => {
+ Setting.showMessage("error", `Task failed to delete: ${error}`);
+ });
+ }
+
+ renderTable(tasks) {
+ const columns = [
+ {
+ title: i18next.t("general:Name"),
+ dataIndex: "name",
+ key: "name",
+ width: "160px",
+ sorter: (a, b) => a.name.localeCompare(b.name),
+ render: (text, record, index) => {
+ return (
+