Error.tsx 3.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
import React, {FunctionComponent} from 'react';
import {Trans, useTranslation} from '~/utils/i18n';
import {WithStyled, backgroundColor, em, link, rem, size, textColor, textLightColor} from '~/utils/style';

import styled from 'styled-components';

const Wrapper = styled.div`
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: ${backgroundColor};
    height: 100%;
    width: 100%;

    > .image {
        background-image: url(${`${process.env.PUBLIC_PATH}/images/empty.svg`});
        background-repeat: no-repeat;
        background-position: center center;
        background-size: 100% 100%;
        ${size(rem(244), rem(280))}
    }

    > .inner {
        width: calc(50% - ${rem(280)});
        color: ${textLightColor};
        ${link}

        h4 {
            color: ${textColor};
            font-size: ${em(18)};
            font-weight: 700;
        }

        p {
            margin: 0;
        }

        ol {
            padding-left: 2em;
            line-height: 1.857142857;
        }
    }
`;

45 46
const reload = () => window.location.reload();

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
const Error: FunctionComponent<WithStyled> = ({className, children}) => {
    const {t} = useTranslation('errors');

    return (
        <Wrapper className={className}>
            <div className="image"></div>
            <div className="inner">
                {children || (
                    <>
                        <h4>{t('errors:common.title')}</h4>
                        <p>{t('errors:common.description')}</p>
                        <ol>
                            <li>
                                <Trans i18nKey="errors:common.1">
                                    Log files are not generated. Please refer to&nbsp;
                                    <a href="https://github.com/PaddlePaddle/VisualDL" target="_blank" rel="noreferrer">
                                        README
                                    </a>
                                    &nbsp;to create log files.
                                </Trans>
                            </li>
                            <li>
                                <Trans i18nKey="errors:common.2">
                                    Log files are generated but data is not written yet. Please refer to&nbsp;
                                    <a
                                        href="https://github.com/PaddlePaddle/VisualDL/blob/develop/docs/components/README.md"
                                        target="_blank"
                                        rel="noreferrer"
                                    >
                                        VisualDL User Guide
                                    </a>
                                    &nbsp;to write visualized data.
                                </Trans>
                            </li>
                            <li>
                                <Trans i18nKey="errors:common.3">
                                    Log files are generated and data is writte. Please try to&nbsp;
84
                                    <a onClick={reload}>Refresh</a>.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                                </Trans>
                            </li>
                            <li>
                                <Trans i18nKey="errors:common.4">
                                    Log files are generated but path to log directory is wrong. Please check your
                                    directory and try again.
                                </Trans>
                            </li>
                        </ol>
                    </>
                )}
            </div>
        </Wrapper>
    );
};

export default Error;