Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingest quota #1152

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 56 additions & 6 deletions src/components/routes/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ function User({ username = null }: UserProps) {
setUser({ ...user, submission_quota: value });
}

function setAsyncSubmissionQuota(value) {
setModified(true);
setUser({ ...user, submission_async_quota: value });
}

function setDailyAPIQuota(value) {
setModified(true);
setUser({ ...user, api_daily_quota: value });
Expand Down Expand Up @@ -426,7 +431,7 @@ function User({ username = null }: UserProps) {
<Chip key={index} variant="outlined" label={option} {...getTagProps({ index })} />
))
}
onChange={(event, value) => setGroups([...new Set(value.map(x => x.toUpperCase()))])}
onChange={(_, value) => setGroups([...new Set(value.map(x => x.toUpperCase()))])}
/>
</>
),
Expand Down Expand Up @@ -462,6 +467,23 @@ function User({ username = null }: UserProps) {
/>
</>
),
submission_async_quota: (
<>
<Typography variant="h4">{t('submission_async_quota')}</Typography>
<Typography variant="caption" color="textSecondary" gutterBottom>
{t('submission_async_quota_edit_title')}
</Typography>
<TextField
autoFocus
type="number"
margin="normal"
variant="outlined"
InputProps={{ inputProps: { min: 0 } }}
onChange={event => setAsyncSubmissionQuota(event.target.value)}
value={user.submission_async_quota}
/>
</>
),
submission_daily_quota: (
<>
<Typography variant="h4">{t('submission_daily_quota')}</Typography>
Expand Down Expand Up @@ -542,7 +564,7 @@ function User({ username = null }: UserProps) {
/>
<label htmlFor="contained-button-file">
<IconButton
onClick={e => {
onClick={() => {
inputRef.current.click();
}}
disabled={!editable}
Expand Down Expand Up @@ -726,7 +748,7 @@ function User({ username = null }: UserProps) {
className={classes.row}
hover={currentUser.is_admin}
style={{ cursor: currentUser.is_admin ? 'pointer' : 'default' }}
onClick={currentUser.is_admin ? event => toggleDrawer('api_quota') : null}
onClick={currentUser.is_admin ? () => toggleDrawer('api_quota') : null}
>
{isXS ? null : <TableCell style={{ whiteSpace: 'nowrap' }}>{t('api_quota')}</TableCell>}
<TableCell width="100%">
Expand All @@ -750,7 +772,7 @@ function User({ username = null }: UserProps) {
className={classes.row}
hover={currentUser.is_admin}
style={{ cursor: currentUser.is_admin ? 'pointer' : 'default' }}
onClick={currentUser.is_admin ? event => toggleDrawer('api_daily_quota') : null}
onClick={currentUser.is_admin ? () => toggleDrawer('api_daily_quota') : null}
>
{isXS ? null : <TableCell style={{ whiteSpace: 'nowrap' }}>{t('api_daily_quota')}</TableCell>}
<TableCell width="100%">
Expand Down Expand Up @@ -787,7 +809,7 @@ function User({ username = null }: UserProps) {
className={classes.row}
hover={currentUser.is_admin}
style={{ cursor: currentUser.is_admin ? 'pointer' : 'default' }}
onClick={currentUser.is_admin ? event => toggleDrawer('submission_quota') : null}
onClick={currentUser.is_admin ? () => toggleDrawer('submission_quota') : null}
>
{isXS ? null : <TableCell style={{ whiteSpace: 'nowrap' }}>{t('submission_quota')}</TableCell>}
<TableCell width="100%">
Expand Down Expand Up @@ -815,7 +837,35 @@ function User({ username = null }: UserProps) {
className={classes.row}
hover={currentUser.is_admin}
style={{ cursor: currentUser.is_admin ? 'pointer' : 'default' }}
onClick={currentUser.is_admin ? event => toggleDrawer('submission_daily_quota') : null}
onClick={currentUser.is_admin ? () => toggleDrawer('submission_async_quota') : null}
>
{isXS ? null : <TableCell style={{ whiteSpace: 'nowrap' }}>{t('submission_async_quota')}</TableCell>}
<TableCell width="100%">
{!isXS ? null : <Typography variant="caption">{t('submission_async_quota')}</Typography>}
{user ? (
<div
style={{
color:
user.submission_async_quota === 0 || user.submission_async_quota === '0'
? theme.palette.action.disabled
: 'inherit'
}}
>
{user.submission_async_quota === 0 || user.submission_async_quota === '0'
? t('no_quota')
: user.submission_async_quota}
</div>
) : (
<Skeleton />
)}
</TableCell>
<TableCell align="right">{currentUser.is_admin ? <ChevronRightOutlinedIcon /> : null}</TableCell>
</TableRow>
<TableRow
className={classes.row}
hover={currentUser.is_admin}
style={{ cursor: currentUser.is_admin ? 'pointer' : 'default' }}
onClick={currentUser.is_admin ? () => toggleDrawer('submission_daily_quota') : null}
>
{isXS ? null : <TableCell style={{ whiteSpace: 'nowrap' }}>{t('submission_daily_quota')}</TableCell>}
<TableCell width="100%">
Expand Down
12 changes: 7 additions & 5 deletions src/locales/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"2fa_scan": "Scan the QRCode below with your application",
"2fa_setup_title": "2-Factor Authentication Setup",
"2fa_temp_otp": "Enter a temporary OTP Token",
"api_daily_quota": "Daily API quota",
"api_daily_quota": "Daily API Quota",
"api_daily_quota_edit_title": "Maximum number of API calls the user is allow to issue each day.",
"api_quota": "API quota",
"api_quota": "API Quota",
"api_quota_edit_title": "Maximum number of concurrent API calls that can run inside the API server. It is the equivalent to the number of threads a script running under your account can have connected to the API server at the same time.",
"apikeys": "Manage API Keys",
"apikeys.add": "Add API Key",
Expand Down Expand Up @@ -104,10 +104,12 @@
"roles": "Roles",
"save": "Save changes",
"security": "Security",
"submission_daily_quota": "Daily Submission quota",
"submission_daily_quota": "Daily Submission Quota",
"submission_daily_quota_edit_title": "Maximum number of Submissions the user is allow to issue each day.",
"submission_quota": "Submission quota",
"submission_quota_edit_title": "Maximum number of submissions processing under you account. Only submissions executed via the submit API and the UI count towards the quota, submissions started using ingest API do not.",
"submission_quota": "Submission Quota",
"submission_quota_edit_title": "Maximum number of submissions processing under your account. Only submissions executed via the submit API and the UI count towards the quota, submissions started using ingest API do not.",
"submission_async_quota": "Submission Ingest Quota",
"submission_async_quota_edit_title": "Maximum number of ingested submissions processing or waiting to be processed under your account. Only submissions executed via the ingest API count towards this quota, submissions started using submit API and the UI do not.",
"success_save": "Changes to your account were successfully saved.",
"token": "Manage security tokens",
"token.add": "Add",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/fr/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
"submission_daily_quota_edit_title": "Nombre maximum de soumissions que l'utilisateur est autorisé à émettre par jour.",
"submission_quota": "Quota de soumissions",
"submission_quota_edit_title": "Nombre maximum de soumission en traitement sous votre compte. Seule les soumissions exécutée via l'API de soumission et l'interface utilisateur sont comptées, les soumissions a commencé à l'aide de l'API d'ingestion ne compte pas envers le quota.",
"submission_async_quota": "Quota de soumissions d'ingestion",
"submission_async_quota_edit_title": "Le nombre maximum de soumissions ingérées en cours ou en attente de traitement sous votre compte. Seules les soumissions exécutées via l'API d'ingestion comptent pour ce quota, les soumissions démarrées à l'aide de l'API de soumission et l'interface utilisateur ne compte pas.",
"success_save": "Les changements à votre compte on été enregistrés avec succès.",
"token": "Gérer les jetons de sécurité",
"token.add": "Ajouter",
Expand Down