Merge "fix: fix the router path and logs in zun container"

This commit is contained in:
Zuul 2022-11-23 07:57:12 +00:00 committed by Gerrit Code Review
commit b41b121a33
13 changed files with 207 additions and 177 deletions

View File

@ -878,39 +878,39 @@ const renderMenu = (t) => {
icon: <ContainerOutlined />, icon: <ContainerOutlined />,
children: [ children: [
{ {
path: '/container/containers-admin', path: '/container-service/containers-admin',
name: t('Containers'), name: t('Containers'),
key: 'zunContainersAdmin', key: 'zunContainersAdmin',
endpoints: 'zun', endpoints: 'zun',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/container\/containers-admin\/detail\/.[^/]+$/, path: /^\/container-service\/containers-admin\/detail\/.[^/]+$/,
name: t('Container Detail'), name: t('Container Detail'),
key: 'zunContainerDetailAdmin', key: 'zunContainerDetailAdmin',
level: 2, level: 2,
routePath: '/container/containers-admin/detail/:id', routePath: '/container-service/containers-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/container/hosts-admin', path: '/container-service/hosts-admin',
name: t('Hosts'), name: t('Hosts'),
key: 'zunHostsAdmin', key: 'zunHostsAdmin',
endpoints: 'zun', endpoints: 'zun',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/container\/hosts-admin\/detail\/.[^/]+$/, path: /^\/container-service\/hosts-admin\/detail\/.[^/]+$/,
name: t('Host Detail'), name: t('Host Detail'),
key: 'zuHostsDetailAdmin', key: 'zuHostsDetailAdmin',
level: 2, level: 2,
routePath: '/container/hosts-admin/detail/:id', routePath: '/container-service/hosts-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/container/services-admin', path: '/container-service/services-admin',
name: t('Services'), name: t('Services'),
key: 'zunServicesAdmin', key: 'zunServicesAdmin',
endpoints: 'zun', endpoints: 'zun',

View File

@ -637,40 +637,40 @@ const renderMenu = (t) => {
icon: <ContainerOutlined />, icon: <ContainerOutlined />,
children: [ children: [
{ {
path: '/container/containers', path: '/container-service/containers',
name: t('Containers'), name: t('Containers'),
key: 'zunContainers', key: 'zunContainers',
endpoints: 'zun', endpoints: 'zun',
level: 1, level: 1,
children: [ children: [
{ {
path: '/container/containers/create', path: '/container-service/containers/create',
name: t('Create Container'), name: t('Create Container'),
key: 'zunContainersCreateContainer', key: 'zunContainersCreateContainer',
level: 2, level: 2,
}, },
{ {
path: /^\/container\/containers\/detail\/.[^/]+$/, path: /^\/container-service\/containers\/detail\/.[^/]+$/,
name: t('Container Detail'), name: t('Container Detail'),
key: 'zunContainerDetail', key: 'zunContainerDetail',
level: 2, level: 2,
routePath: '/container/containers/detail/:id', routePath: '/container-service/containers/detail/:id',
}, },
], ],
}, },
{ {
path: '/container/capsules', path: '/container-service/capsules',
name: t('Capsules'), name: t('Capsules'),
key: 'zunCapsules', key: 'zunCapsules',
endpoints: 'zun', endpoints: 'zun',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/container\/capsules\/detail\/.[^/]+$/, path: /^\/container-service\/capsules\/detail\/.[^/]+$/,
name: t('Capsule Detail'), name: t('Capsule Detail'),
key: 'zunCapsuleDetail', key: 'zunCapsuleDetail',
level: 2, level: 2,
routePath: '/container/capsules/detail/:id', routePath: '/container-service/capsules/detail/:id',
}, },
], ],
}, },

View File

@ -53,7 +53,7 @@ const Share = lazy(() =>
const ContainerInfra = lazy(() => const ContainerInfra = lazy(() =>
import(/* webpackChunkName: "container-infra" */ 'pages/container-infra/App') import(/* webpackChunkName: "container-infra" */ 'pages/container-infra/App')
); );
const Containers = lazy(() => const ContainerService = lazy(() =>
import(/* webpackChunkName: "Container" */ 'pages/container-service/App') import(/* webpackChunkName: "Container" */ 'pages/container-service/App')
); );
const E404 = lazy(() => const E404 = lazy(() =>
@ -113,8 +113,8 @@ export default [
component: ContainerInfra, component: ContainerInfra,
}, },
{ {
path: `/container`, path: `/container-service`,
component: Containers, component: ContainerService,
}, },
{ path: '*', component: E404 }, { path: '*', component: E404 },
], ],

View File

@ -36,31 +36,33 @@ export class Capsules extends Base {
return actionConfigs; return actionConfigs;
} }
getColumns = () => [ getColumns() {
{ return [
title: t('ID/Name'), {
dataIndex: 'meta_name', title: t('ID/Name'),
isLink: true, dataIndex: 'meta_name',
routeName: this.getRouteName('zunCapsuleDetail'), isLink: true,
idKey: 'uuid', routeName: this.getRouteName('zunCapsuleDetail'),
}, idKey: 'uuid',
{ },
title: t('Status'), {
isHideable: true, title: t('Status'),
dataIndex: 'status', isHideable: true,
valueMap: capsuleStatus, dataIndex: 'status',
}, valueMap: capsuleStatus,
{ },
title: t('CPU'), {
isHideable: true, title: t('CPU'),
dataIndex: 'cpu', isHideable: true,
}, dataIndex: 'cpu',
{ },
title: t('Memory'), {
isHideable: true, title: t('Memory'),
dataIndex: 'memory', isHideable: true,
}, dataIndex: 'memory',
]; },
];
}
} }
export default inject('rootStore')(observer(Capsules)); export default inject('rootStore')(observer(Capsules));

View File

@ -59,7 +59,9 @@ export class ContainerDetail extends Base {
} }
get showLogs() { get showLogs() {
return checkPolicyRule('container:logs'); const { status } = this.detailData || {};
const acceptedStatus = ['Created', 'Running', 'Stopped', 'Paused'];
return checkPolicyRule('container:logs') && acceptedStatus.includes(status);
} }
get tabs() { get tabs() {

View File

@ -34,7 +34,7 @@ export class StepCreate extends StepAction {
static title = t('Create Container'); static title = t('Create Container');
static path = '/container/containers/create'; static path = '/container-service/containers/create';
static policy = 'container:create'; static policy = 'container:create';

View File

@ -39,36 +39,34 @@ export class Containers extends Base {
return actionConfigs.actionConfigs; return actionConfigs.actionConfigs;
} }
get rowKey() { getColumns() {
return 'uuid'; return [
{
title: t('ID/Name'),
dataIndex: 'name',
isLink: true,
routeName: this.getRouteName('zunContainerDetail'),
idKey: 'uuid',
},
{
title: t('Status'),
isHideable: true,
dataIndex: 'status',
valueMap: containerStatus,
},
{
title: t('Image'),
isHideable: true,
dataIndex: 'image',
},
{
title: t('Task State'),
isHideable: true,
dataIndex: 'task_state',
valueMap: containerTaskStatus,
},
];
} }
getColumns = () => [
{
title: t('ID/Name'),
dataIndex: 'name',
isLink: true,
routeName: this.getRouteName('zunContainerDetail'),
idKey: 'uuid',
},
{
title: t('Status'),
isHideable: true,
dataIndex: 'status',
valueMap: containerStatus,
},
{
title: t('Image'),
isHideable: true,
dataIndex: 'image',
},
{
title: t('Task State'),
isHideable: true,
dataIndex: 'task_state',
valueMap: containerTaskStatus,
},
];
} }
export default inject('rootStore')(observer(Containers)); export default inject('rootStore')(observer(Containers));

