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';
|
2021-04-29 20:00:59 +00:00
|
|
|
import { scheduleOnce } from '@ember/runloop';
|
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';
|
2021-04-29 20:00:59 +00:00
|
|
|
import { serialize } from 'nomad-ui/utils/qp-serialize';
|
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(
|
2021-12-28 14:45:20 +00:00
|
|
|
SortableFactory([
|
|
|
|
'id',
|
|
|
|
'schedulable',
|
|
|
|
'controllersHealthyProportion',
|
|
|
|
'nodesHealthyProportion',
|
|
|
|
'provider',
|
|
|
|
]),
|
|
|
|
Searchable
|
|
|
|
) {
|
2020-06-10 13:49:16 +00:00
|
|
|
@service system;
|
|
|
|
@service userSettings;
|
2022-08-17 16:59:33 +00:00
|
|
|
@service keyboard;
|
2020-06-10 13:49:16 +00:00
|
|
|
@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',
|
|
|
|
},
|
2021-04-29 20:00:59 +00:00
|
|
|
{
|
|
|
|
qpNamespace: 'namespace',
|
|
|
|
},
|
2020-06-11 13:38:33 +00:00
|
|
|
];
|
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
|
|
|
|
2022-07-11 22:06:18 +00:00
|
|
|
@computed('qpNamespace', 'model.namespaces.[]')
|
2021-04-29 20:00:59 +00:00
|
|
|
get optionsNamespaces() {
|
2021-12-28 14:45:20 +00:00
|
|
|
const availableNamespaces = this.model.namespaces.map((namespace) => ({
|
2021-04-29 20:00:59 +00:00
|
|
|
key: namespace.name,
|
|
|
|
label: namespace.name,
|
|
|
|
}));
|
|
|
|
|
|
|
|
availableNamespaces.unshift({
|
|
|
|
key: '*',
|
|
|
|
label: 'All (*)',
|
|
|
|
});
|
|
|
|
|
|
|
|
// Unset the namespace selection if it was server-side deleted
|
|
|
|
if (!availableNamespaces.mapBy('key').includes(this.qpNamespace)) {
|
|
|
|
// eslint-disable-next-line ember/no-incorrect-calls-with-inline-anonymous-functions
|
|
|
|
scheduleOnce('actions', () => {
|
|
|
|
// eslint-disable-next-line ember/no-side-effects
|
2022-07-11 22:06:18 +00:00
|
|
|
this.set('qpNamespace', '*');
|
2021-04-29 20:00:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return availableNamespaces;
|
|
|
|
}
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
/**
|
|
|
|
Visible volumes are those that match the selected namespace
|
|
|
|
*/
|
2021-04-29 20:00:59 +00:00
|
|
|
@computed('model.volumes.@each.parent', 'system.{namespaces.length}')
|
2020-06-10 13:49:16 +00:00
|
|
|
get visibleVolumes() {
|
2021-04-29 20:00:59 +00:00
|
|
|
if (!this.model.volumes) return [];
|
|
|
|
return this.model.volumes.compact();
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
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
|
|
|
|
2021-04-29 20:00:59 +00:00
|
|
|
setFacetQueryParam(queryParam, selection) {
|
|
|
|
this.set(queryParam, serialize(selection));
|
|
|
|
}
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@action
|
|
|
|
gotoVolume(volume, event) {
|
2021-04-29 20:00:59 +00:00
|
|
|
lazyClick([
|
2022-02-17 15:06:49 +00:00
|
|
|
() =>
|
|
|
|
this.transitionToRoute(
|
|
|
|
'csi.volumes.volume',
|
|
|
|
volume.get('idWithNamespace')
|
|
|
|
),
|
2021-04-29 20:00:59 +00:00
|
|
|
event,
|
|
|
|
]);
|
2020-03-25 12:51:26 +00:00
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|