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

Angular infra dashboards #1901

Merged
merged 18 commits into from Oct 16, 2017
Merged

Conversation

h-kataria
Copy link
Contributor

@h-kataria h-kataria commented Aug 14, 2017

@h-kataria
Copy link
Contributor Author

@himdel please review/suggest how to convert this PR to Angular 2.

@himdel
Copy link
Contributor

himdel commented Sep 25, 2017

@h-kataria Oh, this looks really close now :) 👍

One note.. you probably can't use id in bindings, or rather, you can, but it's confusing whether it's meant as a browser element id or a component-dependent value .. can you rename those to something a bit more descriptive? (Like widget-id maybe? Or is it ems-id?)

Oh, and is patternfly.card the right module? Feels weird to create components in a module we don't own, unless this is really a future patternfly component.. (doesn't matter in practice, just looks surprising :)).

As for angular2 .. We would need to make that whole screen (well, the right cell anyway) an Angular 2 app (that should come first, otherwise you can't use the components) .. then those components should be useable via ngUpgrade as they are now... And once that is working, the actual component conversion should be relatively trivial...

angular.module( 'patternfly.card' ).component('pfAggregateStatusCard', {
  bindings: {
    status: '=',
    showTopBorder: '@?',
    altLayout: '@?',
    layout: '@?'
  },
  templateUrl: '/static/pf_charts/aggregate-status-card.html.haml',
  controller: function () {
    'use strict';
    var vm = this;
    vm.$onInit = function () {
      vm.shouldShowTopBorder = (vm.showTopBorder === 'true');
      vm.isAltLayout = (vm.altLayout === 'true' || vm.layout === 'tall');
      vm.isMiniLayout = (vm.layout === 'mini');
    };
  }
});

would become..

@Component({
  selector: 'pf-aggregate-status-card',
  templateUrl: '/static/pf_charts/aggregate-status-card.html.haml',
  inputs: [ 'status', 'showTopBorder', 'altLayout', 'layout' ],
})
class pfAggregateStatusCard {
  ngOnInit() {
    this.shouldShowTopBorder = (vm.showTopBorder === 'true');
    this.isAltLayout = (vm.altLayout === 'true' || vm.layout === 'tall');
    this.isMiniLayout = (vm.layout === 'mini');
  }
}

and that's pretty much it.. :)

+- unexpected stuff :)

If you wanted to go full typescript right away, you'd also need...

class pfAggregateStatusCard implements OnInit {
  private status: string;
  private showTopBorder: string?;
  private altLayout: string?;
  private layout: string?;

To indicate the types and required/optional for those fields, and to mention it implements the ngOnInit function.


Oh.. and templates.. Right now, we can't have an angular2 template in haml - there's a haml extension for angular2, which works with haml but not hamlit.... Alternatively we could use the JS haml-loader and use template: require('path') instead of that templateUrl... but that means the haml conversion would happen during webpack, in JS code, so we could no longer use i18n there..

That's something I need to look into still... If you wanted to do the angular2 version right away, the only option is html, not haml.

(Unless the only logic in that template is {{foo}} .. in that case, haml is fine.. it just can't quite handle attributes names like (foo) or [bar], etc.)


IMO it still feels like we're not quite there yet with angular2 and I'd rather merge this as an angular 1 dashboard that works, but if it can wait... (Or if you want to solve those issues yourself :).)

@h-kataria h-kataria removed the wip label Sep 25, 2017
@h-kataria h-kataria changed the title [WIP] - Angular infra dashboards Angular infra dashboards Sep 25, 2017
@h-kataria
Copy link
Contributor Author

@himdel can you please point out which id were you referencing to in your comment.

About your comment on usage of patterfly.card yes that's the correct module and usage as far as i could tell from several examples here of different patternfly component usages in AngularJS http://www.patternfly.org/pattern-library/cards/aggregate-status-card/#/code/angular, maybe there is a way to include patternfly globally, i am unsure.

@h-kataria h-kataria force-pushed the angular_infra_dashboards branch 3 times, most recently from 1459d4e to ccca920 Compare September 28, 2017 18:56
@h-kataria
Copy link
Contributor Author

@martinpovolny @himdel i would like to get this PR merged and do any other suggested changes as a follow up PR, please review/merge.

@himdel
Copy link
Contributor

himdel commented Oct 2, 2017

@h-kataria sorry for the delay..

@himdel can you please point out which id were you referencing to in your comment.

Every time you write <component id=...> and mean something different by id than browser element id.

So.. <component id="foo_component_1"> is probably fine, but <component id="#{@record.id}"> sounds like a case where you probably didn't want to search for that element via $('#1000000002345') and so should call that record-id instead (or something).

But looks like you found them all .. only https://github.com/ManageIQ/manageiq-ui-classic/pull/1901/files#diff-1089af45db5ae37204a2abb2310cf1b0R8 remains :).

About your comment on usage of patterfly.card yes that's the correct module and usage as far as i could tell from several examples here of different patternfly component usages in AngularJS http://www.patternfly.org/pattern-library/cards/aggregate-status-card/#/code/angular, maybe there is a way to include patternfly globally, i am unsure.

I mean, it's OK to use them :). I was just concerned we're creating new components and pretending they're from patternfly.. but not a blocker either way :).

@martinpovolny
Copy link

martinpovolny commented Oct 3, 2017

So.. is probably fine, but sounds like a case where you probably didn't want to search for that element via $('#1000000002345') and so should call that record-id instead (or something).

But! The QE would be actually happy if you created some IDs that would have a relation to the entities being displayed. Such as <component id="component_#{@record.id}">. Such markup would help them write tests ;-)