View File

@ -32,65 +32,70 @@ export class Hosts extends Base {
return 'host:get_all'; return 'host:get_all';
} }
getColumns = () => [ getColumns() {
{ return [
title: t('ID/Name'), {
dataIndex: 'name', title: t('ID/Name'),
routeName: 'zuHostsDetailAdmin', dataIndex: 'name',
}, routeName: 'zuHostsDetailAdmin',
{ },
title: t('Architecture'), {
dataIndex: 'architecture', title: t('Architecture'),
isHideable: true, dataIndex: 'architecture',
}, isHideable: true,
{ },
title: t('Total Containers'), {
dataIndex: 'total_containers', title: t('Total Containers'),
isHideable: true, dataIndex: 'total_containers',
}, isHideable: true,
{ },
title: t('CPU (Core)'), {
dataIndex: 'cpu_percent', title: t('CPU (Core)'),
render: (value, record) => ( dataIndex: 'cpu_percent',
<Progress value={value} label={`${record.cpu_used} / ${record.cpus}`} /> render: (value, record) => (
), <Progress
width: 180, value={value}
stringify: (value, record) => label={`${record.cpu_used} / ${record.cpus}`}
`${value}% (${t('Used')}: ${record.cpu_used} / ${t('Total')}: ${ />
record.cpus ),
})`, width: 180,
}, stringify: (value, record) =>
{ `${value}% (${t('Used')}: ${record.cpu_used} / ${t('Total')}: ${
title: t('Configured Memory (GiB)'), record.cpus
dataIndex: 'memory_percent', })`,
render: (value, record) => ( },
<Progress {
value={value} title: t('Configured Memory (GiB)'),
label={`${record.mem_used_gb} / ${record.mem_total_gb}`} dataIndex: 'memory_percent',
/> render: (value, record) => (
), <Progress
width: 180, value={value}
stringify: (value, record) => label={`${record.mem_used_gb} / ${record.mem_total_gb}`}
`${value}% (${t('Used')}: ${record.mem_used_gb} / ${t('Total')}: ${ />
record.mem_total_gb ),
})`, width: 180,
}, stringify: (value, record) =>
{ `${value}% (${t('Used')}: ${record.mem_used_gb} / ${t('Total')}: ${
title: t('Configured Disk (GiB)'), record.mem_total_gb
dataIndex: 'disk_percent', })`,
render: (value, record) => ( },
<Progress {
value={value} title: t('Configured Disk (GiB)'),
label={`${record.disk_used} / ${record.disk_total}`} dataIndex: 'disk_percent',
/> render: (value, record) => (
), <Progress
width: 180, value={value}
stringify: (value, record) => label={`${record.disk_used} / ${record.disk_total}`}
`${value}% (${t('Used')}: ${record.disk_used} / ${t('Total')}: ${ />
record.disk_total ),
})`, width: 180,
}, stringify: (value, record) =>
]; `${value}% (${t('Used')}: ${record.disk_used} / ${t('Total')}: ${
record.disk_total
})`,
},
];
}
} }
export default inject('rootStore')(observer(Hosts)); export default inject('rootStore')(observer(Hosts));

View File

@ -32,50 +32,52 @@ export class Services extends Base {
return 'zun-service:get_all'; return 'zun-service:get_all';
} }
getColumns = () => [ getColumns() {
{ return [
title: t('Name'), {
dataIndex: 'binary', title: t('Name'),
}, dataIndex: 'binary',
{ },
title: t('Hosts'), {
dataIndex: 'host', title: t('Hosts'),
isHideable: true, dataIndex: 'host',
}, isHideable: true,
{ },
title: t('Availability Zone'), {
dataIndex: 'availability_zone', title: t('Availability Zone'),
isHideable: true, dataIndex: 'availability_zone',
}, isHideable: true,
{ },
title: t('Report Count'), {
dataIndex: 'report_count', title: t('Report Count'),
isHideable: true, dataIndex: 'report_count',
}, isHideable: true,
{ },
title: t('Forced Down'), {
dataIndex: 'forced_down', title: t('Forced Down'),
valueRender: 'yesNo', dataIndex: 'forced_down',
isHideable: true, valueRender: 'yesNo',
}, isHideable: true,
{ },
title: t('Forbidden'), {
dataIndex: 'disabled', title: t('Forbidden'),
valueRender: 'yesNo', dataIndex: 'disabled',
isHideable: true, valueRender: 'yesNo',
}, isHideable: true,
{ },
title: t('Service State'), {
dataIndex: 'state', title: t('Service State'),
valueMap: serviceState, dataIndex: 'state',
}, valueMap: serviceState,
{ },
title: t('Last Updated'), {
dataIndex: 'updated_at', title: t('Last Updated'),
isHideable: true, dataIndex: 'updated_at',
valueRender: 'sinceTime', isHideable: true,
}, valueRender: 'sinceTime',
]; },
];
}
} }
export default inject('rootStore')(observer(Services)); export default inject('rootStore')(observer(Services));

