Merge "feat: support flavor to add cpu/memory search filters"

This commit is contained in:
Zuul 2022-10-08 12:03:28 +00:00 committed by Gerrit Code Review
commit 965844d557
8 changed files with 69 additions and 57 deletions

View File

@ -0,0 +1,20 @@
---
features:
- |
Support Flavor add CPU and memory search filters:
* In the Console, Compute - Flavors page, support cpu and memory fuzzy search.
* In the Administrator, Compute - Flavors page, support cpu and memory fuzzy search.
* In the Console, Compute - Instances - Create Instance/Create Ironic, support cpu and
memory fuzzy search in the Specification setting in the first step.
* In the Console, Compute - Instances - Resize, support cpu and memory fuzzy
search in the Specification setting.
* In the Console, Database - Database Instances - Create Database Instance, support cpu
and memory fuzzy search in the Database Flavor setting in the first step.
* In the Console, Capsules - Clusters - Create Cluster Template/Edit Cluster Template,
support cpu and memory fuzzy search in the Flavor / Master Flavor setting in the Spec step.

View File

@ -21,8 +21,8 @@ import {
getBaseColumns, getBaseColumns,
extraColumns, extraColumns,
armCategoryList, armCategoryList,
getFlavorSearchFilters,
} from 'resources/nova/flavor'; } from 'resources/nova/flavor';
import { getOptions } from 'utils/index';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class Flavor extends Base { export class Flavor extends Base {
@ -54,17 +54,7 @@ export class Flavor extends Base {
}); });
get searchFilters() { get searchFilters() {
return [ return getFlavorSearchFilters(armCategoryList);
{
label: t('Name'),
name: 'name',
},
{
label: t('Category'),
name: 'category',
options: getOptions(armCategoryList),
},
];
} }
} }

View File

@ -20,6 +20,7 @@ import {
flavorArchitectures, flavorArchitectures,
getBaseColumns, getBaseColumns,
extraColumns, extraColumns,
getFlavorSearchFilters,
} from 'resources/nova/flavor'; } from 'resources/nova/flavor';
import actionConfigs from './actions'; import actionConfigs from './actions';
@ -60,12 +61,7 @@ export class Flavor extends Base {
}); });
get searchFilters() { get searchFilters() {
return [ return getFlavorSearchFilters();
{
label: t('Name'),
name: 'name',
},
];
} }
} }

View File

@ -22,8 +22,8 @@ import {
extraColumns, extraColumns,
heterogeneousCategoryList, heterogeneousCategoryList,
gpuColumns, gpuColumns,
getFlavorSearchFilters,
} from 'resources/nova/flavor'; } from 'resources/nova/flavor';
import { getOptions } from 'utils/index';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class Flavor extends Base { export class Flavor extends Base {
@ -55,18 +55,7 @@ export class Flavor extends Base {
}); });
get searchFilters() { get searchFilters() {
return [ return getFlavorSearchFilters(heterogeneousCategoryList);
{
label: t('Name'),
name: 'name',
},
{
label: t('Category'),
name: 'category',
options: getOptions(heterogeneousCategoryList),
include: false,
},
];
} }
} }

View File

@ -16,7 +16,11 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { FlavorStore } from 'stores/nova/flavor'; import { FlavorStore } from 'stores/nova/flavor';
import { emptyActionConfig } from 'utils/constants'; import { emptyActionConfig } from 'utils/constants';
import { getBaseColumns, extraColumns } from 'resources/nova/flavor'; import {
getBaseColumns,
extraColumns,
getFlavorSearchFilters,
} from 'resources/nova/flavor';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class Flavor extends Base { export class Flavor extends Base {
@ -52,12 +56,7 @@ export class Flavor extends Base {
} }
get searchFilters() { get searchFilters() {
return [ return getFlavorSearchFilters();
{
label: t('Name'),
name: 'name',
},
];
} }
} }

View File

@ -21,8 +21,8 @@ import {
getBaseColumns, getBaseColumns,
extraColumns, extraColumns,
x86CategoryList, x86CategoryList,
getFlavorSearchFilters,
} from 'resources/nova/flavor'; } from 'resources/nova/flavor';
import { getOptions } from 'utils/index';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class Flavor extends Base { export class Flavor extends Base {
@ -54,17 +54,7 @@ export class Flavor extends Base {
}); });
get searchFilters() { get searchFilters() {
return [ return getFlavorSearchFilters(x86CategoryList);
{
label: t('Name'),
name: 'name',
},
{
label: t('Category'),
name: 'category',
options: getOptions(x86CategoryList),
},
];
} }
} }

View File

@ -29,6 +29,7 @@ import {
isBareMetalFlavor, isBareMetalFlavor,
isBareMetal, isBareMetal,
getFlavorArchInfo, getFlavorArchInfo,
getFlavorSearchFilters,
} from 'resources/nova/flavor'; } from 'resources/nova/flavor';
import styles from './index.less'; import styles from './index.less';
@ -326,12 +327,7 @@ export class FlavorSelectTable extends Component {
data: this.flavors, data: this.flavors,
tableHeader: this.renderTableHeader(), tableHeader: this.renderTableHeader(),
isLoading, isLoading,
filterParams: [ filterParams: getFlavorSearchFilters(),
{
label: t('Name'),
name: 'name',
},
],
value, value,
onChange: this.onChange, onChange: this.onChange,
disabledFunc, disabledFunc,

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { formatSize } from 'utils'; import { formatSize, getOptions } from 'utils';
export const cpuPolicyList = { export const cpuPolicyList = {
dedicated: t('Dedicated'), dedicated: t('Dedicated'),
@ -286,3 +286,35 @@ export const getFlavorArchInfo = (flavor) => {
flavorCategoryList[category] || category flavorCategoryList[category] || category
}`; }`;
}; };
export const getFlavorSearchFilters = (category) => {
const filters = [
{
label: t('Name'),
name: 'name',
},
{
label: t('CPU'),
name: 'vcpus',
filterFunc: (vcpus, value) => {
return (`${vcpus}` || '').includes(value);
},
},
{
label: t('Memory'),
name: 'ram',
filterFunc: (ram, value) => {
return (formatSize(ram, 2) || '').includes(value);
},
},
];
if (category) {
filters.push({
label: t('Category'),
name: 'category',
options: getOptions(armCategoryList),
});
}
return filters;
};