2020-03-25 12:51:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { action, computed } from '@ember/object';
|
2020-03-31 04:29:30 +00:00
|
|
|
import { alias, readOnly } from '@ember/object/computed';
|
2020-03-25 12:51:26 +00:00
|
|
|
import Controller, { inject as controller } from '@ember/controller';
|
|
|
|
import SortableFactory from 'nomad-ui/mixins/sortable-factory';
|
2020-05-07 23:57:51 +00:00
|
|
|
import Searchable from 'nomad-ui/mixins/searchable';
|
2020-05-05 21:26:04 +00:00
|
|
|
import { lazyClick } from 'nomad-ui/helpers/lazy-click';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class IndexController extends Controller.extend(
|
|
|
|
SortableFactory([
|
|
|
|
'id',
|
|
|
|
'schedulable',
|
|
|
|
'controllersHealthyProportion',
|
|
|
|
'nodesHealthyProportion',
|
|
|
|
'provider',
|
|
|
|
]),
|
|
|
|
Searchable
|
|
|
|
) {
|
|
|
|
@service system;
|
|
|
|
@service userSettings;
|
|
|
|
@controller('csi/volumes') volumesController;
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@alias('volumesController.isForbidden')
|
|
|
|
isForbidden;
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-11 13:38:33 +00:00
|
|
|
queryParams = [
|
|
|
|
{
|
|
|
|
currentPage: 'page',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
searchTerm: 'search',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sortProperty: 'sort',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sortDescending: 'desc',
|
|
|
|
},
|
|
|
|
];
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
currentPage = 1;
|
|
|
|
@readOnly('userSettings.pageSize') pageSize;
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
sortProperty = 'id';
|
|
|
|
sortDescending = false;
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed
|
|
|
|
get searchProps() {
|
|
|
|
return ['name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
@computed
|
|
|
|
get fuzzySearchProps() {
|
|
|
|
return ['name'];
|
|
|
|
}
|
2020-05-07 23:57:51 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
fuzzySearchEnabled = true;
|
2020-04-04 02:18:06 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
/**
|
|
|
|
Visible volumes are those that match the selected namespace
|
|
|
|
*/
|
2021-02-17 21:01:44 +00:00
|
|
|
@computed('model.@each.parent', 'system.{activeNamespace.id,namespaces.length}')
|
2020-06-10 13:49:16 +00:00
|
|
|
get visibleVolumes() {
|
|
|
|
if (!this.model) return [];
|
2020-04-04 02:18:06 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
// Namespace related properties are ommitted from the dependent keys
|
|
|
|
// due to a prop invalidation bug caused by region switching.
|
|
|
|
const hasNamespaces = this.get('system.namespaces.length');
|
|
|
|
const activeNamespace = this.get('system.activeNamespace.id') || 'default';
|
|
|
|
|
|
|
|
return this.model
|
|
|
|
.compact()
|
|
|
|
.filter(volume => !hasNamespaces || volume.get('namespace.id') === activeNamespace);
|
|
|
|
}
|
2020-04-04 02:18:06 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@alias('visibleVolumes') listToSort;
|
|
|
|
@alias('listSorted') listToSearch;
|
|
|
|
@alias('listSearched') sortedVolumes;
|
2020-04-04 02:19:49 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@action
|
|
|
|
gotoVolume(volume, event) {
|
|
|
|
lazyClick([() => this.transitionToRoute('csi.volumes.volume', volume.get('plainId')), event]);
|
2020-03-25 12:51:26 +00:00
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|