Skip to content

Commit

Permalink
Merge pull request #591 from ianmcorvidae/periodic-emails
Browse files Browse the repository at this point in the history
Set up preference for periodic email notifications & pass to app submissions
  • Loading branch information
ianmcorvidae authored Sep 26, 2024
2 parents e75a0ae + 35dcc05 commit df9b2b2
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions public/static/locales/en/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"saveBtnLbl": "Save",
"savePrefError": "Unable to save preferences. Please try again.",
"urlImportEmailLbl": "Email me when my URL import status changes",
"periodicEmailLbl": "Email me periodically when analyses are running",
"periodicPeriodLbl": "How frequently to notify about currently running jobs",
"validationMessage": "Please fix all the errors before saving your preferences.",
"waitTimesWarning": "Display Warning about wait times for submitting HPC apps",
"webhooksPrompt": " Add incoming webhook integration. The DE will post notifications to this URL:",
Expand Down
12 changes: 12 additions & 0 deletions src/components/apps/launch/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import AppParamTypes from "components/models/AppParamTypes";
* @param {Object} t i18n translation function
* @param {Object} appDescription
* @param {boolean} appDescription.notify
* @param {boolean} appDescription.notifyPeriodic
* @param {integer} appDescription.periodicPeriod
* @param {string} appDescription.defaultOutputDir
* @param {Object} appDescription.app
* @param {string} appDescription.app.id
Expand All @@ -31,6 +33,8 @@ const initAppLaunchValues = (
t,
{
notify,
notifyPeriodic,
periodicPeriod,
defaultOutputDir,
app: { id, version_id, system_id, name, requirements, groups },
}
Expand Down Expand Up @@ -59,6 +63,8 @@ const initAppLaunchValues = (
launchSteps: [null, null, null, null],
debug: false,
notify,
notifyPeriodic,
periodicPeriod,
output_dir: defaultOutputDir,
name: formatAnalysisName(t, name),
description: "",
Expand Down Expand Up @@ -150,6 +156,8 @@ const initGroupValues = (groups) =>
* @param {string} defaultOutputDir
* @param {Object} formValues
* @param {boolean} formValues.notify
* @param {boolean} formValues.notifyPeriodic
* @param {integer} formValues.periodicPeriod
* @param {boolean} formValues.debug
* @param {string} formValues.name
* @param {string} formValues.description
Expand All @@ -165,6 +173,8 @@ const formatSubmission = (
defaultOutputDir,
{
notify,
notifyPeriodic,
periodicPeriod,
debug,
name,
description,
Expand All @@ -177,6 +187,8 @@ const formatSubmission = (
}
) => ({
notify,
notify_periodic: notifyPeriodic,
periodic_period: periodicPeriod,
debug,
create_output_subdir: output_dir === defaultOutputDir,
name: name.trim(),
Expand Down
4 changes: 4 additions & 0 deletions src/components/apps/launch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const Launch = ({

const preferences = bootstrapInfo?.preferences;
const notify = preferences?.enableAnalysisEmailNotification || false;
const notifyPeriodic = preferences?.enablePeriodicEmailNotification || true;
const periodicPeriod = preferences?.periodicNotificationPeriod || 14400;

const defaultMaxCPUCores = config?.tools?.private.max_cpu_limit;
const defaultMaxMemory = config?.tools?.private.max_memory_limit;
Expand Down Expand Up @@ -140,6 +142,8 @@ const Launch = ({
<AppLaunchWizard
baseId={baseId}
notify={notify}
notifyPeriodic={notifyPeriodic}
periodicPeriod={periodicPeriod}
defaultOutputDir={defaultOutputDir}
defaultMaxCPUCores={defaultMaxCPUCores}
defaultMaxMemory={defaultMaxMemory}
Expand Down
38 changes: 38 additions & 0 deletions src/components/preferences/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import constants from "../../constants";

import buildID from "components/utils/DebugIDUtil";
import FormTextField from "components/forms/FormTextField";
import FormSelectField from "components/forms/FormSelectField";
import FormSwitch from "components/forms/FormSwitch";

import {
Expand All @@ -32,6 +33,7 @@ import {
Divider,
Grid,
InputAdornment,
MenuItem,
Typography,
} from "@mui/material";

Expand Down Expand Up @@ -191,6 +193,42 @@ function General(props) {
label={t("urlImportEmailLbl")}
/>
</Grid>
<Grid item>
<Field
id={buildID(
baseId,
ids.PERIODIC_EMAIL_NOTIFICATION_SWITCH
)}
component={FormSwitch}
name={
prefConstants.keys
.ENABLE_PERIODIC_EMAIL_NOTIFICATION
}
color="primary"
inputProps={{
"aria-label": t("periodicEmailLbl"),
}}
label={t("periodicEmailLbl")}
/>
</Grid>
<Grid item xs={6}>
<Field
id={buildID(baseId, ids.PERIODIC_NOTIFICATION_PERIOD)}
name={prefConstants.keys.PERIODIC_NOTIFICATION_PERIOD}
label={t("periodicPeriodLbl")}
component={FormSelectField}
>
<MenuItem key={1} value={3600}>
1 hour
</MenuItem>
<MenuItem key={2} value={14400}>
4 hours
</MenuItem>
<MenuItem key={3} value={86400}>
24 hours
</MenuItem>
</Field>
</Grid>
</Grid>
<Divider className={classes.dividers} />
<Typography variant="h6" className={classes.sectionHeader}>
Expand Down
2 changes: 2 additions & 0 deletions src/components/preferences/Preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ function Preferences(props) {
analysisKBShortcut: "",
saveSession: false,
enableAnalysisEmailNotification: false,
enablePeriodicEmailNotification: true,
periodicNotificationPeriod: 14400,
enableHPCPrompt: false,
showTourPrompt: false,
webhook: { url: "", type: { type: "" } },
Expand Down
2 changes: 2 additions & 0 deletions src/components/preferences/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default {
ENABLE_IMPORT_EMAIL_NOTIFICATION: "enableImportEmailNotification",
ENABLE_WAIT_TIME_MESSAGE: "enableWaitTimeMessage",
ENABLE_ANALYSIS_EMAIL_NOTIFICATION: "enableAnalysisEmailNotification",
ENABLE_PERIODIC_EMAIL_NOTIFICATION: "enablePeriodicEmailNotification",
PERIODIC_NOTIFICATION_PERIOD: "periodicNotificationPeriod",
ENABLE_HPC_PROMPT: "enableHPCPrompt",
DEFAULT_OUTPUT_FOLDER: "default_output_folder.path",
NOTIFICATION_KB_SC: "notificationKBShortcut",
Expand Down
2 changes: 2 additions & 0 deletions src/components/preferences/ids.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export default {
ANALYSES_EMAIL_NOTIFICATION_SWITCH: "analysesEmailNotificationSwitch",
PERIODIC_EMAIL_NOTIFICATION_SWITCH: "periodicEmailNotificationSwitch",
PERIODIC_NOTIFICATION_PERIOD: "periodicNotificationPeriod",
ANALYSES_KB_SHORTCUT_TEXT: "analysesKbShortcutText",
APPS_KB_SHORTCUT_TEXT: "appKbShortcutText",
BROWSE_BUTTON: "browseButton",
Expand Down
3 changes: 3 additions & 0 deletions src/components/preferences/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export default {
messages: {
analysesViewShortcutLbl: "Open analyses view",
analysisStatusEmailLbl: "Email me when my analysis status changes",
periodicEmailLbl: "Email me periodically when analyses are running",
periodicPeriodLbl:
"How frequently to notify about currently running jobs",
appsViewShortcutLbl: "Open apps view",
browse: "Browse",
cancelBtnLbl: "Cancel",
Expand Down
2 changes: 2 additions & 0 deletions stories/AppBar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const bootStrap = {
analysisKBShortcut: "Y",
saveSession: true,
enableAnalysisEmailNotification: true,
enablePeriodicEmailNotification: true,
periodicNotificationPeriod: 14400,
enableHPCPrompt: true,
},
};
Expand Down
2 changes: 2 additions & 0 deletions stories/preferences/MockBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export default {
analysisKBShortcut: "Y",
saveSession: true,
enableAnalysisEmailNotification: true,
enablePeriodicEmailNotification: true,
periodicNotificationPeriod: 14400,
enableHPCPrompt: true,
},
};
Expand Down

0 comments on commit df9b2b2

Please sign in to comment.