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

Enable server-push using ActionCable #10965

Merged
merged 5 commits into from
Sep 7, 2016
Merged

Conversation

skateman
Copy link
Member

@skateman skateman commented Sep 2, 2016

This PR enables server-push in ManageIQ using ActionCable. The plan is to use it for asynchronous notifications displayed in the form of PatternFly toasts. This PR just implements a PoC solution, where the notifications are logged into the browser's JS console.

For testing it is necessary to run run cp config/cable.yml.sample config/cable.yml or re-run bin/setup. Then log in to the Web UI and open the browser's JavaScript console. Notifications can be emitted using a rails console in the following form:

ActionCable.server.broadcast("notifications_#{user_id}", message)

Where user_id is the numerical database ID of the logged in user and the message is an instance of a Hash object.

@isimluk
Copy link
Member

isimluk commented Sep 2, 2016

Ack. from backend perspective.

@@ -830,7 +830,9 @@ function miqAjaxAuth(url) {

// TODO API.autorenew is called on (non-login) page load - when?
})
.then(null, function() {
.then(function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

aah, can you do this in a separate .then? Because now failures from ws_init would be ignored..

@skateman
Copy link
Member Author

skateman commented Sep 2, 2016

@himdel check it out now

@@ -0,0 +1,23 @@
//= require action_cable

miqInitNotifications = function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

var miqInitNotifications = function () { or function miqInitNotifications() { please :)

delete sessionStorage.miq_token;
};

API.init = function() {
API.autorenew();
miqInitNotifications();
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels wrong to add something quite unrelated to API code since there's no real direct dependency.

Can you rewert the autorenew -> init change please and just call miqInitNotifications in application.html.haml?

Or move this init function outside the API code.

@miq-bot
Copy link
Member

miq-bot commented Sep 6, 2016

Checked commits skateman/manageiq@bd94c54~...ced4ed3 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
8 files checked, 1 offense detected

app/channels/application_cable/connection.rb

@skateman skateman changed the title [WIP] Enable server-push using ActionCable Enable server-push using ActionCable Sep 7, 2016
@skateman
Copy link
Member Author

skateman commented Sep 7, 2016

@himdel fixed, @miq-bot remove_label wip

@dclarizio dclarizio merged commit 81b8c15 into ManageIQ:master Sep 7, 2016
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.

6 participants