-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10208 from hashicorp/f-ui/use-new-chart-stuff
UI: Showed host reservations and allocation utilization by task on existing stats charts
- Loading branch information
Showing
29 changed files
with
854 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<div data-test-chart-tooltip class="chart-tooltip {{if @active "active" "inactive"}}" style={{@style}} ...attributes> | ||
<ol> | ||
{{#each @data as |props|}} | ||
{{yield props.series props.datum (inc props.index)}} | ||
{{yield props.series props.datum (inc props.index)}} | ||
{{/each}} | ||
</ol> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div data-test-primary-metric class="primary-metric" ...attributes | ||
{{did-insert this.start}} | ||
{{did-update this.start}}> | ||
<h4 data-test-primary-metric-title class="title is-5"> | ||
{{#if (eq this.metric "cpu")}} CPU | ||
{{else if (eq this.metric "memory")}} Memory | ||
{{else}} {{this.metric}} {{/if}} | ||
</h4> | ||
<div class="primary-graphic"> | ||
<StatsTimeSeries @data={{this.series}} @dataProp="data" > | ||
<:svg as |c|> | ||
{{#each (reverse this.series) as |series idx|}} | ||
<c.Area @data={{series.data}} @colorScale={{this.colorScale}} @index={{idx}} /> | ||
{{/each}} | ||
</:svg> | ||
<:after as |c|> | ||
<c.Tooltip class="is-snappy" as |series datum idx|> | ||
<li> | ||
<span class="label"><span class="color-swatch swatch-{{this.colorScale}} swatch-{{this.colorScale}}-{{idx}}" />{{series.name}}</span> | ||
{{#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> | ||
{{else}} | ||
<span class="value">{{datum.formatttedY}}</span> | ||
{{/if}} | ||
</li> | ||
</c.Tooltip> | ||
</:after> | ||
</StatsTimeSeries> | ||
</div> | ||
<PrimaryMetric::CurrentValue @chartClass={{this.chartClass}} @percent={{this.data.lastObject.percent}} /> | ||
<div class="annotation" data-test-absolute-value> | ||
{{#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 | ||
{{else}} | ||
<strong>{{this.data.lastObject.used}}</strong> / {{this.reservedAmount}} Total | ||
{{/if}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import Ember from 'ember'; | ||
import Component from '@glimmer/component'; | ||
import { task, timeout } from 'ember-concurrency'; | ||
import { assert } from '@ember/debug'; | ||
import { inject as service } from '@ember/service'; | ||
import { action, get, computed } from '@ember/object'; | ||
|
||
export default class AllocationPrimaryMetric extends Component { | ||
@service('stats-trackers-registry') statsTrackersRegistry; | ||
|
||
/** Args | ||
allocation = null; | ||
metric null; (one of 'cpu' or 'memory' | ||
*/ | ||
|
||
get metric() { | ||
assert('metric is a required argument', this.args.metric); | ||
return this.args.metric; | ||
} | ||
|
||
get allocation() { | ||
return this.args.allocation; | ||
} | ||
|
||
@computed('allocation') | ||
get tracker() { | ||
return this.statsTrackersRegistry.getTracker(this.allocation); | ||
} | ||
|
||
get data() { | ||
if (!this.tracker) return []; | ||
return get(this, `tracker.${this.metric}`); | ||
} | ||
|
||
@computed('tracker.tasks.[]', 'metric') | ||
get series() { | ||
const ret = this.tracker.tasks | ||
.map(task => ({ | ||
name: task.task, | ||
data: task[this.metric], | ||
})) | ||
.reverse(); | ||
|
||
return ret; | ||
} | ||
|
||
get reservedAmount() { | ||
if (this.metric === 'cpu') return this.tracker.reservedCPU; | ||
if (this.metric === 'memory') return this.tracker.reservedMemory; | ||
return null; | ||
} | ||
|
||
get chartClass() { | ||
if (this.metric === 'cpu') return 'is-info'; | ||
if (this.metric === 'memory') return 'is-danger'; | ||
return 'is-primary'; | ||
} | ||
|
||
get colorScale() { | ||
if (this.metric === 'cpu') return 'blues'; | ||
if (this.metric === 'memory') return 'reds'; | ||
return 'ordinal'; | ||
} | ||
|
||
@task(function*() { | ||
do { | ||
this.tracker.poll.perform(); | ||
yield timeout(100); | ||
} while (!Ember.testing); | ||
}) | ||
poller; | ||
|
||
@action | ||
start() { | ||
if (this.tracker) this.poller.perform(); | ||
} | ||
|
||
willDestroy() { | ||
this.poller.cancelAll(); | ||
this.tracker.signalPause.perform(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="columns secondary-graphic"> | ||
<div class="column"> | ||
<div class="inline-chart" data-test-percentage-bar> | ||
<progress | ||
data-test-current-value | ||
class="progress {{@chartClass}} is-small" | ||
value="{{@percent}}" | ||
max="1"> | ||
{{@percent}} | ||
</progress> | ||
</div> | ||
</div> | ||
<div class="column is-minimum"> | ||
<span class="nowrap" data-test-percentage>{{format-percentage @percent total=1}}</span> | ||
</div> | ||
</div> |
Oops, something went wrong.