Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
Fix cron and make top header float
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Cucer committed Feb 22, 2018
1 parent da572d7 commit 49ed9b1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "titime",
"productName": "TiTime - Keeping the time for you",
"version": "1.4.1",
"version": "1.4.2",
"description": "Tool for Instant Time Tracking",
"main": "src/index.js",
"scripts": {
Expand Down
34 changes: 24 additions & 10 deletions src/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,36 @@ export default class Cron {
return this.jobs[name] || null;
}

add(name, cron, job, start = false) {
add(name, cronTime, job, start = false) {
if (this.exists(name)) {
throw new Error(`Cron job "${name}" already exists`);
}

Logger.debug(`Add cron job "${name}" with pattern "${cron}"`);
Logger.debug(`Add cron job "${name}" with pattern "${cronTime}"`);

const instance = new CronJob({
cronTime: cron,
onTick() {
Logger.info(`Run "${name}" cron job`);
let running = false;

return job();
},
start,
});
const onTick = () => {
if (running) {
return Promise.resolve();
}

Logger.info(`Run "${name}" cron job`);

return job()
.then((result) => {
running = false;

return Promise.resolve(result);
})
.catch((error) => {
running = false;

return Promise.reject(error);
});
};

const instance = new CronJob({ cronTime, onTick, start });

this.jobs[name] = instance;

Expand Down
49 changes: 41 additions & 8 deletions src/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,55 @@
.md-content.new-project {
margin: 30px;
}

.md-app-toolbar {
position: absolute;
top: 0;
z-index: 9999;
}

.md-app-scroller {
margin-top: 50px;
}
</style>
</head>
<body>
<app></app>
</body>

<script>
import Vue from 'vue';
import VueMaterial from 'vue-material';
import VueElectron from 'vue-electron';
import App from './component/app';
import Vue from 'vue';
import VueMaterial from 'vue-material';
import VueElectron from 'vue-electron';
import App from './component/app';

// Load global components
Vue.use(VueMaterial)
Vue.use(VueElectron);

new Vue(App).$mount('app');

let prevOffset = 0;
let offset = 0;
let navbar = null;

setInterval(() => {
if (!navbar) {
navbar = document.querySelector('.md-app-toolbar');
}

if (prevOffset !== offset) {
navbar.style.display = 'none';
} else {
navbar.style.top = `${ offset }px`;
navbar.style.display = 'initial';
}

// Load global components
Vue.use(VueMaterial)
Vue.use(VueElectron);
prevOffset = offset;
}, 40);

new Vue(App).$mount('app');
window.onscroll = () => {
offset = window.pageYOffset;
};
</script>
</html>

0 comments on commit 49ed9b1

Please sign in to comment.