Skip to content

Commit

Permalink
feat(frontend): use timestamp for api
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Dec 10, 2024
1 parent 4fa6079 commit 79d44ee
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 66 deletions.
112 changes: 56 additions & 56 deletions src/GZCTF/ClientApp/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ export interface UserInfoModel {
bio?: string | null;
/**
* Registration time
* @format date-time
* @format uint64
*/
registerTimeUtc?: string;
registerTimeUtc?: number;
/**
* Last visit time
* @format date-time
* @format uint64
*/
lastVisitedUtc?: string;
lastVisitedUtc?: number;
/** Last visit IP */
ip?: string;
/** Email */
Expand Down Expand Up @@ -504,9 +504,9 @@ export interface AdminUserInfoModel {
export interface LogMessageModel {
/**
* Log time
* @format date-time
* @format uint64
*/
time?: string;
time?: number;
/** Username */
name?: string | null;
level?: string | null;
Expand Down Expand Up @@ -547,9 +547,9 @@ export interface WriteupInfoModel {
url?: string;
/**
* File upload time
* @format date-time
* @format uint64
*/
uploadTimeUtc?: string;
uploadTimeUtc?: number;
}

/** List response */
Expand Down Expand Up @@ -585,14 +585,14 @@ export interface ContainerInstanceModel {
containerId?: string;
/**
* Container creation time
* @format date-time
* @format uint64
*/
startedAt?: string;
startedAt?: number;
/**
* Expected container stop time
* @format date-time
* @format uint64
*/
expectStopAt?: string;
expectStopAt?: number;
/** Access IP */
ip?: string;
/**
Expand Down Expand Up @@ -734,10 +734,10 @@ export interface PostDetailModel {
authorName?: string | null;
/**
* Publish time
* @format date-time
* @format uint64
* @minLength 1
*/
time: string;
time: number;
}

/** Game information (Edit) */
Expand Down Expand Up @@ -787,21 +787,21 @@ export interface GameInfoModel {
practiceMode?: boolean;
/**
* Start time
* @format date-time
* @format uint64
* @minLength 1
*/
start: string;
start: number;
/**
* End time
* @format date-time
* @format uint64
* @minLength 1
*/
end: string;
end: number;
/**
* Writeup submission deadline
* @format date-time
* @format uint64
*/
writeupDeadline?: string;
writeupDeadline?: number;
/** Writeup additional notes */
writeupNote?: string;
/**
Expand Down Expand Up @@ -836,10 +836,10 @@ export type GameNotice = FormattableDataOfNoticeType & {
id: number;
/**
* Publish time
* @format date-time
* @format uint64
* @minLength 1
*/
time: string;
time: number;
};

/** Formattable data */
Expand Down Expand Up @@ -989,14 +989,14 @@ export interface ContainerInfoModel {
status?: ContainerStatus;
/**
* Container creation time
* @format date-time
* @format uint64
*/
startedAt?: string;
startedAt?: number;
/**
* Expected container stop time
* @format date-time
* @format uint64
*/
expectStopAt?: string;
expectStopAt?: number;
/** Challenge entry point */
entry?: string;
}
Expand Down Expand Up @@ -1183,14 +1183,14 @@ export interface BasicGameInfoModel {
limit?: number;
/**
* Start time
* @format date-time
* @format uint64
*/
start?: string;
start?: number;
/**
* End time
* @format date-time
* @format uint64
*/
end?: string;
end?: number;
}

/** Detailed game information, including detailed introduction and current team registration status */
Expand Down Expand Up @@ -1233,14 +1233,14 @@ export interface DetailedGameInfoModel {
status?: ParticipationStatus;
/**
* Start time
* @format date-time
* @format uint64
*/
start?: string;
start?: number;
/**
* End time
* @format date-time
* @format uint64
*/
end?: string;
end?: number;
}

export interface GameJoinModel {
Expand All @@ -1259,10 +1259,10 @@ export interface GameJoinModel {
export interface ScoreboardModel {
/**
* Update time
* @format date-time
* @format uint64
* @minLength 1
*/
updateTimeUtc: string;
updateTimeUtc: number;
/**
* Blood bonus coefficient
* @format int64
Expand Down Expand Up @@ -1296,9 +1296,9 @@ export interface TopTimeLine {
export interface TimeLine {
/**
* Time
* @format date-time
* @format uint64
*/
time?: string;
time?: number;
/**
* Score
* @format int32
Expand Down Expand Up @@ -1337,9 +1337,9 @@ export interface ScoreboardItem {
divisionRank?: number | null;
/**
* Last submission time
* @format date-time
* @format uint64
*/
lastSubmissionTime?: string;
lastSubmissionTime?: number;
/** List of solved challenges */
solvedChallenges?: ChallengeItem[];
/**
Expand All @@ -1366,9 +1366,9 @@ export interface ChallengeItem {
userName?: string | null;
/**
* Submission time for the challenge, used to calculate the timeline
* @format date-time
* @format uint64
*/
time?: string;
time?: number;
}

/** Submission type */
Expand Down Expand Up @@ -1418,9 +1418,9 @@ export interface Blood {
avatar?: string | null;
/**
* Time when the blood was obtained
* @format date-time
* @format uint64
*/
submitTimeUtc?: string | null;
submitTimeUtc?: number | null;
}

/**
Expand All @@ -1430,10 +1430,10 @@ export interface Blood {
export type GameEvent = FormattableDataOfEventType & {
/**
* Publish time
* @format date-time
* @format uint64
* @minLength 1
*/
time: string;
time: number;
/** Related username */
user?: string;
/** Related team name */
Expand Down Expand Up @@ -1467,9 +1467,9 @@ export interface Submission {
status?: AnswerResult;
/**
* Time the answer was submitted
* @format date-time
* @format uint64
*/
time?: string;
time?: number;
/** User who submitted */
user?: string;
/** Team that submitted */
Expand Down Expand Up @@ -1572,9 +1572,9 @@ export interface FileRecord {
size?: number;
/**
* File modification date
* @format date-time
* @format uint64
*/
updateTime?: string;
updateTime?: number;
}

export interface GameDetailModel {
Expand All @@ -1596,10 +1596,10 @@ export interface GameDetailModel {
writeupRequired: boolean;
/**
* Writeup submission deadline
* @format date-time
* @format uint64
* @minLength 1
*/
writeupDeadline: string;
writeupDeadline: number;
}

/** Participation for review (Admin) */
Expand Down Expand Up @@ -1672,9 +1672,9 @@ export interface ChallengeDetailModel {
export interface ClientFlagContext {
/**
* Close time of the challenge instance
* @format date-time
* @format uint64
*/
closeTime?: string | null;
closeTime?: number | null;
/** Connection method of the challenge instance */
instanceEntry?: string | null;
/** Attachment URL */
Expand Down Expand Up @@ -1739,10 +1739,10 @@ export interface PostInfoModel {
authorName?: string | null;
/**
* Update time
* @format date-time
* @format uint64
* @minLength 1
*/
time: string;
time: number;
}

/** Client configuration */
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/InstanceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface InstanceEntryProps {
}

interface CountdownProps {
time?: string | null
time?: number | null
onTimeout?: () => void
extendEnabled: boolean
enableExtend: () => void
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/WriteupSubmitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import uploadClasses from '@Styles/Upload.module.css'

interface WriteupSubmitModalProps extends ModalProps {
gameId: number
writeupDeadline: string
writeupDeadline: number
}

export const WriteupSubmitModal: FC<WriteupSubmitModalProps> = ({ gameId, writeupDeadline: wpddl, ...props }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ChallengePreviewModalProps extends ModalProps {
}

interface FakeContext {
closeTime: string | null
closeTime: number | null
instanceEntry: string | null
url: string
}
Expand All @@ -36,7 +36,7 @@ export const ChallengePreviewModal: FC<ChallengePreviewModalProps> = (props) =>
const onCreate = () => {
setContext({
...context,
closeTime: dayjs().add(10, 'm').add(10, 's').toJSON(),
closeTime: dayjs().add(10, 'm').add(10, 's').valueOf(),
instanceEntry: 'localhost:2333',
})
}
Expand All @@ -52,7 +52,7 @@ export const ChallengePreviewModal: FC<ChallengePreviewModalProps> = (props) =>
const onExtend = () => {
setContext({
...context,
closeTime: dayjs(context.closeTime).add(10, 'm').toJSON(),
closeTime: dayjs(context.closeTime).add(10, 'm').valueOf(),
instanceEntry: context.instanceEntry,
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/ClientApp/src/components/admin/GameCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const GameCreateModal: FC<GameCreateModalProps> = (props) => {
try {
const res = await api.edit.editAddGame({
title,
start: start.toJSON(),
end: end.toJSON(),
start: start.valueOf(),
end: end.valueOf(),
})
showNotification({
color: 'teal',
Expand Down
6 changes: 3 additions & 3 deletions src/GZCTF/ClientApp/src/pages/admin/games/[id]/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ const GameInfoEdit: FC = () => {
await api.edit.editUpdateGame(game.id!, {
...game,
inviteCode: (game.inviteCode?.length ?? 0 > 6) ? game.inviteCode : null,
start: start.toJSON(),
end: end.toJSON(),
writeupDeadline: end.add(wpddl, 'h').toJSON(),
start: start.valueOf(),
end: end.valueOf(),
writeupDeadline: end.add(wpddl, 'h').valueOf(),
})
showNotification({
color: 'teal',
Expand Down

0 comments on commit 79d44ee

Please sign in to comment.