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

EmsCloud dashboard #3427

Merged
merged 2 commits into from
Jul 25, 2018
Merged

Conversation

alexander-demicev
Copy link

@alexander-demicev alexander-demicev commented Feb 19, 2018

screen shot 2018-05-22 at 14 46 20

This PR adds dashboard for overcloud. Since this dashboard is similar to infra dashboard I moved some generic code from ems infra service to get rid of duplicates.

@himdel @martinpovolny Can you review?
@aufi @mansam Can you test?

@alexander-demicev
Copy link
Author

@miq-bot add_label dashboards, enhancement

@martinpovolny
Copy link
Member

@ZitaNemeckova, @h-kataria : you where involved with the dashboards, can you, please, review this PR?

Thx!

@martinpovolny
Copy link
Member

@alexander-demichev : there seems to be a number of issues from the linters. Can you fix that, please?

@ZitaNemeckova
Copy link
Contributor

It looks good in UI 👍 But I agree that js controllers should be de-duplicated. @alexander-demichev
Do you need help with where they should live or with 1% difference?

@alexander-demicev
Copy link
Author

@ZitaNemeckova Hi, I'm not good at JS, so if you have advice on how to make code better/deduplicate it, I will be happy to get it. :)

@himdel
Copy link
Contributor

himdel commented Feb 21, 2018

@alexander-demichev One thing we definitely need to change - you can't just copy a whole controller and change a few lines. We tried that once with topology, and now we have 5 incompatible implementations :).

The whole difference between EmsCloudHeatmapController and heatmapController is 1 url, 1 label and 2 key names in a hash. So, if you could keep just 1 heatmap controller with the differences passed in as params, please? :) Probably via ManageIQ.app.constant('name', {whatever}) so that you can inject it.

The same goes for the other components, with the added bonus that EmsInfra recentVmsLineChartController and recentHostsLineChartController are already the same thing - would you prefer to merge those too or should I? :)

Thanks :)

@alexander-demicev alexander-demicev force-pushed the emscloud-dashboard branch 5 times, most recently from 4e50770 to 97d513e Compare February 22, 2018 16:48
@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2018

This pull request is not mergeable. Please rebase and repush.

@himdel
Copy link
Contributor

himdel commented Jun 28, 2018

...and the value passed to lineChartTooltipPositionFactory must be unique as well.

@himdel
Copy link
Contributor

himdel commented Jun 28, 2018

