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

Add Monitoring main navigation section, with Alert sections #507

Merged
merged 15 commits into from
Mar 7, 2017

Conversation

moolitayer
Copy link

@moolitayer moolitayer commented Feb 28, 2017

Depends on [MERGED] ManageIQ/manageiq#14096 Adding the new setting

Closes #254

@moolitayer moolitayer changed the title Icon endpoint Add Icon endpoint and hide monitor section by default Feb 28, 2017
@@ -0,0 +1,38 @@
class AlertsListController < ApplicationController
extend ActiveSupport::Concern
include UiServiceMixin
Copy link
Author

Choose a reason for hiding this comment

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

@himdel This probably shouldn't be here, should I create a service for it?

@moolitayer moolitayer force-pushed the icon_endpoint branch 2 times, most recently from 4235661 to 92eedff Compare February 28, 2017 14:38
.then(function() {
return _this.getAlertsData(limit, offset, filters, sortField, sortAscending);
});
};

_this.updateHostIcons = function(response) {
Copy link
Contributor

@himdel himdel Feb 28, 2017

Choose a reason for hiding this comment

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

I'd simplify this to just..

_this.updateHostIcons = function(response) {
  return $http.get('/alerts_list/class_icons')
    .then(function(response) {
      _this.hostIcons = response.data;
      return response;
    });
};

@@ -1,5 +1,6 @@
class AlertsListController < ApplicationController
extend ActiveSupport::Concern
include UiServiceMixin
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this is being used here?

Copy link
Author

Choose a reason for hiding this comment

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

It is used for icons

Copy link
Contributor

@himdel himdel Feb 28, 2017

Choose a reason for hiding this comment

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

Aaah... missed that.. in that case, are you sure that's the right place?

Because .. that's not a list of all available icons (or classes), that's just a list of things that are shown in one of the topology views.

Any chance the UI can ask for a list of classes instead?

def class_icons
res = {}
icons.each do |k, _val|
file_name = "100/#{k.to_s.underscore}.png"
Copy link
Contributor

Choose a reason for hiding this comment

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

this line would be better as k.decorate.listicon_image (assuming k is the class) .. but you'd need to add this method to the relevant decorators... so up to you.

But if you leave this like this, can you mention the list of classes that you're expecting to pass through here please? (So that it's easier to fix after.)

Copy link
Author

Choose a reason for hiding this comment

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

That would be nice and allow me to simplify code a bit, is decorate available for classes too or only instances? I can't seem to use it

Copy link
Contributor

Choose a reason for hiding this comment

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

It is available now :) (You need current master for both manageiq and ui-classic)

Then to use it, all you have to do is add a static method to the relevant decorator...

So you'd go to MiqPolicyDecorator for example, add something like def self.listicon_image; "100/miq_policy.png"; end .. aaand then MiqPolicy.decorate.listicon_image will work.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Don't worry too much about having the method there twice (once class once instance), we were talking about doing something like defaulting to the class method unless the instance method needs to exist because the icon depends on some state, but for now... shrug :).)

Copy link
Author

Choose a reason for hiding this comment

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

uploaded a new version, still haven't convinced it to work tough...
I keep getting:

