@conduction/nextcloud-vue 2.185.1 → 2.186.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget.vue.js +1 -1
  2. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js +83 -2
  3. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js.map +1 -1
  4. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js +147 -104
  5. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js.map +1 -1
  6. package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
  7. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js +58 -0
  8. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js.map +1 -1
  9. package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js +2 -2
  10. package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js.map +1 -1
  11. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
  12. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js +41 -16
  13. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js.map +1 -1
  14. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid3.vue.js.map +1 -1
  15. package/dist/esm/components/CnDividerWidget/index.js +1 -0
  16. package/dist/esm/components/CnDividerWidget/index.js.map +1 -1
  17. package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue.js +1 -1
  18. package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js +158 -5
  19. package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js.map +1 -1
  20. package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js +109 -45
  21. package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js.map +1 -1
  22. package/dist/esm/components/CnHeaderWidget/index.js +0 -1
  23. package/dist/esm/components/CnHeaderWidget/index.js.map +1 -1
  24. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue.js +1 -1
  25. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js +17 -3
  26. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js.map +1 -1
  27. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js +3 -3
  28. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js.map +1 -1
  29. package/dist/esm/components/CnVideoWidget/CnVideoWidget.vue.js +1 -1
  30. package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js +63 -1
  31. package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js.map +1 -1
  32. package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js +20 -10
  33. package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js.map +1 -1
  34. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm.vue.js +1 -1
  35. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js +15 -0
  36. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js.map +1 -1
  37. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js +17 -10
  38. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js.map +1 -1
  39. package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
  40. package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js.map +1 -1
  41. package/dist/esm/dialogs/CnAddWidgetModal.vue.js +1 -1
  42. package/dist/esm/dialogs/CnAddWidgetModal2.vue.js +18 -4
  43. package/dist/esm/dialogs/CnAddWidgetModal2.vue.js.map +1 -1
  44. package/dist/esm/dialogs/CnAddWidgetModal3.vue.js +57 -39
  45. package/dist/esm/dialogs/CnAddWidgetModal3.vue.js.map +1 -1
  46. package/dist/esm/l10n/en.json.js +96 -1
  47. package/dist/esm/l10n/en.json.js.map +1 -1
  48. package/dist/esm/l10n/nl.json.js +96 -1
  49. package/dist/esm/l10n/nl.json.js.map +1 -1
  50. package/dist/esm/library-style.js +1 -1
  51. package/dist/esm/nextcloud-vue.css +309 -192
  52. package/dist/nextcloud-vue.cjs.js +2359 -1605
  53. package/dist/nextcloud-vue.cjs.js.map +2 -2
  54. package/dist/nextcloud-vue.css +309 -192
  55. package/l10n/en.json +96 -1
  56. package/l10n/nl.json +96 -1
  57. package/package.json +1 -1
  58. package/src/components/CnCalendarWidget/CnCalendarWidget.vue +217 -75
  59. package/src/components/CnChartWidget/CnChartWidget.vue +60 -2
  60. package/src/components/CnDashboardGrid/CnDashboardGrid.md +1 -1
  61. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +41 -16
  62. package/src/components/CnDividerWidget/index.js +1 -0
  63. package/src/components/CnFilesWidget/CnFilesWidget.vue +278 -5
  64. package/src/components/CnHeaderWidget/index.js +0 -1
  65. package/src/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue +20 -6
  66. package/src/components/CnVideoWidget/CnVideoWidget.vue +84 -1
  67. package/src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue +19 -1
  68. package/src/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
  69. package/src/dialogs/CnAddWidgetModal.vue +53 -14
@@ -137,8 +137,8 @@
137
137
  :type="type"
138
138
  :height="computedHeight"
139
139
  :width="computedWidth"
140
- :options="mergedOptions"
141
- :series="plottedSeries" />
140
+ :options="apexOptions"
141
+ :series="apexSeries" />
142
142
  </div>
143
143
  <div v-else class="cn-chart-widget__fallback">
144
144
  <!-- @slot Rendered when the ApexCharts peer dependency is not available (defaults to the unavailableLabel text). -->