--- a/app/assets/javascripts/components/recent-resource.js
+++ b/app/assets/javascripts/components/recent-resource.js
@@ -13,10 +13,14 @@ resentResourceController.$inject = ['miqService', '$q', '$http', 'chartsMixin'];
 function resentResourceController(miqService, $q, $http, chartsMixin) {
   var vm = this;
   this.$onInit = function() {
-    vm.id = "recentResourcesLineChart_" + vm.providerId;
+    vm.id = _.uniqueId("recentResourcesLineChart_" + vm.providerId);
     ManageIQ.angular.scope = vm;
     vm.loadingDone = false;
-    vm.config = chartsMixin.chartConfig.recentResourcesConfig;
+
+    vm.config = Object.assign({}, chartsMixin.chartConfig.recentResourcesConfig);
+    vm.config.chartId = _.uniqueId(vm.config.chartId);
+    vm.config.tooltip.position = vm.config.tooltip.position(vm.config.chartId);
+
     vm.timeframeLabel = __('Last 30 Days');
     vm.url = vm.url + vm.providerId;
     var resourcesDataPromise = $http.get(vm.url)
diff --git a/app/assets/javascripts/controllers/ems_common/charts-mixin.js b/app/assets/javascripts/controllers/ems_common/charts-mixin.js
index cbd774c03..1ee543940 100644
--- a/app/assets/javascripts/controllers/ems_common/charts-mixin.js
+++ b/app/assets/javascripts/controllers/ems_common/charts-mixin.js
@@ -76,7 +76,7 @@ angular.module('miq.util').factory('chartsMixin', ['$document', function($docume
       chartId: 'recentResourcesChart',
       tooltip: {
         contents: dailyTimeTooltip,
-        position: lineChartTooltipPositionFactory('recentResourcesChart'),
+        position: lineChartTooltipPositionFactory,
       },
       point: {r: 1},
       size: {height: 145},

works, but you may want to expose that lineChartTooltipPositionFactory in a saner way than overwriting the same field :)

@aufi
Copy link
Member

aufi commented Jun 28, 2018

Thanks @himdel 👍

@himdel
Copy link
Contributor

himdel commented Jun 28, 2018

np :)

Oh and one more thing... after all that is done, angular will complain that [ng:btstrpd] App already bootstrapped with this element '<recent-resource provider-id="17" url="/ems_cloud_dashboard/recent_instances_data/" class="ng-scope">.

That's because we're calling miq_bootstrap with just the element name, but calling it twice, because the element is there twice.

You may want to do something like this instead:

+- id = unique_html_id('recent-resource')
+
 %recent-resource{'provider-id' => @record.id,
-                 'url'         => '/ems_cloud_dashboard/recent_instances_data/'}
+                 'url'         => '/ems_cloud_dashboard/recent_instances_data/',
+                 'id'          => id}
 
 :javascript
-  miq_bootstrap('recent-resource');
+  miq_bootstrap('##{id}');

@alexander-demicev
Copy link
Author

@himdel Thanks for help! Can you check the code again?

@alexander-demicev
Copy link
Author

@terezanovotna
screen shot 2018-07-11 at 14 02 07

@terezanovotna
Copy link

@alexander-demichev Thanks for the screenshot! Can we capitalize OpenStack in the breadcrumbs? and not show (Dashboard)?

Looks good to me!

@alexander-demicev
Copy link
Author

@terezanovotna 'openstack' in breadcrumb is name that user provides, while adding cloud provider, so it can be any word :) and I think it's not possible to remove (Dashboard), as I see all breadcrumbs contain (Summary) or (Dashboard) at the end.

@miq-bot
Copy link
Member

miq-bot commented Jul 18, 2018

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jul 19, 2018

Checked commits alexander-demicev/manageiq-ui-classic@848d778~...03425cf with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
20 files checked, 4 offenses detected

**

  • 💣 💥 🔥 🚒 - Linter/Haml - Linter::Haml STDERR:
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.6-compliant syntax, but you are running 2.3.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

app/controllers/ems_cloud_dashboard_controller.rb

app/helpers/application_helper/toolbar/ems_cloud_center.rb

  • ❗ - Line 106, Col 5 - Layout/IndentArray - Use 2 spaces for indentation in an array, relative to the first position after the preceding left parenthesis.
  • ❗ - Line 123, Col 3 - Layout/IndentArray - Indent the right bracket the same as the first position after the preceding left parenthesis.

@himdel himdel added this to the Sprint 91 Ending Jul 30, 2018 milestone Jul 25, 2018
@himdel himdel merged commit 2fb280b into ManageIQ:master Jul 25, 2018
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 9, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 10, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 10, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 10, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 10, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 14, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 14, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 23, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 23, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Aug 23, 2018
The addition of #recent_records in the following PR:

    ManageIQ#3427

Introduced the following N+1 in the code:

* * *

The code would create an initial query of the following:

    SELECT "vms".*
    FROM "vms"
    WHERE "vms"."type" IN ('MiqTemplate', ...)
      AND "vms"."template"= 't'
      AND (created_on > '2018-07-10 20:47:40.460291' and ems_id = 1)

This means it fetches all of the `vms` table, which is 88 columns, for a
given EMS and date range.

From this is triggered by the `records.sort_by(&:created_on)` in the
previous code, since `sort_by` is just inherited from `Enumerable` in
Ruby's stdlib.  It then calls a `.uniq` on the records, and then
iterates over each record (I am pretty sure this `uniq` does not do
anything, but can't be sure).

In the code, we `strftime` then applied on to the only column that was
actually needed for every row returned (besides the id), and then a
subsequent query is executed on each record to get every record that
matches that date (forgetting to do the original sort by `ems.id` as
well)

All to return a hash that looks like this:

    {
      "2018-01-01" => 123,
      "2018-01-02" => 234,
      "2018-01-03" => 345,
    }

* * *

The code change does all of this, but in SQL, only returning from the DB
an array of 2 element arrays of the same hash as above, and then
converts that array into a hash.

This is done in a single query then, and only instantiates enough data
to then generate the hash, but 0 `ActiveRecord` objects are necessary.
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.

8 participants