Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid values from the manager-api #736

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions web/src/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from 'react';
import { notification } from 'antd';
import { MenuDataItem } from '@ant-design/pro-layout';
import { history } from 'umi';
import moment from 'moment';

import { codeMessage } from './constants';
import IconFont from './iconfont';
Expand Down Expand Up @@ -96,3 +97,12 @@ export const getUrlQuery: (key: string) => string | false = (key: string) => {
}
return false;
};

export const timestampToLocaleString = (timestamp: number) => {
if (!timestamp) {
// TODO: i18n
return "None"
LiteSun marked this conversation as resolved.
Show resolved Hide resolved
}

return moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss')
}
4 changes: 2 additions & 2 deletions web/src/pages/Consumer/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import React, { useRef } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import { Popconfirm, Button, notification } from 'antd';
import moment from 'moment';
import { history, useIntl } from 'umi';
import { PlusOutlined } from '@ant-design/icons';

import { fetchList, remove } from './service';
import { timestampToLocaleString } from '@/helpers';

const Page: React.FC = () => {
const ref = useRef<ActionType>();
Expand All @@ -42,7 +42,7 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'page.consumer.updateTime' }),
dataIndex: 'update_time',
hideInSearch: true,
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'component.global.operation' }),
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Route/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import React, { useRef } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import { Button, Popconfirm, notification, Tag, Space } from 'antd';
import moment from 'moment';
import { history, useIntl } from 'umi';
import { PlusOutlined } from '@ant-design/icons';

import { fetchList, remove } from './service';
import { timestampToLocaleString } from '@/helpers';

const Page: React.FC = () => {
const ref = useRef<ActionType>();
Expand Down Expand Up @@ -63,7 +63,7 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'component.global.updateTime' }),
dataIndex: 'update_time',
hideInSearch: true,
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'component.global.operation' }),
Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/SSL/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import { Button, Popconfirm, notification, Tag } from 'antd';
import { useIntl, history } from 'umi';
import { PlusOutlined } from '@ant-design/icons';
import moment from 'moment';

import { fetchList, remove as removeSSL } from '@/pages/SSL/service';
import { timestampToLocaleString } from '@/helpers';

const Page: React.FC = () => {
const tableRef = useRef<ActionType>();
Expand All @@ -44,13 +44,13 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'page.ssl.list.expirationTime' }),
dataIndex: 'validity_end',
hideInSearch: true,
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'component.global.updateTime' }),
dataIndex: 'update_time',
hideInSearch: true,
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'component.global.operation' }),
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Upstream/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { PageContainer } from '@ant-design/pro-layout';
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import { Popconfirm, Button, notification } from 'antd';
import { history, useIntl } from 'umi';
import moment from 'moment';
import { PlusOutlined } from '@ant-design/icons';

import { fetchList, remove } from './service';
import { timestampToLocaleString } from '@/helpers';

const Page: React.FC = () => {
const ref = useRef<ActionType>();
Expand All @@ -48,7 +48,7 @@ const Page: React.FC = () => {
title: formatMessage({ id: 'upstream.list.edit.time' }),
dataIndex: 'update_time',
hideInSearch: true,
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
render: (text) => timestampToLocaleString(text as number),
},
{
title: formatMessage({ id: 'upstream.list.operation' }),
Expand Down