Skip to content

Commit

Permalink
added import results dialog, renamed files
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Feb 29, 2024
1 parent b6bc2ca commit 849f5ae
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/file-actions-script.js → src/file-actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FileAction, registerFileAction } from '@nextcloud/files'

Check failure on line 1 in src/file-actions.js

View workflow job for this annotation

GitHub Actions / NPM lint

"@nextcloud/files" is extraneous
import { showError, spawnDialog } from '@nextcloud/dialogs'
import ImportIntoTables from './modules/modals/ImportIntoTables.vue'
import FileActionImport from './modules/modals/FileActionImport.vue'

const icon = `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">
<path d="M4,3H20A2,2 0 0,1 22,5V20A2,2 0 0,1 20,22H4A2,2 0 0,1 2,20V5A2,2 0 0,1 4,3M4,7V10H8V7H4M10,7V10H14V7H10M20,10V7H16V10H20M4,12V15H8V12H4M4,20H8V17H4V20M10,12V15H14V12H10M10,20H14V17H10V20M20,20V17H16V20H20M20,12H16V15H20V12Z"/>
Expand All @@ -21,7 +21,7 @@ const fileAction = new FileAction({
return null
}

spawnDialog(ImportIntoTables, { t, file })
spawnDialog(FileActionImport, { t, file, })

Check warning on line 24 in src/file-actions.js

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected trailing comma

return null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@
import { NcModal, NcButton, NcSelect, NcCheckboxRadioSwitch, NcEmojiPicker, NcLoadingIcon } from '@nextcloud/vue'
import { generateUrl } from '@nextcloud/router'
import { Node } from '@nextcloud/files'

Check failure on line 88 in src/modules/modals/FileActionImport.vue

View workflow job for this annotation

GitHub Actions / NPM lint

"@nextcloud/files" is extraneous
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,
Expand Down Expand Up @@ -125,6 +126,7 @@ export default {
emoji: '🔧',
title: this.file.basename,
},
importResults: null,
existingTables: [],
selectedTable: null,
}
Expand Down Expand Up @@ -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 }))
Expand All @@ -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 }))
Expand All @@ -194,6 +196,8 @@ export default {
this.importingFile = false
this.modal = false
spawnDialog(ImportResults, { t, results: this.importResults, })

Check warning on line 200 in src/modules/modals/FileActionImport.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected trailing comma
},
},
}
Expand Down
92 changes: 92 additions & 0 deletions src/modules/modals/ImportResults.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<template>
<NcDialog :name="t('tables', 'Result')" :open.sync="show" size="small">

Check failure on line 2 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
<template #actions>

Check failure on line 3 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
<NcButton :aria-label="t('tables', 'Close')" @click="hideDialog">

Check failure on line 4 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
{{ t('tables', 'Close') }}

Check failure on line 5 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
</NcButton>

Check failure on line 6 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
</template>

Check failure on line 7 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character

Check failure on line 8 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
<table class="import_modal__results">
<tbody>
<tr>
<td>{{ t('tables', 'Found columns') }}</td>
<td>{{ results.found_columns_count }}</td>
</tr>

<tr>
<td>{{ t('tables', 'Matching columns') }}</td>
<td>{{ results.matching_columns_count }}</td>
</tr>

<tr>
<td>{{ t('tables', 'Created columns') }}</td>
<td>{{ results.created_columns_count }}</td>
</tr>


<tr>
<td>{{ t('tables', 'Inserted rows') }}</td>
<td>{{ results.inserted_rows_count }}</td>
</tr>


<tr>
<td>{{ t('tables', 'Value parsing errors') }}</td>
<td>{{ results.errors_parsing_count }}</td>
</tr>

<tr>
<td>{{ t('tables', 'Row creation errors') }}</td>
<td>{{ results.errors_count }}</td>
</tr>
</tbody>
</table>
</NcDialog>
</template>

<script>
import { NcDialog, NcButton } from '@nextcloud/vue'
export default {
name: 'ImportResults',
components: {
NcDialog,
NcButton,
},
props: {
t: {
type: Function,
default: null,
},
results: {

Check warning on line 63 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'results' requires default value to be set

Check warning on line 63 in src/modules/modals/ImportResults.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop "results" should define at least its type
found_columns_count: 0,
matching_columns_count: 0,
created_columns_count: 0,
inserted_rows_count: 0,
errors_parsing_count: 0,
errors_count: 0,
},
},
data() {
return {
show: true,
}
},
methods: {
hideDialog() {
this.show = false
},
},
}
</script>

<style scoped>
.import_modal__results {
width: 100%;
margin-bottom: 10px;
}
</style>
2 changes: 1 addition & 1 deletion webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
}

Expand Down

0 comments on commit 849f5ae

Please sign in to comment.