diff --git a/framework_tvb/tvb/core/services/burst_service.py b/framework_tvb/tvb/core/services/burst_service.py index 154200683cd7a175921adabc5e4388f9ce7a3347..241ac431d6ba9fa75ea4242ce54f7e7d78105647 100644 --- a/framework_tvb/tvb/core/services/burst_service.py +++ b/framework_tvb/tvb/core/services/burst_service.py @@ -217,7 +217,7 @@ class BurstService(object): burst_config.fk_operation_group = operation_group.id burst_config.metric_operation_group = metric_operation_group burst_config.fk_metric_operation_group = metric_operation_group.id - dao.store_entity(burst_config) + return dao.store_entity(burst_config) def store_burst_configuration(self, burst_config, storage_path): bc_path = h5.path_for(storage_path, BurstConfigurationH5, burst_config.gid) diff --git a/framework_tvb/tvb/interfaces/web/controllers/simulator_controller.py b/framework_tvb/tvb/interfaces/web/controllers/simulator_controller.py index ed4a099b578d4439c7a5654ff40ee4bdfdac4987..2c8ca55f62ab75a77ea480122647786fe3e6287c 100644 --- a/framework_tvb/tvb/interfaces/web/controllers/simulator_controller.py +++ b/framework_tvb/tvb/interfaces/web/controllers/simulator_controller.py @@ -27,7 +27,7 @@ # Frontiers in Neuroinformatics (7:10. doi: 10.3389/fninf.2013.00010) # # -import os + import threading from cherrypy.lib.static import serve_file from tvb.adapters.datatypes.db.simulation_history import SimulationHistoryIndex @@ -110,8 +110,8 @@ class SimulatorFragmentRenderingRules(object): def __init__(self, form=None, form_action_url=None, previous_form_action_url=None, is_simulation_copy=False, is_simulation_readonly_load=False, last_form_url=SimulatorWizzardURLs.SET_CONNECTIVITY_URL, last_request_type='GET', is_first_fragment=False, is_launch_fragment=False, is_model_fragment=False, - is_surface_simulation=False, is_noise_fragment=False, is_launch_pse_fragment=False, is_pse_launch=False, - monitor_name=None): + is_surface_simulation=False, is_noise_fragment=False, is_launch_pse_fragment=False, + is_pse_launch=False, monitor_name=None): """ :param is_first_fragment: True only for the first form in the wizzard, to hide Previous button :param is_launch_fragment: True only for the last form in the wizzard to diplay Launch/SetupPSE/Branch, hide Next @@ -165,8 +165,7 @@ class SimulatorFragmentRenderingRules(object): @property def hide_previous_button(self): - if self.load_readonly and not (self.is_simulation_copy and self.is_launch_fragment and - self.last_form_url == SimulatorWizzardURLs.SETUP_PSE_URL): + if self.load_readonly: return True return False @@ -190,13 +189,13 @@ class SimulatorFragmentRenderingRules(object): @property def include_launch_button(self): - if self.is_launch_fragment and (not self.load_readonly or self.is_simulation_copy): + if self.is_launch_fragment and (not self.load_readonly): return True return False @property def hide_launch_and_setup_pse_button(self): - if self.last_form_url != SimulatorWizzardURLs.SETUP_PSE_URL: + if self.last_form_url != SimulatorWizzardURLs.SETUP_PSE_URL and (not self.load_readonly): return True return False @@ -208,13 +207,13 @@ class SimulatorFragmentRenderingRules(object): @property def include_setup_pse(self): - if self.is_launch_fragment and (not self.load_readonly or self.is_simulation_copy): + if self.is_launch_fragment and (not self.load_readonly): return True return False @property def include_launch_pse_button(self): - if self.is_launch_pse_fragment and (not self.load_readonly or self.is_simulation_copy): + if self.is_launch_pse_fragment and (not self.load_readonly): return True return False @@ -260,7 +259,12 @@ class SimulatorController(BurstBaseController): burst_config = BurstConfiguration(project.id) common.add2session(common.KEY_BURST_CONFIG, burst_config) - is_simulator_load = common.get_from_session(common.KEY_IS_SIMULATOR_LOAD) or False + if burst_config.start_time is not None: + is_simulator_load = True + common.add2session(common.KEY_IS_SIMULATOR_LOAD, True) + else: + is_simulator_load = common.get_from_session(common.KEY_IS_SIMULATOR_LOAD) or False + is_simulator_copy = common.get_from_session(common.KEY_IS_SIMULATOR_COPY) or False template_specification['burstConfig'] = burst_config @@ -988,6 +992,7 @@ class SimulatorController(BurstBaseController): is_launch_pse_fragment=True) return rendering_rules.to_dict() + @expose_json @cherrypy.expose @handle_error(redirect=False) @check_user @@ -995,20 +1000,16 @@ class SimulatorController(BurstBaseController): all_range_parameters = self.range_parameters.get_all_range_parameters() range_param1, range_param2 = SimulatorPSERangeFragment.fill_from_post(all_range_parameters, **data) session_stored_simulator = common.get_from_session(common.KEY_SIMULATOR_CONFIG) - is_simulator_copy = common.get_from_session(common.KEY_IS_SIMULATOR_COPY) project = common.get_current_project() user = common.get_logged_user() burst_config = common.get_from_session(common.KEY_BURST_CONFIG) - if is_simulator_copy: - burst_config = burst_config.clone() burst_config.start_time = datetime.now() - burst_config.range1 = range_param1.to_json() if range_param2: burst_config.range2 = range_param2.to_json() - self.burst_service.prepare_burst_for_pse(burst_config) + burst_config = self.burst_service.prepare_burst_for_pse(burst_config) try: thread = threading.Thread(target=self.simulator_service.async_launch_and_prepare_pse, @@ -1020,6 +1021,7 @@ class SimulatorController(BurstBaseController): 'range_param2': range_param2, 'session_stored_simulator': session_stored_simulator}) thread.start() + return {'id': burst_config.id} except BurstServiceException as e: self.logger.exception("Could not launch burst!") return {'error': e.message} diff --git a/framework_tvb/tvb/interfaces/web/static/js/bursts.js b/framework_tvb/tvb/interfaces/web/static/js/bursts.js index a1bfa0e42d92ef20a4bd9ef05d302fb21eaa97b5..c268ff85dcb7831579e8845f4d5122367c6dcc9e 100644 --- a/framework_tvb/tvb/interfaces/web/static/js/bursts.js +++ b/framework_tvb/tvb/interfaces/web/static/js/bursts.js @@ -515,9 +515,18 @@ function fill_burst_name(burstName, isReadOnly) { user_edited_title = false; } +function hideButtonsAfterLaunch(form_elements){ + for(var i = 0; i < form_elements.length; i++){ + if(form_elements[i].type === "button"){ + form_elements[i].style.visibility = "hidden"; + } + } +} + function launchNewPSEBurst(currentForm) { _displayPseSimulationMessage(); var form_data = $(currentForm).serialize(); + hideButtonsAfterLaunch(currentForm.elements); doAjaxCall({ type: "POST", @@ -546,6 +555,7 @@ function launchNewPSEBurst(currentForm) { */ function launchNewBurst(currentForm, launchMode) { var form_data = $(currentForm).serialize(); //Encode form elements for submission + hideButtonsAfterLaunch(currentForm.elements); displayMessage("You've submitted parameters for simulation launch! Please wait for preprocessing steps...", 'warningMessage'); doAjaxCall({