"src/targets/gpu/vscode:/vscode.git/clone" did not exist on "d1e274261ed16e374c8e97242f95ee1c7f04d1ed"
ExpDuration.tsx 3.38 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';
9
import { durationItem1, durationItem2 } 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'>
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
                    <div style={durationItem1}>
                        <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 }
                                    }
                                }
                            }}
                        >
                            <ProgressIndicator className={EXPERIMENT.status} percentComplete={percent} barHeight={15} />
37
                        </TooltipHost>
38
39
40
41
42
43
                        {/* execDuration / maxDuration: 20min / 1h */}
                        <div className='exp-progress'>
                            <span className={`${EXPERIMENT.status} bold`}>{execDurationStr}</span>
                            <span className='joiner'>/</span>
                            <span>{`${maxExecDurationStr} ${maxDurationUnit}`}</span>
                        </div>
44
                    </div>
45
                    <div style={durationItem2}>
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                        <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>
);