diffido/dist/diff.html

77 lines
2.2 KiB
HTML
Raw Normal View History

2018-01-16 22:24:30 +01:00
{% extends "base.html" %}
2018-01-25 23:53:09 +01:00
{% block head %}
2018-01-26 13:18:03 +01:00
<link rel="stylesheet" href="/static/css/diff2html.min.css">
<script src="/static/js/diff2html.min.js"></script>
2018-01-25 23:53:09 +01:00
{% end %}
2018-01-16 22:24:30 +01:00
{% block body %}
2018-01-21 11:20:42 +01:00
<div id="app">
<div class="md-layout">
2018-01-23 22:41:32 +01:00
<div class="md-layout-item">
<md-card id="main-card">
<md-card-header>
<div class="md-title">
<md-button href="/" class="md-icon-button md-primary">
<md-icon>home</md-icon>
</md-button>
Diffido: ${schedule && schedule.title} diff
</div>
</md-card-header>
<md-card-content id="diffpanel-container">
<div id="diffpanel"></div>
</md-card-content>
</md-card>
2018-01-21 11:20:42 +01:00
</div>
</div>
</div>
<script>
Vue.use(VueMaterial.default);
var app = new Vue({
el: '#app',
delimiters: ['${', '}'],
data: {
2018-01-23 22:41:32 +01:00
schedule: {},
2018-01-21 11:20:42 +01:00
history: [],
difftext: '',
id: "{{id}}",
{% try %}
{% if diff %}
diff: "{{diff}}",
{% end %}
{% except %}
diff: null,
{% end %}
{% try %}
{% if oldid %}
oldid: "{{oldid}}",
{% end %}
{% except %}
oldid: null,
{% end %}
},
mounted: function() {
this.getDiff();
},
methods: {
getDiff: function() {
self = this;
2018-01-26 15:08:22 +01:00
var data = axios.get('/api/schedules/' + this.id + '/diff/' + this.diff + '/' + (this.oldid || '')).then(function(response) {
2018-01-23 22:41:32 +01:00
self.schedule = response.data.schedule;
2018-01-21 11:20:42 +01:00
self.difftext = response.data.diff;
2018-01-23 22:41:32 +01:00
var current_size = document.getElementById('diffpanel').offsetWidth;
var pretty_diff = Diff2Html.getPrettyHtml(self.difftext, {showFiles: true, matching: 'none'});
2018-01-21 11:20:42 +01:00
document.getElementById('diffpanel').innerHTML = pretty_diff;
2018-01-23 22:41:32 +01:00
document.getElementById('diffpanel').style['max-width'] = (current_size - 20) + 'px';
2018-01-21 11:20:42 +01:00
});
}
}
});
</script>
2018-01-16 22:24:30 +01:00
{% end %}