format-scheduled-bytes helper

This commit is contained in:
Michael Lange
2021-03-26 10:24:46 -07:00
parent 432ec44ba2
commit efaadd426b
7 changed files with 24 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import { formatScheduledBytes } from 'nomad-ui/utils/units';
import { tagName } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
@@ -35,7 +35,7 @@ export default class AllocationStat extends Component {
@computed('metric', 'stat.used')
get formattedStat() {
if (!this.stat) return undefined;
if (this.metric === 'memory') return formatBytes([this.stat.used]);
if (this.metric === 'memory') return formatScheduledBytes(this.stat.used);
return this.stat.used;
}

View File

@@ -20,7 +20,7 @@
{{#if (eq this.metric "cpu")}}
<span class="value">{{datum.datum.used}} MHz</span>
{{else if (eq this.metric "memory")}}
<span class="value">{{format-bytes datum.datum.used}}</span>
<span class="value">{{format-scheduled-bytes datum.datum.used}}</span>
{{else}}
<span class="value">{{datum.formatttedY}}</span>
{{/if}}
@@ -34,7 +34,7 @@
{{#if (eq this.metric "cpu")}}
<strong>{{this.data.lastObject.used}} MHz</strong> / {{this.reservedAmount}} MHz Total
{{else if (eq this.metric "memory")}}
<strong>{{format-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
<strong>{{format-scheduled-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
{{else}}
<strong>{{this.data.lastObject.used}}</strong> / {{this.reservedAmount}} Total
{{/if}}

View File

@@ -20,7 +20,7 @@
{{#if (eq this.metric "cpu")}}
<strong>{{this.data.lastObject.used}} MHz</strong> / {{this.reservedAmount}} MHz Total
{{else if (eq this.metric "memory")}}
<strong>{{format-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
<strong>{{format-scheduled-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
{{else}}
<strong>{{this.data.lastObject.used}}</strong> / {{this.reservedAmount}} Total
{{/if}}

View File

@@ -14,7 +14,7 @@
{{#if (eq this.metric "cpu")}}
<strong>{{this.data.lastObject.used}} MHz</strong> / {{this.reservedAmount}} MHz Total
{{else if (eq this.metric "memory")}}
<strong>{{format-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
<strong>{{format-scheduled-bytes this.data.lastObject.used}}</strong> / {{this.reservedAmount}} MiB Total
{{else}}
<strong>{{this.data.lastObject.used}}</strong> / {{this.reservedAmount}} Total
{{/if}}

View File

@@ -0,0 +1,16 @@
import Helper from '@ember/component/helper';
import { formatScheduledBytes } from 'nomad-ui/utils/units';
/**
* Scheduled Bytes Formatter
*
* Usage: {{format-scheduled-bytes bytes}}
*
* Outputs the bytes reduced to the resolution the scheduler
* and job spec operate at.
*/
function formatScheduledBytesHelper([bytes]) {
return formatScheduledBytes(bytes);
}
export default Helper.helper(formatScheduledBytesHelper);

View File

@@ -67,7 +67,7 @@
{{x-icon "alert-triangle" class="is-warning"}}
</span>
{{else}}
<div class="inline-chart tooltip" role="tooltip" aria-label="{{format-bytes this.memory.used}} / {{this.taskStats.reservedMemory}} MiB">
<div class="inline-chart tooltip" role="tooltip" aria-label="{{format-scheduled-bytes this.memory.used}} / {{this.taskStats.reservedMemory}} MiB">
<progress
class="progress is-danger is-small"
value="{{this.memory.percent}}"

View File

@@ -108,7 +108,7 @@
</div>
</div>
<div class="annotation" data-test-memory-absolute-value>
<strong>{{format-bytes this.nodeUtilization.totalReservedMemory}}</strong> / {{format-bytes this.nodeUtilization.totalMemory}} reserved
<strong>{{format-scheduled-bytes this.nodeUtilization.totalReservedMemory}}</strong> / {{format-scheduled-bytes this.nodeUtilization.totalMemory}} reserved
</div>
</div>
<div class="dashboard-metric">