Compare commits
2 Commits
8a6b6078c7
...
228f99a2ed
Author | SHA1 | Date | |
---|---|---|---|
228f99a2ed | |||
a48013b752 |
@ -21,7 +21,61 @@ li:nth-of-type(odd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
tag{
|
tag{
|
||||||
background : #00B7FF;
|
background : #00b7ff;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
border-radius: 0.15em;
|
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;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
.task_item{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
120
routes/index.js
120
routes/index.js
@ -6,13 +6,13 @@ var router = express.Router();
|
|||||||
var fileToOpen = 'gtg_tasks'
|
var fileToOpen = 'gtg_tasks'
|
||||||
|
|
||||||
// const convertFiles = true;
|
// const convertFiles = true;
|
||||||
const convertFiles = false;
|
let convertFiles = false;
|
||||||
const computeDataOnExtract = true;
|
let computeDataOnExtract = true;
|
||||||
|
|
||||||
let jsonAllData = {
|
let jsonAllData = {
|
||||||
tasks : {},
|
tasks : {},
|
||||||
stats : {},
|
stats : {},
|
||||||
projects : {},
|
projects: {},
|
||||||
tags : {},
|
tags : {},
|
||||||
}
|
}
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
@ -21,12 +21,12 @@ let jsonAllData = {
|
|||||||
*/
|
*/
|
||||||
router.get('/', async function (req, res, next) {
|
router.get('/', async function (req, res, next) {
|
||||||
|
|
||||||
if(convertFiles){
|
if (convertFiles) {
|
||||||
|
|
||||||
convertOneXmlToJson('gtg_tasks',res)
|
convertOneXmlToJson('gtg_tasks', res)
|
||||||
convertOneXmlToJson('tags',res)
|
convertOneXmlToJson('tags', res)
|
||||||
convertOneXmlToJson('projects',res)
|
convertOneXmlToJson('projects', res)
|
||||||
}else{
|
} else {
|
||||||
console.log('================== conversion de fichiers désactivée dans index.js ================== ')
|
console.log('================== conversion de fichiers désactivée dans index.js ================== ')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,25 +34,32 @@ router.get('/', async function (req, res, next) {
|
|||||||
jsonAllData.tags = require('../sources/tags_gtg.json')
|
jsonAllData.tags = require('../sources/tags_gtg.json')
|
||||||
jsonAllData.tasks = require('../sources/gtg_tasks_gtg.json')
|
jsonAllData.tasks = require('../sources/gtg_tasks_gtg.json')
|
||||||
|
|
||||||
if(computeDataOnExtract){
|
if (computeDataOnExtract) {
|
||||||
|
|
||||||
jsonAllData = computeData(jsonAllData)
|
jsonAllData = computeData(jsonAllData)
|
||||||
}else{
|
computeDataOnExtract = false;
|
||||||
|
} else {
|
||||||
console.log('================== calcul de stats désactivé dans index.js ================== ')
|
console.log('================== calcul de stats désactivé dans index.js ================== ')
|
||||||
}
|
}
|
||||||
console.log('json files read' )
|
console.log('json files read')
|
||||||
res.render('index', {title: "Conversion de GTG tâches", json: jsonAllData})
|
res.render('index', {
|
||||||
|
title: "Conversion de GTG tâches",
|
||||||
|
json : jsonAllData,
|
||||||
|
getPercent,
|
||||||
|
computeBgColorOnProportionOfOpenTasks,
|
||||||
|
getPercentOfOpenTasks
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
async function readfileJson(fileToOpen){
|
async function readfileJson(fileToOpen) {
|
||||||
fs.readFile(`sources/${fileToOpen}`, "utf-8", function (err, data) {
|
fs.readFile(`sources/${fileToOpen}`, "utf-8", function (err, data) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
console.log('ok ', fileToOpen )
|
console.log('ok ', fileToOpen)
|
||||||
return JSON.parse(data)
|
return JSON.parse(data)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeData(jsonAllData){
|
function computeData(jsonAllData) {
|
||||||
|
|
||||||
// trouver le nombre de tâches ayant un tag en particulier
|
// trouver le nombre de tâches ayant un tag en particulier
|
||||||
// et rajouter ce nombre à chaque tag, dans countTasks : N
|
// et rajouter ce nombre à chaque tag, dans countTasks : N
|
||||||
@ -60,52 +67,51 @@ function computeData(jsonAllData){
|
|||||||
|
|
||||||
jsonAllData.stats = {
|
jsonAllData.stats = {
|
||||||
tasksCount : jsonAllData.tasks.project.task.length,
|
tasksCount : jsonAllData.tasks.project.task.length,
|
||||||
tasksClosed : 0,
|
tasksClosed: 0,
|
||||||
tasksOpen : 0,
|
tasksOpen : 0,
|
||||||
listOpen: [],
|
listOpen : [],
|
||||||
listClosed: [],
|
listClosed : [],
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let t of jsonAllData.tasks.project.task ) {
|
for (let t of jsonAllData.tasks.project.task) {
|
||||||
// console.log('t', t)
|
// console.log('t', t)
|
||||||
let tags = t["$"].tags.split(',')
|
let tags = t["$"].tags.split(',')
|
||||||
for(let tag of tags){
|
for (let tag of tags) {
|
||||||
// console.log('tag', tag)
|
// console.log('tag', tag)
|
||||||
jsonAllData.tags.tagstore.tag.map( elem =>{
|
jsonAllData.tags.tagstore.tag.map(elem => {
|
||||||
// console.log('elem', elem)
|
// console.log('elem', elem)
|
||||||
if(elem['$'].name == tag){
|
if (elem['$'].name == tag) {
|
||||||
if(!elem.tasks){
|
if (!elem.tasks) {
|
||||||
elem.tasks = 0
|
elem.tasks = 0
|
||||||
}
|
}
|
||||||
if(!elem.tasksListById){
|
if (!elem.tasksListById) {
|
||||||
elem.tasksListById = []
|
elem.tasksListById = []
|
||||||
}
|
}
|
||||||
if(!elem.tasksListByTitle){
|
if (!elem.tasksListByTitle) {
|
||||||
elem.tasksListByTitle = []
|
elem.tasksListByTitle = []
|
||||||
}
|
}
|
||||||
if(!elem.tasksListIsActiveByTitle){
|
if (!elem.tasksListIsActiveByTitle) {
|
||||||
elem.tasksListIsActiveByTitle = []
|
elem.tasksListIsActiveByTitle = []
|
||||||
}
|
}
|
||||||
if(!elem.tasksListIsDoneByTitle){
|
if (!elem.tasksListIsDoneByTitle) {
|
||||||
elem.tasksListIsDoneByTitle = []
|
elem.tasksListIsDoneByTitle = []
|
||||||
}
|
}
|
||||||
elem.tasks++
|
elem.tasks++
|
||||||
elem.tasksListById.push(t['$'].id)
|
elem.tasksListById.push(t['$'].id)
|
||||||
elem.tasksListByTitle.push(t.title)
|
elem.tasksListByTitle.push(t.title)
|
||||||
if(t['$'].status == "Active"){
|
if (t['$'].status == "Active") {
|
||||||
elem.tasksListIsActiveByTitle.push(t.title)
|
elem.tasksListIsActiveByTitle.push(t.title)
|
||||||
}
|
}
|
||||||
if(t['$'].status == "Done"){
|
if (t['$'].status == "Done") {
|
||||||
elem.tasksListIsDoneByTitle.push(t.title)
|
elem.tasksListIsDoneByTitle.push(t.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// found.tasks++
|
|
||||||
}
|
}
|
||||||
if(t.donedate){
|
if (t.donedate) {
|
||||||
jsonAllData.stats.tasksClosed++;
|
jsonAllData.stats.tasksClosed++;
|
||||||
jsonAllData.stats.listOpen.push(t);
|
jsonAllData.stats.listOpen.push(t);
|
||||||
}else{
|
} else {
|
||||||
jsonAllData.stats.tasksOpen++;
|
jsonAllData.stats.tasksOpen++;
|
||||||
}
|
}
|
||||||
// console.log('tags', tags)
|
// console.log('tags', tags)
|
||||||
@ -113,7 +119,8 @@ function computeData(jsonAllData){
|
|||||||
return jsonAllData
|
return jsonAllData
|
||||||
|
|
||||||
}
|
}
|
||||||
function convertOneXmlToJson(fileToOpen,res){
|
|
||||||
|
function convertOneXmlToJson(fileToOpen, res) {
|
||||||
fs.readFile(`sources/${fileToOpen}.xml`, "utf-8", function (err, data) {
|
fs.readFile(`sources/${fileToOpen}.xml`, "utf-8", function (err, data) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
const results = transformToJson(data, fileToOpen, res)
|
const results = transformToJson(data, fileToOpen, res)
|
||||||
@ -122,7 +129,51 @@ function convertOneXmlToJson(fileToOpen,res){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformToJson(xml,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) {
|
return parseString(xml, function (err, result) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
|
|
||||||
@ -146,5 +197,4 @@ function transformToJson(xml,fileToOpen, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -16,15 +16,23 @@ block content
|
|||||||
span.color couleur
|
span.color couleur
|
||||||
span.parent parent
|
span.parent parent
|
||||||
span.tasks tâches
|
span.tasks tâches
|
||||||
span.tasks actives
|
|
||||||
span.tasks finies
|
span.tasks finies
|
||||||
|
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= t['$'].name
|
||||||
span.color= t['$'].color
|
span.color= t['$'].color
|
||||||
span.parent= t['$'].parent
|
span.parent= t['$'].parent
|
||||||
span.tasks= t.tasks
|
|
||||||
if t.tasksListIsActiveByTitle
|
|
||||||
span.tasks= t.tasksListIsActiveByTitle.length
|
|
||||||
if t.tasksListIsDoneByTitle
|
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.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
|
||||||
|
Loading…
Reference in New Issue
Block a user