diff --git a/ui/app/controllers/csi/plugins/plugin/allocations.js b/ui/app/controllers/csi/plugins/plugin/allocations.js new file mode 100644 index 000000000..0d2168684 --- /dev/null +++ b/ui/app/controllers/csi/plugins/plugin/allocations.js @@ -0,0 +1,43 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; +import { computed } from '@ember/object'; +import { alias, readOnly } from '@ember/object/computed'; +import SortableFactory from 'nomad-ui/mixins/sortable-factory'; +import { lazyClick } from 'nomad-ui/helpers/lazy-click'; + +export default Controller.extend(SortableFactory(['updateTime', 'healthy']), { + userSettings: service(), + + queryParams: { + currentPage: 'page', + sortProperty: 'sort', + sortDescending: 'desc', + }, + + currentPage: 1, + pageSize: readOnly('userSettings.pageSize'), + + sortProperty: 'updateTime', + sortDescending: false, + + combinedAllocations: computed('model.controllers.[]', 'model.nodes.[]', function() { + return this.model.controllers.toArray().concat(this.model.nodes.toArray()); + }), + + listToSort: alias('combinedAllocations'), + sortedAllocations: alias('listSorted'), + // TODO: Add facets for filtering + filteredAllocations: alias('sortedAllocations'), + + resetPagination() { + if (this.currentPage != null) { + this.set('currentPage', 1); + } + }, + + actions: { + gotoAllocation(allocation, event) { + lazyClick([() => this.transitionToRoute('allocations.allocation', allocation), event]); + }, + }, +}); diff --git a/ui/app/templates/csi/plugins/plugin/allocations.hbs b/ui/app/templates/csi/plugins/plugin/allocations.hbs new file mode 100644 index 000000000..6ace3a5db --- /dev/null +++ b/ui/app/templates/csi/plugins/plugin/allocations.hbs @@ -0,0 +1,66 @@ +{{title "CSI Plugin " model.plainID " allocations"}} +
+ +
+
+ {{#if filteredAllocations}} + {{log pageSize}} + {{#list-pagination + source=filteredAllocations + size=pageSize + page=currentPage as |p|}} + {{#list-table + source=p.list + sortProperty=sortProperty + sortDescending=sortDescending + class="with-foot" as |t|}} + {{#t.head}} + + ID + Created + {{#t.sort-by prop="updateTime"}}Modified{{/t.sort-by}} + {{#t.sort-by prop="healthy"}}Health{{/t.sort-by}} + Client + Job + Version + Volumes + CPU + Memory + {{/t.head}} + {{#t.body key="model.allocID" as |row|}} + {{plugin-allocation-row + data-test-controller-allocation=row.model.allocID + pluginAllocation=row.model}} + {{/t.body}} + {{/list-table}} +
+ {{page-size-select onChange=(action resetPagination)}} + +
+ {{/list-pagination}} + {{else}} +
+ {{#if (eq combinedAllocations.length 0)}} +

No Allocations

+

+ The plugin has no allocations. +

+ {{else if (eq filteredAllocations.length 0)}} +

No Matches

+

+ No allocations match your current filter selection. +

+ {{/if}} +
+ {{/if}} +