ExpDuration.tsx 3.53 KB
Newer Older
1
import React from 'react';
2
import { Stack, ProgressIndicator, TooltipHost, DirectionalHint } from '@fluentui/react';
3
import { EXPERIMENT } from '../../../static/datamodel';
4
5
import { CONTROLTYPE, TOOLTIP_BACKGROUND_COLOR } from '../../../static/const';
import { convertDuration, convertTimeAsUnit } from '../../../static/function';
6
7
8
import { EditExperimentParam } from './EditExperimentParam';
import { ExpDurationContext } from './ExpDurationContext';
import { EditExpeParamContext } from './context';
Lijiaoa's avatar
Lijiaoa committed
9
import { leftProgress, durationItem2, progressHeight } from './commonStyle';
10
11
12
13
14
import '../../../static/style/overview/count.scss';

export const ExpDuration = (): any => (
    <ExpDurationContext.Consumer>
        {(value): React.ReactNode => {
15
            const { maxExecDuration, execDuration, maxDurationUnit, updateOverviewPage } = value;
16
17
            const tooltip = maxExecDuration - execDuration;
            const percent = execDuration / maxExecDuration;
18
19
            const execDurationStr = convertDuration(execDuration);
            const maxExecDurationStr = convertTimeAsUnit(maxDurationUnit, maxExecDuration).toString();
20
21
            return (
                <Stack horizontal className='ExpDuration'>
Lijiaoa's avatar
Lijiaoa committed
22
                    <div style={leftProgress}>
23
24
25
26
27
28
29
30
31
32
33
34
35
                        <TooltipHost
                            content={`${convertDuration(tooltip)} remaining`}
                            directionalHint={DirectionalHint.bottomCenter}
                            tooltipProps={{
                                calloutProps: {
                                    styles: {
                                        beak: { background: TOOLTIP_BACKGROUND_COLOR },
                                        beakCurtain: { background: TOOLTIP_BACKGROUND_COLOR },
                                        calloutMain: { background: TOOLTIP_BACKGROUND_COLOR }
                                    }
                                }
                            }}
                        >
Lijiaoa's avatar
Lijiaoa committed
36
37
38
39
40
                            <ProgressIndicator
                                className={EXPERIMENT.status}
                                percentComplete={percent}
                                barHeight={progressHeight}
                            />
41
                        </TooltipHost>
42
43
44
45
46
47
                        {/* execDuration / maxDuration: 20min / 1h */}
                        <div className='exp-progress'>
                            <span className={`${EXPERIMENT.status} bold`}>{execDurationStr}</span>
                            <span className='joiner'>/</span>
                            <span>{`${maxExecDurationStr} ${maxDurationUnit}`}</span>
                        </div>
48
                    </div>
49
                    <div style={durationItem2}>
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
                        <EditExpeParamContext.Provider
                            value={{
                                editType: CONTROLTYPE[0],
                                field: 'maxExecDuration',
                                title: 'Max duration',
                                maxExecDuration: maxExecDurationStr,
                                maxTrialNum: EXPERIMENT.profile.params.maxTrialNum,
                                trialConcurrency: EXPERIMENT.profile.params.trialConcurrency,
                                updateOverviewPage
                            }}
                        >
                            <EditExperimentParam />
                        </EditExpeParamContext.Provider>
                    </div>
                </Stack>
            );
        }}
    </ExpDurationContext.Consumer>
);