diff --git a/kolibri/core/assets/src/api-resources/facilityTask.js b/kolibri/core/assets/src/api-resources/facilityTask.js index 616b34ac5f4..09e2525bc77 100644 --- a/kolibri/core/assets/src/api-resources/facilityTask.js +++ b/kolibri/core/assets/src/api-resources/facilityTask.js @@ -17,4 +17,8 @@ export default new Resource({ dataportalbulksync() { return this.postListEndpoint('startdataportalbulksync'); }, + + deleteFinishedTasks() { + return this.postListEndpoint('deletefinishedtasks'); + }, }); diff --git a/kolibri/core/assets/src/mixins/commonSyncElements.js b/kolibri/core/assets/src/mixins/commonSyncElements.js index 9e28e4e4078..83558b9ab71 100644 --- a/kolibri/core/assets/src/mixins/commonSyncElements.js +++ b/kolibri/core/assets/src/mixins/commonSyncElements.js @@ -1,4 +1,5 @@ -import { StaticNetworkLocationResource } from 'kolibri.resources'; +import some from 'lodash/some'; +import { StaticNetworkLocationResource, FacilityTaskResource } from 'kolibri.resources'; import { createTranslator } from 'kolibri.utils.i18n'; // Strings that might be shared among syncing-related UIs across plugins. @@ -61,5 +62,24 @@ export default { nickname: device_name, }).save(); }, + startKdpSyncTask(facilityId) { + return FacilityTaskResource.dataportalsync(facilityId).then(response => { + return response.data; + }); + }, + fetchKdpSyncTasks() { + return FacilityTaskResource.fetchCollection({ force: true }).then(tasks => { + return tasks.filter(task => (task.type = 'SYNCDATAPORTAL')); + }); + }, + cleanupKdpSyncTasks(tasks, cb) { + if (some(tasks, { type: 'SYNCDATAPORTAL', status: 'COMPLETED' })) { + return FacilityTaskResource.deleteFinishedTasks().then(() => { + if (cb) { + cb(); + } + }); + } + }, }, }; diff --git a/kolibri/core/assets/src/views/sync/ConfirmationRegisterModal.vue b/kolibri/core/assets/src/views/sync/ConfirmationRegisterModal.vue index 84645499b35..dcdbb8a9cca 100644 --- a/kolibri/core/assets/src/views/sync/ConfirmationRegisterModal.vue +++ b/kolibri/core/assets/src/views/sync/ConfirmationRegisterModal.vue @@ -2,7 +2,7 @@ { + this.$emit('success', this.targetFacility); this.submitting = false; }); }) diff --git a/kolibri/core/assets/src/views/sync/FacilityNameAndSyncStatus.vue b/kolibri/core/assets/src/views/sync/FacilityNameAndSyncStatus.vue index d7cf0f2a523..ebfd174d0c0 100644 --- a/kolibri/core/assets/src/views/sync/FacilityNameAndSyncStatus.vue +++ b/kolibri/core/assets/src/views/sync/FacilityNameAndSyncStatus.vue @@ -21,7 +21,7 @@
- @@ -49,12 +50,14 @@ import ContentIcon from 'kolibri.coreVue.components.ContentIcon'; import CoachContentLabel from 'kolibri.coreVue.components.CoachContentLabel'; import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; + import ChannelUpdateAnnotations from './ChannelUpdateAnnotations'; export default { name: 'ContentNodeRow', components: { CoachContentLabel, ContentIcon, + ChannelUpdateAnnotations, }, props: { node: { diff --git a/kolibri/plugins/facility/assets/src/modules/manageCSV/actions.js b/kolibri/plugins/facility/assets/src/modules/manageCSV/actions.js index 215df14f64b..7a3bca76b75 100644 --- a/kolibri/plugins/facility/assets/src/modules/manageCSV/actions.js +++ b/kolibri/plugins/facility/assets/src/modules/manageCSV/actions.js @@ -1,5 +1,5 @@ import logger from 'kolibri.lib.logging'; -import { TaskResource } from 'kolibri.resources'; +import { TaskResource, FacilityTaskResource } from 'kolibri.resources'; import client from 'kolibri.client'; import urls from 'kolibri.urls'; import { TaskStatuses, TaskTypes } from '../../constants'; @@ -95,10 +95,16 @@ function startExportUsers(store) { } function refreshTaskList(store) { - return TaskResource.fetchCollection({ - force: true, - }) - .then(newTasks => { + return Promise.all([ + TaskResource.fetchCollection({ + force: true, + }), + FacilityTaskResource.fetchCollection({ + force: true, + }), + ]) + .then(([newTasks, newFacilityTasks]) => { + console.log(newTasks); checkTaskStatus( store, newTasks, @@ -117,7 +123,7 @@ function refreshTaskList(store) { ); checkTaskStatus( store, - newTasks, + newFacilityTasks, TaskTypes.SYNCDATAPORTAL, store.state.facilityTaskId, 'START_FACILITY_SYNC', diff --git a/kolibri/plugins/facility/assets/src/modules/manageSync/index.js b/kolibri/plugins/facility/assets/src/modules/manageSync/index.js deleted file mode 100644 index 69904c8d997..00000000000 --- a/kolibri/plugins/facility/assets/src/modules/manageSync/index.js +++ /dev/null @@ -1,38 +0,0 @@ -import { displayModal, SET_BUSY, SET_ERROR, SET_MODAL } from '../shared'; - -function defaultState() { - return { - modalShown: false, - projectName: '', - targetFacility: null, - token: '', - }; -} - -export default { - namespaced: true, - state: defaultState(), - mutations: { - SET_STATE(state, payload) { - Object.assign(state, payload); - }, - RESET_STATE(state) { - Object.assign(state, defaultState()); - }, - SET_PROJECT_NAME(state, name) { - state.projectName = name; - }, - SET_TOKEN(state, token) { - state.token = token; - }, - SET_TARGET_FACILITY(state, facility) { - state.targetFacility = facility; - }, - SET_BUSY, - SET_ERROR, - SET_MODAL, - }, - actions: { - displayModal, - }, -}; diff --git a/kolibri/plugins/facility/assets/src/modules/pluginModule.js b/kolibri/plugins/facility/assets/src/modules/pluginModule.js index 5b45588f8f6..1c43895793f 100644 --- a/kolibri/plugins/facility/assets/src/modules/pluginModule.js +++ b/kolibri/plugins/facility/assets/src/modules/pluginModule.js @@ -6,7 +6,6 @@ import classManagement from './classManagement'; import facilityConfig from './facilityConfig'; import userManagement from './userManagement'; import manageCSV from './manageCSV'; -import manageSync from './manageSync'; import importCSV from './importCSV'; export default { @@ -53,7 +52,6 @@ export default { userManagement, facilityConfig, manageCSV, - manageSync, importCSV, }, }; diff --git a/kolibri/plugins/facility/assets/src/routes.js b/kolibri/plugins/facility/assets/src/routes.js index 1711437c68a..fd22f508915 100644 --- a/kolibri/plugins/facility/assets/src/routes.js +++ b/kolibri/plugins/facility/assets/src/routes.js @@ -95,7 +95,6 @@ export default [ path: '/:facility_id?/data', handler: () => { store.dispatch('preparePage', { isAsync: false }); - store.commit('manageSync/RESET_STATE'); }, }, { diff --git a/kolibri/plugins/facility/assets/src/views/DataPage/SyncInterface/index.vue b/kolibri/plugins/facility/assets/src/views/DataPage/SyncInterface/index.vue index 4163e7716d1..5ad99eb2abd 100644 --- a/kolibri/plugins/facility/assets/src/views/DataPage/SyncInterface/index.vue +++ b/kolibri/plugins/facility/assets/src/views/DataPage/SyncInterface/index.vue @@ -18,48 +18,48 @@ {{ $tr('facility') }} - - + + - + - + - + @@ -69,14 +69,15 @@