color range

This commit is contained in:
Tykayn 2021-03-02 10:57:26 +01:00 committed by tykayn
parent a48013b752
commit 228f99a2ed
3 changed files with 138 additions and 51 deletions

View File

@ -21,15 +21,24 @@ li:nth-of-type(odd){
}
tag{
background : #00B7FF;
background : #00b7ff;
padding: 0.5em;
border-radius: 0.15em;
}
button{
border: 0;
padding: 0.5em 1em;
border-radius: 0.2em;
cursor:pointer;
}
.toggle + ul{
height: 0;
visibility: collapse;
}
.toggle:focus{
background:#00b7ff;
color: white;
}
.toggle:focus + ul{
height: 100%;
transition: all ease 0.5s;
@ -39,3 +48,34 @@ tag{
padding: 0.5em;
margin-left: 1em;
}
.text-right{
text-align: right;
}
.proportion-over-95{
background: #b9ffbe;
}
.proportion-over-90{
background: aquamarine;
}
.proportion-over-80{
background: #b8ffe8;
}
.proportion-over-65{
background: #e5ffb8;
}
.proportion-over-50{
background: #ffffd9;
}
.proportion-over-40{
background: #ffeed5;
}
.proportion-over-25{
background: #d6bcaa;
}
.proportion-over-15{
background: #e5cbd0;
}
.proportion-over-0{
background: #a59098;
}

View File

@ -42,9 +42,13 @@ router.get('/', async function (req, res, next) {
console.log('================== calcul de stats désactivé dans index.js ================== ')
}
console.log('json files read')
res.render('index', {title: "Conversion de GTG tâches",
res.render('index', {
title: "Conversion de GTG tâches",
json : jsonAllData,
getPercentOfOpenTasks})
getPercent,
computeBgColorOnProportionOfOpenTasks,
getPercentOfOpenTasks
})
});
async function readfileJson(fileToOpen) {
@ -115,6 +119,7 @@ function computeData(jsonAllData){
return jsonAllData
}
function convertOneXmlToJson(fileToOpen, res) {
fs.readFile(`sources/${fileToOpen}.xml`, "utf-8", function (err, data) {
if (err) console.log(err);
@ -127,6 +132,47 @@ function convertOneXmlToJson(fileToOpen,res){
function getPercentOfOpenTasks(someCount) {
return Math.round(100 * someCount / jsonAllData.stats.tasksOpen)
}
function getPercent(someCount, total) {
return Math.round(100 * someCount / total)
}
function computeBgColorOnProportionOfOpenTasks(someProportionNumber) {
let result = '';
if(someProportionNumber >= 95){
result = 'proportion-over-95'
}
else if(someProportionNumber >= 90){
result = 'proportion-over-90'
}
else if(someProportionNumber >= 80){
result = 'proportion-over-80'
}
else if(someProportionNumber >= 65){
result = 'proportion-over-65'
}
else if(someProportionNumber >= 50){
result = 'proportion-over-50'
}
else if(someProportionNumber >= 40){
result = 'proportion-over-40'
}
else if(someProportionNumber >= 25){
result = 'proportion-over-25'
}
else if(someProportionNumber >= 15){
result = 'proportion-over-15'
}
console.log('result', someProportionNumber, result)
return result;
}
function exportToMarkdown() {
}
function transformToJson(xml, fileToOpen, res) {
return parseString(xml, function (err, result) {
if (err) console.log(err);
@ -151,5 +197,4 @@ function transformToJson(xml,fileToOpen, res) {
});
}
module.exports = router;

View File

@ -24,13 +24,15 @@ block content
span.name= t['$'].name
span.color= t['$'].color
span.parent= t['$'].parent
span.tasks= t.tasks
if t.tasksListIsDoneByTitle
span.tasks= t.tasksListIsDoneByTitle.length
span.text-right= t.tasks
if t.tasksListIsDoneByTitle
span.text-right.tasks= t.tasksListIsDoneByTitle.length
if t.tasksListIsActiveByTitle
span.tasks #{t.tasksListIsActiveByTitle.length}
span.tasks #{getPercentOfOpenTasks(t.tasksListIsActiveByTitle.length)} %
button.toggle voir
span.text-right.tasks #{t.tasksListIsActiveByTitle.length}
span.text-right.tasks(class=computeBgColorOnProportionOfOpenTasks(getPercent(t.tasksListIsActiveByTitle.length, t.tasks))) #{getPercent(t.tasksListIsActiveByTitle.length, t.tasks)} %
span.text-right.tasks #{getPercentOfOpenTasks(t.tasksListIsActiveByTitle.length)} %
button.text-right.toggle voir
ul
each activetask in t.tasksListIsActiveByTitle
li.task_item= activetask