-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #11094 from hashicorp/f-sysbatch-ui-luiz
sysbatch UI luiz
- Loading branch information
Showing
21 changed files
with
349 additions
and
196 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,58 @@ | ||
import { computed } from '@ember/object'; | ||
import DistributionBar from './distribution-bar'; | ||
import classic from 'ember-classic-decorator'; | ||
import { countBy } from 'lodash'; | ||
|
||
@classic | ||
export default class ClientStatusBar extends DistributionBar { | ||
layoutName = 'components/distribution-bar'; | ||
|
||
'data-test-client-status-bar' = true; | ||
allocationContainer = null; | ||
nodes = null; | ||
totalNodes = null; | ||
jobClientStatus = null; | ||
|
||
@computed('nodes') | ||
@computed('jobClientStatus') | ||
get data() { | ||
const statuses = { | ||
queued: 0, | ||
'not scheduled': this.totalNodes - this.nodes.length, | ||
starting: 0, | ||
running: 0, | ||
complete: 0, | ||
degraded: 0, | ||
failed: 0, | ||
lost: 0, | ||
}; | ||
const formattedNodes = this.nodes.map(node => { | ||
const [[_, allocs]] = Object.entries(node); | ||
return allocs.map(alloc => alloc.clientStatus); | ||
}); | ||
for (const node of formattedNodes) { | ||
const statusCount = countBy(node, status => status); | ||
const hasOnly1Status = Object.keys(statusCount).length === 1; | ||
|
||
if (hasOnly1Status) { | ||
if (statusCount.running > 0) { | ||
statuses.running++; | ||
} | ||
if (statusCount.failed > 0) { | ||
statuses.failed++; | ||
} | ||
if (statusCount.lost > 0) { | ||
statuses.lost++; | ||
} | ||
if (statusCount.complete > 0) { | ||
statuses.complete++; | ||
} | ||
} else if (!hasOnly1Status && !!statusCount.running) { | ||
if (!!statusCount.failed || !!statusCount.lost) { | ||
statuses.degraded++; | ||
} else if (statusCount.pending) { | ||
statuses.starting++; | ||
} | ||
} else { | ||
// if no allocations then queued -- job registered, hasn't been assigned clients to run -- no allocations | ||
// may only have this state for a few milliseconds | ||
statuses.queued++; | ||
} | ||
} | ||
|
||
return [ | ||
{ label: 'Not Scheduled', value: statuses['not scheduled'], className: 'not-scheduled' }, | ||
{ label: 'Queued', value: statuses.queued, className: 'queued' }, | ||
{ | ||
label: 'Queued', | ||
value: this.jobClientStatus.byStatus.queued.length, | ||
className: 'queued', | ||
}, | ||
{ | ||
label: 'Starting', | ||
value: statuses.starting, | ||
value: this.jobClientStatus.byStatus.starting.length, | ||
className: 'starting', | ||
layers: 2, | ||
}, | ||
{ label: 'Running', value: statuses.running, className: 'running' }, | ||
{ | ||
label: 'Running', | ||
value: this.jobClientStatus.byStatus.running.length, | ||
className: 'running', | ||
}, | ||
{ | ||
label: 'Complete', | ||
value: statuses.complete, | ||
value: this.jobClientStatus.byStatus.complete.length, | ||
className: 'complete', | ||
}, | ||
{ label: 'Degraded', value: statuses.degraded, className: 'degraded' }, | ||
{ label: 'Failed', value: statuses.failed, className: 'failed' }, | ||
{ label: 'Lost', value: statuses.lost, className: 'lost' }, | ||
{ | ||
label: 'Degraded', | ||
value: this.jobClientStatus.byStatus.degraded.length, | ||
className: 'degraded', | ||
}, | ||
{ | ||
label: 'Failed', | ||
value: this.jobClientStatus.byStatus.failed.length, | ||
className: 'failed', | ||
}, | ||
{ | ||
label: 'Lost', | ||
value: this.jobClientStatus.byStatus.lost.length, | ||
className: 'lost', | ||
}, | ||
{ | ||
label: 'Not Scheduled', | ||
value: this.jobClientStatus.byStatus.notScheduled.length, | ||
className: 'not-scheduled', | ||
}, | ||
]; | ||
} | ||
} |
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,25 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
import { classNames } from '@ember-decorators/component'; | ||
import classic from 'ember-classic-decorator'; | ||
|
||
@classic | ||
@classNames('boxed-section') | ||
export default class JobClientSummary extends Component { | ||
@service store; | ||
|
||
job = null; | ||
jobClientStatus = null; | ||
|
||
@computed | ||
get isExpanded() { | ||
const storageValue = window.localStorage.nomadExpandJobClientSummary; | ||
return storageValue != null ? JSON.parse(storageValue) : true; | ||
} | ||
|
||
persist(item, isOpen) { | ||
window.localStorage.nomadExpandJobClientSummary = isOpen; | ||
this.notifyPropertyChange('isExpanded'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import AbstractJobPage from './abstract'; | ||
import classic from 'ember-classic-decorator'; | ||
import { inject as service } from '@ember/service'; | ||
import jobClientStatus from 'nomad-ui/utils/properties/job-client-status'; | ||
|
||
@classic | ||
export default class Sysbatch extends AbstractJobPage { | ||
@service store; | ||
|
||
@jobClientStatus('nodes', 'job') jobClientStatus; | ||
|
||
get nodes() { | ||
return this.store.peekAll('node'); | ||
} | ||
} |
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,5 +1,15 @@ | ||
import AbstractJobPage from './abstract'; | ||
import classic from 'ember-classic-decorator'; | ||
import { inject as service } from '@ember/service'; | ||
import jobClientStatus from 'nomad-ui/utils/properties/job-client-status'; | ||
|
||
@classic | ||
export default class System extends AbstractJobPage {} | ||
export default class System extends AbstractJobPage { | ||
@service store; | ||
|
||
@jobClientStatus('nodes', 'job') jobClientStatus; | ||
|
||
get nodes() { | ||
return this.store.peekAll('node'); | ||
} | ||
} |
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 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,3 +1,5 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class ClientsRoute extends Route {} | ||
export default class ClientsRoute extends Route { | ||
// TODO: add watcher for nodes. | ||
} |
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
35 changes: 35 additions & 0 deletions
35
ui/app/templates/components/job-page/parts/job-client-summary.hbs
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,35 @@ | ||
<ListAccordion data-test-job-summary @source={{array this.job}} @key="id" @startExpanded={{this.isExpanded}} @onToggle={{action this.persist}} as |a|> | ||
<a.head @buttonLabel={{if a.isOpen "collapse" "expand"}}> | ||
<div class="columns"> | ||
<div class="column is-minimum nowrap"> | ||
Job Status in Client | ||
<span class="badge {{if a.isOpen "is-white" "is-light"}}"> | ||
{{this.jobClientStatus.totalNodes}} | ||
</span> | ||
</div> | ||
|
||
{{#unless a.isOpen}} | ||
<div class="column"> | ||
<div class="inline-chart bumper-left"> | ||
<ClientStatusBar @jobClientStatus={{this.jobClientStatus}} @isNarrow={{true}} /> | ||
</div> | ||
</div> | ||
{{/unless}} | ||
</div> | ||
</a.head> | ||
<a.body> | ||
<ClientStatusBar @jobClientStatus={{this.jobClientStatus}} class="split-view" as |chart|> | ||
<ol data-test-legend class="legend"> | ||
{{#each chart.data as |datum index|}} | ||
<li class="{{datum.className}} {{if (eq datum.label chart.activeDatum.label) "is-active"}} {{if (eq datum.value 0) "is-empty"}}"> | ||
<span class="color-swatch {{if datum.className datum.className (concat "swatch-" index)}}" /> | ||
<span class="value" data-test-legend-value="{{datum.className}}">{{datum.value}}</span> | ||
<span class="label"> | ||
{{datum.label}} | ||
</span> | ||
</li> | ||
{{/each}} | ||
</ol> | ||
</ClientStatusBar> | ||
</a.body> | ||
</ListAccordion> |
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
Oops, something went wrong.