Skip to content

Commit

Permalink
Add shortcuts for next and after next quarters
Browse files Browse the repository at this point in the history
  • Loading branch information
scyv committed Aug 15, 2018
1 parent c922870 commit 167a319
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
4 changes: 2 additions & 2 deletions both/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function checkUserLoggedIn(ctx) {
}

Meteor.methods({
"startPomodoro"() {
"startPomodoro"(customLength) {
checkUserLoggedIn(this);
const pomodoro = Factory.createPomodoro(this.userId);
pomodoro.start = new Date();
pomodoro.targetLength = Meteor.user().profile.settings.pomodoroLength;
pomodoro.targetLength = customLength || Meteor.user().profile.settings.pomodoroLength;
Pomodoros.insert(pomodoro);
},
"stopPomodoro"(comment) {
Expand Down
15 changes: 15 additions & 0 deletions client/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ body {
cursor: pointer;
}



.row {
margin-bottom: 10px;
}
Expand Down Expand Up @@ -57,6 +59,10 @@ body {
color: #ffffff;
}

.col-sm-12 {
padding: 0;
}

}

.save-success {
Expand All @@ -68,6 +74,15 @@ body {
margin-top: 1rem;
width: 100%;
}

.btn-group {
padding: 0;
width: 100%;
}

.btn-group button {
width: 50%;
}
}

.timeLeft {
Expand Down
27 changes: 26 additions & 1 deletion client/js/pomodoro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { ProgressCircle} from "./progressCircle";

let progressIndicator = undefined;

function calcNextQuarter(quarter) {
return moment().startOf('hour').add((Math.floor((moment().minute() + 3) / 15) + quarter) * 15, 'minute');
}

function calcNextQuarterMinutes(quarter) {
return calcNextQuarter(quarter).diff(new Date(), 'minutes');
}

Template.pomodoro.helpers({
pomodoroLoading() {
Expand All @@ -16,7 +23,7 @@ Template.pomodoro.helpers({
},
runningPomodoro() {
Session.get("reactiveTimer");
if (!progressIndicator || !progressIndicator.isRendered()) {
if (!progressIndicator || !progressIndicator.isRendered()) {
renderPomodoroPie();
}

Expand Down Expand Up @@ -53,6 +60,14 @@ Template.pomodoro.helpers({
},
wideScreen() {
return Session.get("isWideScreen") && Teams.find().count() > 0;
},
nextQuarter() {
Session.get("reactiveTimer");
return calcNextQuarter(1).format("LT");
},
afterNextQuarter() {
Session.get("reactiveTimer");
return calcNextQuarter(2).format("LT");
}
});

Expand All @@ -67,6 +82,16 @@ Template.pomodoro.events({
},
"click .btn-remove-subscription"() {
Meteor.call("removeIncomingSubscription", this.from);
},
"click .btn-next-quarter"() {
Meteor.call("startPomodoro", calcNextQuarterMinutes(1), ()=> {
NotificationCenter.notifyStarted();
});
},
"click .btn-after-next-quarter"() {
Meteor.call("startPomodoro", calcNextQuarterMinutes(2), ()=> {
NotificationCenter.notifyStarted();
});
}
});

Expand Down
2 changes: 1 addition & 1 deletion client/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</div>
{{> yield}}
</div>
<footer class="text-muted small text-center"><hr>Version: 1.6.0 | Powered by <a href="https://meteor.com">Meteor</a> | Having issues? Want to contribute? Go to the <a href="https://github.com/scyv/ketchup">Github Repository</a>!</footer>
<footer class="text-muted small text-center"><hr>Version: 1.7.0 | Powered by <a href="https://meteor.com">Meteor</a> | Having issues? Want to contribute? Go to the <a href="https://github.com/scyv/ketchup">Github Repository</a>!</footer>

</template>
24 changes: 14 additions & 10 deletions client/views/pomodoro.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<template name="pomodoro">
<div class="{{rowClass}}">
<div class="row">
<div class="col-xs-12 text-center">
<div class="pie"></div>
</div>
</div>
{{#if pomodoroLoading}}
<div class="row">
<div class="col-xs-12 text-center">
Laden...
<div class="pie"></div>
</div>
</div>
{{else}}
{{#if pomodoroLoading}}
<div class="row">
<div class="col-xs-12 text-center">
Laden...
</div>
</div>
{{else}}
<div class="row timer">
<div class=" text-center">
<div class="text-center">
{{#if runningPomodoro}}
{{#with runningPomodoro}}
<button class="btn btn-lg btn-interrupt btn-danger">
Expand All @@ -24,6 +24,10 @@
<button class="btn btn-lg btn-start btn-success">
<i class="glyphicon glyphicon-play"></i> Starten
</button>
<div class="btn-group" role="group" aria-label="Shortcuts">
<button type="button" class="btn btn-default col-md-6 btn-next-quarter">Bis {{nextQuarter}}</button>
<button type="button" class="btn btn-default col-md-6 btn-after-next-quarter">Bis {{afterNextQuarter}}</button>
</div>
{{/if}}
</div>
</div>
Expand All @@ -39,7 +43,7 @@
</ul>
</div>
</div>
{{/if}}
{{/if}}
</div>
{{#if wideScreen}}
<div class="col-xs-6 widescreen teams">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ketchup",
"version": "1.5.0",
"version": "1.7.0",
"private": true,
"scripts": {
"start": "meteor run"
Expand Down

0 comments on commit 167a319

Please sign in to comment.