From 849f5aef512caf03a0c3edbc01465f498ca4807e Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Thu, 29 Feb 2024 17:10:12 -0500 Subject: [PATCH] added import results dialog, renamed files Signed-off-by: Elizabeth Danzberger --- ...file-actions-script.js => file-actions.js} | 4 +- ...ortIntoTables.vue => FileActionImport.vue} | 16 ++-- src/modules/modals/ImportResults.vue | 92 +++++++++++++++++++ webpack.js | 2 +- 4 files changed, 105 insertions(+), 9 deletions(-) rename src/{file-actions-script.js => file-actions.js} (89%) rename src/modules/modals/{ImportIntoTables.vue => FileActionImport.vue} (91%) create mode 100644 src/modules/modals/ImportResults.vue diff --git a/src/file-actions-script.js b/src/file-actions.js similarity index 89% rename from src/file-actions-script.js rename to src/file-actions.js index 79cc3ce0e..60fac20b6 100644 --- a/src/file-actions-script.js +++ b/src/file-actions.js @@ -1,6 +1,6 @@ import { FileAction, registerFileAction } from '@nextcloud/files' import { showError, spawnDialog } from '@nextcloud/dialogs' -import ImportIntoTables from './modules/modals/ImportIntoTables.vue' +import FileActionImport from './modules/modals/FileActionImport.vue' const icon = ` @@ -21,7 +21,7 @@ const fileAction = new FileAction({ return null } - spawnDialog(ImportIntoTables, { t, file }) + spawnDialog(FileActionImport, { t, file, }) return null }, diff --git a/src/modules/modals/ImportIntoTables.vue b/src/modules/modals/FileActionImport.vue similarity index 91% rename from src/modules/modals/ImportIntoTables.vue rename to src/modules/modals/FileActionImport.vue index 77c380800..473f53fa0 100644 --- a/src/modules/modals/ImportIntoTables.vue +++ b/src/modules/modals/FileActionImport.vue @@ -86,12 +86,13 @@ import { NcModal, NcButton, NcSelect, NcCheckboxRadioSwitch, NcEmojiPicker, NcLoadingIcon } from '@nextcloud/vue' import { generateUrl } from '@nextcloud/router' import { Node } from '@nextcloud/files' -import { showError, showSuccess } from '@nextcloud/dialogs' +import { showError, showSuccess, spawnDialog } from '@nextcloud/dialogs' import axios from '@nextcloud/axios' import RowFormWrapper from '../../shared/components/ncTable/partials/rowTypePartials/RowFormWrapper.vue' +import ImportResults from './ImportResults.vue' export default { - name: 'ImportIntoTables', + name: 'FileActionImport', components: { NcModal, @@ -125,6 +126,7 @@ export default { emoji: '🔧', title: this.file.basename, }, + importResults: null, existingTables: [], selectedTable: null, } @@ -170,9 +172,9 @@ export default { this.importingFile = true if (this.importAsNew) { - const tableCreated = await importToNewTable(this.newTable.title, this.newTable.emoji, this.file, this.createMissingColumns) + this.importResults = await importToNewTable(this.newTable.title, this.newTable.emoji, this.file) - if (!tableCreated) { + if (!this.importResults) { showError(t('tables', 'Could not create table')) } else { showSuccess(t('tables', 'Created table "{emoji} {table}"', { emoji: this.newTable.emoji, table: this.newTable.title })) @@ -183,9 +185,9 @@ export default { return } - const imported = await importToExistingTable(this.selectedTable.value, this.file.path, this.createMissingColumns) + this.importResults = await importToExistingTable(this.selectedTable.value, this.file, this.createMissingColumns) - if (!imported) { + if (!this.importResults) { showError(t('tables', 'Could not import data to table')) } else { showSuccess(t('tables', 'Imported to table "{table}"', { table: this.selectedTable.label })) @@ -194,6 +196,8 @@ export default { this.importingFile = false this.modal = false + + spawnDialog(ImportResults, { t, results: this.importResults, }) }, }, } diff --git a/src/modules/modals/ImportResults.vue b/src/modules/modals/ImportResults.vue new file mode 100644 index 000000000..2753c726d --- /dev/null +++ b/src/modules/modals/ImportResults.vue @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ t('tables', 'Found columns') }}{{ results.found_columns_count }}
{{ t('tables', 'Matching columns') }}{{ results.matching_columns_count }}
{{ t('tables', 'Created columns') }}{{ results.created_columns_count }}
{{ t('tables', 'Inserted rows') }}{{ results.inserted_rows_count }}
{{ t('tables', 'Value parsing errors') }}{{ results.errors_parsing_count }}
{{ t('tables', 'Row creation errors') }}{{ results.errors_count }}
+ + + + + + diff --git a/webpack.js b/webpack.js index d4cd5444e..847147498 100644 --- a/webpack.js +++ b/webpack.js @@ -3,7 +3,7 @@ const webpackConfig = require('@nextcloud/webpack-vue-config') webpackConfig.entry = { main: path.join(__dirname, 'src', 'main.js'), - files: path.join(__dirname, 'src', 'file-actions-script.js'), + files: path.join(__dirname, 'src', 'file-actions.js'), reference: path.join(__dirname, 'src', 'reference.js'), }