From a2d9cc175cdcc67931632250bcda6c5ca70bc654 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 2 Mar 2021 11:10:53 +0100 Subject: [PATCH] gradient color on proportional number of tasks compared to maximum --- output/.gitkeep | 0 output/export_tags.md | 1 + public/stylesheets/style.css | 5 ++++- routes/index.js | 24 ++++++++++++++++++++++-- views/index.jade | 5 +++-- 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 output/.gitkeep create mode 100644 output/export_tags.md diff --git a/output/.gitkeep b/output/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/output/export_tags.md b/output/export_tags.md new file mode 100644 index 0000000..9c03e1c --- /dev/null +++ b/output/export_tags.md @@ -0,0 +1 @@ +# Export de Tags GTG du 02/03/2021 à 11:09:59 \ No newline at end of file diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 3e187fd..e53ab65 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -51,7 +51,10 @@ button{ .text-right{ text-align: right; } - +.emphasis{ + font-weight: 700; + background: aquamarine; +} .proportion-over-95{ background: #b9ffbe; } diff --git a/routes/index.js b/routes/index.js index 8f8d766..15a3d15 100644 --- a/routes/index.js +++ b/routes/index.js @@ -41,6 +41,7 @@ router.get('/', async function (req, res, next) { } else { console.log('================== calcul de stats désactivé dans index.js ================== ') } + exportToMarkdown(res) console.log('json files read') res.render('index', { title: "Conversion de GTG tâches", @@ -69,6 +70,7 @@ function computeData(jsonAllData) { tasksCount : jsonAllData.tasks.project.task.length, tasksClosed: 0, tasksOpen : 0, + maxTasksCountPerTag : 0, listOpen : [], listClosed : [], } @@ -106,7 +108,11 @@ function computeData(jsonAllData) { elem.tasksListIsDoneByTitle.push(t.title) } } + if(elem.tasks > jsonAllData.stats.maxTasksCountPerTag){ + jsonAllData.stats.maxTasksCountPerTag = elem.tasks + } }) + } if (t.donedate) { jsonAllData.stats.tasksClosed++; @@ -165,11 +171,25 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) { result = 'proportion-over-15' } - console.log('result', someProportionNumber, result) return result; } -function exportToMarkdown() { +function exportToMarkdown(res) { + + let datenow = new Date(); + let dataTagsMd = '# Export de Tags GTG du '+ datenow.toLocaleString(); + // write file to disk + fs.writeFile('output/export_tags.md', dataTagsMd, 'utf8', (err) => { + + if (err) { + console.log(`Error writing file: ${err}`); + res.send(err) + } else { + console.log(`File \`output/export_tags.md\` is written successfully!`); + + } + + }); } diff --git a/views/index.jade b/views/index.jade index 45ecac4..aa721f3 100644 --- a/views/index.jade +++ b/views/index.jade @@ -10,6 +10,7 @@ block content li #{json.stats.tasksClosed} fermées section.tags h2 #{json.tags.tagstore.tag.length} Tags + p maximum de #{json.stats.maxTasksCountPerTag} tâches pour un tag. ul.tags li.head span.name nom @@ -21,11 +22,11 @@ block content span.tasks actives % each t in json.tags.tagstore.tag li - span.name= t['$'].name + span.name(class= {emphasis: t.tasks == json.stats.maxTasksCountPerTag})= t['$'].name span.color= t['$'].color span.parent= t['$'].parent if t.tasksListIsDoneByTitle - span.text-right= t.tasks + span.text-right(class=computeBgColorOnProportionOfOpenTasks(getPercent(t.tasks, json.stats.maxTasksCountPerTag)))= t.tasks if t.tasksListIsDoneByTitle span.text-right.tasks= t.tasksListIsDoneByTitle.length if t.tasksListIsActiveByTitle