Skip to content

Commit 7cae315

Browse files
committed
Add export size to export wizard
1 parent ff58749 commit 7cae315

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

kolibri/plugins/management/assets/src/views/manage-content-page/wizard-export.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<div class="main">
1111
<template v-if="!drivesLoading">
1212
<div class="modal-message">
13+
<p>
14+
{{ $tr('exportPromptPrefix', { numChannels: allChannels.length }) }}
15+
({{ exportContentSize }})
16+
</p>
1317
<drive-list
1418
:value="selectedDrive"
1519
:drives="wizardState.driveList"
@@ -53,15 +57,19 @@
5357
import kButton from 'kolibri.coreVue.components.kButton';
5458
import loadingSpinner from 'kolibri.coreVue.components.loadingSpinner';
5559
import driveList from './wizards/drive-list';
60+
import sumBy from 'lodash/sumBy';
61+
5662
export default {
5763
name: 'wizardExport',
5864
$trs: {
59-
title: 'Export to a Local Drive',
60-
available: 'Available Storage:',
61-
notWritable: 'Not writable',
65+
available: 'available',
6266
cancel: 'Cancel',
6367
export: 'Export',
68+
exportPromptPrefix: 'You are about to export {numChannels, number} {numChannels, plural, one {channel} other {channels}}',
69+
notWritable: 'Not writable',
6470
refresh: 'Refresh',
71+
title: 'Export to where?',
72+
waitForTotalSize: 'Calculating total size...',
6573
},
6674
components: {
6775
coreModal,
@@ -77,10 +85,18 @@
7785
canSubmit() {
7886
return !this.drivesLoading && !this.wizardState.busy && this.selectedDrive !== '';
7987
},
88+
exportContentSize() {
89+
const allChannelsHaveStats = this.allChannels.length === Object.keys(this.channelsWithStats).length;
90+
if (allChannelsHaveStats) {
91+
const totalSize = sumBy(Object.values(this.channelsWithStats), 'totalFileSizeInBytes');
92+
return bytesForHumans(totalSize);
93+
}
94+
return this.$tr('waitForTotalSize');
95+
},
8096
},
8197
methods: {
8298
formatEnabledMsg(drive) {
83-
return `${this.$tr('available')} ${bytesForHumans(drive.freespace)}`;
99+
return `${bytesForHumans(drive.freespace)} ${this.$tr('available')}`;
84100
},
85101
driveIsEnabled(drive) {
86102
return drive.writable;
@@ -100,7 +116,11 @@
100116
},
101117
},
102118
vuex: {
103-
getters: { wizardState: state => state.pageState.wizardState },
119+
getters: {
120+
allChannels: (state) => state.core.channels.list,
121+
channelsWithStats: state => state.pageState.channelFileSummaries,
122+
wizardState: state => state.pageState.wizardState,
123+
},
104124
actions: {
105125
transitionWizardPage: manageContentActions.transitionWizardPage,
106126
updateWizardLocalDriveList: actions.updateWizardLocalDriveList,

kolibri/plugins/management/assets/src/views/manage-content-page/wizards/drive-list.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
<k-radio-button
1414
v-for="drive in enabledDrives"
1515
:key="drive.id"
16-
:label="genEnabledDriveLabel(drive)"
16+
:label="enabledDriveLabel(drive)"
1717
:radiovalue="drive.id"
1818
v-model="selectedDrive"
1919
@change="$emit('change', drive.id)"
2020
/>
2121
<k-radio-button
2222
v-for="drive in disabledDrives"
2323
:key="drive.id"
24-
:label="genDisabledDriveLabel(drive)"
24+
:label="disabledDriveLabel(drive)"
2525
:radiovalue="drive.id"
2626
:disabled="true"
2727
v-model="selectedDrive"
@@ -37,6 +37,7 @@
3737
import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
3838
3939
export default {
40+
name: 'wizardDriveList',
4041
components: { kRadioButton },
4142
props: {
4243
value: {
@@ -69,20 +70,19 @@
6970
},
7071
},
7172
methods: {
72-
genEnabledDriveLabel(drive) {
73+
enabledDriveLabel(drive) {
7374
let driveLabel = drive.name;
7475
if (this.enabledMsg) {
7576
driveLabel += ` (${this.enabledMsg(drive)})`;
7677
}
7778
return driveLabel;
7879
},
79-
genDisabledDriveLabel(drive) {
80+
disabledDriveLabel(drive) {
8081
return `${drive.name} (${this.disabledMsg})`;
8182
},
8283
},
83-
name: 'wizardDriveList',
8484
$trs: {
85-
drivesFound: 'Drives found:',
85+
drivesFound: 'Drives found',
8686
noDrivesDetected: 'No drives were detected',
8787
},
8888
};

0 commit comments

Comments
 (0)