Ping @mfalesni

@h-kataria
Copy link
Contributor Author

@martinpovolny addressed your comment regarding adding ids for each component

@martinpovolny
Copy link

@h-kataria : just glanced over the CC issues, many are trivial to fix.

- Changed dashboard service calls to send up individual calls to build charts
- some code cleanup to remove dummy heatmap data setup

https://www.pivotaltracker.com/story/show/150048620
And other components that are needed to show Global Utilization charts: c3Chart, donutChart, donutPctChart, sparklineChart components along with their counterpart controllers, templates etc.
And Line chart component and related controllers, template, views to display Recent Hosts & Recent VMs line charts.
- Removed unused old code and moved files appropriately under ems_infra_dashboard directory
- Addressed some rubocop warning in ems_infra_dashboard_service

https://www.pivotaltracker.com/story/show/150048620
Addressed syntax related code climate warnings that were brought over by downloading patternfly components from patternfly repo.

https://www.pivotaltracker.com/story/show/147962059
Added unique id for each component that can be referenced in QE tests

https://www.pivotaltracker.com/story/show/147962059
@himdel
Copy link
Contributor

himdel commented Oct 11, 2017

@h-kataria I've found the source of the bug...

previously, pf-line-chart would never go without a ng-if="loadingDone".

Now, only heatmap does that, so the others need a similar bit of code as well.

(And yes, this could be considered a PF bug, but right now, we have to fix it :).)

Added loadingDone checks to make sure to load charts once data is available

https://www.pivotaltracker.com/story/show/147962059
@h-kataria
Copy link
Contributor Author

@himdel thx for your help on getting Error: url or json or rows or columns is required. error fixed. Please re-test/re-review. I think i have all the issues addressed now. @epwinchell is working on styling changes, we should have those soon.

@epwinchell
Copy link
Contributor

epwinchell commented Oct 12, 2017

@martinpovolny Could you have a look at what needs to be done to make the charts resize inside the cards like the main dashboard and cap & u charts? (The donut charts may be an exception) Thanks.

@martinpovolny
Copy link

@martinpovolny Could you have a look at what needs to be done to make the charts resize inside the cards like the main dashboard and cap & u charts? (The donut charts may be an exception) Thanks.

