diff --git a/src/pages/dashboard.py b/src/pages/dashboard.py index 77e7d53d67252119e40c595fab13b1e1a06ce473..18c87a8c37b50d3431c917d031fa6758456e712e 100644 --- a/src/pages/dashboard.py +++ b/src/pages/dashboard.py @@ -14,7 +14,13 @@ from eurad_plot import get_euradim_plot, get_timeseries_plot import os import zipfile from cryptography.fernet import Fernet -from deployment_settings import key +import pyunicore.client as uc_client +import pyunicore.credentials as uc_credentials +from deployment_settings import ( + KEY, + UNICORE_BASE, UFTP_BASE, + UNICORE_USER, UNICORE_PASSWORD + ) # the following should be done with static files! APP_HOME = Path.cwd() @@ -612,7 +618,7 @@ def create_jobs_tab(language_id=0): ), dbc.ModalFooter([ dbc.Button( - f"{run_label[language_id]}", id=f"{modal['id']}run", class_name="fzj_style_btn", n_clicks=0 + f"{run_label[language_id]}", id=f"{modal['id']}_run", class_name="fzj_style_btn", n_clicks=0 ), dbc.Button( f"{close_label[language_id]}", id=f"{modal['id']}_close", class_name="fzj_style_btn", n_clicks=0 @@ -805,7 +811,7 @@ def login_open(lb_click, lc_click, name, password): if not user: return no_update, no_update, no_update, no_update, dbc.Alert(["No such user!"], color="danger") else: - fernet = Fernet(key) + fernet = Fernet(KEY) db_password = fernet.decrypt(user[1]).decode() if db_password == password: language_id=user[2] @@ -855,9 +861,10 @@ def get_user_id(user_dict): @callback( - Output("eurad_im_modal", "is_open"), + Output("eurad_im_modal", "is_open", allow_duplicate=True), Input("eurad_im_open", "n_clicks"), Input("eurad_im_close", "n_clicks"), + prevent_initial_call=True ) def eurad_im_modal(open_button, close_button): if ctx.triggered_id == "eurad_im_open": @@ -866,6 +873,23 @@ def eurad_im_modal(open_button, close_button): return False +@callback( + Output("eurad_im_modal", "is_open", allow_duplicate=True), + Input("eurad_im_run", "n_clicks"), + prevent_initial_call=True +) +def eurad_im_job_run(run_button): + base_url = f"{UNICORE_BASE}JURECA/rest/core" + credentials = uc_credentials.UsernamePassword(UNICORE_USER, UNICORE_PASSWORD) + client = uc_client.Client(credentials, base_url) + job_description = {'Executable': "/p/project/cjicg21/schroeder5/Destine_AQ/start_destine_demonstrator.sh", "Job type": "ON_LOGIN_NODE", 'Arguments':[], } + job = client.new_job(job_description) + if ctx.triggered_id == "eurad_im_open": + return True + else: + return False + + @callback( Output("eurad_im_download_result", "data"), Input("eurad_im_output_download", "n_clicks"),