Skip to content

Commit

Permalink
added coach mode fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jahidem committed Dec 31, 2022
1 parent 596e735 commit 57e88b5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 30 deletions.
16 changes: 8 additions & 8 deletions core/homeWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export default class HomeWindow {
},
});
if (HomeWindow.thisWindow != null) {
// HomeWindow.thisWindow.loadURL(
// 'file://' + __dirname + '/../index.html#/home'
// );
HomeWindow.thisWindow.loadURL("http://localhost:3000/#/home");
HomeWindow.thisWindow.loadURL(
'file://' + __dirname + '/../index.html#/home'
);
// HomeWindow.thisWindow.loadURL("http://localhost:3000/#/home");

HomeWindow.thisWindow.on("closed", HomeWindow.onClose);
}
Expand Down Expand Up @@ -87,8 +87,8 @@ export default class HomeWindow {
});

if (HomeWindow.logWindow != null) {
// HomeWindow.logWindow.loadURL('file://' + __dirname + '/../index.html#/log');
HomeWindow.logWindow.loadURL("http://localhost:3000/#/log");
HomeWindow.logWindow.loadURL('file://' + __dirname + '/../index.html#/log');
// HomeWindow.logWindow.loadURL("http://localhost:3000/#/log");
}
}

Expand Down Expand Up @@ -138,8 +138,8 @@ export default class HomeWindow {
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
// HomeWindow.potmWindow.loadURL('file://' + __dirname + '/../index.html#/potm');
HomeWindow.potmWindow.loadURL("http://localhost:3000/#/potm");
HomeWindow.potmWindow.loadURL('file://' + __dirname + '/../index.html#/potm');
// HomeWindow.potmWindow.loadURL("http://localhost:3000/#/potm");
// HomeWindow.potmWindow.on("closed", HomeWindow.closePotmWindow);
}
}
Expand Down
Binary file modified core/prisma/sqlite.db
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "potm",
"productName": "potm",
"version": "1.1.0",
"productName": "potm 1.2.0",
"version": "1.2.0",
"homepage": ".",
"private": true,
"main": "build/core/main.js",
Expand Down Expand Up @@ -73,7 +73,7 @@
},
"build": {
"appId": "com.jahidem.potm",
"productName": "POTM",
"productName": "POTM 1.2.0",
"publish": [
{
"provider": "github",
Expand Down
19 changes: 19 additions & 0 deletions src/redux/slice/contest-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ interface ContestState {
reportRow: ReportRow[];
reportGenerate: GenerateReport;
listLogs: StandingLogs[];
adminMode: Boolean;
}
const initialState: ContestState = {
list: [],
Expand All @@ -128,6 +129,7 @@ const initialState: ContestState = {
reportRow: [],
reportGenerate: GenerateReport.IDLE,
listLogs: [],
adminMode: true,
};

const ContestSlice = createSlice({
Expand All @@ -136,6 +138,19 @@ const ContestSlice = createSlice({
reducers: {
filterAllContest(state) {
let filtered = state.list.filter((contest: Contest) => {
if (state.adminMode) {
return (
new Date(contest.startTimeSeconds * 1000) <
new Date(state.epochEnd) &&
new Date(state.epochStart) <=
new Date(contest.startTimeSeconds * 1000) &&
contest.phase == ContestPhase.FINISHED &&
(contest.name.includes("Div. 3") ||
contest.name.includes("Div. 2") ||
contest.name.includes("Codeforces Global Round"))
);
}

return (
new Date(contest.startTimeSeconds * 1000) <
new Date(state.epochEnd) &&
Expand Down Expand Up @@ -182,6 +197,9 @@ const ContestSlice = createSlice({
updateAllowOC(state, arr: PayloadAction<(string | number)[]>) {
state.allowOC = arr.payload;
},
toggleAdmin(state) {
state.adminMode = !state.adminMode;
},
updateReportRow(
state,
contestStanding: PayloadAction<ContestStanding.RootObject>
Expand Down Expand Up @@ -257,5 +275,6 @@ export const {
saveAllContest,
generateRanking,
loadLogList,
toggleAdmin,
} = ContestSlice.actions;
export default ContestSlice.reducer;
43 changes: 25 additions & 18 deletions src/screen/components/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Checkbox,
CheckboxGroup,
Stack,
Switch,
} from "@chakra-ui/react";
import { ChevronDownIcon } from "@chakra-ui/icons";
import { useEffect, useState } from "react";
Expand All @@ -18,6 +19,7 @@ import {
setEpochStart,
setEpochEnd,
updateAllowDiv,
toggleAdmin,
} from "../../redux/slice/contest-slice";

interface ChooserState {
Expand All @@ -34,6 +36,7 @@ const initials = {

const Setting = () => {
const contestLoading = useAppSelector((state) => state.cfapi.contestLoading);
const adminMode = useAppSelector((state) => state.contest.adminMode);
const dispatch = useAppDispatch();

const [start, setStart] = useState<ChooserState>(initials);
Expand Down Expand Up @@ -102,22 +105,23 @@ const Setting = () => {

return (
<>
<Flex flexDir="column" p="1.6rem 2rem">
<Flex flexDir="column" p="1.6rem 2rem" h="100%">
<Text
color="darkblue"
alignSelf="center"
fontSize="1.6rem"
fontWeight="500"
>
Choose the period for POTM
Choose the period and division
</Text>
<Flex justifyContent="space-between" my="2rem">

<Flex justifyContent="space-between" my="1.4rem">
<Flex
justifyContent="space-between"
width="16rem"
alignItems="center"
>
<Text fontSize="1.4rem" fontWeight="semibold">
<Text fontSize="1.4rem" fontWeight="semibold" mr="1.4rem">
From:
</Text>
<Select
Expand Down Expand Up @@ -177,7 +181,7 @@ const Setting = () => {
width="15rem"
alignItems="center"
>
<Text fontSize="1.4rem" fontWeight="semibold">
<Text fontSize="1.4rem" fontWeight="semibold" mr="1.4rem">
To:
</Text>
<Select
Expand Down Expand Up @@ -232,23 +236,26 @@ const Setting = () => {
/>
</Flex>
</Flex>
<Box my="0 1rem">
<Text
color="darkblue"
fontSize="1.6rem"
fontWeight="500"
textAlign="left"
>
Filter:
<Flex alignItems="center" m="1.4rem 1.4rem 0 0">
<Text fontSize="1.4rem" mr="1.4rem" fontWeight="semibold">
Coach mode
</Text>

<Flex mt="0.8rem" ml="1rem">
<Text fontSize="1.3rem" mr="1.4rem" fontWeight="semibold">
Division:{" "}
<Switch
size="lg"
isChecked={adminMode ? true : false}
onChange={() => dispatch(toggleAdmin())}
colorScheme="teal"
/>
</Flex>
<Box my="0 1rem" opacity={adminMode ? "0.6" : "1"}>
<Flex my="1.4rem">
<Text fontSize="1.4rem" mr="1.4rem" fontWeight="semibold">
Division:
</Text>
<CheckboxGroup
defaultValue={checkedDiv}
onChange={(value) => setCheckedDiv(value)}
isDisabled={adminMode ? true : false}
>
<Stack spacing={[3]} direction={["row"]}>
<Checkbox colorScheme="teal" size="lg" value="Div. 1">
Expand All @@ -272,7 +279,7 @@ const Setting = () => {
</Box>

<Button
m="3rem 1rem 0 2rem"
m="1.4rem 1rem 0 2rem"
size="lg"
fontSize="1.4rem"
colorScheme="teal"
Expand Down
5 changes: 4 additions & 1 deletion src/screen/homeScreen/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Home = () => {
colSpan={2}
bg="rgb(247, 249, 249,1)"
borderRadius="11px"
boxShadow="0.1px 0.1px 4px rgb(115,115,115, 0.2)"
>
<Contestant />
</GridItem>
Expand All @@ -43,18 +44,20 @@ const Home = () => {
rowSpan={4}
bg="rgb(247, 249, 249,1)"
borderRadius="11px"
boxShadow="0.1px 0.1px 4px rgb(115,115,115, 0.2)"
>
<Setting />
</GridItem>
<GridItem
height="calc(100vh - 350px)"
height="calc(100vh - 370px)"
rowSpan={6}
p="1rem"
mt="1.4rem"
colSpan={4}
bg="rgb(178,216,216,0.2)"
borderRadius="11px"
overflowY="scroll"
boxShadow="0.1px 0.1px 4px rgb(115,115,115, 0.2)"
>
<ContestTable />
</GridItem>
Expand Down

0 comments on commit 57e88b5

Please sign in to comment.