Skip to content

Commit

Permalink
Fix according to review
Browse files Browse the repository at this point in the history
Use ng-class, ng-attr-, ng-class, ng-href
Move urls from switch to object (pretty)
  • Loading branch information
ZitaNemeckova committed Mar 12, 2018
1 parent 20b0b88 commit b553931
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/widget-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ ManageIQ.angular.app.component('widgetFooter', {
template: [
'<div class="card-pf-footer">',
__('Updated'),
"{{vm.widgetLastRun}}",
'{{vm.widgetLastRun}}',
' | ',
__('Next'),
"{{vm.widgetNextRun}}",
'{{vm.widgetNextRun}}',
'</div>',
].join("\n"),
});
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/widget-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ManageIQ.angular.app.component('widgetMenu', {
' <div ng-if="vm.shortcutsMissing()">',
__('No shortcuts are authorized for this user, contact your Administrator'),
' </div>',
' <tr ng-if="!vm.shortcutsMissing()" ng-repeat="shortcut in vm.widgetModel.shortcuts">',
' <tr ng-repeat="shortcut in vm.widgetModel.shortcuts">',
' <td>',
' <a title="' + __("Click to go this location") + '" href="{{shortcut.href}}">',
' <a ng-attr-title="{{__("Click to go this location")}}" ng-href="{{shortcut.href}}">',
'{{shortcut.description}}',
' </a>',
' </td>',
Expand Down
24 changes: 12 additions & 12 deletions app/assets/javascripts/components/widget-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ ManageIQ.angular.app.component('widgetWrapper', {
controller: ['$http', 'miqService', '$sce', function($http, miqService, $sce) {
var vm = this;

var widgetTypeUrl = {
menu: '/dashboard/widget_menu_data/',
report: '/dashboard/widget_report_data/',
chart: '/dashboard/widget_chart_data/',
rss: '/dashboard/widget_rss_data/',
};

var deferred = miqDeferred();
vm.promise = deferred.promise;

Expand All @@ -37,17 +44,10 @@ ManageIQ.angular.app.component('widgetWrapper', {
};

vm.widgetUrl = function() {
switch (vm.widgetType) {
case 'menu':
return '/dashboard/widget_menu_data/' + vm.widgetId;
case 'report':
return '/dashboard/widget_report_data/' + vm.widgetId;
case 'chart':
return '/dashboard/widget_chart_data/' + vm.widgetId;
case 'rss':
return '/dashboard/widget_rss_data/' + vm.widgetId;
default:
console.log('Something went wrong. There is no support for widget type of ', vm.widgetType);
if (widgetTypeUrl.hasOwnProperty(vm.widgetType)) {
return [widgetTypeUrl[vm.widgetType], vm.widgetId].join('/');
} else {
console.log('Something went wrong. There is no support for widget type of ', vm.widgetType);
}
};
}],
Expand All @@ -65,7 +65,7 @@ ManageIQ.angular.app.component('widgetWrapper', {
' </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 }">',
' <div ng-if="vm.widgetBlank === \'true\' || vm.widgetModel" ng-attr-id="{{vm.innerDivId}}" ng-class="{ hidden: vm.widgetModel.minimized, mc:true }">',
' <widget-empty ng-if="vm.widgetBlank === \'true\'"></widget-empty>',
' <div ng-if="vm.widgetBlank === \'false\'" ng-switch on="vm.widgetType">',
' <widget-menu ng-switch-when="menu" widget-id="{{vm.widgetId}}" widget-model="vm.widgetModel">',
Expand Down

0 comments on commit b553931

Please sign in to comment.