This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: try timeline vis upgrade to v0.2.2
- Loading branch information
Showing
5 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Timeline } from 'antd'; | ||
import * as React from 'react'; | ||
import { PomodoroRecord } from '../../monitor/type'; | ||
import { getIndexToTitleApp } from '../../monitor/sessionManager'; | ||
import { EfficiencyAnalyser } from '../../../efficiency/efficiency'; | ||
import { to2digits } from '../../utils'; | ||
|
||
interface Props { | ||
record: PomodoroRecord; | ||
efficiencyAnalyser: EfficiencyAnalyser; | ||
} | ||
|
||
function formatTime(time: number) { | ||
const date = new Date(time); | ||
const hour = to2digits(date.getHours()); | ||
const m = to2digits(date.getMinutes()); | ||
const s = to2digits(date.getSeconds()); | ||
return `${hour}:${m}:${s}.${date.getMilliseconds()}`; | ||
} | ||
|
||
export const PomodoroTimeline = (props: Props) => { | ||
const data: any[] = []; | ||
let time = props.record.startTime; | ||
const indexToTitle = getIndexToTitleApp(props.record); | ||
for (let i = 0; i < props.record.stayTimeInSecond!.length; i += 1) { | ||
const stay = props.record.stayTimeInSecond![i]; | ||
const index = props.record.switchActivities![i]; | ||
const [title, app] = indexToTitle[index]; | ||
const isDistracting = props.efficiencyAnalyser.getIsDistracting(app, title); | ||
const sTime = formatTime(time); | ||
|
||
data.push( | ||
<Timeline.Item color={isDistracting ? 'red' : 'green'}> | ||
<p>{app}</p> | ||
<p>{title}</p> | ||
<p>{sTime}</p> | ||
</Timeline.Item> | ||
); | ||
|
||
time += stay; | ||
} | ||
|
||
return <Timeline>{data}</Timeline>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters