Skip to content

Commit d1d9e31

Browse files
author
Andreas Müller
committed
add the issue title to the frames for gtt log, to provide a better overview
1 parent 380bb5b commit d1d9e31

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/gtt-log.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Config = require('./include/file-config');
77
const Cli = require('./include/cli');
88
const Time = require('./models/time');
99
const Tasks = require('./include/tasks');
10+
const mergeRequest = require('./models/mergeRequest');
1011

1112
program
1213
.option('--verbose', 'show verbose output')
@@ -24,6 +25,14 @@ function toHumanReadable(input) {
2425
return Time.toHumanReadable(Math.ceil(input), config.get('hoursPerDay'), timeFormat);
2526
}
2627

28+
function column(str, n){
29+
if(str.length > n) {
30+
str = str.substr(0, n-1) + "…"
31+
}
32+
return str.padEnd(n);
33+
};
34+
35+
2736
tasks.log()
2837
.then(({frames, times}) => {
2938
Object.keys(frames).sort().forEach(date => {
@@ -47,9 +56,12 @@ tasks.log()
4756
.sort((a, b) => a.start.isBefore(b.start) ? -1 : 1)
4857
.forEach(frame => {
4958
let toSync = (Math.ceil(frame.duration) - parseInt(_.reduce(frame.notes, (n, m) => (n + m.time), 0))) != 0;
50-
let durationText = toSync ? toHumanReadable(frame.duration).yellow : toHumanReadable(frame.duration);
51-
let issue = frame.resource.new ? `new ${frame.resource.type + ' "' + frame.resource.id.blue}"` : `${(frame.resource.type + ' #' + frame.resource.id).blue}`;
52-
console.log(` ${frame.id} ${frame.start.clone().format('HH:mm').green} to ${frame.stop.clone().format('HH:mm').green}\t${durationText}\t\t${frame.project.magenta}\t\t${issue}\t\t${frame.note!=null?frame.note:''}`)
59+
let durationText = toSync ? toHumanReadable(frame.duration).padEnd(14).yellow : toHumanReadable(frame.duration).padEnd(14);
60+
let issue = frame.resource.new ?
61+
column(`(new ${frame.resource.type + ' "' + frame.resource.id}")`, 70).bgBlue:
62+
`${(frame.resource.type + ' #' + frame.resource.id).padEnd(20).blue}${column(frame.title!=null?frame.title:'', 50)}`;
63+
console.log(` ${frame.id} ${frame.start.clone().format('HH:mm').green} to ${frame.stop.clone().format('HH:mm').green}\t${durationText}`+
64+
`${column(frame.project, 50).magenta}${issue}${frame.note!=null?frame.note:''}`);
5365
});
5466
});
5567
}

src/include/tasks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class tasks {
6262
this.sync.resources[type][id]
6363
.make(project, id, frame.resource.new)
6464
.then(() => {
65+
frame.title = this.sync.resources[type][id].data.title;
6566
if (callback) callback();
6667
done();
6768
})

src/models/baseFrame.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class baseFrame {
2626
this.timezone = config.get('timezone');
2727
this.notes = [];
2828
this._note = note;
29+
this._title = null;
2930
}
3031

3132
static fromJson(config, json) {
@@ -37,6 +38,7 @@ class baseFrame {
3738
frame.notes = json.notes;
3839
frame.timezone = json.timezone;
3940
frame.modified = json.modified;
41+
frame._title = json.title? json.title: null;
4042
frame.validate();
4143

4244
return frame;
@@ -71,6 +73,7 @@ class baseFrame {
7173
stop: frame._stop,
7274
timezone: frame.timezone,
7375
modified: frame.modified,
76+
title: frame._title,
7477
note: frame._note,
7578
});
7679
}
@@ -91,6 +94,14 @@ class baseFrame {
9194
return this.timezone ? this._stop ? moment(this._stop).tz(this.timezone) : false : (this._stop ? moment(this._stop) : false );
9295
}
9396

97+
set title(title) {
98+
this._title = title;
99+
}
100+
101+
get title() {
102+
return this._title;
103+
}
104+
94105
get note() {
95106
return this._note;
96107
}

src/models/frame.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class frame extends BaseFrame {
4343
stop: this._stop,
4444
timezone: this.timezone,
4545
modified: skipModified ? this.modified : moment(),
46+
title: this._title,
4647
note: this._note
4748
}, null, "\t"));
4849
}

0 commit comments

Comments
 (0)