|
6 | 6 | <template> |
7 | 7 | <Modal |
8 | 8 | class="import-modal" |
9 | | - size="large" |
| 9 | + size="normal" |
10 | 10 | :name="$t('calendar', 'Import destination selection')" |
11 | 11 | @close="cancelImport"> |
12 | | - <h2 class="import-modal__title"> |
13 | | - {{ $t('calendar', 'Import calendars') }} |
14 | | - </h2> |
15 | | - <h4 class="import-modal__subtitle"> |
16 | | - <!-- eslint-disable-next-line no-irregular-whitespace --> |
17 | | - {{ $t('calendar', 'Please select a calendar to import into …') }} |
18 | | - </h4> |
19 | | - |
20 | | - <transition-group class="import-modal__file-list" tag="ul"> |
21 | | - <li key="import-header-row" class="import-modal-file-item import-modal-file-item--header"> |
22 | | - <div class="import-modal-file-item__filename"> |
23 | | - {{ $t('calendar', 'Filename') }} |
24 | | - </div> |
25 | | - <div class="import-modal-file-item__calendar-select"> |
26 | | - {{ $t('calendar', 'Calendar to import into') }} |
27 | | - </div> |
28 | | - </li> |
29 | | - <ImportScreenRow v-for="(file, index) in files" :key="`import-file-${index}`" :file="file" /> |
30 | | - </transition-group> |
31 | | - |
32 | | - <div class="import-modal__actions"> |
33 | | - <NcButton @click="cancelImport"> |
34 | | - {{ $t('calendar', 'Cancel') }} |
35 | | - </NcButton> |
36 | | - <NcButton class="primary" @click="importCalendar"> |
37 | | - {{ $n('calendar', 'Import calendar', 'Import calendars', files.length) }} |
38 | | - </NcButton> |
39 | | - </div> |
| 12 | + <template v-if="isSelecting"> |
| 13 | + <transition-group class="import-modal__file-list" tag="ul"> |
| 14 | + <ImportScreenRow v-for="entry in entries" :key="`import-file-${entry.file.id}`" :entry="entry" /> |
| 15 | + </transition-group> |
| 16 | + |
| 17 | + <div class="import-modal__actions"> |
| 18 | + <NcButton @click="cancelImport"> |
| 19 | + {{ $t('calendar', 'Cancel') }} |
| 20 | + </NcButton> |
| 21 | + <NcButton variant="primary" @click="importCalendar"> |
| 22 | + <template #icon> |
| 23 | + <Upload :size="20" /> |
| 24 | + </template> |
| 25 | + {{ $n('calendar', 'Import calendar', 'Import calendars', entries.length) }} |
| 26 | + </NcButton> |
| 27 | + </div> |
| 28 | + </template> |
| 29 | + |
| 30 | + <template v-else> |
| 31 | + <h4 class="import-modal__title"> |
| 32 | + {{ activeFileLabel }} |
| 33 | + </h4> |
| 34 | + |
| 35 | + <NcProgressBar class="import-modal__progress-bar" :value="progressValue" size="medium" /> |
| 36 | + |
| 37 | + <div class="import-modal__counters"> |
| 38 | + <NcNoteCard type="info"> |
| 39 | + <strong>{{ totals.discovered }}</strong> {{ $t('calendar', 'Discovered') }} |
| 40 | + </NcNoteCard> |
| 41 | + <NcNoteCard type="info"> |
| 42 | + <strong>{{ totals.processed }}</strong> {{ $t('calendar', 'Processed') }} |
| 43 | + </NcNoteCard> |
| 44 | + <NcNoteCard type="success"> |
| 45 | + <strong>{{ totals.created }}</strong> {{ $t('calendar', 'Created') }} |
| 46 | + </NcNoteCard> |
| 47 | + <NcNoteCard type="info"> |
| 48 | + <strong>{{ totals.updated }}</strong> {{ $t('calendar', 'Updated') }} |
| 49 | + </NcNoteCard> |
| 50 | + <NcNoteCard type="warning"> |
| 51 | + <strong>{{ totals.exists }}</strong> {{ $t('calendar', 'Skipped') }} |
| 52 | + </NcNoteCard> |
| 53 | + <NcNoteCard type="error"> |
| 54 | + <strong>{{ totals.error }}</strong> {{ $t('calendar', 'Errors') }} |
| 55 | + </NcNoteCard> |
| 56 | + </div> |
| 57 | + </template> |
40 | 58 | </Modal> |
41 | 59 | </template> |
42 | 60 |
|
43 | 61 | <script> |
44 | | -import { NcModal as Modal, NcButton } from '@nextcloud/vue' |
| 62 | +import { NcModal as Modal, NcButton, NcNoteCard, NcProgressBar } from '@nextcloud/vue' |
| 63 | +import Upload from 'vue-material-design-icons/TrayArrowUp.vue' |
45 | 64 | import ImportScreenRow from './ImportScreenRow.vue' |
46 | 65 |
|
47 | 66 | export default { |
48 | 67 | name: 'ImportScreen', |
49 | 68 | components: { |
50 | 69 | NcButton, |
| 70 | + NcNoteCard, |
| 71 | + NcProgressBar, |
51 | 72 | ImportScreenRow, |
52 | 73 | Modal, |
| 74 | + Upload, |
53 | 75 | }, |
54 | 76 |
|
55 | 77 | props: { |
56 | | - files: { |
| 78 | + entries: { |
57 | 79 | type: Array, |
58 | 80 | required: true, |
59 | 81 | }, |
| 82 | +
|
| 83 | + stage: { |
| 84 | + type: String, |
| 85 | + required: true, |
| 86 | + }, |
| 87 | +
|
| 88 | + totals: { |
| 89 | + type: Object, |
| 90 | + required: true, |
| 91 | + }, |
| 92 | +
|
| 93 | + activeSession: { |
| 94 | + type: Object, |
| 95 | + default: null, |
| 96 | + }, |
| 97 | + }, |
| 98 | +
|
| 99 | + emits: ['cancelImport', 'importCalendar'], |
| 100 | +
|
| 101 | + computed: { |
| 102 | + isSelecting() { |
| 103 | + return this.stage === 'selecting' |
| 104 | + }, |
| 105 | +
|
| 106 | + progressValue() { |
| 107 | + return Math.round(this.totals.processed / Math.max(this.totals.discovered, 1) * 100) |
| 108 | + }, |
| 109 | +
|
| 110 | + activeFileLabel() { |
| 111 | + if (!this.activeSession) { |
| 112 | + return this.$t('calendar', 'Preparing import…') |
| 113 | + } |
| 114 | +
|
| 115 | + return this.$t('calendar', 'Importing {fileName} into {calendar}', { |
| 116 | + fileName: this.activeSession.fileName, |
| 117 | + calendar: this.activeSession.targetDisplayName || this.$t('calendar', 'selected calendar'), |
| 118 | + }) |
| 119 | + }, |
60 | 120 | }, |
61 | 121 |
|
62 | 122 | methods: { |
|
0 commit comments