[----] F, [2017-02-28T20:19:32.671115 #5014:2f04e3c] FATAL -- : Error caught: [NoMethodError] undefined method `listicon_image' for #<Draper::CollectionDecorator:0x0000000b7d4280>
/home/mtayer/dev/manageiq-ui-classic/app/controllers/alerts_list_controller.rb:22:in `block in class_icons'

I'll try to rebase the client code as well tomorrow

Copy link
Contributor

Choose a reason for hiding this comment

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

..for #<Draper::CollectionDecorator..

That's a dead giveaway that you have not updated ManageIQ ;)

@himdel
Copy link
Contributor

himdel commented Feb 28, 2017

@moolitayer nice work, completely agreed with the approach, just found a few details.. :)

@moolitayer
Copy link
Author

moolitayer commented Feb 28, 2017

Thanks for the review @himdel! addressed comments.

@moolitayer moolitayer force-pushed the icon_endpoint branch 3 times, most recently from 625f0fa to d981fd7 Compare March 1, 2017 09:36
@moolitayer
Copy link
Author

@himdel cool, working now, thanks.
Also I had to rebase @jeff-phillips-18's stuff, so maybe now it would be better to merge this one when we finish code review

@moolitayer
Copy link
Author

@miq-bot add_label "pending core", enhancement, euwe/no

@miq-bot
Copy link
Member

miq-bot commented Mar 1, 2017

@moolitayer Cannot apply the following label because they are not recognized: "pending core"

@simon3z
Copy link
Contributor

simon3z commented Mar 1, 2017

@moolitayer if this is supposed to replace #254 isn't the title of the PR misleading?

@simon3z
Copy link
Contributor

simon3z commented Mar 1, 2017

@miq-bot assign moolitayer

@moolitayer moolitayer changed the title Add Icon endpoint and hide monitor section by default Add Monitoring main navigation section, with Alert sections Mar 1, 2017
@moolitayer
Copy link
Author

@moolitayer if this is supposed to replace #254 isn't the title of the PR misleading?

Updated the title

@@ -0,0 +1,5 @@
class ContainerNodeDecorator < MiqDecorator
def self.listicon_image
ActionController::Base.helpers.image_path("100/container_node.png")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep this in line with the rest.. listicon_image never calls image_path, only returns the string.

It's the caller's responsibility to call image_path.

Copy link
Author

Choose a reason for hiding this comment

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

sorry, fixed

@@ -16,6 +16,14 @@ def index
redirect_to :action => 'show'
end

def class_icons
res = {}
['ManageIQ::Providers::Kubernetes::ContainerManager::ContainerNode'].each do |klass|
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, is this really always just this one class?

Or are we expecting more to be added?

deferred.resolve(response);
});
return deferred.promise;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

... I guess you forgot to remove the original version? I'm seeing updateHostIcons twice now.

return $http.get('/alerts_list/class_icons')
.then(function(response) {
_this.hostIcons = response.data;
return response;
Copy link
Contributor

@himdel himdel Mar 1, 2017

Choose a reason for hiding this comment

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

extra space ;) (one too many now)

}

summaryItem.objectType = objectType.replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
summaryItem.objectTypeImg = path + 'vendor-' + summaryItem.objectType + suffix;
Copy link
Member

Choose a reason for hiding this comment

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

This path needs to come from the server as well I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, same problem :)

@moolitayer
Copy link
Author

@jeff-phillips-18 would it be possible for you to address the comments still outstanding from @himdel ?
I don't understand the topics. If not let me know I will try to figure them out (event part of them is good)

@jeff-phillips-18
Copy link
Member

@moolitayer I have put up a PR to your branch with fixes for the outstanding issues.

@moolitayer
Copy link
Author

Thanks @jeff-phillips-18 ! I guess I could have done the same thing instead of creating this PR. Next time...

@moolitayer
Copy link
Author

@himdel Ready for another review!

@himdel
Copy link
Contributor

himdel commented Mar 6, 2017

@moolitayer So.. how do I enable the feature? Adding :monitoring: true under :product as usual didn't work.

@moolitayer
Copy link
Author

moolitayer commented Mar 6, 2017

@himdel use

:prototype:
  :monitoring: true

(the name was discussed in ManageIQ/manageiq#14096)

@himdel
Copy link
Contributor

himdel commented Mar 7, 2017

Tested in the UI, looks good 👍, except for the sopLink link, which always has an empty href now. (href vs ng-href I expect).

Will merge when fixed :)

EDIT: aaand fixed :) ($parent.$parent.item is not great, but needs fixing on the patternfly side)
..waiting for green travis..

@miq-bot
Copy link
Member

miq-bot commented Mar 7, 2017

Checked commits moolitayer/manageiq-ui-classic@dc62746~...4e3dd03 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
11 files checked, 0 offenses detected
Everything looks good. 🏆

@himdel himdel added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 7, 2017
@himdel himdel merged commit d0e63ae into ManageIQ:master Mar 7, 2017
@moolitayer
Copy link
Author

@himdel Thank you very much for the fast responses and vigilant review! 🍺

@jeff-phillips-18 🎉

@himdel
Copy link
Contributor

himdel commented Mar 7, 2017

🙇‍♂️ :)

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.

5 participants