diff --git a/packages/slycat/web/server/__init__.py b/packages/slycat/web/server/__init__.py index 27901c28c..8b4b0fd30 100644 --- a/packages/slycat/web/server/__init__.py +++ b/packages/slycat/web/server/__init__.py @@ -135,8 +135,11 @@ def parse_existing_file(database, parser, input, attachment, model, aid): :return: not used """ kwargs = {} - aids = [] - aids.append(aid) + if not isinstance(aid, list): + aids = [] + aids.append(aid) + else: + aids = aid try: slycat.web.server.plugin.manager.parsers[parser]["parse"](database, model, input, attachment, aids, **kwargs) diff --git a/packages/slycat/web/server/handlers.py b/packages/slycat/web/server/handlers.py index ca37d0fcb..054c1a038 100644 --- a/packages/slycat/web/server/handlers.py +++ b/packages/slycat/web/server/handlers.py @@ -443,6 +443,8 @@ def put_project_csv_data(pid, file_key, parser, mid, aids): cherrypy.log.error(str(e)) model = database.get("model", mid) + if isinstance(aids, str): + aids = aids.split(',') slycat.web.server.parse_existing_file(database, parser, True, attachment, model, aids) return {"Status": "Success"} diff --git a/packages/slycat/web/server/upload.py b/packages/slycat/web/server/upload.py index 02345b3e2..30b3bf30e 100644 --- a/packages/slycat/web/server/upload.py +++ b/packages/slycat/web/server/upload.py @@ -249,13 +249,13 @@ def numeric_order(x): if '.h5' in self._aids[1] or '.hdf5' in self._aids[1]: slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input, files, self._aids, **self._kwargs) - if isinstance(self._aids[0], list): - slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input, - files, self._aids[0], **self._kwargs) + elif isinstance(self._aids[0], list): + slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input, + files, self._aids[0], **self._kwargs) else: slycat.web.server.plugin.manager.parsers[self._parser]["parse"](database, model, self._input, - files, self._aids, **self._kwargs) - if model["model-type"] == "parameter-image" and self.useProjectData == True: + files, self._aids, **self._kwargs) + if model["model-type"] == "parameter-image" and self.useProjectData == True and '.h5' not in self._aids[1] and '.hdf5' not in self._aids[1]: # Use project data slycat.web.server.handlers.create_project_data(self._mid, self._aids, files) except Exception as e: diff --git a/web-server/plugins/slycat-hdf5-parser.py b/web-server/plugins/slycat-hdf5-parser.py index 2c850e602..f0b5f4d7b 100644 --- a/web-server/plugins/slycat-hdf5-parser.py +++ b/web-server/plugins/slycat-hdf5-parser.py @@ -78,7 +78,6 @@ def parse_file(file, model, database): def parse(database, model, input, files, aids, **kwargs): # Read HDF5 file - slycat.web.server.handlers.create_project_data(model['_id'], aids, files) start = time.time() # parsed = [parse_file(file, model, database) for file in files] @@ -89,10 +88,17 @@ def parse(database, model, input, files, aids, **kwargs): # slycat.web.server.put_model_arrayset_data(database, model, aid, "%s/.../..." % array_index, combined_data) end = time.time() - model = database.get("model", model['_id']) - slycat.web.server.put_model_parameter(database, model, "error-messages", "") - model["db_creation_time"] = (end - start) - database.save(model) + database = slycat.web.server.database.couchdb.connect() + model = database.get("model", model["_id"]) + with slycat.web.server.database.couchdb.db_lock: + model["db_creation_time"] = (end - start) + database.save(model) + # If the user selected to not save project data, this will only be temporary during the wizard to parse the HDF5 file + slycat.web.server.handlers.create_project_data(model['_id'], aids, files) + slycat.web.server.put_model_parameter(database, model, "error-messages", "") + # model["db_creation_time"] = (end - start) + # model = database.get("model", model['_id']) + # database_curr.save(model) def register_slycat_plugin(context): context.register_parser("slycat-hdf5-parser", "HDF5", ["table"], parse) \ No newline at end of file diff --git a/web-server/plugins/slycat-parameter-image/js/wizard-ui.js b/web-server/plugins/slycat-parameter-image/js/wizard-ui.js index bbff5db3e..aed5976c7 100644 --- a/web-server/plugins/slycat-parameter-image/js/wizard-ui.js +++ b/web-server/plugins/slycat-parameter-image/js/wizard-ui.js @@ -97,7 +97,7 @@ function constructor(params) { file_key: component.selected_file(), parser: component.parser(), mid: component.model._id(), - aids: "data-table", + aids: [["data-table"], component.current_aids()], success: function (response) { var data = JSON.stringify(response); @@ -225,8 +225,7 @@ function constructor(params) { component.cancel = function () { component.smb_wizard_login_root.unmount(); if (component.model._id()) { - client - .get_project_data_in_model_fetch({ + client.get_project_data_in_model_fetch({ mid: component.model._id(), }) .then((did) => { @@ -352,8 +351,8 @@ function constructor(params) { }; component.existing_table = function () { - var fileName = component.selected_file; - component.current_aids = fileName(); + var fileName = component.selected_file(); + component.current_aids(fileName); component.get_server_files(); }; @@ -561,6 +560,26 @@ function constructor(params) { mid: component.model._id(), success : (results) => { + if (component.model._id() && component.useProjectData() == false) { + client.get_project_data_in_model_fetch({ + mid: component.model._id(), + }) + .then((did) => { + // if the data id isn't empty + // delete model first + client.delete_model_fetch({ mid: component.model._id() }).then(() => { + // Get list of model ids project data is used in + if (did.length >= 1) { + client.get_project_data_parameter_fetch({ did: did, param: "mid" }).then((models) => { + // if there are no more models using that project data, delete it + if (models && models.length === 0) { + client.delete_project_data_fetch({ did: did }); + } + }); + } + }); + }); + } component.finish(); } }) diff --git a/web-server/plugins/slycat-parameter-image/wizard-ui.html b/web-server/plugins/slycat-parameter-image/wizard-ui.html index fd9ec1283..8a6da8ef0 100644 --- a/web-server/plugins/slycat-parameter-image/wizard-ui.html +++ b/web-server/plugins/slycat-parameter-image/wizard-ui.html @@ -10,10 +10,10 @@ @@ -127,7 +127,7 @@
-
HDF5 Inputs
+
HDF5 Inputs