history.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {% extends "base.html" %}
  2. {% block body %}
  3. <div id="app">
  4. <div class="md-layout">
  5. <div class="md-layout-item" md-card>
  6. <md-card id="main-card">
  7. <md-card-header>
  8. <div class="md-title">
  9. <md-button href="/" class="md-icon-button md-primary">
  10. <md-icon>home</md-icon>
  11. </md-button>
  12. Diffido - ${schedule && schedule.title} history
  13. </div>
  14. </md-card-header>
  15. <md-card-content>
  16. <md-table id="history-table" v-model="filtered_history">
  17. <md-table-toolbar>
  18. <md-switch v-model="show_empty" @change="toggleShowEmpty">show entries with no changes</md-switch>
  19. </md-table-toolbar>
  20. <md-table-row slot="md-table-row" slot-scope="{item}">
  21. <md-table-cell>
  22. (<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>)
  23. <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>
  24. <md-radio name="diff" v-model="diff" :value="item.id" :seq="item.seq"></md-radio>
  25. </md-table-cell>
  26. <md-table-cell md-label="commit ID" md-sort-by="id">${ item.id }</md-table-cell>
  27. <md-table-cell md-label="message" md-sort-by="message">${ item.message }</md-table-cell>
  28. <md-table-cell md-label="changes" md-sort-by="message">+${ item.insertions || 0 },-${ item.deletions || 0 }</md-table-cell>
  29. </md-table-row>
  30. </md-table>
  31. </md-card-content>
  32. </md-card>
  33. </div>
  34. </div>
  35. </div>
  36. <script>
  37. Vue.use(VueMaterial.default);
  38. var app = new Vue({
  39. el: '#app',
  40. delimiters: ['${', '}'],
  41. data: {
  42. show_empty: false,
  43. schedule: {},
  44. history: [],
  45. filtered_history: [],
  46. oldid: null,
  47. diff: null,
  48. last_id: null,
  49. {% if isinstance(id, str) %}
  50. id: "{{id}}",
  51. {% else %}
  52. id: null,
  53. {% end %}
  54. },
  55. mounted: function() {
  56. this.getHistory();
  57. },
  58. methods: {
  59. getHistory: function() {
  60. self = this;
  61. var data = axios.get('/api/history/' + this.id).then(function(response) {
  62. self.history = response.data.history;
  63. self.updateFilter();
  64. self.schedule = response.data.schedule;
  65. self.last_id = response.data.last_id;
  66. });
  67. },
  68. updateFilter: function() {
  69. if (this.show_empty) {
  70. this.filtered_history = this.history;
  71. return;
  72. }
  73. self = this;
  74. this.filtered_history = _.filter(self.history, 'changes');
  75. },
  76. toggleShowEmpty: function() {
  77. this.updateFilter();
  78. }
  79. }
  80. });
  81. </script>
  82. <style>
  83. body {
  84. background-color: white;
  85. padding: 6px;
  86. }
  87. .md-table {
  88. height: 80%;
  89. }
  90. .placeholder {
  91. width: 36px;
  92. display: inline-block;
  93. }
  94. </style>
  95. {% end %}