diffido/dist/history.html

130 lines
4.8 KiB
HTML
Raw Normal View History

2018-01-21 01:26:46 +01:00
{% extends "base.html" %}
{% block body %}
<div id="app">
<div class="md-layout">
<div class="md-layout-item" md-card>
2018-01-23 22:41:32 +01:00
<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>
2018-01-23 23:12:25 +01:00
<md-table id="history-table" v-model="filtered_history">
2018-01-23 22:41:32 +01:00
<md-table-toolbar>
2018-01-23 23:12:25 +01:00
<md-switch v-model="show_empty" @change="toggleShowEmpty">show entries with no changes</md-switch>
2018-01-26 16:50:49 +01:00
<br />
<md-button class="md-button md-primary" @click="compareSelected()" :disabled="!(oldid && diff)">
Compare selected revisions
</md-button>
2018-01-23 22:41:32 +01:00
</md-table-toolbar>
<md-table-row slot="md-table-row" slot-scope="{item}">
<md-table-cell>
2018-01-30 21:49:04 +01:00
<div class="md-layout md-alignment-center-center">
<div class="md-layout-item">
(<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>&nbsp;|&nbsp;<a :href="'/diff.html?id=' + id + '&diff=' + item.id">prev</a>)&nbsp;
</div>
<div class="md-layout-item">
<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>
</div>
<div class="md-layout-item">
<md-radio name="diff" v-model="diff" :value="item.id" :seq="item.seq"></md-radio>
</div>
</div>
2018-01-23 22:41:32 +01:00
</md-table-cell>
2018-01-30 21:49:04 +01:00
<md-table-cell md-label="info" md-sort-by="id">
Commit: <strong>${ prettifyCommitID(item) }</strong>
<md-tooltip md-direction="bottom">${ item.id }</md-tooltip>
<br />
Changes: +${ item.insertions || 0 },-${ item.deletions || 0 }
</md-table-cell>
<md-table-cell md-label="date" md-sort-by="date">${ prettifyDate(item.message) }</md-table-cell>
2018-01-23 22:41:32 +01:00
</md-table-row>
</md-table>
</md-card-content>
</md-card>
2018-01-21 01:26:46 +01:00
</div>
</div>
</div>
<script>
Vue.use(VueMaterial.default);
var app = new Vue({
el: '#app',
delimiters: ['${', '}'],
data: {
2018-01-23 23:12:25 +01:00
show_empty: false,
2018-01-23 22:41:32 +01:00
schedule: {},
2018-01-21 01:26:46 +01:00
history: [],
2018-01-23 23:12:25 +01:00
filtered_history: [],
2018-01-21 11:20:42 +01:00
oldid: null,
diff: null,
2018-01-26 11:10:02 +01:00
last_id: null,
2018-01-21 01:26:46 +01:00
{% if isinstance(id, str) %}
id: "{{id}}",
{% else %}
id: null,
{% end %}
},
mounted: function() {
this.getHistory();
},
methods: {
getHistory: function() {
self = this;
2018-01-26 15:08:22 +01:00
var data = axios.get('/api/schedules/' + this.id + '/history').then(function(response) {
2018-01-21 01:26:46 +01:00
self.history = response.data.history;
2018-01-23 23:12:25 +01:00
self.updateFilter();
2018-01-23 22:41:32 +01:00
self.schedule = response.data.schedule;
2018-01-26 11:10:02 +01:00
self.last_id = response.data.last_id;
2018-01-21 01:26:46 +01:00
});
2018-01-23 23:12:25 +01:00
},
2018-01-30 21:49:04 +01:00
prettifyCommitID: function(item) {
var cid = item.id || '';
return cid.substring(0, 7);
},
prettifyDate: function(date) {
2018-02-09 16:36:01 +01:00
if (!date) {
return '';
}
2018-01-30 21:49:04 +01:00
return date.substring(0, date.indexOf('.'));
},
2018-01-23 23:12:25 +01:00
updateFilter: function() {
2018-01-23 23:16:04 +01:00
if (this.show_empty) {
this.filtered_history = this.history;
return;
}
2018-01-23 23:12:25 +01:00
self = this;
2018-01-23 23:16:04 +01:00
this.filtered_history = _.filter(self.history, 'changes');
2018-01-23 23:12:25 +01:00
},
toggleShowEmpty: function() {
this.updateFilter();
2018-01-26 16:50:49 +01:00
},
compareSelected: function() {
if (!(this.oldid && this.diff)) {
return;
}
window.location = '/diff.html?id=' + this.id + '&oldid=' + this.oldid + '&diff=' + this.diff;
2018-01-21 01:26:46 +01:00
}
}
});
</script>
2018-01-27 11:48:40 +01:00
{% end %}
2018-01-21 01:26:46 +01:00
2018-01-27 11:48:40 +01:00
{% block style %}
2018-01-21 01:26:46 +01:00
2018-01-26 11:10:02 +01:00
.placeholder {
width: 36px;
display: inline-block;
}
2018-01-21 01:26:46 +01:00
{% end %}