From fc8b8cf527be2c65e2138b9c9420c13518d66132 Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Thu, 4 Jan 2024 21:47:35 +0530 Subject: [PATCH 1/7] % added in title --- .../src/views/ManageTasksPage/TaskPanel.vue | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 4a2ab128cbd..23175530c40 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -256,10 +256,48 @@ }); }, }, + watch: { + taskPercentage(newPercentage) { + if (newPercentage !== null) { + const formattedPercentage = (newPercentage * 100).toFixed(2) + '%'; + const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + + let titlePrefix = ''; + if (this.task.type === TaskTypes.REMOTECONTENTIMPORT || + this.task.type === TaskTypes.DISKCONTENTIMPORT) { + titlePrefix = this.$tr('importChannelWhole', { channelName }); + } else if (this.task.type === TaskTypes.DELETECHANNEL + || this.task.type === TaskTypes.DELETECONTENT) { + titlePrefix = this.$tr('deleteChannelWhole', { channelName }); + } + + document.title = `${formattedPercentage} - ${titlePrefix}`; + } + + }, + 'task.status': { + immediate: true, + handler(newStatus) { + const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + if (newStatus === TaskStatuses.CANCELED) { + document.title = 'Cancelled - ' + channelName; + } else if (newStatus === TaskStatuses.FAILED) { + document.title = 'Failed - ' + channelName; + } else if (newStatus === TaskStatuses.COMPLETED) { + document.title = 'Completed - ' + channelName; + } else { + document.title = "Task manager"; + } + }, + }, +}, + methods: { handleClick() { if (this.taskIsCompleted || this.taskIsFailed) { this.$emit('clickclear'); + document.title = 'Task Manager'; + } else { this.$emit('clickcancel'); } From 9f85c90527c06ca435c5411af2b3e81c8e7e3ccf Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Thu, 4 Jan 2024 21:59:24 +0530 Subject: [PATCH 2/7] Linting error removed --- .../src/views/ManageTasksPage/TaskPanel.vue | 76 ++++++++++--------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 23175530c40..49ee925bb94 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -256,48 +256,52 @@ }); }, }, - watch: { - taskPercentage(newPercentage) { - if (newPercentage !== null) { - const formattedPercentage = (newPercentage * 100).toFixed(2) + '%'; - const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); - - let titlePrefix = ''; - if (this.task.type === TaskTypes.REMOTECONTENTIMPORT || - this.task.type === TaskTypes.DISKCONTENTIMPORT) { - titlePrefix = this.$tr('importChannelWhole', { channelName }); - } else if (this.task.type === TaskTypes.DELETECHANNEL - || this.task.type === TaskTypes.DELETECONTENT) { - titlePrefix = this.$tr('deleteChannelWhole', { channelName }); - } - - document.title = `${formattedPercentage} - ${titlePrefix}`; - } - - }, - 'task.status': { - immediate: true, - handler(newStatus) { - const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); - if (newStatus === TaskStatuses.CANCELED) { - document.title = 'Cancelled - ' + channelName; - } else if (newStatus === TaskStatuses.FAILED) { - document.title = 'Failed - ' + channelName; - } else if (newStatus === TaskStatuses.COMPLETED) { - document.title = 'Completed - ' + channelName; - } else { - document.title = "Task manager"; - } + watch: { + taskPercentage(newPercentage) { + if (newPercentage !== null) { + const formattedPercentage = (newPercentage * 100).toFixed(2) + '%'; + const channelName = + this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + + let titlePrefix = ''; + if ( + this.task.type === TaskTypes.REMOTECONTENTIMPORT || + this.task.type === TaskTypes.DISKCONTENTIMPORT + ) { + titlePrefix = this.$tr('importChannelWhole', { channelName }); + } else if ( + this.task.type === TaskTypes.DELETECHANNEL || + this.task.type === TaskTypes.DELETECONTENT + ) { + titlePrefix = this.$tr('deleteChannelWhole', { channelName }); + } + + document.title = `${formattedPercentage} - ${titlePrefix}`; + } + }, + 'task.status': { + immediate: true, + handler(newStatus) { + const channelName = + this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + if (newStatus === TaskStatuses.CANCELED) { + document.title = 'Cancelled - ' + channelName; + } else if (newStatus === TaskStatuses.FAILED) { + document.title = 'Failed - ' + channelName; + } else if (newStatus === TaskStatuses.COMPLETED) { + document.title = 'Completed - ' + channelName; + } else { + document.title = 'Task manager'; + } + }, + }, }, - }, -}, methods: { handleClick() { if (this.taskIsCompleted || this.taskIsFailed) { this.$emit('clickclear'); - document.title = 'Task Manager'; - + document.title = 'Task manager'; } else { this.$emit('clickcancel'); } From d50e1ab9805885ce1e3b55930012cecf38afb6f1 Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Thu, 11 Jan 2024 13:06:44 +0530 Subject: [PATCH 3/7] internationalization issue resolved --- .../src/views/ManageTasksPage/TaskPanel.vue | 16 ++++++++++------ .../assets/src/views/ManageTasksPage/index.vue | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 49ee925bb94..1b09f78bc6c 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -142,6 +142,10 @@ type: Object, required: true, }, + appBarTitle: { + type: String, + required: true, + }, }, computed: { buttonLabel() { @@ -259,7 +263,7 @@ watch: { taskPercentage(newPercentage) { if (newPercentage !== null) { - const formattedPercentage = (newPercentage * 100).toFixed(2) + '%'; + const formattedPercentage = this.$formatNumber(newPercentage, { style: 'percent' }); const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); @@ -284,14 +288,15 @@ handler(newStatus) { const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + if (newStatus === TaskStatuses.CANCELED) { - document.title = 'Cancelled - ' + channelName; + document.title = this.$tr('statusCanceled') + ' - ' + channelName; } else if (newStatus === TaskStatuses.FAILED) { - document.title = 'Failed - ' + channelName; + document.title = this.$tr('statusFailed') + ' - ' + channelName; } else if (newStatus === TaskStatuses.COMPLETED) { - document.title = 'Completed - ' + channelName; + document.title = this.$tr('statusComplete') + ' - ' + channelName; } else { - document.title = 'Task manager'; + document.title = this.appBarTitle; } }, }, @@ -301,7 +306,6 @@ handleClick() { if (this.taskIsCompleted || this.taskIsFailed) { this.$emit('clickclear'); - document.title = 'Task manager'; } else { this.$emit('clickcancel'); } diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue index 4699084cb1b..c3c1b90fb17 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue @@ -35,6 +35,7 @@ :key="task.id" :task="task" class="task-panel" + :appBarTitle="$tr('appBarTitle')" :style="{ borderBottomColor: $themePalette.grey.v_200 }" @clickclear="handleClickClear(task)" @clickcancel="handleClickCancel(task)" From 96e1eb286aa5521fc6064afdded487bf5e8baa2c Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Fri, 12 Jan 2024 15:52:36 +0530 Subject: [PATCH 4/7] changes try for metainfo --- .../src/views/ManageTasksPage/TaskPanel.vue | 78 +++++++++++-------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 1b09f78bc6c..cf65bbc7a91 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -130,6 +130,11 @@ export default { name: 'TaskPanel', + metaInfo() { + return { + title: `${this.formattedPercentage} - ${this.dynamicTitle}`, + }; + }, mixins: [commonCoreStrings], setup() { const { windowIsSmall } = useKResponsiveWindow(); @@ -148,6 +153,36 @@ }, }, computed: { + dynamicTitle() { + const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); + + if (this.task.status === TaskStatuses.RUNNING || this.task.status === TaskStatuses.QUEUED) { + if ( + this.task.type === TaskTypes.REMOTECONTENTIMPORT || + this.task.type === TaskTypes.DISKCONTENTIMPORT + ) { + return this.$tr('importChannelWhole', { channelName: channelName }); + } else if ( + this.task.type === TaskTypes.DELETECHANNEL || + this.task.type === TaskTypes.DELETECONTENT + ) { + return this.$tr('deleteChannelWhole', { channelName: channelName }); + } + } else if (this.task.status === TaskStatuses.CANCELED) { + return this.$tr('statusCanceled', { channelName: channelName }); + } else if (this.task.status === TaskStatuses.FAILED) { + return this.$tr('statusFailed', { channelName: channelName }); + } else if (this.task.status === TaskStatuses.COMPLETED) { + return this.$tr('statusComplete', { channelName: channelName }); + } + return this.appBarTitle; // Default title + }, + + formattedPercentage() { + return this.taskPercentage !== null + ? this.$formatNumber(this.taskPercentage, { style: 'percent' }) + : ''; + }, buttonLabel() { if (this.taskIsClearable) { return this.coreString('clearAction'); @@ -261,42 +296,23 @@ }, }, watch: { - taskPercentage(newPercentage) { - if (newPercentage !== null) { - const formattedPercentage = this.$formatNumber(newPercentage, { style: 'percent' }); - const channelName = - this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); - - let titlePrefix = ''; - if ( - this.task.type === TaskTypes.REMOTECONTENTIMPORT || - this.task.type === TaskTypes.DISKCONTENTIMPORT - ) { - titlePrefix = this.$tr('importChannelWhole', { channelName }); - } else if ( - this.task.type === TaskTypes.DELETECHANNEL || - this.task.type === TaskTypes.DELETECONTENT - ) { - titlePrefix = this.$tr('deleteChannelWhole', { channelName }); + taskPercentage: { + handler(newPercentage) { + if (newPercentage !== null) { + this.$meta().refresh(); } - - document.title = `${formattedPercentage} - ${titlePrefix}`; - } + }, }, + 'task.status': { immediate: true, handler(newStatus) { - const channelName = - this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); - - if (newStatus === TaskStatuses.CANCELED) { - document.title = this.$tr('statusCanceled') + ' - ' + channelName; - } else if (newStatus === TaskStatuses.FAILED) { - document.title = this.$tr('statusFailed') + ' - ' + channelName; - } else if (newStatus === TaskStatuses.COMPLETED) { - document.title = this.$tr('statusComplete') + ' - ' + channelName; - } else { - document.title = this.appBarTitle; + if ( + newStatus === TaskStatuses.CANCELED || + newStatus === TaskStatuses.FAILED || + newStatus === TaskStatuses.COMPLETED + ) { + this.$meta().refresh(); } }, }, From fa48ecd8061e8797126262f8a46240d02674be79 Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Sat, 13 Jan 2024 10:43:54 +0530 Subject: [PATCH 5/7] updated title to use metainfo of parent --- .../src/views/ManageTasksPage/TaskPanel.vue | 29 +++++++++++-------- .../src/views/ManageTasksPage/index.vue | 7 ++++- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index cf65bbc7a91..3a0fd7ca932 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -130,11 +130,6 @@ export default { name: 'TaskPanel', - metaInfo() { - return { - title: `${this.formattedPercentage} - ${this.dynamicTitle}`, - }; - }, mixins: [commonCoreStrings], setup() { const { windowIsSmall } = useKResponsiveWindow(); @@ -166,16 +161,18 @@ this.task.type === TaskTypes.DELETECHANNEL || this.task.type === TaskTypes.DELETECONTENT ) { - return this.$tr('deleteChannelWhole', { channelName: channelName }); + return this.$tr('deleteChannelWhole', { channelName: channelName }) + channelName; } } else if (this.task.status === TaskStatuses.CANCELED) { - return this.$tr('statusCanceled', { channelName: channelName }); + return this.$tr('statusCanceled') + ' - ' + channelName; } else if (this.task.status === TaskStatuses.FAILED) { - return this.$tr('statusFailed', { channelName: channelName }); + return this.$tr('statusFailed'); } else if (this.task.status === TaskStatuses.COMPLETED) { - return this.$tr('statusComplete', { channelName: channelName }); + return this.$tr('statusComplete') + ' - ' + channelName; + } else if (this.task.status === TaskStatuses.CANCELING) { + return this.$tr('statusCanceling') + ' - ' + channelName; } - return this.appBarTitle; // Default title + return this.appBarTitle; }, formattedPercentage() { @@ -297,9 +294,10 @@ }, watch: { taskPercentage: { + immediate: true, handler(newPercentage) { if (newPercentage !== null) { - this.$meta().refresh(); + this.emitUpdatedTitle(); } }, }, @@ -309,16 +307,23 @@ handler(newStatus) { if ( newStatus === TaskStatuses.CANCELED || + newStatus === TaskStatuses.CANCELING || newStatus === TaskStatuses.FAILED || newStatus === TaskStatuses.COMPLETED ) { - this.$meta().refresh(); + this.emitUpdatedTitle(); } }, }, }, methods: { + emitUpdatedTitle() { + const title = this.taskIsRunning + ? `${this.formattedPercentage} - ${this.dynamicTitle}` + : this.dynamicTitle; + this.$emit('update-title', title); + }, handleClick() { if (this.taskIsCompleted || this.taskIsFailed) { this.$emit('clickclear'); diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue index c3c1b90fb17..7783e612924 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue @@ -39,6 +39,7 @@ :style="{ borderBottomColor: $themePalette.grey.v_200 }" @clickclear="handleClickClear(task)" @clickcancel="handleClickCancel(task)" + @update-title="updateAppBarTitle" /> @@ -75,7 +76,7 @@ name: 'ManageTasksPage', metaInfo() { return { - title: this.$tr('appBarTitle'), + title: this.pageTitle, }; }, components: { @@ -94,6 +95,7 @@ data() { return { loading: true, + pageTitle: this.$tr('appBarTitle'), }; }, computed: { @@ -136,6 +138,9 @@ } }, methods: { + updateAppBarTitle(updatedTitle) { + this.pageTitle = updatedTitle; + }, handleClickClear(task) { TaskResource.clear(task.id).catch(() => { // error silently From 1b21ae91b68673e20f4b5d5354f8c0bf85a376d5 Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Sat, 20 Jan 2024 17:57:40 +0530 Subject: [PATCH 6/7] Percentage added index.vue --- .../src/views/ManageTasksPage/TaskPanel.vue | 94 +------------------ .../src/views/ManageTasksPage/index.vue | 61 ++++++++++-- .../assets/src/views/commonDeviceStrings.js | 24 +++++ 3 files changed, 81 insertions(+), 98 deletions(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 3a0fd7ca932..404a3efb72b 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -94,6 +94,7 @@ import bytesForHumans from 'kolibri.utils.bytesForHumans'; import { TaskStatuses, TaskTypes } from 'kolibri.utils.syncTaskUtils'; + import commonDeviceStrings from '../commonDeviceStrings'; const typeToTrMap = { [TaskTypes.REMOTECONTENTIMPORT]: 'importChannelPartial', @@ -130,7 +131,7 @@ export default { name: 'TaskPanel', - mixins: [commonCoreStrings], + mixins: [commonCoreStrings, commonDeviceStrings], setup() { const { windowIsSmall } = useKResponsiveWindow(); return { @@ -142,44 +143,8 @@ type: Object, required: true, }, - appBarTitle: { - type: String, - required: true, - }, }, computed: { - dynamicTitle() { - const channelName = this.task.extra_metadata.channel_name || this.$tr('unknownChannelName'); - - if (this.task.status === TaskStatuses.RUNNING || this.task.status === TaskStatuses.QUEUED) { - if ( - this.task.type === TaskTypes.REMOTECONTENTIMPORT || - this.task.type === TaskTypes.DISKCONTENTIMPORT - ) { - return this.$tr('importChannelWhole', { channelName: channelName }); - } else if ( - this.task.type === TaskTypes.DELETECHANNEL || - this.task.type === TaskTypes.DELETECONTENT - ) { - return this.$tr('deleteChannelWhole', { channelName: channelName }) + channelName; - } - } else if (this.task.status === TaskStatuses.CANCELED) { - return this.$tr('statusCanceled') + ' - ' + channelName; - } else if (this.task.status === TaskStatuses.FAILED) { - return this.$tr('statusFailed'); - } else if (this.task.status === TaskStatuses.COMPLETED) { - return this.$tr('statusComplete') + ' - ' + channelName; - } else if (this.task.status === TaskStatuses.CANCELING) { - return this.$tr('statusCanceling') + ' - ' + channelName; - } - return this.appBarTitle; - }, - - formattedPercentage() { - return this.taskPercentage !== null - ? this.$formatNumber(this.taskPercentage, { style: 'percent' }) - : ''; - }, buttonLabel() { if (this.taskIsClearable) { return this.coreString('clearAction'); @@ -292,38 +257,8 @@ }); }, }, - watch: { - taskPercentage: { - immediate: true, - handler(newPercentage) { - if (newPercentage !== null) { - this.emitUpdatedTitle(); - } - }, - }, - - 'task.status': { - immediate: true, - handler(newStatus) { - if ( - newStatus === TaskStatuses.CANCELED || - newStatus === TaskStatuses.CANCELING || - newStatus === TaskStatuses.FAILED || - newStatus === TaskStatuses.COMPLETED - ) { - this.emitUpdatedTitle(); - } - }, - }, - }, methods: { - emitUpdatedTitle() { - const title = this.taskIsRunning - ? `${this.formattedPercentage} - ${this.dynamicTitle}` - : this.dynamicTitle; - this.$emit('update-title', title); - }, handleClick() { if (this.taskIsCompleted || this.taskIsFailed) { this.$emit('clickclear'); @@ -346,31 +281,6 @@ message: 'Exported size: ({bytesText})', context: 'Indicates the number of resources and their size.', }, - - statusInProgress: { - message: 'In-progress', - context: 'Label indicating that a task is in progress.', - }, - statusInQueue: { - message: 'Waiting', - context: 'Label indicating that a task is queued.\n', - }, - statusComplete: { - message: 'Finished', - context: 'Label indicating that the *task* was completed successfully.', - }, - statusFailed: { - message: 'Failed', - context: 'Label indicating that a task failed, i.e. it has not been completed.', - }, - statusCanceled: { - message: 'Canceled', - context: 'Refers to a canceled task in the task manager section.', - }, - statusCanceling: { - message: 'Canceling', - context: 'Refers to a task being canceled in the task manager section.', - }, importChannelWhole: { message: `Import '{channelName}'`, context: diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue index 7783e612924..c3c78d7ab61 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/index.vue @@ -123,10 +123,9 @@ }, }, watch: { - managedTasks(val) { - if (val.length > 0) { - this.loading = false; - } + managedTasks: { + handler: 'updateManagedTasks', + deep: true, }, }, mounted() { @@ -138,8 +137,58 @@ } }, methods: { - updateAppBarTitle(updatedTitle) { - this.pageTitle = updatedTitle; + formattedPercentage(val) { + return this.$formatNumber(val, { style: 'percent' }); + }, + formattedNumber(val) { + return this.$formatNumber(val); + }, + + updateManagedTasks(val) { + if (val.length > 0) { + this.loading = false; + } + // Additional logic or updates related to managedTasks + this.updateAppBarTitle(); + }, + updateAppBarTitle() { + const inProgressTasks = this.managedTasks.filter(task => task.status === 'RUNNING'); + const failedTasks = this.managedTasks.filter(task => task.status === 'FAILED'); + const canceledTasks = this.managedTasks.filter(task => task.status === 'CANCELED'); + const totalTasks = this.managedTasks.length; + const completedTasks = this.managedTasks.filter(task => task.status === 'COMPLETED'); + + if (failedTasks.length === 1) { + this.pageTitle = `${this.deviceString('statusFailed')} - ${ + failedTasks[0].extra_metadata.channel_name + } `; + } else if (failedTasks.length > 1) { + this.pageTitle = `${this.formattedNumber(failedTasks.length)} - ${this.deviceString( + 'statusFailed' + )}`; + } else if (totalTasks === 1 && inProgressTasks.length === 1) { + const inProgressTask = inProgressTasks[0]; + this.pageTitle = `${this.formattedPercentage(inProgressTask.percentage)} - ${ + inProgressTask.extra_metadata.channel_name + } `; + } else if (totalTasks > 1 && inProgressTasks.length >= 1) { + const averageProgress = + inProgressTasks.reduce((sum, task) => sum + task.percentage, 0) / + inProgressTasks.length; + if (averageProgress === 1) { + this.pageTitle = this.deviceString('statusComplete'); + } else { + this.pageTitle = `${this.formattedPercentage(averageProgress)} - ${this.deviceString( + 'statusInProgress' + )}`; + } + } else if (totalTasks > 0 && completedTasks.length === totalTasks) { + this.pageTitle = this.deviceString('statusComplete'); + } else if (canceledTasks.length > 0) { + this.pageTitle = this.deviceString('statusCanceled'); + } else { + this.pageTitle = this.$tr('appBarTitle'); + } }, handleClickClear(task) { TaskResource.clear(task.id).catch(() => { diff --git a/kolibri/plugins/device/assets/src/views/commonDeviceStrings.js b/kolibri/plugins/device/assets/src/views/commonDeviceStrings.js index 4b65899af34..77ada105324 100644 --- a/kolibri/plugins/device/assets/src/views/commonDeviceStrings.js +++ b/kolibri/plugins/device/assets/src/views/commonDeviceStrings.js @@ -43,6 +43,30 @@ const deviceStrings = createTranslator('CommonDeviceStrings', { message: 'Newly downloaded resources will be added to the primary storage location', context: 'Label for primary storage location.', }, + statusInProgress: { + message: 'In-progress', + context: 'Label indicating that a task is in progress.', + }, + statusInQueue: { + message: 'Waiting', + context: 'Label indicating that a task is queued.\n', + }, + statusComplete: { + message: 'Finished', + context: 'Label indicating that the *task* was completed successfully.', + }, + statusFailed: { + message: 'Failed', + context: 'Label indicating that a task failed, i.e. it has not been completed.', + }, + statusCanceled: { + message: 'Canceled', + context: 'Refers to a canceled task in the task manager section.', + }, + statusCanceling: { + message: 'Canceling', + context: 'Refers to a task being canceled in the task manager section.', + }, }); /** From 205cb7835e543689a9a83b531c77af40a753264b Mon Sep 17 00:00:00 2001 From: Garvit Singhal Date: Sat, 20 Jan 2024 18:25:10 +0530 Subject: [PATCH 7/7] frotend test error resolved --- .../device/assets/src/views/ManageTasksPage/TaskPanel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue index 404a3efb72b..a4cacad4719 100644 --- a/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue +++ b/kolibri/plugins/device/assets/src/views/ManageTasksPage/TaskPanel.vue @@ -249,7 +249,7 @@ }, statusText() { const trName = statusToTrMap[this.task.status]; - return this.$tr(trName); + return this.deviceString(trName); }, startedByText() { return this.$tr('startedByUser', {