Merge "feat: show logs of a zun container"
This commit is contained in:
commit
67a8db0e95
@ -76,6 +76,9 @@ export class ZunClient extends Base {
|
||||
key: 'container_actions',
|
||||
responseKey: 'containerAction',
|
||||
},
|
||||
{
|
||||
key: 'logs',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -1533,6 +1533,7 @@
|
||||
"Nigeria": "Nigeria",
|
||||
"No": "No",
|
||||
"No Console": "No Console",
|
||||
"No Logs...": "No Logs...",
|
||||
"No Monitor": "No Monitor",
|
||||
"No Outputs": "No Outputs",
|
||||
"No Proxy": "No Proxy",
|
||||
|
@ -1533,6 +1533,7 @@
|
||||
"Nigeria": "尼日利亚",
|
||||
"No": "否",
|
||||
"No Console": "",
|
||||
"No Logs...": "暂无日志...",
|
||||
"No Monitor": "无监控",
|
||||
"No Outputs": "无输出",
|
||||
"No Proxy": "非代理",
|
||||
|
@ -0,0 +1,44 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import globalContainersStore from 'stores/zun/containers';
|
||||
|
||||
export default function Logs(props) {
|
||||
const [logs, setLogs] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const getLogs = async () => {
|
||||
setLoading(true);
|
||||
const cb = await globalContainersStore.fetchLogs(props.detail.uuid);
|
||||
setLogs(cb);
|
||||
setLoading(false);
|
||||
};
|
||||
getLogs();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
margin: '0 16px 16px',
|
||||
padding: 16,
|
||||
backgroundColor: '#90a4ae',
|
||||
borderRadius: 4,
|
||||
color: '#fff',
|
||||
fontSize: 14,
|
||||
}}
|
||||
>
|
||||
{logs || loading ? <pre>{logs}</pre> : t('No Logs...')}
|
||||
</div>
|
||||
);
|
||||
}
|
@ -14,9 +14,11 @@ import { inject, observer } from 'mobx-react';
|
||||
import Base from 'containers/TabDetail';
|
||||
import globalContainersStore from 'src/stores/zun/containers';
|
||||
import { containerStatus } from 'resources/zun/container';
|
||||
import { checkPolicyRule } from 'resources/skyline/policy';
|
||||
import actionConfigs from '../actions';
|
||||
import BaseDetail from './BaseDetail';
|
||||
import ActionLogs from './ActionLogs';
|
||||
import Logs from './Logs';
|
||||
|
||||
export class ContainerDetail extends Base {
|
||||
init() {
|
||||
@ -56,8 +58,12 @@ export class ContainerDetail extends Base {
|
||||
];
|
||||
}
|
||||
|
||||
get showLogs() {
|
||||
return checkPolicyRule('container:logs');
|
||||
}
|
||||
|
||||
get tabs() {
|
||||
return [
|
||||
const items = [
|
||||
{
|
||||
title: t('Detail'),
|
||||
key: 'general_info',
|
||||
@ -69,6 +75,14 @@ export class ContainerDetail extends Base {
|
||||
component: ActionLogs,
|
||||
},
|
||||
];
|
||||
if (this.showLogs) {
|
||||
items.push({
|
||||
title: t('Logs'),
|
||||
key: 'logs',
|
||||
component: Logs,
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ export const actionEvent = {
|
||||
compute__do_container_restart: t('Restart Container'),
|
||||
compute__do_container_pause: t('Pause Container'),
|
||||
compute__do_container_unpause: t('Unpause Container'),
|
||||
compute__do_container_resize: t('Resize Container'),
|
||||
compute__do_container_rebuild: t('Rebuild Container'),
|
||||
compute__do_container_kill: t('Kill Container'),
|
||||
compute__do_container_delete: t('Delete Container'),
|
||||
|
@ -81,6 +81,11 @@ export class ContainersStore extends Base {
|
||||
const stats = (await this.client.stats.list(uuid)) || {};
|
||||
return { ...item, ...stats };
|
||||
}
|
||||
|
||||
async fetchLogs(id) {
|
||||
const logs = await this.client.logs.list(id);
|
||||
return logs;
|
||||
}
|
||||
}
|
||||
|
||||
const globalContainersStore = new ContainersStore();
|
||||
|
Loading…
Reference in New Issue
Block a user