let-value="value">
<span *ngFor="let state of value; last as last">
<span class="badge"
- [ngClass]="{'badge-success': ['in', 'up'].includes(state), 'badge-danger': ['down', 'out'].includes(state)}">{{ state }}</span>
+ [ngClass]="{'badge-success': ['in', 'up'].includes(state), 'badge-danger': ['down', 'out', 'destroyed'].includes(state)}">{{ state }}</span>
<span *ngIf="!last"> </span>
</span>
</ng-template>
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
-import _ = require('lodash');
+import * as _ from 'lodash';
import { BsModalService } from 'ngx-bootstrap/modal';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { EMPTY, of } from 'rxjs';
stats: {
stat_bytes_used: n * n,
stat_bytes: n * n * n
- }
+ },
+ state: []
});
const expectAttributeOnEveryOsd = (attr: string) =>
expect(component.osds[0].collectedStates).toEqual(['in', 'up']);
});
+ it('should have "destroyed" state in "collectedStates"', () => {
+ osds[0].state.push('destroyed');
+ osds[0].up = 0;
+ component.getOsdList();
+
+ expectAttributeOnEveryOsd('collectedStates');
+ expect(component.osds[0].collectedStates).toEqual(['in', 'destroyed']);
+ });
+
it('should have custom attribute "stats_history.out_bytes"', () => {
expectAttributeOnEveryOsd('stats_history.out_bytes');
expect(component.osds[0].stats_history.out_bytes).toEqual([1, 2]);
osds = [];
protected static collectStates(osd) {
- return [osd['in'] ? 'in' : 'out', osd['up'] ? 'up' : 'down'];
+ const states = [osd['in'] ? 'in' : 'out'];
+ if (osd['up']) {
+ states.push('up');
+ } else if (osd.state.includes('destroyed')) {
+ states.push('destroyed');
+ } else {
+ states.push('down');
+ }
+ return states;
}
constructor(