fix: fix the trove instance store

fix the trove instance store to get better extension

Change-Id: I20950d667bbdac621644e4f8def5384eff48e67c
This commit is contained in:
xusongfu 2022-07-25 11:10:28 +08:00
parent af67087953
commit 7fb3e6eb2c
3 changed files with 41 additions and 14 deletions

View File

@ -34,11 +34,11 @@ export class BaseDetail extends Base {
},
{
label: t('Datastore'),
dataIndex: 'datastore.type',
dataIndex: 'type',
},
{
label: t('Datastore Version'),
dataIndex: 'datastore.version',
dataIndex: 'version',
},
{
label: t('Status'),
@ -62,13 +62,13 @@ export class BaseDetail extends Base {
const options = [
{
label: t('Flavor'),
dataIndex: 'flavor.id',
dataIndex: 'flavor',
render: (value) => {
return this.getLinkRender(
'flavorDetail',
value,
value.name,
{
id: value,
id: value.id,
},
null
);
@ -76,7 +76,8 @@ export class BaseDetail extends Base {
},
{
label: t('Volume Size'),
dataIndex: 'volume.size',
dataIndex: 'size',
render: (value) => (value ? `${value}GiB` : '-'),
},
{
label: t('Created'),
@ -119,7 +120,7 @@ export class BaseDetail extends Base {
},
{
label: t('Database Port'),
dataIndex: 'datastore.type',
dataIndex: 'type',
render: (value) => {
switch (value) {
case 'mysql':

View File

@ -17,7 +17,6 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import globalInstancesStore from 'stores/trove/instances';
import { InstanceStatus } from 'resources/trove/database';
import { get as _get } from 'lodash';
import actions from './actions';
export class Instances extends Base {
@ -58,13 +57,11 @@ export class Instances extends Base {
},
{
title: t('Datastore'),
dataIndex: 'datastore',
render: (value) => _get(value, 'type', '-'),
dataIndex: 'type',
},
{
title: t('Datastore Version'),
dataIndex: 'datastore',
render: (value) => _get(value, 'version', '-'),
dataIndex: 'version',
isHideable: true,
},
{
@ -85,9 +82,9 @@ export class Instances extends Base {
},
{
title: t('Volume Size'),
dataIndex: 'volume',
dataIndex: 'size',
isHideable: true,
render: (value) => (value ? `${value.size}GiB` : '-'),
render: (value) => (value ? `${value}GiB` : '-'),
},
{
title: t('Status'),

View File

@ -15,6 +15,8 @@
import Base from 'stores/base';
import client from 'client';
import { action, observable } from 'mobx';
import globalFlavorStore from 'stores/nova/flavor';
import { get as _get } from 'lodash';
export class InstancesStore extends Base {
@observable
@ -36,6 +38,33 @@ export class InstancesStore extends Base {
return client.trove.instancesAdmin;
}
get mapper() {
return (data) => ({
...data,
type: _get(data, 'datastore.type'),
version: _get(data, 'datastore.version'),
size: _get(data, 'volume.size'),
});
}
async detailDidFetch(item) {
const flavor = await globalFlavorStore.fetchDetail({
id: _get(item, 'flavor.id'),
});
return {
...item,
flavor: { ...item.flavor, ...flavor },
};
}
listDidFetch(items) {
if (items.length === 0) return items;
return items.map((it) => ({
...it,
project_id: it.tenant_id,
}));
}
@action
async create(newbody) {
return this.submitting(this.client.create(newbody));