mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-30 11:10:04 +00:00
feat(pomodoro): add better integration with time tracking #32
This commit is contained in:
parent
c7bfa49e14
commit
ae332680df
3 changed files with 62 additions and 21 deletions
|
|
@ -114,12 +114,15 @@
|
|||
syncPath: '~/sync.json',
|
||||
},
|
||||
pomodoro: {
|
||||
isEnabled: true,
|
||||
duration: moment.duration(45, 'minutes'),
|
||||
breakDuration: moment.duration(5, 'minutes'),
|
||||
longerBreakDuration: moment.duration(15, 'minutes'),
|
||||
cyclesBeforeLongerBreak: 4,
|
||||
isStopTrackingOnBreak: true,
|
||||
isStopTrackingOnLongBreak: true,
|
||||
isOnlyTrackPomodoroTime: false,
|
||||
isShowDistractionsOnBreak: true,
|
||||
isEnabled: true,
|
||||
},
|
||||
isTakeABreakEnabled: false,
|
||||
takeABreakMinWorkingTime: undefined,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
class PomodoroButton {
|
||||
/* @ngInject */
|
||||
constructor($rootScope, $interval, Dialogs, Tasks) {
|
||||
constructor($rootScope, $interval, Dialogs, Tasks, LS_DEFAULTS) {
|
||||
this.$rootScope = $rootScope;
|
||||
this.$interval = $interval;
|
||||
this.Dialogs = Dialogs;
|
||||
|
|
@ -24,6 +24,10 @@
|
|||
this.data = this.$rootScope.r.currentSession.pomodoro || {};
|
||||
this.$rootScope.r.currentSession.pomodoro = this.data;
|
||||
|
||||
if (!this.$rootScope.r.config.pomodoro) {
|
||||
this.$rootScope.r.config.pomodoro = LS_DEFAULTS.config.pomodoro;
|
||||
}
|
||||
|
||||
this.config = this.$rootScope.r.config.pomodoro;
|
||||
|
||||
this.initSession();
|
||||
|
|
@ -80,8 +84,11 @@
|
|||
sessionDone() {
|
||||
this.data.isOnBreak = !this.data.isOnBreak;
|
||||
if (this.data.isOnBreak) {
|
||||
this.lastCurrentTask = this.Tasks.getCurrent();
|
||||
this.Tasks.updateCurrent(undefined);
|
||||
if ((this.config.isStopTrackingOnBreak && this.isOnShortBreak()) ||
|
||||
(this.config.isStopTrackingOnLongBreak && this.isOnLongBreak())) {
|
||||
this.lastCurrentTask = this.Tasks.getCurrent();
|
||||
this.Tasks.updateCurrent(undefined);
|
||||
}
|
||||
} else {
|
||||
this.data.currentCycle++;
|
||||
this.selectTask()
|
||||
|
|
@ -91,17 +98,14 @@
|
|||
}
|
||||
|
||||
setSessionTimerTime() {
|
||||
if (this.data.isOnBreak) {
|
||||
// init break session timer
|
||||
if (this.data.currentCycle % this.config.cyclesBeforeLongerBreak === 0) {
|
||||
this.data.currentSessionTime = moment
|
||||
.duration(this.config.longerBreakDuration)
|
||||
.asMilliseconds();
|
||||
} else {
|
||||
this.data.currentSessionTime = moment
|
||||
.duration(this.config.breakDuration)
|
||||
.asMilliseconds();
|
||||
}
|
||||
if (this.isOnLongBreak()) {
|
||||
this.data.currentSessionTime = moment
|
||||
.duration(this.config.longerBreakDuration)
|
||||
.asMilliseconds();
|
||||
} else if (this.isOnShortBreak()) {
|
||||
this.data.currentSessionTime = moment
|
||||
.duration(this.config.breakDuration)
|
||||
.asMilliseconds();
|
||||
} else {
|
||||
// init work session timer
|
||||
this.data.currentSessionTime = moment.duration(this.config.duration).asMilliseconds();
|
||||
|
|
@ -125,19 +129,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
isOnLongBreak() {
|
||||
return (this.data.isOnBreak && (this.data.currentCycle % this.config.cyclesBeforeLongerBreak === 0));
|
||||
}
|
||||
|
||||
isOnShortBreak() {
|
||||
return (this.data.isOnBreak && (this.data.currentCycle % this.config.cyclesBeforeLongerBreak !== 0));
|
||||
}
|
||||
|
||||
selectTask(cb) {
|
||||
const execCbIfGiven = () => {
|
||||
if (cb) {
|
||||
cb.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
if (!this.Tasks.getCurrent()) {
|
||||
if (this.lastCurrentTask) {
|
||||
this.Tasks.updateCurrent(this.lastCurrentTask);
|
||||
cb && cb.apply(this);
|
||||
execCbIfGiven();
|
||||
} else {
|
||||
this.Dialogs('TASK_SELECTION')
|
||||
.then(() => {
|
||||
cb && cb.apply(this);
|
||||
});
|
||||
.then(execCbIfGiven);
|
||||
}
|
||||
} else {
|
||||
cb && cb.apply(this);
|
||||
execCbIfGiven();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
<div class="md-subhead">Pomodoro Settings</div>
|
||||
<p>The pomodoro timer can be configured via 4 settings. The duration of every work session, the duration of normal breaks, the number of work sessions to run before a longer break is started and the duration of this longer break.</p>
|
||||
<p>You can also set if you want to display your distractions during your pomodoro breaks.</p>
|
||||
|
||||
<p>Setting "Pause time tracking on pomodoro break" will also track your breaks as work time spent on a task. Setting "Pause time tracking on <strong>longer</strong> pomodoro break" will do the same for the longer breaks.</p>
|
||||
<p>Enabling "Only track pomodoro time" will disable time tracking if you're not in an active pomodoro work session.</p>
|
||||
|
||||
</help-section>
|
||||
|
||||
|
|
@ -109,6 +110,27 @@
|
|||
ng-model="vm.settings.pomodoro.cyclesBeforeLongerBreak">
|
||||
</md-input-container>
|
||||
|
||||
<div>
|
||||
<md-switch ng-model="vm.settings.pomodoro.isStopTrackingOnBreak"
|
||||
aria-label="Pause time tracking on pomodoro break">
|
||||
Pause time tracking on pomodoro break
|
||||
</md-switch>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<md-switch ng-model="vm.settings.pomodoro.isStopTrackingOnLongBreak"
|
||||
aria-label="Pause time tracking on longer pomodoro break">
|
||||
Pause time tracking on <strong>longer</strong> pomodoro break
|
||||
</md-switch>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<md-switch ng-model="vm.settings.pomodoro.isOnlyTrackPomodoroTime"
|
||||
aria-label="Only track pomodoro time">
|
||||
Only track pomodoro time
|
||||
</md-switch>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<md-switch ng-model="vm.settings.pomodoro.isShowDistractionsOnBreak"
|
||||
aria-label="Show distractions on break">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue