diffido/dist/history.html

105 lines
3.5 KiB
HTML

{% extends "base.html" %}
{% block body %}
<div id="app">
<div class="md-layout">
<div class="md-layout-item" md-card>
<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} history
</div>
</md-card-header>
<md-card-content>
<md-table id="history-table" v-model="filtered_history">
<md-table-toolbar>
<md-switch v-model="show_empty" @change="toggleShowEmpty">show entries with no changes</md-switch>
</md-table-toolbar>
<md-table-row slot="md-table-row" slot-scope="{item}">
<md-table-cell>
(<a v-if="item.seq > 1" :href="'/diff.html?id=' + id + '&oldid=' + item.id + '&diff=' + last_id">cur</a><span v-if="item.seq == 1">cur</span> | <a :href="'/diff.html?id=' + id + '&diff=' + item.id">prev</a>)
<md-radio name="oldid" v-model="oldid" :value="item.id" v-if="item.seq > 1" :seq="item.seq"></md-radio><span class="placeholder" v-if="item.seq == 1"></span>
<md-radio name="diff" v-model="diff" :value="item.id" :seq="item.seq"></md-radio>
</md-table-cell>
<md-table-cell md-label="commit ID" md-sort-by="id">${ item.id }</md-table-cell>
<md-table-cell md-label="message" md-sort-by="message">${ item.message }</md-table-cell>
<md-table-cell md-label="changes" md-sort-by="message">+${ item.insertions || 0 },-${ item.deletions || 0 }</md-table-cell>
</md-table-row>
</md-table>
</md-card-content>
</md-card>
</div>
</div>
</div>
<script>
Vue.use(VueMaterial.default);
var app = new Vue({
el: '#app',
delimiters: ['${', '}'],
data: {
show_empty: false,
schedule: {},
history: [],
filtered_history: [],
oldid: null,
diff: null,
last_id: null,
{% if isinstance(id, str) %}
id: "{{id}}",
{% else %}
id: null,
{% end %}
},
mounted: function() {
this.getHistory();
},
methods: {
getHistory: function() {
self = this;
var data = axios.get('/api/history/' + this.id).then(function(response) {
self.history = response.data.history;
self.updateFilter();
self.schedule = response.data.schedule;
self.last_id = response.data.last_id;
});
},
updateFilter: function() {
if (this.show_empty) {
this.filtered_history = this.history;
return;
}
self = this;
this.filtered_history = _.filter(self.history, 'changes');
},
toggleShowEmpty: function() {
this.updateFilter();
}
}
});
</script>
<style>
body {
background-color: white;
padding: 6px;
}
.md-table {
height: 80%;
}
.placeholder {
width: 36px;
display: inline-block;
}
</style>
{% end %}