I searched the history and believe that what I did is gone with the last bits of jqplot. It must have been somehow redone for C3, but that was not me (or I don't remember). Ping @PanSpagetka, Robin, can you answer this, please?

@miq-bot
Copy link
Member

miq-bot commented Oct 14, 2017

Checked commits h-kataria/manageiq-ui-classic@e9b3ee8~...d663770 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
11 files checked, 17 offenses detected

app/views/ems_infra/_aggregate-status-card.html.haml

  • ⚠️ - Line 7 - Line is too long. [165/160]
  • ⚠️ - Line 7 - Space missing after comma.

app/views/ems_infra/_heatmap.html.haml

  • ⚠️ - Line 9 - Line is too long. [412/160]

app/views/ems_infra/_recent-hosts-line-chart.html.haml

  • ⚠️ - Line 7 - Line is too long. [244/160]

app/views/ems_infra/_recent-vms-line-chart.html.haml

  • ⚠️ - Line 7 - Line is too long. [244/160]

app/views/ems_infra/_utilization-trend-chart.html.haml

  • ⚠️ - Line 15 - Redundant curly braces around a hash parameter.
  • ⚠️ - Line 9 - Space found before comma.

app/views/static/pf_charts/aggregate-status-card.html.haml

  • ⚠️ - Line 12 - Line is too long. [172/160]
  • ⚠️ - Line 13 - Line is too long. [162/160]
  • ⚠️ - Line 2 - Line is too long. [201/160]
  • ⚠️ - Line 33 - Line is too long. [178/160]
  • ⚠️ - Line 48 - Line is too long. [182/160]
  • ⚠️ - Line 51 - Line is too long. [165/160]
  • ⚠️ - Line 57 - Line is too long. [164/160]

app/views/static/pf_charts/donut-pct-chart.html.haml

  • ⚠️ - Line 2 - Line is too long. [167/160]

app/views/static/pf_charts/utilization-trend-chart.html.haml

  • ⚠️ - Line 18 - Line is too long. [178/160]
  • ⚠️ - Line 22 - Line is too long. [233/160]

@himdel
Copy link
Contributor

himdel commented Oct 16, 2017

so..another round of ui testing..

  • the single provider logo is consistently smaller now

untitled

EDIT: but it matches the PF style 👍

  • the clusters/hosts/vms... bar now uses black icons not blue, and those are visible even when the number is 0 (on master, they were visible only when nonzero)

icons

EDIT: black is right, the the icon being always visible makes more sense anyway 👍

  • it also says "0 Cluster" instead of "0 Clusters"

cluster

  • the clusters/hosts/vms... bar sometimes shows different labels and/or different things

bar

EDIT: but deployment role is the same thing as cluster, except different name

  • cluster utilization is larger when no data

cluster-util

EDIT: but does not break anything 👍

  • global utilization never has any data, even though it should

global-util

EDIT: this is caused by the difference in date range .. 30.days.ago 👍 (https://github.com/ManageIQ/manageiq-ui-classic/pull/1901/files#diff-482f2c40348265e920c212dd5ba8e8a4R161)

@epwinchell
Copy link
Contributor

epwinchell commented Oct 16, 2017

the clusters/hosts/vms... bar now uses black icons not blue..

@himdel This is correct Patternfly. Containers, specifically styled theirs blue.

https://rawgit.com/patternfly/patternfly/master-dist/dist/tests/cards.html
http://www.patternfly.org/pattern-library/dashboard/dashboard-layout/

@himdel
Copy link
Contributor

himdel commented Oct 16, 2017

So, any remaning problems are not really that important, merging..

@himdel himdel merged commit fd0d087 into ManageIQ:master Oct 16, 2017
@himdel himdel added this to the Sprint 71 Ending Oct 16, 2017 milestone Oct 16, 2017
@h-kataria h-kataria deleted the angular_infra_dashboards branch October 24, 2017 03:30
$q.all([promiseProviderData]).then(function() {
vm.status = {
// "title": vm.provider.name,
"iconImage": "/assets/svg/vendor-" + getIcon(vm.provider.type) + ".svg",
Copy link
Contributor

@himdel himdel May 15, 2018

Choose a reason for hiding this comment

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

This does not work outside the development enrionment.

Image paths must be created using the image_path helper, ruby-side

(noticed the same problem in #3806)

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.

None yet

7 participants