Make job alloc/children summary collapsable (and persist the choice in localStorage)

This commit is contained in:
Michael Lange
2018-07-12 12:06:42 -07:00
parent a58e591910
commit 78e66d4100
3 changed files with 53 additions and 21 deletions

View File

@@ -1,13 +1,17 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import { computed } from '@ember/object';
export default Component.extend({
store: service(),
job: null,
summary: alias('job.summary'),
classNames: ['boxed-section'],
isExpanded: computed(function() {
const storageValue = window.localStorage.nomadExpandJobSummary;
return storageValue != null ? JSON.parse(storageValue) : true;
}),
persist(item, isOpen) {
window.localStorage.nomadExpandJobSummary = isOpen;
this.notifyPropertyChange('isExpanded');
},
});

View File

@@ -32,6 +32,7 @@
.accordion-head-content {
width: 100%;
margin-right: 1.5em;
}
.accordion-toggle {

View File

@@ -1,16 +1,41 @@
<div class="boxed-section-head">
<div>
{{#if job.hasChildren}}
Children Status <span class="badge is-white">{{summary.totalChildren}}</span>
{{else}}
Allocation Status <span class="badge is-white">{{summary.totalAllocs}}</span>
{{/if}}
</div>
</div>
<div class="boxed-section-body">
{{#component (if job.hasChildren "children-status-bar" "allocation-status-bar")
allocationContainer=summary
job=summary
{{#list-accordion source=(array job) key="id" startExpanded=isExpanded onToggle=(action persist) as |a|}}
{{#a.head buttonLabel=(if a.isOpen "collapse" "expand")}}
<div class="columns">
<div class="column is-minimum nowrap">
{{#if a.item.hasChildren}}
Children Status
<span class="badge {{if a.isOpen "is-white" "is-light"}}">
{{a.item.summary.totalChildren}}
</span>
{{else}}
Allocation Status
<span class="badge {{if a.isOpen "is-white" "is-light"}}">
{{a.item.summary.totalAllocs}}
</span>
{{/if}}
</div>
{{#if (not a.isOpen)}}
<div class="column">
<div class="inline-chart bumper-left">
{{#if a.item.hasChildren}}
{{#if (gt a.item.totalChildren 0)}}
{{children-status-bar job=a.item isNarrow=true}}
{{else}}
<em class="is-faded">No Children</em>
{{/if}}
{{else}}
{{allocation-status-bar allocationContainer=a.item isNarrow=true}}
{{/if}}
</div>
</div>
{{/if}}
</div>
{{/a.head}}
{{#a.body}}
{{#component (if a.item.hasChildren "children-status-bar" "allocation-status-bar")
allocationContainer=a.item.summary
job=a.item.summary
class="split-view" as |chart|}}
<ol data-test-legend class="legend">
{{#each chart.data as |datum index|}}
@@ -24,4 +49,6 @@
{{/each}}
</ol>
{{/component}}
</div>
{{/a.body}}
{{/list-accordion}}