Skip to content

Commit 3cbcded

Browse files
committed
Very basic checkbox and mirage alloc placement depending on running node
1 parent 716df52 commit 3cbcded

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

ui/app/components/topo-viz.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default class TopoViz extends Component {
9393
buildTopology() {
9494
const nodes = this.args.nodes;
9595
const allocations = this.args.allocations;
96+
console.log('building topo', nodes, allocations);
9697

9798
// Nodes may not have a resources property due to having an old Nomad agent version.
9899
const badNodes = [];

ui/app/controllers/topology.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export default class TopologyControllers extends Controller.extend(Searchable) {
157157

158158
@alias('userSettings.showTopoVizPollingNotice') showPollingNotice;
159159

160+
@tracked showEmptyNodes = true;
161+
160162
@tracked pre09Nodes = null;
161163

162164
get filteredNodes() {
@@ -191,7 +193,8 @@ export default class TopologyControllers extends Controller.extend(Searchable) {
191193
: true) &&
192194
(node.name.includes(searchTerm) ||
193195
node.datacenter.includes(searchTerm) ||
194-
node.nodeClass.includes(searchTerm))
196+
node.nodeClass.includes(searchTerm)) &&
197+
(this.showEmptyNodes || node.allocations.length > 0)
195198
);
196199
});
197200
}

ui/app/routes/topology.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class TopologyRoute extends Route.extend(WithForbiddenState) {
1616
@service system;
1717

1818
model() {
19+
console.log('re-firing model');
1920
return RSVP.hash({
2021
allocations: this.store.query('allocation', {
2122
resources: true,

ui/app/templates/topology.hbs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,14 @@
487487
</div>
488488
<div class="toolbar-item is-right-aligned is-mobile-full-width">
489489
<div class="button-bar">
490+
{{!-- HDS checkbox for selecting whether to show or hide empty nodes, default true --}}
491+
Show empty nodes? {{this.showEmptyNodes}}
492+
<Hds::Form::Checkbox::Field checked={{this.showEmptyNodes}} name="show-empty-nodes"
493+
{{on "change" (fn (mut this.showEmptyNodes) (not this.showEmptyNodes))}}
494+
as |F|>
495+
<F.Label>Show Empty Nodes</F.Label>
496+
</Hds::Form::Checkbox::Field>
497+
490498
<MultiSelectDropdown
491499
data-test-node-pool-facet
492500
@label="Node Pool"
@@ -525,6 +533,7 @@
525533
</div>
526534
</div>
527535
</div>
536+
{{log "Allocations from topology.hbs" this.model.allocations}}
528537
<TopoViz
529538
@nodes={{this.filteredNodes}}
530539
@allocations={{this.model.allocations}}
@@ -541,4 +550,4 @@
541550
</div>
542551
{{/if}}
543552
</section>
544-
</PageLayout>
553+
</PageLayout>

ui/mirage/factories/allocation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ export default Factory.extend({
194194
const namespace = allocation.namespace || job.namespace;
195195
const node = allocation.nodeId
196196
? server.db.nodes.find(allocation.nodeId)
197-
: pickOne(server.db.nodes);
197+
: pickOne(
198+
server.db.nodes.where({ status: 'ready' }) || pickOne(server.db.nodes)
199+
);
198200
const taskGroup = allocation.taskGroup
199201
? server.db.taskGroups.findBy({ name: allocation.taskGroup })
200202
: pickOne(server.db.taskGroups.where({ jobId: job.id }));

ui/mirage/scenarios/default.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ function smallCluster(server) {
105105
},
106106
'withMeta'
107107
);
108+
// Create one more node that is unusable
109+
server.create('node', {
110+
name: 'unusable-node',
111+
status: 'down',
112+
meta: { unusable: true },
113+
});
108114
server.createList('job', 10, { createRecommendations: true });
109115
server.create('job', {
110116
withGroupServices: true,

0 commit comments

Comments
 (0)