Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create MVP UI for imports when background queue processing is taking place #25041

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Nov 24, 2022

Overview

Create acceptable UI for imports when background queue processing is taking place

BackGround queue processing requires three things

  1. enable civi-import core extension

  2. the setting to be enabled - eg.
    drush @dmaster cvapi Setting.create enableBackgroundQueue=1

  3. a job to run in the background processing the queue. In build-kit environments running coworker run from the site directory will generally work

The result of this is that the Import will run in the background and the user does not have to keep the browser tab open

Before

There is a placeholder screen

image

After

import

Technical Details

I decided to do an import-specific version of this in the import extension to avoid having to figure out larger issues around this & also to provide a space where the experience could be tailored to imports. This approach made removing this last blocker more manageable.

I think there is a lot of scope to improve wording but I left that out of scope for this commit. The main thing we probably want to communicate is that they can close the browser, bookmark the page & come back

Comments

The csv I used for testing is in this ext - https://github.com/eileenmcnaughton/testdata/tree/master/csvs

@civibot civibot bot added the master label Nov 24, 2022
@civibot
Copy link

civibot bot commented Nov 24, 2022

(Standard links)

@eileenmcnaughton eileenmcnaughton changed the title Create acceptable UI for when background queue processing is taking place Create acceptable UI for importswhen background queue processing is taking place Nov 24, 2022
@eileenmcnaughton eileenmcnaughton changed the title Create acceptable UI for importswhen background queue processing is taking place Create MVP UI for importswhen background queue processing is taking place Nov 24, 2022
@eileenmcnaughton eileenmcnaughton changed the title Create MVP UI for importswhen background queue processing is taking place Create MVP UI for imports when background queue processing is taking place Nov 24, 2022
Comment on lines 4 to 13
var target = '#crm-import-progress';
var url = CRM.vars.civiimport.url;
// Load the snippet into the container
CRM.loadPage(url, {
target: target,
block: false
})
window.setInterval(function() {
CRM.$(target).crmSnippet('refresh');
}, 1000);
Copy link
Member

@colemanw colemanw Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS code needs to be enclosed otherwise variables are in the global scope.

Suggested change
var target = '#crm-import-progress';
var url = CRM.vars.civiimport.url;
// Load the snippet into the container
CRM.loadPage(url, {
target: target,
block: false
})
window.setInterval(function() {
CRM.$(target).crmSnippet('refresh');
}, 1000);
CRM.$(function($) {
var target = '#crm-import-progress';
var url = CRM.vars.civiimport.url;
// Load the snippet into the container
CRM.loadPage(url, {
target: target,
block: false
});
window.setInterval(function() {
$(target).crmSnippet('refresh');
}, 1000);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @colemanw - I fixed this & retested it & it worked :-)

block: false
})
window.setInterval(function () {
CRM.$(target).crmSnippet('refresh');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of hits on the server. Best skip if the user isn't paying attention...

Suggested change
CRM.$(target).crmSnippet('refresh');
if (document.hasFocus()) {
CRM.$(target).crmSnippet('refresh');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh - good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This gives us a usable monitoring page for imports, without having to plan
out a solution that covers all potential use cases.

It should be a quick way to get this functionality operational
@seamuslee001 seamuslee001 merged commit f936e84 into civicrm:master Nov 28, 2022
@seamuslee001 seamuslee001 deleted the import_backgroup branch November 28, 2022 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants