-
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 #4529 from hashicorp/f-ui-job-overview-allocs
UI: Recent allocs + job allocs view
- Loading branch information
Showing
38 changed files
with
616 additions
and
111 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import PromiseArray from 'nomad-ui/utils/classes/promise-array'; | ||
|
||
export default Component.extend({ | ||
sortProperty: 'modifyIndex', | ||
sortDescending: true, | ||
sortedAllocations: computed('[email protected]', function() { | ||
return new PromiseArray({ | ||
promise: this.get('job.allocations').then(allocations => | ||
allocations | ||
.sortBy('modifyIndex') | ||
.reverse() | ||
.slice(0, 5) | ||
), | ||
}); | ||
}), | ||
|
||
actions: { | ||
gotoAllocation(allocation) { | ||
this.transitionToRoute('allocations.allocation', allocation); | ||
}, | ||
}, | ||
}); |
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,39 @@ | ||
import { alias } from '@ember/object/computed'; | ||
import Controller from '@ember/controller'; | ||
import { computed } from '@ember/object'; | ||
import Sortable from 'nomad-ui/mixins/sortable'; | ||
import Searchable from 'nomad-ui/mixins/searchable'; | ||
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting'; | ||
|
||
export default Controller.extend(Sortable, Searchable, WithNamespaceResetting, { | ||
queryParams: { | ||
currentPage: 'page', | ||
searchTerm: 'search', | ||
sortProperty: 'sort', | ||
sortDescending: 'desc', | ||
}, | ||
|
||
currentPage: 1, | ||
pageSize: 25, | ||
|
||
sortProperty: 'modifyIndex', | ||
sortDescending: true, | ||
|
||
job: alias('model'), | ||
|
||
searchProps: computed(() => ['shortId', 'name', 'taskGroupName']), | ||
|
||
allocations: computed('model.allocations.[]', function() { | ||
return this.get('model.allocations') || []; | ||
}), | ||
|
||
listToSort: alias('allocations'), | ||
listToSearch: alias('listSorted'), | ||
sortedAllocations: alias('listSearched'), | ||
|
||
actions: { | ||
gotoAllocation(allocation) { | ||
this.transitionToRoute('allocations.allocation', allocation); | ||
}, | ||
}, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Route from '@ember/routing/route'; | ||
import { collect } from '@ember/object/computed'; | ||
import { watchRelationship } from 'nomad-ui/utils/properties/watch'; | ||
import WithWatchers from 'nomad-ui/mixins/with-watchers'; | ||
|
||
export default Route.extend(WithWatchers, { | ||
model() { | ||
const job = this.modelFor('jobs.job'); | ||
return job.get('allocations').then(() => job); | ||
}, | ||
|
||
startWatchers(controller, model) { | ||
controller.set('watchAllocations', this.get('watchAllocations').perform(model)); | ||
}, | ||
|
||
watchAllocations: watchRelationship('allocations'), | ||
|
||
watchers: collect('watchAllocations'), | ||
}); |
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
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
46 changes: 46 additions & 0 deletions
46
ui/app/templates/components/job-page/parts/recent-allocations.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,46 @@ | ||
<div class="boxed-section"> | ||
<div class="boxed-section-head"> | ||
Recent Allocations | ||
</div> | ||
<div class="boxed-section-body is-full-bleed"> | ||
{{#if job.allocations.length}} | ||
{{#list-table | ||
source=sortedAllocations | ||
sortProperty=sortProperty | ||
sortDescending=sortDescending | ||
class="with-foot" as |t|}} | ||
{{#t.head}} | ||
<th class="is-narrow"></th> | ||
<th>ID</th> | ||
<th>Task Group</th> | ||
<th>Created</th> | ||
<th>Modified</th> | ||
<th>Status</th> | ||
<th>Version</th> | ||
<th>Client</th> | ||
<th>CPU</th> | ||
<th>Memory</th> | ||
{{/t.head}} | ||
{{#t.body as |row|}} | ||
{{allocation-row | ||
data-test-allocation=row.model.id | ||
allocation=row.model | ||
context="job" | ||
onClick=(action "gotoAllocation" row.model)}} | ||
{{/t.body}} | ||
{{/list-table}} | ||
{{else}} | ||
<div class="empty-message" data-test-empty-recent-allocations> | ||
<h3 class="empty-message-headline" data-test-empty-recent-allocations-headline>No Allocations</h3> | ||
<p class="empty-message-body" data-test-empty-recent-allocations-message>No allocations have been placed.</p> | ||
</div> | ||
{{/if}} | ||
</div> | ||
{{#if job.allocations.length}} | ||
<div class="boxed-section-foot"> | ||
<p class="pull-right" data-test-view-all-allocations>{{#link-to "jobs.job.allocations" job}} | ||
View all {{job.allocations.length}} {{pluralize "allocation" job.allocations.length}} | ||
{{/link-to}}</p> | ||
</div> | ||
{{/if}} | ||
</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 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.