Skip to content

Commit

Permalink
feat: server info page time stamp display. (#1256)
Browse files Browse the repository at this point in the history
* fix: server info page time stamp display.

* fix: format codes

Co-authored-by: 琚致远 <juzhiyuan@apache.org>
Co-authored-by: litesun <sunyi@apache.org>
  • Loading branch information
3 people committed Jan 12, 2021
1 parent a5b2b15 commit 2a2e882
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions web/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Settings as LayoutSettings,
TopNavHeaderProps,
} from '@ant-design/pro-layout';
import moment from 'moment';

import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer';
Expand All @@ -34,6 +35,7 @@ export async function getInitialState(): Promise<{
currentUser?: API.CurrentUser;
settings?: LayoutSettings;
}> {
moment.locale(['en-US', 'zh-CN']);
const token = localStorage.getItem('token');
if (!token) {
history.replace(`/user/login?redirect=${encodeURIComponent(window.location.pathname)}`);
Expand Down
12 changes: 11 additions & 1 deletion web/src/pages/ServerInfo/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React, { useEffect, useState } from 'react';
import { Select, Empty, Form } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
import { useIntl } from 'umi';
import moment from 'moment';

import { fetchInfoList } from './service';
import styles from './style.less';
Expand All @@ -31,7 +32,16 @@ const ServerInfo: React.FC = () => {
const [form] = Form.useForm();

useEffect(() => {
fetchInfoList().then((list) => {
fetchInfoList().then((infoList) => {
const list = infoList.map(item => {
return {
...item,
boot_time: moment(item.boot_time * 1000).format('YYYY-MM-DD HH:mm:ss'),
last_report_time: moment(item.last_report_time * 1000).format('YYYY-MM-DD HH:mm:ss'),
up_time: moment(item.boot_time * 1000).fromNow(true),
}
});

setNodeList(list);
if (list.length) {
form.setFieldsValue({
Expand Down

0 comments on commit 2a2e882

Please sign in to comment.