Skip to content

Commit

Permalink
More sensible allocTypes listing
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Feb 16, 2023
1 parent ce339cb commit 0466c49
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 44 deletions.
5 changes: 2 additions & 3 deletions ui/app/components/job-status/allocation-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
{{/each-in}}
</div>
{{else}}
<div class="alloc-representation">
<div class="ungrouped-allocs">
{{#each-in @allocBlocks as |status count|}}
{{!-- {{log "eachin" status count}} --}}
{{#if (gt count 0)}}
{{#each (range 0 count) as |alloc|}}
{{#each (range 0 count)}}
<span class="represented-allocation {{status}}"></span>
{{/each}}
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/job-status/allocation-status-block.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
style={{html-safe (concat "width: " @width "%")}}
>
{{#if this.countToShow}}
<div class="allocs">
<div class="ungrouped-allocs">
{{#each (range 0 this.countToShow)}}
<span class="represented-allocation {{@status}}"></span>
<span class="represented-allocation {{@status}}" />
{{/each}}
</div>
{{/if}}
Expand Down
16 changes: 4 additions & 12 deletions ui/app/components/job-status/panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<header>Manipulate mock data:</header>
{{#each this.allocTypes as |type|}}
<label>
<strong>{{capitalize type}}: {{get @job.summary type}}</strong>
<strong>{{capitalize type.label}}: {{get @job.summary type.property}}</strong>
<input type="range"
{{on "input" (fn this.modifyMockAllocs type)}}
{{on "input" (fn this.modifyMockAllocs type.property)}}
min="0"
max="1000"
value={{get @job.summary type}}
value={{get @job.summary type.property}}
steps="1">
</label>
{{/each}}
Expand All @@ -35,15 +35,7 @@
{{#if (eq this.mode "current")}}
<h3 class="title is-4 running-allocs-title"><strong>{{@job.runningAllocs}}/{{this.totalAllocs}}</strong> Allocations Running</h3>
<JobStatus::AllocationRow @totalAllocs={{this.totalAllocs}}
@allocBlocks={{hash
running=@job.runningAllocs
failed=@job.failedAllocs
unknown=@job.unknownAllocs
queued=@job.queuedAllocs
complete=@job.completeAllocs
starting=@job.startingAllocs
lost=@job.lostAllocs
}}
@allocBlocks={{this.allocBlocks}}
/>
{{/if}}
{{#if (eq this.mode "historical")}}
Expand Down
35 changes: 24 additions & 11 deletions ui/app/components/job-status/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@ import { action } from '@ember/object';
export default class JobStatusPanelComponent extends Component {

allocTypes = [
"runningAllocs",
"failedAllocs",
"unknownAllocs",
"queuedAllocs",
"completeAllocs",
"startingAllocs",
"lostAllocs"
]
"running",
"failed",
"unknown",
// "queued",
"complete",
// "starting",
"lost"
].map((type) => {
return {
label: type,
property: `${type}Allocs`
}
})

get allocBlocks() {
return this.allocTypes.reduce((blocks, type) => {
blocks[type.label] = this.args.job[type.property];
return blocks;
}, {});
}

/**
* @type {('current'|'historical')}
*/
Expand All @@ -27,11 +40,11 @@ export default class JobStatusPanelComponent extends Component {

// TODO: eventually we will want this from a new property on a job.
get totalAllocs() {
return this.allocTypes.reduce((sum, type) => sum + this.args.job[type], 0);
return this.allocTypes.reduce((sum, type) => sum + this.args.job[type.property], 0);
}

@action
modifyMockAllocs(type, { target: { value } }) {
this.args.job[type] = +value;
modifyMockAllocs(propName, { target: { value } }) {
this.args.job[propName] = +value;
}
}
14 changes: 7 additions & 7 deletions ui/app/styles/components/job-status-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
}

.alloc-representation {
.ungrouped-allocs {
display: grid;
gap: 10px;
grid-auto-flow: column;
Expand All @@ -55,19 +55,19 @@
grid-template-columns: auto;
}

& > .allocs {
& > .ungrouped-allocs {
display: grid;
grid-auto-flow: column;
gap: 10px;
}

.represented-allocation {
text-align: center;
font-size: 0;
grid-auto-columns: unset;
& > .represented-allocation {
width: 32px;
}
}

.represented-allocation.rest {
font-size: 0.8rem;
text-align: center;
display: grid;
align-content: center;
font-weight: bold;
Expand Down
9 changes: 0 additions & 9 deletions ui/mirage/scenarios/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ function smallCluster(server) {
id: 'service-haver',
namespaceId: 'default',
});
server.create('job', {
withGroupServices: true,
withTaskServices: true,
name: 'mixed-alloc-job',
id: 'mixed-alloc-job',
namespaceId: 'default',
type: 'service',
activeDeployment: true,
});
server.createList('allocFile', 5);
server.create('allocFile', 'dir', { depth: 2 });
server.createList('csi-plugin', 2);
Expand Down

0 comments on commit 0466c49

Please sign in to comment.