@@ -1077,6 +1077,13 @@ export default {
1077
1077
  // once at creation (data, not computed — matches the dashboard
1078
1078
  // date-chip convention).
1079
1079
  viewsGroupLabel: t('nextcloud-vue', 'Chart view'),
1080
+ // What the apexcharts wrapper is bound to: one raw object and one raw
1081
+ // array, kept equal to `mergedOptions` / `plottedSeries` by filling
1082
+ // them in place. The wrapper builds a chart from them (on mount and
1083
+ // on its own type / size rebuilds) but never sees them change, so
1084
+ // its watchers never fire; `updateChart` updates the live chart.
1085
+ apexOptions: markRaw({}),
1086
+ apexSeries: markRaw([]),
1080
1087
  }
1081
1088
  },
1082
1089
 
@@ -1884,6 +1891,16 @@ export default {
1884
1891
  })
1885
1892
  },
1886
1893
 
1894
+ /**
1895
+ * The options and series the chart draws, as one value, so a data
1896
+ * change that moves both reaches the chart as one update.
1897
+ *
1898
+ * @return {Array} `[mergedOptions, plottedSeries]`.
1899
+ */
1900
+ chartPayload() {
1901
+ return [this.mergedOptions, this.plottedSeries]
1902
+ },
1903
+
1887
1904
  mergedOptions() {
1888
1905
  const isPieType = ['pie', 'donut', 'radialBar'].includes(this.type)
1889
1906
 
@@ -2053,6 +2070,10 @@ export default {
2053
2070
  },
2054
2071
 
2055
2072
  watch: {
2073
+ chartPayload() {
2074
+ this.updateChart()
2075
+ },
2076
+
2056
2077
  groupByKey() {
2057
2078
  this.fetchGroupBy()
2058
2079
  },
@@ -2073,6 +2094,7 @@ export default {
2073
2094
  created() {
2074
2095
  // markRaw: `data()` is deeply reactive and would proxy the component.
2075
2096
  this.chartComponent = markRaw(VueApexCharts)
2097
+ this.syncChartBinding()
2076
2098
  },
2077
2099
 
2078
2100
  mounted() {
@@ -2206,6 +2228,42 @@ export default {
2206
2228
  }
2207
2229
  },
2208
2230
 
2231
+ /**
2232
+ * Fill the wrapper's bound options and series with the current ones,
2233
+ * in place, so a chart the wrapper (re)builds starts from them.
2234
+ *
2235
+ * @return {void}
2236
+ */
2237
+ syncChartBinding() {
2238
+ const options = this.apexOptions
2239
+ for (const key of Object.keys(options)) {
2240
+ delete options[key]
2241
+ }
2242
+ Object.assign(options, this.mergedOptions)
2243
+ const series = this.plottedSeries
2244
+ this.apexSeries.splice(0, this.apexSeries.length, ...(Array.isArray(series) ? series : []))
2245
+ },
2246
+
2247
+ /**
2248
+ * Show new options and series in the live chart as one in-place,
2249
+ * unanimated `updateOptions`, instead of the wrapper's
2250
+ * `updateOptions` + `updateSeries` pair: every ApexCharts update clears
2251
+ * and redraws the whole SVG and measures each label again, which on a
2252
+ * full dashboard page costs far more than the data change itself. The
2253
+ * entry animation on first draw is unaffected. ApexCharts skips a
2254
+ * payload identical to the last one.
2255
+ *
2256
+ * @return {void}
2257
+ */
2258
+ updateChart() {
2259
+ this.syncChartBinding()
2260
+ const apex = this.$refs.chart?.chart
2261
+ if (typeof apex?.updateOptions !== 'function') {
2262
+ return
2263
+ }
2264
+ apex.updateOptions({ ...this.mergedOptions, series: this.plottedSeries }, false, false)
2265
+ },
2266
+
2209
2267
  /**
2210
2268
  * Re-measure and redraw the chart after its box changed size, without
2211
2269
  * rebuilding it.
@@ -102,7 +102,7 @@ export default {
102
102
  | `columnWeights` | Array | `null` | Optional weights for the twelve-column grid's column groups, as `[{ span, weight }]` (e.g. three groups of 4 weighted 352/435/352). Applies only on the full twelve-column grid and not while editing; items on a side-column track are left alone. `null` keeps twelve equal shares. |
103
103
  | `margin` | Number | `12` | Gutter between grid items in pixels |
104
104
  | `minWidth` | Number | `2` | Minimum widget width in grid units |
105
- | `minHeight` | Number | `2` | Minimum widget height in grid units |
105
+ | `minHeight` | Number | `2` | Minimum widget height in grid units. A layout item's own `minHeight` replaces it for that item (a divider registers `minHeight: 1`). |
106
106
  | `columnOpts` | Object | `null` | GridStack v12 responsive `columnOpts` bag; when set the grid reflows its column count across screen sizes. Build with `getDashboardColumnOpts()`. Default `null` = fixed `columns`. |
107
107
  | `cellHeightCssVar` | String | `null` | When set, `cellHeight` is mirrored into this CSS custom property on the document root at init. Default `null` = none. |
108
108
  | `itemKey` | Function | `null` | Optional `(item) => string\|number` to derive each item's render key; forces a re-render when an item changes in a way its `id` doesn't capture (e.g. style edits). Default `null` = key on `item.id`. |
@@ -195,7 +195,7 @@ export default {
195
195
  name: 'CnDashboardGrid',
196
196
 
197
197
  props: {
198
- /** Array of layout items: { id, gridX, gridY, gridWidth, gridHeight, ...extra } */
198
+ /** Array of layout items: { id, gridX, gridY, gridWidth, gridHeight, minHeight?, ...extra }. An item's `minHeight` (layout rows) replaces the grid's own for that item. */
199
199
  layout: {
200
200
  type: Array,
201
201
  required: true,
@@ -750,8 +750,20 @@ export default {
750
750
  },
751
751
 
752
752
  /**
753
- * The smallest height an item may take, in grid rows: `minHeight`
754
- * layout rows, except for a size-to-content cell on split rows, which
753
+ * The smallest height an item may take, in layout rows: the item's own
754
+ * `minHeight` (a divider may be one row), else the grid's.
755
+ *
756
+ * @param {object} item The layout item.
757
+ * @return {number} The minimum height in layout rows.
758
+ */
759
+ itemMinHeight(item) {
760
+ const own = item && item.minHeight
761
+ return Number.isFinite(own) && own >= 1 ? Math.floor(own) : this.minHeight
762
+ },
763
+
764
+ /**
765
+ * The smallest height an item may take, in grid rows: its minimum
766
+ * height in layout rows, except for a size-to-content cell on split rows, which
755
767
  * may shrink to its content down to one grid row. The minimum is for
756
768
  * resizing by hand, and that only happens on whole rows in edit mode.
757
769
  *
@@ -763,7 +775,7 @@ export default {
763
775
  if (this.rowSplit !== 1 && this.sizeToContentAttr(item) !== undefined) {
764
776
  return 1
765
777
  }
766
- return this.minHeight * this.rowSplit
778
+ return this.itemMinHeight(item) * this.rowSplit
767
779
  },
768
780
 
769
781
  /**
@@ -1227,10 +1239,14 @@ export default {
1227
1239
  if (!this.grid || typeof this.grid.enable !== 'function') {
1228
1240
  return
1229
1241
  }
1242
+ // On the raw grid: enabled through Vue's proxy, GridStack binds its
1243
+ // drag handlers to the proxy and a drop never ends, so the move is
1244
+ // shown but no `change` follows.
1245
+ const grid = toRaw(this.grid)
1230
1246
  if (this.editable && !this.reflowed) {
1231
- this.grid.enable()
1247
+ grid.enable()
1232
1248
  } else {
1233
- this.grid.disable()
1249
+ grid.disable()
1234
1250
  }
1235
1251
  },
1236
1252
 
@@ -1415,12 +1431,13 @@ export default {
1415
1431
  * edge instead of pushing it into negative coordinates.
1416
1432
  *
1417
1433
  * @param {{x: number, y: number, w: number, h: number}} rect the candidate.
1434
+ * @param {object} [item] the layout item, whose own `minHeight` applies.
1418
1435
  * @return {{x: number, y: number, w: number, h: number}} the clamped rectangle.
1419
1436
  */
1420
- clampRect(rect) {
1437
+ clampRect(rect, item) {
1421
1438
  const cols = this.effectiveColumns
1422
1439
  const w = Math.min(Math.max(rect.w, this.minWidth), cols)
1423
- const h = Math.max(rect.h, this.minHeight)
1440
+ const h = Math.max(rect.h, item ? this.itemMinHeight(item) : this.minHeight)
1424
1441
  return {
1425
1442
  x: Math.min(Math.max(rect.x, 0), Math.max(cols - w, 0)),
1426
1443
  y: Math.max(rect.y, 0),
@@ -1453,7 +1470,7 @@ export default {
1453
1470
  }
1454
1471
 
1455
1472
  const current = this.currentRect(item)
1456
- const next = this.clampRect({ ...current, ...patch })
1473
+ const next = this.clampRect({ ...current, ...patch }, item)
1457
1474
 
1458
1475
  if (next.x === current.x && next.y === current.y
1459
1476
  && next.w === current.w && next.h === current.h) {
@@ -1463,7 +1480,7 @@ export default {
1463
1480
  return true
1464
1481
  }
1465
1482
 
1466
- this.grid.update(el, next)
1483
+ toRaw(this.grid).update(el, next)
1467
1484
 
1468
1485
  this.announce(kind === 'resize'
1469
1486
  ? t('nextcloud-vue', '{label} resized to {width} columns by {height} rows', {
@@ -1695,13 +1712,14 @@ export default {
1695
1712
  if (!this.grid || !this.$refs.gridContainer) {
1696
1713
  return
1697
1714
  }
1715
+ const grid = toRaw(this.grid)
1698
1716
  const added = []
1699
1717
  for (const item of this.itemsInRowOrder) {
1700
1718
  const el = this.$refs.gridContainer.querySelector(`[gs-id="${item.id}"]`)
1701
1719
  if (!el) {
1702
1720
  continue
1703
1721
  }
1704
- const node = this.grid.engine.nodes.find((n) => String(n.id) === String(item.id))
1722
+ const node = grid.engine.nodes.find((n) => String(n.id) === String(item.id))
1705
1723
  if (!node) {
1706
1724
  added.push(el)
1707
1725
  } else if (node.el === el) {
@@ -1712,16 +1730,23 @@ export default {
1712
1730
  // where the hidden widget had been. A drag reports the
1713
1731
  // grid's own position back, which matches and does
1714
1732
  // nothing here.
1733
+ // A width or height the layout changed (a form, an
1734
+ // undo) is synced the same way. A size-to-content cell
1735
+ // keeps the height its content gave it.
1715
1736
  const x = item.gridX ?? node.x
1716
1737
  const y = Number.isFinite(item.gridY) ? item.gridY * this.rowSplit : node.y
1717
- if (x !== node.x || y !== node.y) {
1738
+ const w = Number.isFinite(item.gridWidth) ? item.gridWidth : node.w
1739
+ const h = Number.isFinite(item.gridHeight) && this.sizeToContentAttr(item) === undefined
1740
+ ? item.gridHeight * this.rowSplit
1741
+ : node.h
1742
+ if (x !== node.x || y !== node.y || w !== node.w || h !== node.h) {
1718
1743
  // The layout said where it goes; GridStack's `change`
1719
1744
  // for it is not a user's arrangement and is not
1720
1745
  // reported back (it would write the display-only
1721
1746
  // compaction into the authored layout).
1722
1747
  this.applyingLayout = true
1723
1748
  try {
1724
- this.grid.update(el, { x, y })
1749
+ grid.update(el, { x, y, w, h })
1725
1750
  } finally {
1726
1751
  this.applyingLayout = false
1727
1752
  }
@@ -1729,8 +1754,8 @@ export default {
1729
1754
  } else {
1730
1755
  // Drop the stale node without touching its detached DOM,
1731
1756
  // then adopt the new element so GridStack sizes/places it.
1732
- this.grid.removeWidget(node.el, false, false)
1733
- this.grid.makeWidget(el)
1757
+ grid.removeWidget(node.el, false, false)
1758
+ grid.makeWidget(el)
1734
1759
  }
1735
1760
  }
1736
1761
  this.addWidgetsInOrder(added)
@@ -1742,7 +1767,7 @@ export default {
1742
1767
  for (const node of toRemove) {
1743
1768
  const el = this.$refs.gridContainer.querySelector(`[gs-id="${node.id}"]`)
1744
1769
  if (el) {
1745
- this.grid.removeWidget(el, false)
1770
+ toRaw(this.grid).removeWidget(el, false)
1746
1771
  }
1747
1772
  }
1748
1773
 
@@ -15,6 +15,7 @@ registerDashboardWidget('divider', {
15
15
  },
16
16
  displayName: 'Divider',
17
17
  icon: 'Minus',
18
+ minHeight: 1,
18
19
  })
19
20
 
20
21
  export { CnDividerWidget }
@@ -83,6 +83,48 @@
83
83
  {{ t('nextcloud-vue', 'Drop files to upload') }}
84
84
  </div>
85
85
 
86
+ <div v-if="uploads.length > 0" class="cn-files-widget__uploads" role="status">
87
+ <p class="cn-files-widget__uploads-total">
88
+ {{ uploadTotalLabel }}
89
+ <button
90
+ v-if="!uploading"
91
+ type="button"
92
+ class="cn-files-widget__notice-dismiss"
93
+ @click="dismissUploads">
94
+ {{ t('nextcloud-vue', 'Dismiss') }}
95
+ </button>
96
+ </p>
97
+ <ul class="cn-files-widget__uploads-list">
98
+ <li
99
+ v-for="(upload, index) in uploads"
100
+ :key="index"
101
+ class="cn-files-widget__progress-item"
102
+ :class="'cn-files-widget__progress-item--' + upload.status">
103
+ <span class="cn-files-widget__upload-name">{{ upload.name }}</span>
104
+ <span
105
+ class="cn-files-widget__upload-progress"
106
+ role="progressbar"
107
+ :aria-label="upload.name"
108
+ aria-valuemin="0"
109
+ aria-valuemax="100"
110
+ :aria-valuenow="uploadPercent(upload)">
111
+ <span class="cn-files-widget__upload-bar" :style="{ width: uploadPercent(upload) + '%' }" />
112
+ </span>
113
+ <span class="cn-files-widget__upload-status">{{ uploadStatusLabel(upload) }}</span>
114
+ </li>
115
+ </ul>
116
+ </div>
117
+
118
+ <div v-if="deleteNotice" class="cn-files-widget__notice" role="alert">
119
+ <span>{{ deleteNotice }}</span>
120
+ <button
121
+ type="button"
122
+ class="cn-files-widget__notice-dismiss"
123
+ @click="deleteNotice = null">
124
+ {{ t('nextcloud-vue', 'Dismiss') }}
125
+ </button>
126
+ </div>
127
+
86
128
  <div v-if="loading" class="cn-files-widget__state">
87
129
  {{ t('nextcloud-vue', 'Loading folder…') }}
88
130
  </div>
@@ -192,7 +234,7 @@
192
234
  </template>
193
235
 
194
236
  <script>
195
- import { translate as t } from '@nextcloud/l10n'
237
+ import { translatePlural as n, translate as t } from '@nextcloud/l10n'
196
238
  import { generateUrl } from '@nextcloud/router'
197
239
  import CnFilesWidgetDeleteDialog from '../../dialogs/CnFilesWidgetDeleteDialog.vue'
198
240
  import CnFilePreview from '../CnFilePreview/CnFilePreview.vue'
@@ -349,6 +391,13 @@ export default {
349
391
  isDragging: false,
350
392
  // Depth counter so nested dragenter/dragleave don't flicker the overlay.
351
393
  dragDepth: 0,
394
+ // The files of the current or last upload batch, each
395
+ // `{ name, size, loaded, status, error }` with status `queued`,
396
+ // `uploading`, `done` or `failed`.
397
+ uploads: [],
398
+ uploading: false,
399
+ // Why the last delete was refused, shown until dismissed.
400
+ deleteNotice: null,
352
401
  }
353
402
  },
354
403
 
@@ -448,9 +497,35 @@ export default {
448
497
  * @return {boolean} `true` unless `content.showThumbnails` is explicitly false.
449
498
  */
450
499
  showThumbnails() {
500
+ // Tree mode lists names only, whatever `showThumbnails` says.
501
+ if (this.content?.viewMode === 'tree') {
502
+ return false
503
+ }
451
504
  return this.content?.showThumbnails !== false
452
505
  },
453
506
 
507
+ /**
508
+ * The batch line above the upload list: bytes sent of the total while
509
+ * uploading, then how many files arrived.
510
+ *
511
+ * @return {string} the label.
512
+ */
513
+ uploadTotalLabel() {
514
+ const total = this.uploads.reduce((sum, upload) => sum + upload.size, 0)
515
+ if (this.uploading) {
516
+ const loaded = this.uploads.reduce((sum, upload) => sum + upload.loaded, 0)
517
+ return t('nextcloud-vue', 'Uploading {loaded} / {total}', {
518
+ loaded: this.formatSize(loaded),
519
+ total: this.formatSize(total),
520
+ })
521
+ }
522
+ const failed = this.uploads.filter((upload) => upload.status === 'failed').length
523
+ if (failed > 0) {
524
+ return n('nextcloud-vue', '{count} file could not be uploaded', '{count} files could not be uploaded', failed, { count: failed })
525
+ }
526
+ return t('nextcloud-vue', 'Upload complete')
527
+ },
528
+
454
529
  /**
455
530
  * Heuristic write-permission check: an empty folder optimistically
456
531
  * surfaces the upload button (the backend re-validates), otherwise at
@@ -895,6 +970,7 @@ export default {
895
970
  if (!target) {
896
971
  return
897
972
  }
973
+ this.deleteNotice = null
898
974
  try {
899
975
  const { default: axios } = await import('@nextcloud/axios')
900
976
 
@@ -909,7 +985,10 @@ export default {
909
985
  )
910
986
  await axios.delete(url)
911
987
  this.items = this.items.filter((item) => item.fileId !== target.fileId)
912
- } catch {
988
+ } catch (err) {
989
+ this.deleteNotice = err?.response?.status === 403
990
+ ? t('nextcloud-vue', 'You no longer have permission to delete {name}.', { name: target.name })
991
+ : t('nextcloud-vue', 'Could not delete {name}.', { name: target.name })
913
992
  this.fetchContents()
914
993
  } finally {
915
994
  this.confirmTarget = null
@@ -955,32 +1034,148 @@ export default {
955
1034
  }
956
1035
 
957
1036
  const formData = new FormData()
1037
+ const files = []
958
1038
  for (let i = 0; i < fileList.length; i++) {
959
1039
  formData.append('files[]', fileList[i])
1040
+ files.push(fileList[i])
960
1041
  }
1042
+ this.uploads = files.map((file) => ({ name: file.name, size: Number(file.size) || 0, loaded: 0, status: 'queued', error: '' }))
1043
+ this.uploading = true
1044
+ const onUploadProgress = (event) => this.trackUploadProgress(event)
961
1045
 
962
1046
  try {
963
1047
  const { default: axios } = await import('@nextcloud/axios')
964
1048
 
1049
+ let response
965
1050
  if (this.objectBound) {
966
1051
  const objectUrl = generateUrl(
967
1052
  `${this.objectApiBase}/objects/{register}/{schema}/{objectId}/filesMultipart`,
968
1053
  { register: this.register, schema: this.schemaSlug, objectId: this.objectId },
969
1054
  )
970
- await axios.post(objectUrl, formData)
1055
+ response = await axios.post(objectUrl, formData, { onUploadProgress })
971
1056
  } else {
972
1057
  const url = generateUrl(
973
1058
  `${this.apiBase}/api/widgets/files/{placementId}/upload`,
974
1059
  { placementId: this.placementId },
975
1060
  )
976
- await axios.post(url, formData, {
1061
+ response = await axios.post(url, formData, {
977
1062
  params: { currentPath: this.currentSubPath },
1063
+ onUploadProgress,
978
1064
  })
979
1065
  }
1066
+ this.settleUploads(Array.isArray(response?.data?.errors) ? response.data.errors : [])
980
1067
  this.fetchContents()
981
- } catch {
1068
+ } catch (err) {
1069
+ const reason = this.uploadErrorLabel(err?.response?.data?.error)
1070
+ this.uploads = this.uploads.map((upload) => ({ ...upload, status: 'failed', error: reason }))
982
1071
  this.fetchContents()
1072
+ } finally {
1073
+ this.uploading = false
1074
+ }
1075
+ },
1076
+
1077
+ /**
1078
+ * Spread the batch's sent bytes over its files in upload order: the
1079
+ * files before the byte count are done sending, the one it falls in is
1080
+ * uploading, the rest are queued.
1081
+ *
1082
+ * @param {{loaded: number, total?: number}} event axios' upload progress.
1083
+ * @return {void}
1084
+ */
1085
+ trackUploadProgress(event) {
1086
+ const size = this.uploads.reduce((sum, upload) => sum + upload.size, 0)
1087
+ const total = Number(event?.total) || size
1088
+ const scale = total > 0 ? size / total : 0
1089
+ let remaining = Number(event?.loaded || 0) * scale
1090
+ this.uploads = this.uploads.map((upload) => {
1091
+ const loaded = Math.max(0, Math.min(upload.size, remaining))
1092
+ remaining -= upload.size
1093
+ let status = 'queued'
1094
+ if (loaded >= upload.size && upload.size > 0) {
1095
+ status = 'done'
1096
+ } else if (loaded > 0) {
1097
+ status = 'uploading'
1098
+ }
1099
+ return { ...upload, loaded, status }
1100
+ })
1101
+ },
1102
+
1103
+ /**
1104
+ * Mark the batch finished: a file the host names in `errors`
1105
+ * (`{ name, error }`) failed with that reason, every other one arrived.
1106
+ *
1107
+ * @param {Array<{name: string, error?: string}>} errors the host's per-file errors.
1108
+ * @return {void}
1109
+ */
1110
+ settleUploads(errors) {
1111
+ const byName = new Map(errors.map((entry) => [String(entry?.name ?? ''), entry]))
1112
+ this.uploads = this.uploads.map((upload) => {
1113
+ const entry = byName.get(upload.name)
1114
+ if (entry) {
1115
+ return { ...upload, status: 'failed', error: this.uploadErrorLabel(entry.error) }
1116
+ }
1117
+ return { ...upload, loaded: upload.size, status: 'done', error: '' }
1118
+ })
1119
+ },
1120
+
1121
+ /**
1122
+ * The reason shown for a file that did not upload, from the host's code.
1123
+ *
1124
+ * @param {string|undefined} code the error code (`insufficient_storage`, …).
1125
+ * @return {string} the localised reason.
1126
+ */
1127
+ uploadErrorLabel(code) {
1128
+ if (code === 'insufficient_storage') {
1129
+ return t('nextcloud-vue', 'Not enough storage space')
1130
+ }
1131
+ if (code === 'no_access' || code === 'forbidden') {
1132
+ return t('nextcloud-vue', 'You may not upload to this folder')
1133
+ }
1134
+ if (code === 'mime_type_not_allowed' || code === 'mime_not_allowed') {
1135
+ return t('nextcloud-vue', 'This file type is not allowed here')
983
1136
  }
1137
+ return t('nextcloud-vue', 'Upload failed')
1138
+ },
1139
+
1140
+ /**
1141
+ * The percentage of one file sent, for its progress bar.
1142
+ *
1143
+ * @param {object} upload an entry of `uploads`.
1144
+ * @return {number} 0 to 100.
1145
+ */
1146
+ uploadPercent(upload) {
1147
+ if (upload.status === 'done') {
1148
+ return 100
1149
+ }
1150
+ return upload.size > 0 ? Math.round((upload.loaded / upload.size) * 100) : 0
1151
+ },
1152
+
1153
+ /**
1154
+ * The status text of one file in the upload list.
1155
+ *
1156
+ * @param {object} upload an entry of `uploads`.
1157
+ * @return {string} the label.
1158
+ */
1159
+ uploadStatusLabel(upload) {
1160
+ if (upload.status === 'failed') {
1161
+ return upload.error
1162
+ }
1163
+ if (upload.status === 'done') {
1164
+ return this.uploading ? t('nextcloud-vue', 'Sent') : t('nextcloud-vue', 'Uploaded')
1165
+ }
1166
+ if (upload.status === 'uploading') {
1167
+ return t('nextcloud-vue', 'Uploading {percent}%', { percent: this.uploadPercent(upload) })
1168
+ }
1169
+ return t('nextcloud-vue', 'Queued')
1170
+ },
1171
+
1172
+ /**
1173
+ * Clear a finished upload list.
1174
+ *
1175
+ * @return {void}
1176
+ */
1177
+ dismissUploads() {
1178
+ this.uploads = []
984
1179
  },
985
1180
 
986
1181
  /**
@@ -1307,6 +1502,84 @@ export default {
1307
1502
  display: none;
1308
1503
  }
1309
1504
 
1505
+ .cn-files-widget__uploads,
1506
+ .cn-files-widget__notice {
1507
+ margin: 4px 0 8px;
1508
+ padding: 8px 12px;
1509
+ border: 1px solid var(--color-border);
1510
+ border-radius: var(--border-radius);
1511
+ font-size: 13px;
1512
+ }
1513
+
1514
+ .cn-files-widget__notice {
1515
+ display: flex;
1516
+ align-items: center;
1517
+ justify-content: space-between;
1518
+ gap: 8px;
1519
+ border-color: var(--color-error);
1520
+ }
1521
+
1522
+ .cn-files-widget__uploads-total {
1523
+ display: flex;
1524
+ justify-content: space-between;
1525
+ gap: 8px;
1526
+ margin: 0 0 4px;
1527
+ font-weight: 600;
1528
+ }
1529
+
1530
+ .cn-files-widget__uploads-list {
1531
+ margin: 0;
1532
+ padding: 0;
1533
+ list-style: none;
1534
+ }
1535
+
1536
+ .cn-files-widget__progress-item {
1537
+ display: grid;
1538
+ grid-template-columns: minmax(0, 1fr) 80px auto;
1539
+ align-items: center;
1540
+ gap: 8px;
1541
+ padding: 2px 0;
1542
+ }
1543
+
1544
+ .cn-files-widget__upload-name {
1545
+ overflow: hidden;
1546
+ text-overflow: ellipsis;
1547
+ white-space: nowrap;
1548
+ }
1549
+
1550
+ .cn-files-widget__upload-progress {
1551
+ display: block;
1552
+ height: 6px;
1553
+ overflow: hidden;
1554
+ border-radius: 3px;
1555
+ background: var(--color-background-dark);
1556
+ }
1557
+
1558
+ .cn-files-widget__upload-bar {
1559
+ display: block;
1560
+ height: 100%;
1561
+ background: var(--color-primary-element);
1562
+ }
1563
+
1564
+ .cn-files-widget__progress-item--failed .cn-files-widget__upload-status {
1565
+ color: var(--color-error-text, var(--color-error));
1566
+ }
1567
+
1568
+ .cn-files-widget__upload-status {
1569
+ color: var(--color-text-maxcontrast);
1570
+ }
1571
+
1572
+ .cn-files-widget__notice-dismiss {
1573
+ padding: 0;
1574
+ border: none;
1575
+ background: transparent;
1576
+ color: inherit;
1577
+ font: inherit;
1578
+ font-weight: normal;
1579
+ text-decoration: underline;
1580
+ cursor: pointer;
1581
+ }
1582
+
1310
1583
  .cn-files-widget__pagination {
1311
1584
  text-align: center;
1312
1585
  padding: 8px 0;
@@ -19,7 +19,6 @@ registerDashboardWidget('header', {
19
19
  backgroundImageUrl: '',
20
20
  backgroundImageFileId: null,
21
21
  backgroundColor: '',
22
- overlayMode: 'none',
23
22
  overlayColor: '',
24
23
  overlayOpacity: 0.4,
25
24
  textColor: '',