Skip to content

Commit

Permalink
Merge branch 'ui-v2' of github.com:IGS/gEAR into ui-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Aug 30, 2024
2 parents 2f6642a + f876671 commit 9c55231
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/geardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ def get_analysis(analysis, dataset_id, session_id):

# Check that the h5ad file exists
if not os.path.exists(ana.dataset_path()):
raise FileNotFoundError("No h5 file found for the passed in analysis")
raise FileNotFoundError("No h5 file found for the passed in analysis {}".format(ana.dataset_path()))

else:
ds = Dataset(id=dataset_id, has_h5ad=1)
h5_path = ds.get_file_path()

# Let's not fail if the file isn't there
if not os.path.exists(h5_path):
raise FileNotFoundError("No h5 file found for this dataset")
raise FileNotFoundError("No h5 file found for this dataset {}".format(h5_path))
ana = Analysis(type='primary', dataset_id=dataset_id)
return ana

Expand Down
15 changes: 12 additions & 3 deletions www/cgi/save_dataset_display.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def main():
cursor = cnx.get_cursor()

user = geardb.get_user_from_session_id(session_id=session_id)

if not user:
print('User not found for session_id {}'.format(session_id), file=sys.stderr)
sys.stdout = original_stdout
print('Content-Type: application/json\n\n')
print(json.dumps(dict(display_id=None, success=False)))
return

user_id = user.id

if display_id:
Expand All @@ -113,10 +121,10 @@ def main():
WHERE id = %s;
"""
cursor.execute(query, (label, plot_type, plotly_config, display_id))
result = dict(success=True)
result = dict(display_id=display_id, success=True)
else:
print('UPDATE DIDNT HAPPEN?', file=sys.stderr)
result = dict(success=False)
result = dict(display_id=display_id, success=False)
else:
# Display doesn't exist yet, insert new

Expand Down Expand Up @@ -155,7 +163,8 @@ def main():
print("Invalid filename: {}".format(filename), file=sys.stderr)
sys.stdout = original_stdout
print('Content-Type: application/json\n\n')
print(json.dumps(dict(success=False)))
result["success"] = False
print(json.dumps(result))
return

# Add plot_type to config so it can be passed in the POST cmd as well
Expand Down
8 changes: 8 additions & 0 deletions www/dataset_curator.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ <h5 class="title is-5 is-clickable js-collapsable-trigger">
<input id="new-display-label" class="input" type="text" placeholder="Enter name of display" />
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" id="overwrite-display-check" disabled>
Overwrite existing display instead
</label>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
Expand Down
23 changes: 20 additions & 3 deletions www/js/curator_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let catColumns = [];
let levels = {}; // categorical columns as keys + groups as values

let datasetId = null;
let chosenDisplayId = null;
let organismId = null;
let analysisObj = null;

Expand Down Expand Up @@ -344,8 +345,8 @@ const curatorApiCallsMixin = {
throw new Error("Could not save this new display. Please contact the gEAR team.");
}

// Make new display card and make it the default display
renderUserDisplayCard({id: display_id, label, plot_type: plotType, plotly_config: plotConfig}, display_id);
// Ensure the display is not a default display (the user must choose to make it default)
renderUserDisplayCard({id: display_id, label, plot_type: plotType, plotly_config: plotConfig}, -1);

return display_id;
} catch (error) {
Expand Down Expand Up @@ -535,6 +536,12 @@ const chooseNewDisplay = async () => {
document.getElementById("plot-type-select-c-failed").classList.remove("is-hidden");
document.getElementById("plot-options-s-success").classList.add("is-hidden");

// Ensure display saves as a new display
chosenDisplayId = null;
document.getElementById("overwrite-display-check").checked = false;
document.getElementById("overwrite-display-check").disabled = true;
disableCheckboxLabel(document.getElementById("overwrite-display-check"), true);

// update genes, analysis, and plot type selects in parallel
await Promise.all([
updateDatasetGenes(),
Expand Down Expand Up @@ -602,6 +609,11 @@ const cloneDisplay = async (event, display) => {
const cloneElt = event.currentTarget;
cloneElt.classList.add("is-loading");

// Give user option to overwrite display
chosenDisplayId = display.id;
document.getElementById("overwrite-display-check").disabled = false;
disableCheckboxLabel(document.getElementById("overwrite-display-check"), false);

await updateDatasetGenes(),

document.getElementById("analysis-select").disabled = false;
Expand Down Expand Up @@ -1585,7 +1597,12 @@ document.getElementById("save-display-btn").addEventListener("click", async (eve
const label = document.getElementById("new-display-label").value;
event.target.classList.add("is-loading");
try {
const displayId = await curatorApiCallsMixin.saveDatasetDisplay(datasetId, null, label, plotStyle.plotType, plotStyle.plotConfig);
let displayIdToUse = null;
if (document.getElementById("overwrite-display-check").checked) {
displayIdToUse = chosenDisplayId;
}

const displayId = await curatorApiCallsMixin.saveDatasetDisplay(datasetId, displayIdToUse, label, plotStyle.plotType, plotStyle.plotConfig);
createToast("Display saved.", "is-success");

if (document.getElementById("make-default-display-check").checked) {
Expand Down
8 changes: 8 additions & 0 deletions www/multigene_curator.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,14 @@ <h5 class="title is-5 is-clickable js-collapsable-trigger">
<input id="new-display-label" class="input" type="text" placeholder="Enter name of display" />
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" id="overwrite-display-check" disabled>
Overwrite existing display instead
</label>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
Expand Down

0 comments on commit 9c55231

Please sign in to comment.