Skip to content

Commit

Permalink
feat: close 022
Browse files Browse the repository at this point in the history
  • Loading branch information
VladyslavKurmaz committed Oct 28, 2024
1 parent 53f7aaa commit 6eee807
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 93 deletions.
34 changes: 17 additions & 17 deletions .todo
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ team:
email: [email protected]
name: Vladyslav Kurmaz
timeline:
"v0.2.0":
date: "2024-09-04"
"v0.3.0":
date: "2024-09-12"
"v0.4.0":
date: "2024-09-15"
"v0.5.0":
date: "2024-09-23"
"v0.6.0":
date: "2024-10-22"
"v0.7.0":
date: "2024-10"
- name: v0.7.0
date: 2024-10-28 23:55:00 GMT+0200
- name: v0.6.0
date: 2024-10-22 17:30:00 GMT+0200
- name: v0.5.0
date: 2024-09-23 17:30:00 GMT+0200
- name: v0.4.0
date: 2024-09-15 17:30:00 GMT+0200
- name: v0.3.0
date: 2024-09-12 17:30:00 GMT+0200
- name: v0.2.0
date: 2024-09-04 17:30:00 GMT+0200
tasks: |
[>:022:v0.7.0] Describe command @vlad.k
[+:022:v0.7.0] Describe command - project @vlad.k
[+:021:v0.6.0] Add project description section @vlad.k
[+:020:v0.5.0] Add option to display tasks with different statuses: --backlog, --indev, --done @vlad.k
[+:019:v0.5.0] Add component as optional parameter for ls command @vlad.k
[-:018:v0.7.0] Generate snapshot @vlad.k
[-:018:v0.8.0] Generate snapshot @vlad.k
[+:017:v0.5.0] Add SRS section @vlad.k
[-:016:v0.7.0] Add describe command with resolved links @vlad.k
[-:016:v0.8.0] Add describe command with resolved links @vlad.k
[x:015:v0.5.0] Integrate .tpm folder at repository root level to store snapshots @vlad.k
[-:014:v0.7.0] Update README.md with Hello World section using <https://github.com/project-talan/tln-demo> repository @vlad.k
[-:014:v0.8.0] Update README.md with Hello World section using <https://github.com/project-talan/tln-demo> repository @vlad.k
[+:013:v0.6.0] Add search @vlad.k
[+:012:v0.6.0] Add CI/CD @vlad.k
[+:011:v0.6.0] Add unit test framework @vlad.k
[+:010:v0.6.0] Extract tags, timeline from task description @vlad.k
[+:009:v0.5.0] Add command to generate .todo template --team, --timeline, --tasks, --force @vlad.k
[+:008:v0.6.0] Merge multiple descriptions from one file @vlad.k
[-:007:v0.7.0] Server command: express server + fs watch @vlad.k
[-:007:v0.8.0] Server command: express server + fs watch @vlad.k
[-] Create API using express @vlad.k
[-] Implement web part: Dashboard @vlad.k
[-] Implement web part: Timeline @vlad.k
Expand Down
1 change: 1 addition & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class App {
if (c) {
if (what.project) {
result.projects = await c.describeProject();
// console.log(result.projects[0].summary.timeline);
}
}
return result;
Expand Down
26 changes: 21 additions & 5 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const assign = require('assign-deep');
const sourceFactory = require('./source');
const projectFactory = require('./project');
const memberFactory = require('./member');
const deadlineFactory = require('./deadline');
const timelineFactory = require('./timeline');
const taskFactory = require('./task');
const srsFactory = require('./srs');

Expand All @@ -29,7 +29,7 @@ class Component {
this.sources = [];
this.project = [];
this.team = null;
this.timeline = null;
this.timeline = [];
this.tasks = [];
this.srs = null;
this.components = [];
Expand Down Expand Up @@ -117,8 +117,12 @@ class Component {
result |= true;
}
if (data.timeline) {
this.timeline = assign({}, data.timeline);
result |= true;
if (data.timeline.length) {
const timeline = timelineFactory.create(this.logger, source);
await timeline.load(data.timeline);
this.timeline.push(timeline);
result |= true;
}
}
if (data.tasks) {
const task = taskFactory.create(this.logger, source);
Expand Down Expand Up @@ -187,6 +191,8 @@ class Component {
}
// timeline
if (what.timeline && this.timeline) {
summary.timeline = summary.timeline.concat(await timeline.getSummary(0));

if (Object.keys(this.timeline).length) {
this.logger.con((require('yaml')).stringify({ timeline: this.timeline }));
}
Expand Down Expand Up @@ -253,7 +259,8 @@ class Component {
project = assign(project, p);
});
let summary = {
tasks: { todo: 0, indev: 0, tbd: 0, blocked: 0, done: 0, dropped: 0 }
tasks: { todo: 0, indev: 0, tbd: 0, blocked: 0, done: 0, dropped: 0 },
timeline: []
};
project.summary = await this.getSummary(summary);
project.summary.team = this.getTeam({}, false, true);
Expand All @@ -266,6 +273,15 @@ class Component {
}

async getSummary(summary) {
for (const timeline of this.timeline) {
summary.timeline = summary.timeline.concat(await timeline.getSummary({features: 0}));
}
for (const deadline of summary.timeline) {
const tsks = await Promise.all(this.tasks.map(async t => t.getCountByDeadlime(deadline.name)));
const cnt = tsks.reduce((acc, c) => acc + c, 0);
deadline.features += cnt;
}
//
for (const task of this.tasks) {
summary.tasks = await task.getSummary(summary.tasks);
};
Expand Down
17 changes: 0 additions & 17 deletions src/deadline.js

This file was deleted.

7 changes: 6 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const yaml = require('js-yaml');


const utils = require('./utils');
const {version} = require('../package.json');

class Server {

Expand Down Expand Up @@ -43,6 +44,10 @@ class Server {
ea.get('/main.js', (req, res) => {
res.send(getLocalContent('main.js'));
})
// API
ea.get('/info', (req, res) => {
res.send(this.makeResponce({version}));
})
ea.get('/teams', (req, res) => {
res.send(this.makeResponce(root.getTeam({}, true, true)));
})
Expand All @@ -62,7 +67,7 @@ class Server {
})

ea.listen(port, () => {
this.logger.con(`start server on http://localhost:${port} in ${readOnly?'read-only':'read-write'} mode`);
this.logger.con(`start server version ${version} on http://localhost:${port} in ${readOnly?'read-only':'read-write'} mode`);
})

}
Expand Down
5 changes: 5 additions & 0 deletions src/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class Task {
return tasksSummary;
}

async getCountByDeadlime(deadline) {
const st = await Promise.all(this.tasks.map(async t => t.getCountByDeadlime(deadline)));
return this.deadline === deadline ? 1 : 0 + st.reduce((acc, c) => acc + c, 0);
}

}

module.exports.create = (logger, source) => {
Expand Down
25 changes: 25 additions & 0 deletions src/timeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const assign = require('assign-deep');

class Timeline {

constructor(logger, source) {
this.logger = logger;
this.source = source;
this.deadlines = [];
}

async load(data) {
this.deadlines = data.map(r => assign({}, r));
}

async getSummary(options) {
return this.deadlines.map(r => { return { ...assign({}, r), ...options } });
}

}

module.exports.create = (logger, source) => {
return new Timeline(logger, source);
}
4 changes: 2 additions & 2 deletions src/deadline.spec.js → src/timeline.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const chai = require('chai');

const deadlineFactory = require('./deadline');
const timelineFactory = require('./timeline');

const { expect } = chai;

Expand All @@ -9,7 +9,7 @@ const logger = require('./logger').create(0);
describe('Timeline entity', function () {

it('can be created', function () {
expect(deadlineFactory.create(logger)).not.to.be.null;
expect(timelineFactory.create(logger)).not.to.be.null;
});

});
35 changes: 8 additions & 27 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">tpm<span class="px-2"><small><sub>v0.6.0</sub></small></span></a>
<a class="navbar-brand" href="#">tpm<span class="px-2"><small><sub id="nav_version"></sub></small></span></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand All @@ -35,7 +35,7 @@
<button class="nav-link active" id="dashboard-tab" data-bs-toggle="tab" data-bs-target="#dashboard-tab-pane" type="button" role="tab" aria-controls="dashboard-tab-pane" aria-selected="true">Dashboard</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">Timeline</button>
<button class="nav-link" id="timeline-tab" data-bs-toggle="tab" data-bs-target="#timeline-tab-pane" type="button" role="tab" aria-controls="timeline-tab-pane" aria-selected="false">Timeline</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">Team</button>
Expand Down Expand Up @@ -63,42 +63,23 @@
</div>
</nav>

<div class="container my-2">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="#">Library</a></li>
<li class="breadcrumb-item active" aria-current="page">Data</li>
<li>
<div class="btn-group">
<button type="button" class="btn btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
</li>
</ol>
</nav>
<!--i class="bi bi-github"></i-->
<div class="container pt-4">
<!-- Tabs -->
<div class="tab-content" id="myTabContent">
<!-- Dashboard -->
<div class="tab-pane fade show active" id="dashboard-tab-pane" role="tabpanel" aria-labelledby="dashboard-tab" tabindex="0">
<p class="fs-5 d-none">
<i class="bi bi-github"></i>
</p>
<div class="album">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-2 g-3" id="dashboard_project_list"></div>
</div>
</div>
</div>
<!-- Timeline -->
<div class="tab-pane fade" id="profile-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
<div id="chart_div"></div>
<div class="tab-pane fade" id="timeline-tab-pane" role="tabpanel" aria-labelledby="timeline-tab" tabindex="0">
<div id="timeline_gantt_chart"></div>
</div>
<!-- Team -->
<div class="tab-pane fade" id="contact-tab-pane" role="tabpanel" aria-labelledby="contact-tab" tabindex="0">
Expand Down
Loading

0 comments on commit 6eee807

Please sign in to comment.