mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
format-scheduled-bytes helper
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
16
ui/app/helpers/format-scheduled-bytes.js
Normal file
16
ui/app/helpers/format-scheduled-bytes.js
Normal 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);
|
||||
@@ -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}}"
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user