View File

@ -23,7 +23,7 @@ import HostsDetail from '../containers/Hosts/Detail';
import StepCreateContainer from '../containers/Containers/actions/StepCreate'; import StepCreateContainer from '../containers/Containers/actions/StepCreate';
import Services from '../containers/Services'; import Services from '../containers/Services';
const PATH = '/container'; const PATH = '/container-service';
export default [ export default [
{ {
path: PATH, path: PATH,

View File

@ -21,6 +21,13 @@ export class CapsulesStore extends Base {
return client.zun.capsules; return client.zun.capsules;
} }
get mapper() {
return (data) => ({
...data,
id: data.uuid,
});
}
@action @action
async create(newbody) { async create(newbody) {
return this.client.create(newbody); return this.client.create(newbody);

View File

@ -22,6 +22,13 @@ export class ContainersStore extends Base {
return client.zun.containers; return client.zun.containers;
} }
get mapper() {
return (data) => ({
...data,
id: data.uuid,
});
}
@action @action
async create(newbody) { async create(newbody) {
return this.submitting(this.client.create(newbody)); return this.submitting(this.client.create(newbody));

View File

@ -19,6 +19,13 @@ export class ServicesStore extends Base {
get client() { get client() {
return client.zun.services; return client.zun.services;
} }
get mapper() {
return (data) => ({
...data,
id: data.uuid,
});
}
} }
const globalServicesStore = new ServicesStore(); const globalServicesStore = new ServicesStore();