diff --git a/src/gtt-log.js b/src/gtt-log.js index 835afc3..d9e9d42 100755 --- a/src/gtt-log.js +++ b/src/gtt-log.js @@ -7,6 +7,7 @@ const Config = require('./include/file-config'); const Cli = require('./include/cli'); const Time = require('./models/time'); const Tasks = require('./include/tasks'); +const mergeRequest = require('./models/mergeRequest'); program .option('--verbose', 'show verbose output') @@ -24,6 +25,14 @@ function toHumanReadable(input) { return Time.toHumanReadable(Math.ceil(input), config.get('hoursPerDay'), timeFormat); } +function column(str, n){ + if(str.length > n) { + str = str.substr(0, n-1) + "…" + } + return str.padEnd(n); + }; + + tasks.log() .then(({frames, times}) => { Object.keys(frames).sort().forEach(date => { @@ -47,9 +56,12 @@ tasks.log() .sort((a, b) => a.start.isBefore(b.start) ? -1 : 1) .forEach(frame => { let toSync = (Math.ceil(frame.duration) - parseInt(_.reduce(frame.notes, (n, m) => (n + m.time), 0))) != 0; - let durationText = toSync ? toHumanReadable(frame.duration).yellow : toHumanReadable(frame.duration); - let issue = frame.resource.new ? `new ${frame.resource.type + ' "' + frame.resource.id.blue}"` : `${(frame.resource.type + ' #' + frame.resource.id).blue}`; - 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:''}`) + let durationText = toSync ? toHumanReadable(frame.duration).padEnd(14).yellow : toHumanReadable(frame.duration).padEnd(14); + let issue = frame.resource.new ? + column(`(new ${frame.resource.type + ' "' + frame.resource.id}")`, 70).bgBlue: + `${(frame.resource.type + ' #' + frame.resource.id).padEnd(20).blue}${column(frame.title!=null?frame.title:'', 50)}`; + console.log(` ${frame.id} ${frame.start.clone().format('HH:mm').green} to ${frame.stop.clone().format('HH:mm').green}\t${durationText}`+ + `${column(frame.project, 50).magenta}${issue}${frame.note!=null?frame.note:''}`); }); }); } diff --git a/src/include/tasks.js b/src/include/tasks.js index 8f3f199..9a63816 100755 --- a/src/include/tasks.js +++ b/src/include/tasks.js @@ -62,6 +62,7 @@ class tasks { this.sync.resources[type][id] .make(project, id, frame.resource.new) .then(() => { + frame.title = this.sync.resources[type][id].data.title; if (callback) callback(); done(); }) diff --git a/src/models/baseFrame.js b/src/models/baseFrame.js index 5d099c9..292b993 100755 --- a/src/models/baseFrame.js +++ b/src/models/baseFrame.js @@ -26,6 +26,7 @@ class baseFrame { this.timezone = config.get('timezone'); this.notes = []; this._note = note; + this._title = null; } static fromJson(config, json) { @@ -37,6 +38,7 @@ class baseFrame { frame.notes = json.notes; frame.timezone = json.timezone; frame.modified = json.modified; + frame._title = json.title? json.title: null; frame.validate(); return frame; @@ -71,6 +73,7 @@ class baseFrame { stop: frame._stop, timezone: frame.timezone, modified: frame.modified, + title: frame._title, note: frame._note, }); } @@ -91,6 +94,14 @@ class baseFrame { return this.timezone ? this._stop ? moment(this._stop).tz(this.timezone) : false : (this._stop ? moment(this._stop) : false ); } + set title(title) { + this._title = title; + } + + get title() { + return this._title; + } + get note() { return this._note; } diff --git a/src/models/frame.js b/src/models/frame.js index 377e806..870b1fb 100755 --- a/src/models/frame.js +++ b/src/models/frame.js @@ -43,6 +43,7 @@ class frame extends BaseFrame { stop: this._stop, timezone: this.timezone, modified: skipModified ? this.modified : moment(), + title: this._title, note: this._note }, null, "\t")); } diff --git a/src/models/report.js b/src/models/report.js index b2fade5..328a80c 100755 --- a/src/models/report.js +++ b/src/models/report.js @@ -168,8 +168,8 @@ class report extends Base { "project": this.project.data.path_with_namespace, "after": (cursor===undefined)?'':cursor, "entryPerPage": 30, - "startTime": this.config.get('from'), - "endTime": this.config.get('to') + "startTime": this.config.get('from').format("Y-M-D"), + "endTime": this.config.get('to').format("Y-M-D") } };