Skip to content

Commit

Permalink
Merge pull request #8331 from jredrejo/feedback_hacking_session
Browse files Browse the repository at this point in the history
Fix syncing when password-less flow is enabled
  • Loading branch information
bjester authored Aug 19, 2021
2 parents 366b49c + b82bb69 commit 17edb21
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
4 changes: 3 additions & 1 deletion kolibri/plugins/device/assets/src/views/syncTaskUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export function syncFacilityTaskDisplayInfo(task) {
description: statusDescription,
});
} else {
statusMsg = statusDescription;
if (task.type === TaskTypes.SYNCLOD && task.status === TaskStatuses.FAILED)
statusMsg = `${statusDescription}: ${task.exception}`;
else statusMsg = statusDescription;
}

if (task.status === TaskStatuses.COMPLETED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import PasswordTextbox from 'kolibri.coreVue.components.PasswordTextbox';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import commonSyncElements from 'kolibri.coreVue.mixins.commonSyncElements';
import { ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants';
import { DemographicConstants, ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants';
import CatchErrors from 'kolibri.utils.CatchErrors';
import OnboardingForm from '../onboarding-forms/OnboardingForm';
import { FacilityImportResource, SetupSoUDTasksResource } from '../../api';
Expand Down Expand Up @@ -151,20 +151,23 @@
},
handleSubmit() {
const task_name = 'kolibri.plugins.setup_wizard.tasks.startprovisionsoud';
const password = this.password === '' ? DemographicConstants.NOT_SPECIFIED : this.password;
const params = {
baseurl: this.device.baseurl,
username: this.username,
password: this.password,
password: password,
facility_id: this.facility.id,
device_name: this.device.name,
};
SetupSoUDTasksResource.createTask(task_name, params)
.then(task => {
task['device_id'] = this.device.id;
task['facility_name'] = this.facility.name;
this.lodService.send({
type: 'CONTINUE',
value: {
username: this.username,
password: this.password,
password: password,
full_name: task.full_name,
task: task,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import commonSyncElements from 'kolibri.coreVue.mixins.commonSyncElements';
import FacilityTaskPanel from '../../../../../device/assets/src/views/FacilitiesPage/FacilityTaskPanel.vue';
import WelcomeModal from '../../../../../device/assets/src/views/WelcomeModal.vue';
import { TaskStatuses, TaskTypes } from '../../../../../device/assets/src/constants.js';
import { TaskStatuses } from '../../../../../device/assets/src/constants.js';
import OnboardingForm from '../onboarding-forms/OnboardingForm';
import { SetupSoUDTasksResource } from '../../api';
Expand All @@ -77,7 +77,7 @@
mixins: [commonCoreStrings, commonSyncElements],
data() {
return {
loadingTask: {},
loadingTask: this.state.value.task,
isPolling: false,
welcomeModal: false,
user: null,
Expand All @@ -86,9 +86,12 @@
inject: ['lodService', 'state'],
computed: {
usersDevice() {
const users = this.state.value.users.filter(user => user.task === null);
const users = this.state.value.users.filter(u => u.task === null);
return users;
},
loadingTaskID() {
return this.state.value.task.id;
},
facility() {
return this.state.value.facility;
},
Expand All @@ -98,22 +101,25 @@
this.pollTask();
},
methods: {
fullName(task_id) {
const user = this.state.value.users.filter(u => u.task == task_id)[0];
this.user = user;
return user.full_name;
userForTask() {
return this.state.value.users.filter(u => u.task == this.loadingTaskID)[0];
},
pollTask() {
SetupSoUDTasksResource.fetchCollection({ force: true }).then(tasks => {
const soudTasks = tasks.filter(t => t.type === TaskTypes.SYNCLOD);
const soudTasks = tasks.filter(t => t.id == this.loadingTaskID);
if (soudTasks.length > 0) {
if (this.user === null) this.user = this.userForTask();
this.loadingTask = {
...soudTasks[0],
facility_name: this.facility.name,
full_name: this.fullName(soudTasks[0].id),
device_id: this.state.value.device.id,
facility_name: this.loadingTask.facility_name,
full_name: this.loadingTask.full_name,
device_id: this.loadingTask.device_id,
};
if (this.loadingTask.status === TaskStatuses.COMPLETED) this.finishedTask();
if (this.loadingTask.status === TaskStatuses.FAILED) {
this.state.value.users.pop();
this.isPolling = false;
}
} else this.isPolling = false;
});
if (this.isPolling) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
};
SetupSoUDTasksResource.createTask(task_name, params)
.then(task => {
task['device_id'] = this.device.id;
task['facility_name'] = this.facility.name;
this.lodService.send({
type: 'CONTINUE',
value: {
Expand Down

0 comments on commit 17edb21

Please sign in to comment.