added reload group tasks
parent
f548371f3a
commit
65eed057a5
|
@ -4,10 +4,12 @@ import "./App.css";
|
||||||
import PageContent from "./Components/PageContent";
|
import PageContent from "./Components/PageContent";
|
||||||
import SideMenu from "./Components/SideMenu";
|
import SideMenu from "./Components/SideMenu";
|
||||||
import Login from "./Pages/Login";
|
import Login from "./Pages/Login";
|
||||||
import { Layout } from "antd";
|
import { Layout, notification } from "antd";
|
||||||
import { UseUserSession, WebSocketProvider } from "./utils";
|
import { UseUserSession, WebSocketProvider } from "./utils";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
const [notificationApi, notificationContextHolder] =
|
||||||
|
notification.useNotification();
|
||||||
const { userSession, setUserSession } = UseUserSession();
|
const { userSession, setUserSession } = UseUserSession();
|
||||||
|
|
||||||
if (!userSession) {
|
if (!userSession) {
|
||||||
|
@ -23,9 +25,11 @@ export default function App() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout style={{ minHeight: "100vh" }}>
|
<Layout style={{ minHeight: "100vh" }}>
|
||||||
|
{notificationContextHolder}
|
||||||
<WebSocketProvider
|
<WebSocketProvider
|
||||||
userSession={userSession}
|
userSession={userSession}
|
||||||
setUserSession={setUserSession}
|
setUserSession={setUserSession}
|
||||||
|
notificationApi={notificationApi}
|
||||||
>
|
>
|
||||||
<SideMenu setUserSession={setUserSession}></SideMenu>
|
<SideMenu setUserSession={setUserSession}></SideMenu>
|
||||||
<PageContent></PageContent>
|
<PageContent></PageContent>
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
||||||
import { Badge, Button, Divider, Popconfirm, Space, Table } from "antd";
|
import { Badge, Button, Divider, Popconfirm, Space, Table } from "antd";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Constants, FormatDatetime, GetDuration } from "../../utils";
|
import {
|
||||||
|
Constants,
|
||||||
|
FormatDatetime,
|
||||||
|
GetDuration,
|
||||||
|
SentMessagesCommands,
|
||||||
|
WebSocketContext,
|
||||||
|
} from "../../utils";
|
||||||
|
import { useContext } from "react";
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -58,6 +65,8 @@ export default function GroupTaskTableList({
|
||||||
showGroupTypeSelectionModal,
|
showGroupTypeSelectionModal,
|
||||||
groupTasks,
|
groupTasks,
|
||||||
}) {
|
}) {
|
||||||
|
const webSocketContext = useContext(WebSocketContext);
|
||||||
|
|
||||||
const getStatusBadge = (status) => {
|
const getStatusBadge = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Constants.GROUP_TASKS_STATUS.FINISHED:
|
case Constants.GROUP_TASKS_STATUS.FINISHED:
|
||||||
|
@ -98,6 +107,12 @@ export default function GroupTaskTableList({
|
||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOnConfirm = (category) => {
|
||||||
|
webSocketContext.SendSocketMessage(SentMessagesCommands.ReloadGroupTasks, {
|
||||||
|
category: category,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Divider orientation="left">{categoryGroup.category}</Divider>
|
<Divider orientation="left">{categoryGroup.category}</Divider>
|
||||||
|
@ -118,8 +133,9 @@ export default function GroupTaskTableList({
|
||||||
|
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
placement="left"
|
placement="left"
|
||||||
title="Are you sure you want to reload the group?"
|
title="Are you sure you want to reload the group configs?"
|
||||||
okText="Yes"
|
okText="Yes"
|
||||||
|
onConfirm={() => handleOnConfirm(categoryGroup.category)}
|
||||||
>
|
>
|
||||||
<Button icon={<ReloadOutlined />}>Reload</Button>
|
<Button icon={<ReloadOutlined />}>Reload</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
|
37
src/utils.js
37
src/utils.js
|
@ -78,6 +78,8 @@ const ReceivedMessagesCommands = {
|
||||||
NewGroupTaskStep: 4,
|
NewGroupTaskStep: 4,
|
||||||
UpdateGroupTaskStep: 5,
|
UpdateGroupTaskStep: 5,
|
||||||
UpdateGroupTask: 6,
|
UpdateGroupTask: 6,
|
||||||
|
ReloadingGroupTasks: 7,
|
||||||
|
GroupTasksReloaded: 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
// commands sent to the backend server
|
// commands sent to the backend server
|
||||||
|
@ -85,9 +87,15 @@ export const SentMessagesCommands = {
|
||||||
StartGroupTasks: 1,
|
StartGroupTasks: 1,
|
||||||
TaskFailedTryAgainRunTaskStep: 2,
|
TaskFailedTryAgainRunTaskStep: 2,
|
||||||
TaskContinueTaskStep: 3,
|
TaskContinueTaskStep: 3,
|
||||||
|
ReloadGroupTasks: 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function WebSocketProvider({ children, userSession, setUserSession }) {
|
export function WebSocketProvider({
|
||||||
|
children,
|
||||||
|
userSession,
|
||||||
|
setUserSession,
|
||||||
|
notificationApi,
|
||||||
|
}) {
|
||||||
const [isReady, setIsReady] = useState(false);
|
const [isReady, setIsReady] = useState(false);
|
||||||
const [connectionBadgeStatus, setConnectionBadgeStatus] = useState(
|
const [connectionBadgeStatus, setConnectionBadgeStatus] = useState(
|
||||||
webSocketContextPreview.ConnectionBadgeStatus
|
webSocketContextPreview.ConnectionBadgeStatus
|
||||||
|
@ -165,8 +173,31 @@ export function WebSocketProvider({ children, userSession, setUserSession }) {
|
||||||
return newArr;
|
return newArr;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
case ReceivedMessagesCommands.ReloadingGroupTasks:
|
||||||
console.log("unknown command", cmd);
|
notificationApi["warning"]({
|
||||||
|
message: `Group ${body} is reloading`,
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case ReceivedMessagesCommands.GroupTasksReloaded:
|
||||||
|
setCategoryGroups((arr) => {
|
||||||
|
const newArr = [...arr];
|
||||||
|
|
||||||
|
newArr[
|
||||||
|
arr.findIndex((arr1) => arr1.category === body.Category)
|
||||||
|
].groups = body.UpdatedGroups;
|
||||||
|
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
|
||||||
|
notificationApi["info"]({
|
||||||
|
message: `Group ${body.Category} reloaded`,
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReceivedMessagesCommands.default:
|
||||||
|
console.error("unknown command", cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue