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
mgr/dashboard: remove daemon list for badges #46565
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,13 +1,11 @@ | ||||||
<cd-table [data]="data" | ||||||
columnMode="flex" | ||||||
[columns]="columns" | ||||||
[autoReload]="-1" | ||||||
(fetchData)="refresh()" | ||||||
[status]="tableStatus"> | ||||||
</cd-table> | ||||||
<ng-container *ngIf="empty"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to cache data yourself. Angular works better when you check the data you want. Angular does the memoization for you.
Suggested change
|
||||||
<strong class="text-danger" | ||||||
i18n>There are no daemons</strong> | ||||||
</ng-container> | ||||||
|
||||||
<ng-template #healthTmpl | ||||||
let-row="row" | ||||||
let-value="value"> | ||||||
<span [ngClass]="row.health_color | mirrorHealthColor">{{ value }}</span> | ||||||
</ng-template> | ||||||
<ng-container *ngFor="let daemon of daemons | keyvalue"> | ||||||
<span *ngIf="daemon.value > 0" | ||||||
[ngClass]="daemon.key | mirrorHealthColor" | ||||||
class="m-1" | ||||||
i18n>{{daemon.value}} {{daemonStatus(daemon.key)}}</span> | ||||||
Pegonzal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
</ng-container> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,7 +4,6 @@ import { Subscription } from 'rxjs'; | |||||
|
||||||
import { RbdMirroringService } from '~/app/shared/api/rbd-mirroring.service'; | ||||||
import { TableStatusViewCache } from '~/app/shared/classes/table-status-view-cache'; | ||||||
import { CephShortVersionPipe } from '~/app/shared/pipes/ceph-short-version.pipe'; | ||||||
|
||||||
@Component({ | ||||||
selector: 'cd-mirroring-daemons', | ||||||
|
@@ -17,46 +16,40 @@ export class DaemonListComponent implements OnInit, OnDestroy { | |||||
|
||||||
subs: Subscription; | ||||||
|
||||||
data: []; | ||||||
columns: {}; | ||||||
data: any[]; | ||||||
daemons: {}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's name things clearly: this is count/histogram of the daemon statuses, not the daemons themselves. Additionally, a proper type should be here
Suggested change
Or: enum DaemonStatus {
up,
down,
}
let countDaemon: {[Key in DaemonStatus as string]: number} = {up: 1, down: 2}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I Will do it. I'll be more careful with the naming |
||||||
empty: boolean; | ||||||
|
||||||
tableStatus = new TableStatusViewCache(); | ||||||
|
||||||
constructor( | ||||||
private rbdMirroringService: RbdMirroringService, | ||||||
private cephShortVersionPipe: CephShortVersionPipe | ||||||
) {} | ||||||
constructor(private rbdMirroringService: RbdMirroringService) { | ||||||
this.empty = false; | ||||||
} | ||||||
|
||||||
ngOnInit() { | ||||||
this.columns = [ | ||||||
{ prop: 'instance_id', name: $localize`Instance`, flexGrow: 2 }, | ||||||
{ prop: 'id', name: $localize`ID`, flexGrow: 2 }, | ||||||
{ prop: 'server_hostname', name: $localize`Hostname`, flexGrow: 2 }, | ||||||
{ | ||||||
prop: 'version', | ||||||
name: $localize`Version`, | ||||||
pipe: this.cephShortVersionPipe, | ||||||
flexGrow: 2 | ||||||
}, | ||||||
{ | ||||||
prop: 'health', | ||||||
name: $localize`Health`, | ||||||
cellTemplate: this.healthTmpl, | ||||||
flexGrow: 1 | ||||||
} | ||||||
]; | ||||||
|
||||||
this.subs = this.rbdMirroringService.subscribeSummary((data) => { | ||||||
this.data = data.content_data.daemons; | ||||||
this.tableStatus = new TableStatusViewCache(data.status); | ||||||
this.daemons = this.countDaemons(); | ||||||
}); | ||||||
} | ||||||
|
||||||
ngOnDestroy(): void { | ||||||
this.subs.unsubscribe(); | ||||||
} | ||||||
|
||||||
refresh() { | ||||||
this.rbdMirroringService.refresh(); | ||||||
countDaemons(): {} { | ||||||
const daemon_states = { info: 0, error: 0, warning: 0, success: 0 }; | ||||||
this.empty = this.data.length > 0 ? false : true; | ||||||
for (let i = 0; i < this.data.length; i++) { | ||||||
const health_color = this.data[i]['health_color']; | ||||||
daemon_states[health_color]++; | ||||||
} | ||||||
return daemon_states; | ||||||
} | ||||||
|
||||||
daemonStatus(daemon_status: string): string { | ||||||
const display_names = {success: 'UP', error: 'DOWN', warning: 'WARNING', info: 'UNKNOWN'}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is rather an enum. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont see how would this work as an enum since im getting the values from the keys in the HTML
Comment on lines
+42
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure this mapping is ok? error and down seem 2 different conditions (down means that the service is not running, while error means the service is running but encountered a condition that impedes it from continuing). And info = unknown is a bit shocking to me... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yo are right, I think it should be 'error'. I also agree that info = unknoen is a little bit wierd but thats what I'm getting from the backend. From get_daemon_health function at src/pybind/mgr/dashboard/controllers/rbd_mirroring.py |
||||||
return display_names[daemon_status]; | ||||||
} | ||||||
} |
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.
Let's always use the ngIf="this else that".