Skip to content

Commit

Permalink
Fixed counter text
Browse files Browse the repository at this point in the history
  • Loading branch information
PatentLobster committed Jun 14, 2020
1 parent b0f0736 commit a101e7a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://itzik.co"
},
"description": "Track your office hours.",
"version": "0.1.6",
"version": "0.1.7",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
Expand Down
5 changes: 3 additions & 2 deletions src/components/Countdown.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="timeLeft" class="daily-target">
<span>First Login: {{firstLogin}}</span>
<span>Goal: {{dailyGoal}}</span>
<span>Goal: {{goal}}</span>
<span>Time left: {{ timeLeft }}</span>
</div>
</template>
Expand All @@ -16,19 +16,20 @@
computed: {
...mapState([
'firstLogin',
'dailyGoal',
'settings'
]),
},
data: () => {
return {
timeLeft: null,
goal: "00:04:20",
}
},
methods: {
updateClock() {
let hoursToGo = (this.settings.countDown) ? this.settings.countDown : 9;
const goal = moment(this.firstLogin, "HH:mm:ss").add(hoursToGo, "hours");
this.goal = goal.format("HH:mm:ss");
const now = moment(new Date(), "HH:mm:ss");
const offset = goal.diff(now);
this.timeLeft = moment.utc(offset).format("HH:mm:ss");
Expand Down
24 changes: 3 additions & 21 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import Vuex from 'vuex'
import types from "@/store/types";
import {remote} from 'electron'
import settings from 'electron-settings';
// settings.configure({atomicSave: true});
// console.log(settings.file());

import moment from 'moment';

const db = remote.getGlobal('db');
Expand All @@ -20,7 +19,6 @@ export default new Vuex.Store({
"date": `2020-02-02`,
},
firstLogin: "",
dailyGoal: "",
settings: [],
},
mutations: {
Expand All @@ -34,33 +32,21 @@ export default new Vuex.Store({
state.days = payload;
},
[types.SET_CURRENT](state, payload) {
state.firstLogin = payload[0];
state.dailyGoal = payload[1];
state.firstLogin = payload;
},
[types.FETCH_SETTINGS](state, payload) {
state.settings = payload;
},
},
actions: {
[types.GET_SETTINGS]({commit}) {
// db.find({settings: "settings"}, (err, result) => {
// commit(types.FETCH_SETTINGS, result);
// });
const settingsArr = settings.getSync();
commit(types.FETCH_SETTINGS, settingsArr)
},
/* eslint-disable no-unused-vars */
async [types.SET_SETTINGS]({commit}, k) {
console.log("se", k);
await settings.set(k[0], k[1]);
commit(types.FETCH_SETTINGS, settings.getSync());
// await settings.set({hjo});
// settings.set({hours: 8});

// db.update({settings: "settings"}, { $set: { system: 'solar system' } }, {}, (err, result) => {
// console.log(result);
// commit(types.FETCH_SETTINGS, result);
// });
},
[types.FETCH_ALL_DAYS]({commit}) {
db.find({}, (err, result) => {
Expand Down Expand Up @@ -122,8 +108,7 @@ export default new Vuex.Store({
});

const firstLoginObj = moment(todayObj[0].clockIn[0], "HH:mm:ss");

commit(types.SET_CURRENT, [firstLoginObj.format("HH:mm:ss"), firstLoginObj.add(9, "hours").format("HH:mm:ss")]);
commit(types.SET_CURRENT, firstLoginObj.format("HH:mm:ss"));
});
},
[types.FETCH_CURRENT]({commit}, request) {
Expand All @@ -138,9 +123,6 @@ export default new Vuex.Store({
} else {
commit(types.SET, result[0]);
}
// const today = moment(new Date(), "YYYY-MM-DD").format("YYYY-MM-DD");
// console.log(this.firstLogin);
// console.log("days", this.days);
});
},

Expand Down
3 changes: 1 addition & 2 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@
]),
},
created() {
console.log(this.currentMonth);
this.GET_SETTINGS(true);
this.FETCH_DAYS(this.currentMonth);
this.GET_SETTINGS();
},
}
Expand Down

0 comments on commit a101e7a

Please sign in to comment.