-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 #7872 from hashicorp/f-ui/csi-phase-2
UI: CSI Plugins Pages
- Loading branch information
Showing
39 changed files
with
962 additions
and
91 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,44 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { formatBytes } from 'nomad-ui/helpers/format-bytes'; | ||
|
||
export default Component.extend({ | ||
tagName: '', | ||
|
||
allocation: null, | ||
statsTracker: null, | ||
isLoading: false, | ||
error: null, | ||
metric: 'memory', // Either memory or cpu | ||
|
||
statClass: computed('metric', function() { | ||
return this.metric === 'cpu' ? 'is-info' : 'is-danger'; | ||
}), | ||
|
||
cpu: alias('statsTracker.cpu.lastObject'), | ||
memory: alias('statsTracker.memory.lastObject'), | ||
|
||
stat: computed('metric', 'cpu', 'memory', function() { | ||
const { metric } = this; | ||
if (metric === 'cpu' || metric === 'memory') { | ||
return this[this.metric]; | ||
} | ||
}), | ||
|
||
formattedStat: computed('metric', 'stat.used', function() { | ||
if (!this.stat) return; | ||
if (this.metric === 'memory') return formatBytes([this.stat.used]); | ||
return this.stat.used; | ||
}), | ||
|
||
formattedReserved: computed( | ||
'metric', | ||
'statsTracker.reservedMemory', | ||
'statsTracker.reservedCPU', | ||
function() { | ||
if (this.metric === 'memory') return `${this.statsTracker.reservedMemory} MiB`; | ||
if (this.metric === 'cpu') return `${this.statsTracker.reservedCPU} MHz`; | ||
} | ||
), | ||
}); |
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,7 @@ | ||
import { alias } from '@ember/object/computed'; | ||
import AllocationRow from 'nomad-ui/components/allocation-row'; | ||
|
||
export default AllocationRow.extend({ | ||
pluginAllocation: null, | ||
allocation: alias('pluginAllocation.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,5 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default Controller.extend({ | ||
isForbidden: false, | ||
}); |
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,40 @@ | ||
import { inject as service } from '@ember/service'; | ||
import { alias, readOnly } from '@ember/object/computed'; | ||
import Controller, { inject as controller } from '@ember/controller'; | ||
import SortableFactory from 'nomad-ui/mixins/sortable-factory'; | ||
import { lazyClick } from 'nomad-ui/helpers/lazy-click'; | ||
|
||
export default Controller.extend(SortableFactory([]), { | ||
userSettings: service(), | ||
pluginsController: controller('csi/plugins'), | ||
|
||
isForbidden: alias('pluginsController.isForbidden'), | ||
|
||
queryParams: { | ||
currentPage: 'page', | ||
sortProperty: 'sort', | ||
sortDescending: 'desc', | ||
}, | ||
|
||
currentPage: 1, | ||
pageSize: readOnly('userSettings.pageSize'), | ||
|
||
sortProperty: 'id', | ||
sortDescending: false, | ||
|
||
listToSort: alias('model'), | ||
sortedPlugins: alias('listSorted'), | ||
|
||
// TODO: Remove once this page gets search capability | ||
resetPagination() { | ||
if (this.currentPage != null) { | ||
this.set('currentPage', 1); | ||
} | ||
}, | ||
|
||
actions: { | ||
gotoPlugin(plugin, event) { | ||
lazyClick([() => this.transitionToRoute('csi.plugins.plugin', plugin.plainId), event]); | ||
}, | ||
}, | ||
}); |
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,18 @@ | ||
import Controller from '@ember/controller'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Controller.extend({ | ||
sortedControllers: computed('model.controllers.@each.updateTime', function() { | ||
return this.model.controllers.sortBy('updateTime').reverse(); | ||
}), | ||
|
||
sortedNodes: computed('model.nodes.@each.updateTime', function() { | ||
return this.model.nodes.sortBy('updateTime').reverse(); | ||
}), | ||
|
||
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
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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
import { computed } from '@ember/object'; | ||
import Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
// import { fragmentArray } from 'ember-data-model-fragments/attributes'; | ||
import { fragmentArray } from 'ember-data-model-fragments/attributes'; | ||
|
||
export default Model.extend({ | ||
plainId: attr('string'), | ||
|
||
topologies: attr(), | ||
provider: attr('string'), | ||
version: attr('string'), | ||
|
||
controllers: fragmentArray('storage-controller', { defaultValue: () => [] }), | ||
nodes: fragmentArray('storage-node', { defaultValue: () => [] }), | ||
|
||
controllerRequired: attr('boolean'), | ||
controllersHealthy: attr('number'), | ||
controllersExpected: attr('number'), | ||
|
||
controllersHealthyProportion: computed('controllersHealthy', 'controllersExpected', function() { | ||
return this.controllersHealthy / this.controllersExpected; | ||
}), | ||
|
||
nodesHealthy: attr('number'), | ||
nodesExpected: attr('number'), | ||
|
||
// controllers: fragmentArray('storage-controller', { defaultValue: () => [] }), | ||
// nodes: fragmentArray('storage-node', { defaultValue: () => [] }), | ||
nodesHealthyProportion: computed('nodesHealthy', 'nodesExpected', function() { | ||
return this.nodesHealthy / this.nodesExpected; | ||
}), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Route from '@ember/routing/route'; | ||
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state'; | ||
import notifyForbidden from 'nomad-ui/utils/notify-forbidden'; | ||
|
||
export default Route.extend(WithForbiddenState, { | ||
store: service(), | ||
|
||
breadcrumbs: [ | ||
{ | ||
label: 'Storage', | ||
args: ['csi.index'], | ||
}, | ||
], | ||
|
||
model() { | ||
return this.store.query('plugin', { type: 'csi' }).catch(notifyForbidden(this)); | ||
}, | ||
}); |
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,13 @@ | ||
import Route from '@ember/routing/route'; | ||
import { collect } from '@ember/object/computed'; | ||
import { watchQuery } from 'nomad-ui/utils/properties/watch'; | ||
import WithWatchers from 'nomad-ui/mixins/with-watchers'; | ||
|
||
export default Route.extend(WithWatchers, { | ||
startWatchers(controller) { | ||
controller.set('modelWatch', this.watch.perform({ type: 'csi' })); | ||
}, | ||
|
||
watch: watchQuery('plugin'), | ||
watchers: collect('watch'), | ||
}); |
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,41 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Route from '@ember/routing/route'; | ||
import { collect } from '@ember/object/computed'; | ||
import notifyError from 'nomad-ui/utils/notify-error'; | ||
import { watchRecord } from 'nomad-ui/utils/properties/watch'; | ||
import WithWatchers from 'nomad-ui/mixins/with-watchers'; | ||
|
||
export default Route.extend(WithWatchers, { | ||
store: service(), | ||
system: service(), | ||
|
||
breadcrumbs: plugin => [ | ||
{ | ||
label: 'Plugins', | ||
args: ['csi.plugins'], | ||
}, | ||
{ | ||
label: plugin.plainId, | ||
args: ['csi.plugins.plugin', plugin.plainId], | ||
}, | ||
], | ||
|
||
startWatchers(controller, model) { | ||
if (!model) return; | ||
|
||
controller.set('watchers', { | ||
model: this.watch.perform(model), | ||
}); | ||
}, | ||
|
||
serialize(model) { | ||
return { plugin_name: model.get('plainId') }; | ||
}, | ||
|
||
model(params) { | ||
return this.store.findRecord('plugin', `csi/${params.plugin_name}`).catch(notifyError(this)); | ||
}, | ||
|
||
watch: watchRecord('plugin'), | ||
watchers: collect('watch'), | ||
}); |
Oops, something went wrong.