Repository navigation
mgr/dashboard: Dashboard info cards refactoring - #22902
Conversation
| @@ -0,0 +1,27 @@ | |||
| <div class="col-md-6"> | |||
There was a problem hiding this comment.
Having <div class="col-md-6"> inside the component template is very limiting. I recommend that this shoudl be declared outsite, by the one that uses the component:
<div class="col-md-6">
<cd-info-card ...
...
There was a problem hiding this comment.
I agree. I'll implement it.
epuertat
left a comment
There was a problem hiding this comment.
Great first step towards a more flexible landing page, Alfonso!
Please, have a look at the approach mentioned below. Tried to provide examples on how the component could be instantiated and fully initialized from the HTML template, instead of relying on TS initialization. This should save all the initialization boilerplate and a few other bits of code, and we could besides add new widgets without touching any TS code.
| </div> | ||
| <cd-info-card | ||
| *ngIf="monitorsCard" | ||
| [infoCard]="monitorsCard"> |
There was a problem hiding this comment.
What about making the info card parametrizable and exposing those params from the template:
<cd-info-card
[title]="Monitors"
[link]="/monitor"
[iconClass]="fa-database"
[info]='contentData.mon_status | monSummary'
></cd-info-card>| </cd-info-card> | ||
|
|
||
| <cd-info-card | ||
| *ngIf="osdCard" |
There was a problem hiding this comment.
<cd-info-card
[title]="OSDs"
[link]='/osd'
[iconClass]='fa-hdff'
[info]='contentData.mon_status | osdSummary'
></cd-info-card>| </div> | ||
| </div> | ||
| <cd-info-card | ||
| *ngIf="mdsCard" |
There was a problem hiding this comment.
<cd-info-card
[title]="Metadata Servers"
[iconClass]='fa-folder'
[info]='contentData.mon_status | mdsSummary'
></cd-info-card>| </cd-info-card> | ||
|
|
||
| <cd-info-card | ||
| *ngIf="mgrCard" |
There was a problem hiding this comment.
<cd-info-card
[title]="Managers"
[iconClass]='fa-cog'
[info]='contentData.mon_status | mgrSummary'
></cd-info-card>| </div> | ||
| </div> | ||
| <cd-info-card | ||
| *ngIf="healthStatusCard" |
There was a problem hiding this comment.
This first card is the trickiest one. One approach could be by-passing the HTML within the tags to the cd-info-card template (via tags):
<cd-info-card
[title]="Health"
[info]="contentData.health.status | healthColor"
>
<ul>
<li *ngFor="let check of contentData.health.checks">
<span [ngStyle]="check.severity | healthColor">{{ check.type }}</span>: {{ check.summary.message }}
</li>
</ul>
</cd-info-card>|
I agree with @epuertat and would even go 1 step further and remove the <cd-info-card [title]="Health">
<ng-container i18n>Overall status: </ng-container>
<span [ngStyle]="contentData.health.status | healthColor">{{ contentData.health.status }}</span>
<ul>
<li *ngFor="let check of contentData.health.checks">
<span [ngStyle]="check.severity | healthColor">{{ check.type }}</span>: {{ check.summary.message }}
</li>
</ul>
</cd-info-card><cd-info-card [title]="Pools">
<table class="table table-condensed">
...
</table>
</cd-info-card><cd-info-card [title]="Usage">
<table class="ceph-chartbox">
...
</table>
</cd-info-card> |
| @@ -17,6 +17,8 @@ import { OsdSummaryPipe } from './osd-summary.pipe'; | |||
| import { PgStatusStylePipe } from './pg-status-style.pipe'; | |||
| import { PgStatusPipe } from './pg-status.pipe'; | |||
|
|
|||
There was a problem hiding this comment.
Please remove this blank line.
| </fieldset> | ||
| </div> | ||
| </div> | ||
| <cd-info-card |
There was a problem hiding this comment.
we usually keep the first attribute in the same line of the element and align the following attributes in the column of the 1st attribute.
There was a problem hiding this comment.
I see.
But (only asking), is it not better for readability to have standard indentation (2-4 spaces) than indentation/alignment depending on tag length?
| </div> | ||
| </div> | ||
| <cd-info-card | ||
| *ngIf="healthStatusCard" |
There was a problem hiding this comment.
I think this could be simplified if you moved this verification inside CdInfoCard, that way you just need to declared it once.
|
|
||
| import { InfoCard } from '../info-card/info-card'; | ||
| import { InfoCardAdditionalInfo } from '../info-card/info-card-additional-info'; | ||
|
|
There was a problem hiding this comment.
Please remove this blank line.
We should have only 3 groups of imports (groups are separated by a blank line), 1 for @angular imports, another for external plugins and the last for our imports.
| @@ -4,6 +4,15 @@ import * as _ from 'lodash'; | |||
|
|
|||
| import { DashboardService } from '../../../shared/api/dashboard.service'; | |||
|
|
|||
There was a problem hiding this comment.
Please remove this blank line.
|
Hi @epuertat @tspmelo, |
|
@tspmelo My suggestion to @alfonsomthd was simply to open the component tag arguments, so cards could be stateless and fully characterized by their However, the idea to allow the interface to pass 'free-form' HTML tags/templating was just to cope with the current design, not to enforce that, as in my opinion it's better to move visual hinting (colors, formatting, etc.) to the widget's logic, being that the single responsibility for a widget (information representation). What about something like the following design (if anyone wants to modify it, please let me know and I'll share an editable link): |
epuertat
left a comment
There was a problem hiding this comment.
Thank you for taking into account my suggestions! Please, just ensure to check my minor comments and proceed as you consider, but you can count on my ok.
| </div> | ||
| </div> | ||
| </div> | ||
| <cd-info-card title="MONITORS" |
There was a problem hiding this comment.
Just a minor comment, but uppercase here would be just a style, so title could be 'Monitors' or even 'monitors', and then capitalize it in the component template:
{{ title | uppercase }}There was a problem hiding this comment.
I'm not in favor of forcing the uppercase. In fact, there are design proposals to move to "Monitors".
| </div> | ||
| </div> | ||
| <cd-info-card title="MONITORS" | ||
| class="col-md-6" |
There was a problem hiding this comment.
If col-md-6 seems to be the default one, why not overriding it, or setting it as default:
@Input() class: string = 'col-md-6';There was a problem hiding this comment.
I'll implement it.
By setting it at selector level I was trying to avoid an additional enclosing < div > (needed to respect the current look and feel).
It would also be good to define if the project style guide contains "Convention over configuration" (e.g. providing sensible default values as much as possible)
in order for all contributors to follow the same coding style.
There was a problem hiding this comment.
Love that 'convention over configuration'! Not sure if there's a style guide for Ceph (only could find this). This might be an interesting topic to discuss!
| @@ -0,0 +1,18 @@ | |||
| <div [class]="class"> | |||
| <div class="well"> | |||
There was a problem hiding this comment.
We can add a class (eg. class = "info-card") and put all scss inside it. Example
.info-card{
.center-block{...
...
}
You can still achieve that if you pass free form html. @epuertat I like your proposed design. Should we implement that in this PR or wait for the redesign of the health page with all the new cards? @alfonsomthd If we don't implement @epuertat suggestion, I would suggest to also wrap the |
| selector: 'cd-info-card', | ||
| templateUrl: './info-card.component.html', | ||
| styleUrls: ['./info-card.component.scss'], | ||
| encapsulation: ViewEncapsulation.None, |
There was a problem hiding this comment.
Please don't use this encapsulation.
This will result in the css from this component to be applied to the whole document.
|
@alfonsomthd We don't need to create new components in order to use the |
|
@alfonsomthd Please add a title to the commit with a brief summary. |
…g page: Info encapsulated in cd-info-card selector: - Overall health status, MON/OSD/MDS/MGR status Fixes: https://tracker.ceph.com/issues/24778 Signed-off-by: Alfonso Martínez <[email protected]>

Refactor:
Create common Card component for info shown in landing page:
This will bring a common template and will be easier for maintain and refactor landing page in the future.
Fixes: https://tracker.ceph.com/issues/24778