From 38decfdb2787cab50be06279b2f42c59a812e130 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 10 Sep 2020 13:48:32 -0400 Subject: [PATCH] Improve message when there is nothing to import or export. --- nci_seer/import_export.py | 4 ++-- nci_seer/web_client/views/HierarchyWidget.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nci_seer/import_export.py b/nci_seer/import_export.py index aeafcc5a..b0cf77be 100644 --- a/nci_seer/import_export.py +++ b/nci_seer/import_export.py @@ -188,9 +188,9 @@ def ingestData(ctx, user=None): # noqa elif ext.lower() not in {'.zip', '.txt', '.xml'}: imageFiles.append(filePath) if not len(excelFiles): - raise Exception('Failed to find any excel files in import directory.') + ctx.update(message='Failed to find any excel files in import directory.') if not len(imageFiles): - raise Exception('Failed to find any image files in import directory.') + ctx.update(message='Failed to find any image files in import directory.') manifest, excelReport = readExcelFiles(excelFiles, ctx) missingImages = [] report = [] diff --git a/nci_seer/web_client/views/HierarchyWidget.js b/nci_seer/web_client/views/HierarchyWidget.js index 7849545f..137d5d28 100644 --- a/nci_seer/web_client/views/HierarchyWidget.js +++ b/nci_seer/web_client/views/HierarchyWidget.js @@ -18,6 +18,7 @@ function performAction(action) { error: null }).done((resp) => { let text = actions[action].done; + let any = false; if (resp.action === 'ingest') { [ ['added', 'added'], @@ -29,6 +30,7 @@ function performAction(action) { ].forEach(([key, desc]) => { if (resp[key]) { text += ` ${resp[key]} image${resp[key] > 1 ? 's' : ''} ${desc}.`; + any = true; } }); [ @@ -37,8 +39,12 @@ function performAction(action) { ].forEach(([key, desc]) => { if (resp[key]) { text += ` ${resp[key]} Excel file${resp[key] > 1 ? 's' : ''} ${desc}.`; + any = true; } }); + if (!any) { + text += ' Nothing to import.'; + } } if (resp.action === 'export' || resp.action === 'exportall') { [ @@ -48,8 +54,12 @@ function performAction(action) { ].forEach(([key, desc]) => { if (resp[key]) { text += ` ${resp[key]} image${resp[key] > 1 ? 's' : ''} ${desc}.`; + any = true; } }); + if (!any) { + text += ' Nothing to export.'; + } } events.trigger('g:alert', { icon: 'ok',