diff --git a/releasenotes/notes/feat_instance_log_to_nova-c14b17bdd1e4b708.yaml b/releasenotes/notes/feat_instance_log_to_nova-c14b17bdd1e4b708.yaml new file mode 100644 index 00000000..0d96cdeb --- /dev/null +++ b/releasenotes/notes/feat_instance_log_to_nova-c14b17bdd1e4b708.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + feat: Adding log feature to Nova instance detail page. + Log tab has been added to the Nova instance detail interface. \ No newline at end of file diff --git a/src/pages/compute/containers/Instance/Detail/Log/index.jsx b/src/pages/compute/containers/Instance/Detail/Log/index.jsx new file mode 100644 index 00000000..e88a2513 --- /dev/null +++ b/src/pages/compute/containers/Instance/Detail/Log/index.jsx @@ -0,0 +1,102 @@ +import React, { useEffect, useState } from 'react'; +import globalInstanceLogStore from 'src/stores/nova/instance'; +import { Button, Col, Form, InputNumber, Row, Skeleton } from 'antd'; +import { SearchOutlined, SettingOutlined } from '@ant-design/icons'; +import classnames from 'classnames'; +import styles from 'src/components/Tables/Base/index.less'; + +export default function Log(props) { + const [logs, setLogs] = useState(''); + const [loading, setLoading] = useState(true); + + useEffect(() => { + getLogs(35); + }, []); + + const getLogs = async (tailSize) => { + setLoading(true); + const data = await globalInstanceLogStore.fetchLogs(props.detail.id, tailSize); + setLogs(data.output); + setLoading(false); + }; + + function onFinish(value) { + getLogs(value.number); + } + + async function viewFullLog() { + setLoading(true); + const data = await globalInstanceLogStore.fetchLogs(props.detail.id, null); + const newWindow = window.open('console', '_blank'); + const title = t('Console Log'); + const htmlContent = ` + +
+${data.output}+ + `; + newWindow.document.write(htmlContent); + newWindow.document.close(); + setLoading(false); + } + + return ( +
{logs}: t('No Logs...')} +