Update modal terminal
This commit is contained in:
parent
c4a5b1c499
commit
a88ff44ebd
|
|
@ -890,6 +890,9 @@ function App() {
|
||||||
listLicense={listLicense}
|
listLicense={listLicense}
|
||||||
getListIos={getListIos}
|
getListIos={getListIos}
|
||||||
getListLicense={getListLicense}
|
getListLicense={getListLicense}
|
||||||
|
setScenarios={setScenarios}
|
||||||
|
listBrands={listBrands}
|
||||||
|
listCategories={listCategories}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <ModalConfirmRunScenario
|
{/* <ModalConfirmRunScenario
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import type {
|
||||||
TUser,
|
TUser,
|
||||||
} from "../../untils/types";
|
} from "../../untils/types";
|
||||||
import type { Socket } from "socket.io-client";
|
import type { Socket } from "socket.io-client";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
const ModalRunScenario = ({
|
const ModalRunScenario = ({
|
||||||
open,
|
open,
|
||||||
|
|
@ -48,7 +48,7 @@ const ModalRunScenario = ({
|
||||||
user: TUser;
|
user: TUser;
|
||||||
socket: Socket | null;
|
socket: Socket | null;
|
||||||
setIsDisable: (value: boolean) => void;
|
setIsDisable: (value: boolean) => void;
|
||||||
station: TStation;
|
station: TStation | undefined;
|
||||||
listBrands: TBrands[];
|
listBrands: TBrands[];
|
||||||
listCategories: TCategories[];
|
listCategories: TCategories[];
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -57,6 +57,15 @@ const ModalRunScenario = ({
|
||||||
const [inputSeries, setInputSeries] = useState<string[]>([]);
|
const [inputSeries, setInputSeries] = useState<string[]>([]);
|
||||||
const [inputTitle, setInputTitle] = useState("");
|
const [inputTitle, setInputTitle] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) {
|
||||||
|
setOptionBrand("");
|
||||||
|
setOptionCategory("");
|
||||||
|
setInputSeries([]);
|
||||||
|
setInputTitle("");
|
||||||
|
}
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
const filteredScenarios = () => {
|
const filteredScenarios = () => {
|
||||||
let listScenarios = [...scenarios];
|
let listScenarios = [...scenarios];
|
||||||
if (inputTitle.trim())
|
if (inputTitle.trim())
|
||||||
|
|
@ -497,8 +506,8 @@ const ModalRunScenario = ({
|
||||||
)
|
)
|
||||||
socket?.emit("run_all_dpelp", {
|
socket?.emit("run_all_dpelp", {
|
||||||
lineIds: selectedLines?.map((el) => el.id),
|
lineIds: selectedLines?.map((el) => el.id),
|
||||||
stationName: station.name,
|
stationName: station?.name,
|
||||||
stationId: Number(station.id),
|
stationId: Number(station?.id),
|
||||||
scenarioName: scenario.title,
|
scenarioName: scenario.title,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import type {
|
||||||
FileInfo,
|
FileInfo,
|
||||||
IScenario,
|
IScenario,
|
||||||
SwitchPortsProps,
|
SwitchPortsProps,
|
||||||
|
TBrands,
|
||||||
|
TCategories,
|
||||||
TDataTicket,
|
TDataTicket,
|
||||||
TextFSM,
|
TextFSM,
|
||||||
TextTSMLicense,
|
TextTSMLicense,
|
||||||
|
|
@ -36,7 +38,7 @@ import {
|
||||||
IconPlug,
|
IconPlug,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { ButtonDPELP, ButtonScenario } from "../ButtonAction";
|
import { ButtonDPELP } from "../ButtonAction";
|
||||||
import CopyIcon from "../CopyIcon";
|
import CopyIcon from "../CopyIcon";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
@ -46,6 +48,8 @@ import { listBaudDefault } from "../../untils/constanst";
|
||||||
import { motion } from "motion/react";
|
import { motion } from "motion/react";
|
||||||
import ModalSelectIOS from "./ModalSelectIOS";
|
import ModalSelectIOS from "./ModalSelectIOS";
|
||||||
import ModalSelectLicense from "./ModalSelectLicense";
|
import ModalSelectLicense from "./ModalSelectLicense";
|
||||||
|
import ModalRunScenario from "./ModalRunScenario";
|
||||||
|
import DrawerScenario from "./ModalScenario";
|
||||||
const apiUrl = import.meta.env.VITE_BACKEND_URL;
|
const apiUrl = import.meta.env.VITE_BACKEND_URL;
|
||||||
|
|
||||||
const INIT_TICKET = {
|
const INIT_TICKET = {
|
||||||
|
|
@ -69,6 +73,9 @@ const ModalTerminal = ({
|
||||||
listLicense,
|
listLicense,
|
||||||
getListLicense,
|
getListLicense,
|
||||||
getListIos,
|
getListIos,
|
||||||
|
listBrands,
|
||||||
|
listCategories,
|
||||||
|
setScenarios,
|
||||||
}: {
|
}: {
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
|
@ -81,6 +88,9 @@ const ModalTerminal = ({
|
||||||
listLicense: FileInfo[];
|
listLicense: FileInfo[];
|
||||||
getListLicense: () => void;
|
getListLicense: () => void;
|
||||||
getListIos: () => void;
|
getListIos: () => void;
|
||||||
|
listBrands: TBrands[];
|
||||||
|
listCategories: TCategories[];
|
||||||
|
setScenarios: (value: React.SetStateAction<IScenario[]>) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const user = useMemo(() => {
|
const user = useMemo(() => {
|
||||||
return localStorage.getItem("user") &&
|
return localStorage.getItem("user") &&
|
||||||
|
|
@ -101,6 +111,8 @@ const ModalTerminal = ({
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
const [openSelectIos, setOpenSelectIos] = useState<boolean>(false);
|
const [openSelectIos, setOpenSelectIos] = useState<boolean>(false);
|
||||||
const [openSelectLicense, setOpenSelectLicense] = useState<boolean>(false);
|
const [openSelectLicense, setOpenSelectLicense] = useState<boolean>(false);
|
||||||
|
const [openScenarioModal, setOpenScenarioModal] = useState<boolean>(false);
|
||||||
|
const [openDrawerScenario, setOpenDrawerScenario] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (opened && line?.tickets && line?.tickets?.length > 0) {
|
if (opened && line?.tickets && line?.tickets?.length > 0) {
|
||||||
|
|
@ -466,8 +478,17 @@ const ModalTerminal = ({
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Modal
|
<Modal
|
||||||
|
zIndex={95}
|
||||||
opened={opened}
|
opened={opened}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
if (openDrawerScenario) {
|
||||||
|
setOpenDrawerScenario(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (openScenarioModal) {
|
||||||
|
setOpenScenarioModal(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (openSelectIos) return;
|
if (openSelectIos) return;
|
||||||
onClose();
|
onClose();
|
||||||
if (
|
if (
|
||||||
|
|
@ -1164,49 +1185,18 @@ const ModalTerminal = ({
|
||||||
(el) => el.title.toUpperCase() === "DPELP"
|
(el) => el.title.toUpperCase() === "DPELP"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Menu trigger="hover" withArrow shadow="md" position="top">
|
<Button
|
||||||
<Menu.Target>
|
fw={400}
|
||||||
<Button
|
disabled={isDisable}
|
||||||
fw={400}
|
variant="outline"
|
||||||
disabled={isDisable}
|
color="yellow"
|
||||||
variant="filled"
|
style={{ height: "30px", width: "100px" }}
|
||||||
color="yellow"
|
onClick={() => {
|
||||||
style={{ height: "30px", width: "100px" }}
|
setOpenScenarioModal(true);
|
||||||
onClick={() => {}}
|
}}
|
||||||
>
|
>
|
||||||
Scenario
|
Scenario
|
||||||
</Button>
|
</Button>
|
||||||
</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
<Box
|
|
||||||
px="xs"
|
|
||||||
py="sm"
|
|
||||||
style={{
|
|
||||||
display: "grid",
|
|
||||||
gridTemplateColumns: "1fr 1fr",
|
|
||||||
gap: "12px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{scenarios.map((el, i) => (
|
|
||||||
<ButtonScenario
|
|
||||||
key={i}
|
|
||||||
socket={socket}
|
|
||||||
selectedLines={line ? [line] : []}
|
|
||||||
isDisable={isDisable}
|
|
||||||
onClick={() => {
|
|
||||||
// setSelectedLines([]);
|
|
||||||
setIsDisable(true);
|
|
||||||
setTimeout(() => {
|
|
||||||
setIsDisable(false);
|
|
||||||
}, 5000);
|
|
||||||
}}
|
|
||||||
scenario={el}
|
|
||||||
station={stationItem}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
|
||||||
<Button
|
<Button
|
||||||
disabled={isDisable}
|
disabled={isDisable}
|
||||||
fw={400}
|
fw={400}
|
||||||
|
|
@ -1524,6 +1514,31 @@ const ModalTerminal = ({
|
||||||
line={line}
|
line={line}
|
||||||
getListLicense={getListLicense}
|
getListLicense={getListLicense}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ModalRunScenario
|
||||||
|
open={openScenarioModal}
|
||||||
|
setOpen={setOpenScenarioModal}
|
||||||
|
scenarios={scenarios}
|
||||||
|
isDisable={isDisable}
|
||||||
|
selectedLines={line ? [line] : []}
|
||||||
|
user={user}
|
||||||
|
socket={socket}
|
||||||
|
setIsDisable={setIsDisable}
|
||||||
|
station={stationItem}
|
||||||
|
setOpenEdit={setOpenDrawerScenario}
|
||||||
|
listBrands={listBrands}
|
||||||
|
listCategories={listCategories}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Drawer Scenario để Add/Edit */}
|
||||||
|
<DrawerScenario
|
||||||
|
scenarios={scenarios}
|
||||||
|
setScenarios={setScenarios}
|
||||||
|
externalOpened={openDrawerScenario}
|
||||||
|
onExternalClose={() => setOpenDrawerScenario(false)}
|
||||||
|
listBrands={listBrands}
|
||||||
|
listCategories={listCategories}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue