gradient color on proportional number of tasks compared to maximum

This commit is contained in:
Tykayn 2021-03-02 11:10:53 +01:00 committed by tykayn
parent 228f99a2ed
commit a2d9cc175c
5 changed files with 30 additions and 5 deletions

0
output/.gitkeep Normal file
View File

1
output/export_tags.md Normal file
View File

@ -0,0 +1 @@
# Export de Tags GTG du 02/03/2021 à 11:09:59

View File

@ -51,7 +51,10 @@ button{
.text-right{ .text-right{
text-align: right; text-align: right;
} }
.emphasis{
font-weight: 700;
background: aquamarine;
}
.proportion-over-95{ .proportion-over-95{
background: #b9ffbe; background: #b9ffbe;
} }

View File

@ -41,6 +41,7 @@ router.get('/', async function (req, res, next) {
} else { } else {
console.log('================== calcul de stats désactivé dans index.js ================== ') console.log('================== calcul de stats désactivé dans index.js ================== ')
} }
exportToMarkdown(res)
console.log('json files read') console.log('json files read')
res.render('index', { res.render('index', {
title: "Conversion de GTG tâches", title: "Conversion de GTG tâches",
@ -69,6 +70,7 @@ function computeData(jsonAllData) {
tasksCount : jsonAllData.tasks.project.task.length, tasksCount : jsonAllData.tasks.project.task.length,
tasksClosed: 0, tasksClosed: 0,
tasksOpen : 0, tasksOpen : 0,
maxTasksCountPerTag : 0,
listOpen : [], listOpen : [],
listClosed : [], listClosed : [],
} }
@ -106,7 +108,11 @@ function computeData(jsonAllData) {
elem.tasksListIsDoneByTitle.push(t.title) elem.tasksListIsDoneByTitle.push(t.title)
} }
} }
if(elem.tasks > jsonAllData.stats.maxTasksCountPerTag){
jsonAllData.stats.maxTasksCountPerTag = elem.tasks
}
}) })
} }
if (t.donedate) { if (t.donedate) {
jsonAllData.stats.tasksClosed++; jsonAllData.stats.tasksClosed++;
@ -165,11 +171,25 @@ function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
result = 'proportion-over-15' result = 'proportion-over-15'
} }
console.log('result', someProportionNumber, result)
return 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!`);
}
});
} }

View File

@ -10,6 +10,7 @@ block content
li #{json.stats.tasksClosed} fermées li #{json.stats.tasksClosed} fermées
section.tags section.tags
h2 #{json.tags.tagstore.tag.length} Tags h2 #{json.tags.tagstore.tag.length} Tags
p maximum de #{json.stats.maxTasksCountPerTag} tâches pour un tag.
ul.tags ul.tags
li.head li.head
span.name nom span.name nom
@ -21,11 +22,11 @@ block content
span.tasks actives % span.tasks actives %
each t in json.tags.tagstore.tag each t in json.tags.tagstore.tag
li li
span.name= t['$'].name span.name(class= {emphasis: t.tasks == json.stats.maxTasksCountPerTag})= t['$'].name
span.color= t['$'].color span.color= t['$'].color
span.parent= t['$'].parent span.parent= t['$'].parent
if t.tasksListIsDoneByTitle if t.tasksListIsDoneByTitle
span.text-right= t.tasks span.text-right(class=computeBgColorOnProportionOfOpenTasks(getPercent(t.tasks, json.stats.maxTasksCountPerTag)))= t.tasks
if t.tasksListIsDoneByTitle if t.tasksListIsDoneByTitle
span.text-right.tasks= t.tasksListIsDoneByTitle.length span.text-right.tasks= t.tasksListIsDoneByTitle.length
if t.tasksListIsActiveByTitle if t.tasksListIsActiveByTitle