From eae571d5a9deaf75171efd095f8e38520819c496 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Tue, 23 Jan 2018 22:41:32 +0100 Subject: [PATCH] improve history and diff page style --- diffido.py | 7 ++++--- dist/base.html | 2 ++ dist/diff.html | 28 +++++++++++++++++++------ dist/history.html | 51 +++++++++++++++++++++++++++++----------------- dist/index.html | 9 +++++++- dist/schedule.html | 7 +++---- 6 files changed, 71 insertions(+), 33 deletions(-) diff --git a/diffido.py b/diffido.py index b9bd3b0..4eb9c03 100755 --- a/diffido.py +++ b/diffido.py @@ -209,11 +209,11 @@ def get_history(id_): lastid = history[0]['id'] for idx, item in enumerate(history): item['seq'] = idx + 1 - return {'history': history, 'lastid': lastid} + schedule = get_schedule(id_) + return {'history': history, 'lastid': lastid, 'schedule': schedule} def get_diff(id_, commit_id='HEAD', old_commit_id=None): - logger.warn('MEHHHH %s %s %s' % (id_, commit_id, old_commit_id)) def _history(id_, commit_id, old_commit_id, queue): os.chdir('storage/%s' % id_) p = subprocess.Popen([GIT_CMD, 'diff', old_commit_id or '%s~' % commit_id, commit_id], @@ -225,7 +225,8 @@ def get_diff(id_, commit_id='HEAD', old_commit_id=None): p.start() res = queue.get().decode('utf-8') p.join() - return {'diff': res} + schedule = get_schedule(id_) + return {'diff': res, 'schedule': schedule} def scheduler_update(scheduler, id_): diff --git a/dist/base.html b/dist/base.html index dc16df2..6d4bf64 100644 --- a/dist/base.html +++ b/dist/base.html @@ -7,11 +7,13 @@ + + {% block body %}{% end %} diff --git a/dist/diff.html b/dist/diff.html index 24bf5fa..efbbcad 100644 --- a/dist/diff.html +++ b/dist/diff.html @@ -3,8 +3,21 @@ {% block body %}
-
-
+
+ + +
+ + home + + Diffido: ${schedule && schedule.title} diff +
+
+ + +
+
+
@@ -17,6 +30,7 @@ var app = new Vue({ el: '#app', delimiters: ['${', '}'], data: { + schedule: {}, history: [], difftext: '', id: "{{id}}", @@ -42,9 +56,12 @@ var app = new Vue({ getDiff: function() { self = this; var data = axios.get('/api/diff/' + this.id + '/' + this.diff + '/' + (this.oldid || '')).then(function(response) { + self.schedule = response.data.schedule; self.difftext = response.data.diff; - var pretty_diff = Diff2Html.getPrettyHtml(self.difftext); + var current_size = document.getElementById('diffpanel').offsetWidth; + var pretty_diff = Diff2Html.getPrettyHtml(self.difftext, {showFiles: true, matching: 'none'}); document.getElementById('diffpanel').innerHTML = pretty_diff; + document.getElementById('diffpanel').style['max-width'] = (current_size - 20) + 'px'; }); } } @@ -55,12 +72,11 @@ var app = new Vue({ body { background-color: white; + padding: 6px; } .md-table { - width: 60%; - min-height: 800px; - max-height: 800px; + height: 80%; } diff --git a/dist/history.html b/dist/history.html index b2a1491..78f8644 100644 --- a/dist/history.html +++ b/dist/history.html @@ -4,21 +4,34 @@
- - -

History

-
- - - (curcur | prev) - ---- - - - ${ item.id } - ${ item.message } - +${ item.insertions || 0 },-${ item.deletions || 0 } - -
+ + +
+ + home + + Diffido - ${schedule && schedule.title} history +
+
+ + + + +

History

+
+ + + (curcur | prev) + ---- + + + ${ item.id } + ${ item.message } + +${ item.insertions || 0 },-${ item.deletions || 0 } + +
+
+
@@ -31,6 +44,7 @@ var app = new Vue({ el: '#app', delimiters: ['${', '}'], data: { + schedule: {}, history: [], oldid: null, diff: null, @@ -48,8 +62,8 @@ var app = new Vue({ getHistory: function() { self = this; var data = axios.get('/api/history/' + this.id).then(function(response) { - console.log(response); self.history = response.data.history; + self.schedule = response.data.schedule; self.lastid = response.data.lastid; }); } @@ -61,12 +75,11 @@ var app = new Vue({ body { background-color: white; + padding: 6px; } .md-table { - width: 60%; - min-height: 800px; - max-height: 800px; + height: 80%; } diff --git a/dist/index.html b/dist/index.html index 7e418dc..40bee22 100644 --- a/dist/index.html +++ b/dist/index.html @@ -7,6 +7,9 @@
+ + home + Diffido add_circle_outline @@ -20,7 +23,11 @@ ${ item.id } ${ item.title } ${ item.url } - history + + + history + + diff --git a/dist/schedule.html b/dist/schedule.html index e143538..75c833a 100644 --- a/dist/schedule.html +++ b/dist/schedule.html @@ -10,23 +10,22 @@ home - Schedule ${schedule && schedule.title} + Diffido: ${(schedule && schedule.title) || 'new'} schedule
-
- +
- +