From 49ed9b195a33514961f6b59748e50f77223459b0 Mon Sep 17 00:00:00 2001 From: Alexander Cucer Date: Thu, 22 Feb 2018 13:42:08 +0200 Subject: [PATCH] Fix cron and make top header float --- package.json | 2 +- src/cron.js | 34 ++++++++++++++++++++++--------- src/view/index.html | 49 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 28ae846..6f321cc 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/cron.js b/src/cron.js index 92faf2a..7cb035a 100644 --- a/src/cron.js +++ b/src/cron.js @@ -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; diff --git a/src/view/index.html b/src/view/index.html index 62acb84..fd434a1 100644 --- a/src/view/index.html +++ b/src/view/index.html @@ -21,6 +21,16 @@ .md-content.new-project { margin: 30px; } + + .md-app-toolbar { + position: absolute; + top: 0; + z-index: 9999; + } + + .md-app-scroller { + margin-top: 50px; + } @@ -28,15 +38,38 @@