From eb85dbb6f468448acda61306623e9512c33381b0 Mon Sep 17 00:00:00 2001
From: Skander Hatira <skander.hatira@inrae.fr>
Date: Thu, 31 Mar 2022 13:38:33 +0200
Subject: [PATCH] added notifications button for slurm mails

---
 resources/biseps                                 |  2 +-
 src/backend/helpers/createProfile.js             |  8 +++++---
 src/backend/helpers/createProfileComparison.js   |  8 +++++---
 src/components/ComparisonStepper/GlobalConfig.js | 14 ++++++++++++++
 src/components/Login/Login.js                    |  8 +++++---
 src/components/Stepper/GlobalConfig.js           | 14 ++++++++++++++
 src/components/Table/Table.js                    |  1 +
 src/hooks/useConfig.js                           |  2 ++
 8 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/resources/biseps b/resources/biseps
index 418fbdd..876f966 160000
--- a/resources/biseps
+++ b/resources/biseps
@@ -1 +1 @@
-Subproject commit 418fbdd0d56a33f9c48f1dcf5aa16e4f38f65009
+Subproject commit 876f966022371d2c9c0a6236bd109f851f48475f
diff --git a/src/backend/helpers/createProfile.js b/src/backend/helpers/createProfile.js
index f44f512..c7ea6e4 100644
--- a/src/backend/helpers/createProfile.js
+++ b/src/backend/helpers/createProfile.js
@@ -27,9 +27,11 @@ function createProfile(body, uniqueDir, uniqueDirRemote) {
     };
     const slurmProfile = {
         jobs: parseInt(body.jobs),
-        cluster:
-            "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards} --mail-type=FAIL,END --mail-user=" +
-            body.email,
+        cluster: body.notification
+            ? "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards}" +
+              "--mail-type=FAIL,END --mail-user=" +
+              body.email
+            : "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards}",
         "default-resources": ["cpus=1", "mem_mb=10000", "time_min=5440"],
         configfile: body.remote
             ? "config/config.yaml"
diff --git a/src/backend/helpers/createProfileComparison.js b/src/backend/helpers/createProfileComparison.js
index 01b4584..5265577 100644
--- a/src/backend/helpers/createProfileComparison.js
+++ b/src/backend/helpers/createProfileComparison.js
@@ -29,9 +29,11 @@ function createProfile(body, uniqueDir, uniqueDirRemote) {
     };
     const slurmProfile = {
         jobs: parseInt(body.jobs),
-        cluster:
-            "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards} --mail-type=FAIL,END --mail-user=" +
-            body.email,
+        cluster: body.notification
+            ? "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards}" +
+              "--mail-type=FAIL,END --mail-user=" +
+              body.email
+            : "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o logs_slurm/{rule}_{wildcards} -e logs_slurm/{rule}_{wildcards}",
         "default-resources": ["cpus=1", "mem_mb=10000", "time_min=5440"],
         configfile: body.remote
             ? "config/configComparison.yaml"
diff --git a/src/components/ComparisonStepper/GlobalConfig.js b/src/components/ComparisonStepper/GlobalConfig.js
index af9f7d5..304c4cb 100644
--- a/src/components/ComparisonStepper/GlobalConfig.js
+++ b/src/components/ComparisonStepper/GlobalConfig.js
@@ -609,6 +609,20 @@ export default function GlobalConfig() {
                 label="SLURM Cluster"
               ></FormControlLabel>
             </Grid>
+            <Grid item xs={12} sm={4}>
+              <FormControlLabel
+                className={classes.formControl}
+                control={
+                  <Checkbox
+                    onChange={handleCheckBox}
+                    color="secondary"
+                    name="notification"
+                    checked={compState.notification}
+                  />
+                }
+                label="Send Email Notification"
+              ></FormControlLabel>
+            </Grid>
           </Grid>
         ) : (
           <Grid item xs={12} sm={4}>
diff --git a/src/components/Login/Login.js b/src/components/Login/Login.js
index 9ac0d51..b1b7815 100644
--- a/src/components/Login/Login.js
+++ b/src/components/Login/Login.js
@@ -83,7 +83,7 @@ const Login = () => {
     signup(userData, dispatch, history);
   };
   const { errors } = state;
-
+  console.log(errors);
   return (
     <Container component="main" maxWidth="md">
       <CssBaseline />
@@ -99,7 +99,7 @@ const Login = () => {
             onChange={onChange}
             value={state.name}
             error={errors.name === ""}
-            helperText={errors.name === "" ? "Empty!" : errors.name}
+            helperText={errors.name === "" ? "Empty!" : errors.namenotfound}
             className={classnames("", {
               invalid: errors.name || errors.namenotfound,
             })}
@@ -118,7 +118,9 @@ const Login = () => {
             onChange={onChange}
             value={state.password}
             error={errors.password === ""}
-            helperText={errors.password === "" ? "Empty!" : errors.password}
+            helperText={
+              errors.password === "" ? "Empty!" : errors.passwordincorrect
+            }
             className={classnames("", {
               invalid: errors.password || errors.passwordincorrect,
             })}
diff --git a/src/components/Stepper/GlobalConfig.js b/src/components/Stepper/GlobalConfig.js
index bb70b33..295117d 100644
--- a/src/components/Stepper/GlobalConfig.js
+++ b/src/components/Stepper/GlobalConfig.js
@@ -441,6 +441,20 @@ export default function GlobalConfig() {
                 label="SLURM Cluster"
               ></FormControlLabel>
             </Grid>
+            <Grid item xs={12} sm={4}>
+              <FormControlLabel
+                className={classes.formControl}
+                control={
+                  <Checkbox
+                    onChange={handleCheckBox}
+                    color="secondary"
+                    name="notification"
+                    checked={runState.notification}
+                  />
+                }
+                label="Send Email Notification"
+              ></FormControlLabel>
+            </Grid>
           </Grid>
         ) : (
           <Grid item xs={12} sm={4}>
diff --git a/src/components/Table/Table.js b/src/components/Table/Table.js
index 346a06a..8d762a4 100644
--- a/src/components/Table/Table.js
+++ b/src/components/Table/Table.js
@@ -172,6 +172,7 @@ export default function InteractiveList() {
         sftp.end();
       })
       .catch((err) => {
+        setLoading((prevState) => ({ ...prevState, [idx]: false }));
         console.error(err.message);
         sftp.end();
       });
diff --git a/src/hooks/useConfig.js b/src/hooks/useConfig.js
index aa10df8..fdfc0d7 100644
--- a/src/hooks/useConfig.js
+++ b/src/hooks/useConfig.js
@@ -35,6 +35,7 @@ const useProvideConfig = () => {
     l: 20,
     n: 0,
     subsample: false,
+    notification: true,
     cluster: false,
     remote: false,
     cpu: "1",
@@ -63,6 +64,7 @@ const useProvideConfig = () => {
     contexts: ["CpG"],
     genome: "",
     species: "",
+    notification: true,
     annot: "",
     remoteDir: "",
     outdir: "",
-- 
GitLab