forked from pinks/eris
Compare commits
1 Commits
main
...
daily-jobs
Author | SHA1 | Date |
---|---|---|
nameless | c86f4b3c2e |
|
@ -7,6 +7,7 @@ export const configSchema = {
|
|||
pausedReason: { type: ["string", "null"] },
|
||||
maxUserJobs: { type: "number" },
|
||||
maxJobs: { type: "number" },
|
||||
maxDailyJobs: { type: "number" },
|
||||
defaultParams: {
|
||||
type: "object",
|
||||
properties: {
|
||||
|
@ -21,7 +22,7 @@ export const configSchema = {
|
|||
},
|
||||
},
|
||||
},
|
||||
required: ["adminUsernames", "maxUserJobs", "maxJobs", "defaultParams"],
|
||||
required: ["adminUsernames", "maxUserJobs", "maxJobs", "maxDailyJobs", "defaultParams"],
|
||||
} as const satisfies JsonSchema;
|
||||
|
||||
export type Config = jsonType<typeof configSchema>;
|
||||
|
@ -33,6 +34,7 @@ export async function getConfig(): Promise<Config> {
|
|||
pausedReason: config?.pausedReason ?? null,
|
||||
maxUserJobs: config?.maxUserJobs ?? Infinity,
|
||||
maxJobs: config?.maxJobs ?? Infinity,
|
||||
maxDailyJobs: config?.maxDailyJobs ?? Infinity,
|
||||
defaultParams: config?.defaultParams ?? {},
|
||||
};
|
||||
}
|
||||
|
@ -43,6 +45,7 @@ export async function setConfig(newConfig: Partial<Config>): Promise<void> {
|
|||
pausedReason: newConfig.pausedReason ?? oldConfig.pausedReason,
|
||||
maxUserJobs: newConfig.maxUserJobs ?? oldConfig.maxUserJobs,
|
||||
maxJobs: newConfig.maxJobs ?? oldConfig.maxJobs,
|
||||
maxDailyJobs: newConfig.maxDailyJobs ?? oldConfig.maxDailyJobs,
|
||||
defaultParams: newConfig.defaultParams ?? oldConfig.defaultParams,
|
||||
};
|
||||
await db.set(["config"], config);
|
||||
|
|
|
@ -231,6 +231,46 @@ export function SettingsPage(props: { sessionId: string | null }) {
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<label className="flex flex-col items-stretch gap-1">
|
||||
<span className="text-sm">
|
||||
Daily limit {newParams?.maxDailyJobs != null ? "(Changed)" : ""}
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<input
|
||||
className="input-text w-20"
|
||||
type="number"
|
||||
min={1}
|
||||
max={500}
|
||||
step={1}
|
||||
disabled={getParams.isLoading || !getUser.data?.admin}
|
||||
value={newParams?.maxDailyJobs ??
|
||||
getParams.data?.maxDailyJobs ??
|
||||
0}
|
||||
onChange={(e) =>
|
||||
setNewParams((params) => ({
|
||||
...params,
|
||||
dailyLimit: Number(e.target.value),
|
||||
}))}
|
||||
/>
|
||||
<input
|
||||
className="input-range flex-grow"
|
||||
type="range"
|
||||
min={1}
|
||||
max={500}
|
||||
step={1}
|
||||
disabled={getParams.isLoading || !getUser.data?.admin}
|
||||
value={newParams?.maxDailyJobs ??
|
||||
getParams.data?.maxDailyJobs ??
|
||||
0}
|
||||
onChange={(e) =>
|
||||
setNewParams((params) => ({
|
||||
...params,
|
||||
maxDailyJobs: Number(e.target.value),
|
||||
}))}
|
||||
/>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{patchParamsError
|
||||
? (
|
||||
<p className="alert">
|
||||
|
|
Loading…
Reference in New Issue