Skip to content

Commit

Permalink
Merge pull request #107 from DigitalSlideArchive/empty-import-message
Browse files Browse the repository at this point in the history
Improve message when there is nothing to import or export.
  • Loading branch information
manthey authored Sep 10, 2020
2 parents 4060ca6 + 38decfd commit 654324b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nci_seer/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
10 changes: 10 additions & 0 deletions nci_seer/web_client/views/HierarchyWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -29,6 +30,7 @@ function performAction(action) {
].forEach(([key, desc]) => {
if (resp[key]) {
text += ` ${resp[key]} image${resp[key] > 1 ? 's' : ''} ${desc}.`;
any = true;
}
});
[
Expand All @@ -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') {
[
Expand All @@ -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',
Expand Down

0 comments on commit 654324b

Please sign in to comment.