-
Notifications
You must be signed in to change notification settings - Fork 356
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 wrapper for widget in Dashboard #3281
Conversation
3deda8f
to
a09044e
Compare
4287e38
to
6b5b2d0
Compare
@himdel please have a look, thanks :) |
%widget-wrapper{"widget-id" => presenter.widget.id, | ||
"widget-type" => presenter.widget.content_type, | ||
"widget-buttons" => presenter.widget_buttons, | ||
"widget_blank" => widget_blank, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
widget-blank
;)
}; | ||
}], | ||
template: [ | ||
'<div id="{{vm.divId}}">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ng-attr-id
for all those id={{..
please ;)
' </h2>', | ||
' </div>', | ||
' </div>', | ||
' <widget-error ng-if="vm.error === true"></widget-error>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace..
b1505a8
to
20b0b88
Compare
@miq-bot remove_label wip |
@karelhala please review, thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise looks good, however consider moving widget wrapper inside haml file and use angularTemplateUrl so we get HTML highlights.
Also @ZitaNemeckova it would be even better if this would have been moved to common pack if possible. So we get to use ES6 goodies and have more readable code.
template: [ | ||
'<div class="card-pf-footer">', | ||
__('Updated'), | ||
"{{vm.widgetLastRun}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use single quotes.
' <td>', | ||
' <a title="' + __("Click to go this location") + '" href="{{shortcut.href}}">', | ||
' </div>', | ||
' <tr ng-if="!vm.shortcutsMissing()" ng-repeat="shortcut in vm.widgetModel.shortcuts">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the ng-if
, if sortcuts has length of 0 ng-repeat
will repeat zero times.
' </div>', | ||
' <tr ng-if="!vm.shortcutsMissing()" ng-repeat="shortcut in vm.widgetModel.shortcuts">', | ||
' <td>', | ||
' <a title="' + __("Click to go this location") + '" href="{{shortcut.href}}">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use ng-attr-title
to make it more readable. Also use ng-href
so angular has time to work with it.
<a ng-attr-title="{{__("Click to go this location")}}" ng-href="{{shortcut.href}}">
' </div>', | ||
' <widget-error ng-if="vm.error === true"></widget-error>', | ||
' <widget-spinner ng-if="!vm.widgetModel && vm.widgetBlank == \'false\' && !vm.error"></widget-spinner>', | ||
' <div ng-if="vm.widgetBlank === \'true\' || vm.widgetModel" class="mc" id="{{vm.innerDivId}}" ng-class="{ hidden: vm.widgetModel.minimized }">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can join class and ng-class together and use ng-attr-id
so angular has time to work correctly:
<div ng-if="vm.widgetBlank === \'true\' || vm.widgetModel" ng-attr-id="{{vm.innerDivId}}" ng-class="{ hidden: vm.widgetModel.minimized, mc: true }">
ng-attr-id
} | ||
}; | ||
}], | ||
template: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to place this HTML inside static haml file and load is using template-url
?
vm.widgetUrl = function() { | ||
switch (vm.widgetType) { | ||
case 'menu': | ||
return '/dashboard/widget_menu_data/' + vm.widgetId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use constants for these strings.
var dashboard = 'dashboard';
var widgetTypes = {
menu: 'widget_menu_data';
report: 'widget_report_data';
chart: 'widget_chart_data';
rss: 'widget_rss_data';
}
// ...
var buildURL = function(type) {
return ['dashboard', type, vm.widgetId].join('/');
}
And use it inside widgetUrl
as
vm.widgetUrl = function() {
if(widgetTypes.hasOwnProperty(vm.widgetType)) {
return buildURL(widgetTypes[vm.widgetType]);
} else {
console.log('Something went wrong. There is no support for widget type of ', vm.widgetType);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferred to have a whole url to make it easier to find it. That's why it's not pretty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it still makes sense to use an object instead of a switch. But yes, please keep the whole url together, this will be a part of the component definition later.
b553931
to
cce9f3d
Compare
@karelhala Agreed but I would prefer to move it in follow-up PR. And for moving HTML from components to haml it breaks specs because haml isn't compiled. Otherwise I fixed it as you suggested. Thanks :) |
@karelhala : Can we merge this one? |
@martinpovolny sure go ahead, I forgot to mark is as OK. |
' </div>', | ||
' <tr ng-repeat="shortcut in vm.widgetModel.shortcuts">', | ||
' <td>', | ||
' <a ng-attr-title="{{__("Click to go this location")}}" ng-href="{{shortcut.href}}">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZitaNemeckova this was better as it used to be. You can't use __
inside of {{
. (And no reason to use ng-attr-title for a static string.)
(Or you need to do $scope.__ = __;
in this controller.)
template: [ | ||
'<div class="blank-slate-pf" style="padding: 10px">', | ||
' <div class="blank-slate-pf-icon">', | ||
' <i class="fa fa-spin fa-spinner"></i>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing 2 spaces ;)
just needed to include/mock all the dependencies and not use jquery selectors
cce9f3d
to
4495c35
Compare
' <td>', | ||
' <a title="' + __("Click to go this location") + '" href="{{shortcut.href}}">', | ||
' <a title="' +__("Click to go this location")+ '" ng-href="{{shortcut.href}}">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces
Use ng-class, ng-attr-, ng-class, ng-href Move urls from switch to object (pretty)
Mock missing setupVerticalNavigation function from PatternFly
4495c35
to
67cd442
Compare
Tried clicking on the "Zoom in" button...
So.. looks like you can't remove
|
Fixed issue with footer (see here) and same id warnings. |
Replace one partial call with widget-footer component, move lightbox-panel on same level as notification-app, move last_run and next_run to helper(no duplication of code) and fix same id warnings
998735a
to
0c94918
Compare
Checked commits ZitaNemeckova/manageiq-ui-classic@7b67b85~...0c94918 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 **
app/helpers/dashboard_helper.rb
|
LGTM, I can press all the buttons now :) The footer spacing around the " | " between the 2 dates changed a bit, but this is just less extra whitespace, no problem 👍 |
TODO:
GET
request failureError widget:
Spinner widget (it spins):
@miq-bot add_label wip, dashboards, gaprindashvili/no