history.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. <br />
  20. <md-button class="md-button md-primary" @click="compareSelected()" :disabled="!(oldid && diff)">
  21. Compare selected revisions
  22. </md-button>
  23. </md-table-toolbar>
  24. <md-table-row slot="md-table-row" slot-scope="{item}">
  25. <md-table-cell>
  26. (<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>)
  27. <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>
  28. <md-radio name="diff" v-model="diff" :value="item.id" :seq="item.seq"></md-radio>
  29. </md-table-cell>
  30. <md-table-cell md-label="commit ID" md-sort-by="id">${ item.id }</md-table-cell>
  31. <md-table-cell md-label="message" md-sort-by="message">${ item.message }</md-table-cell>
  32. <md-table-cell md-label="changes" md-sort-by="message">+${ item.insertions || 0 },-${ item.deletions || 0 }</md-table-cell>
  33. </md-table-row>
  34. </md-table>
  35. </md-card-content>
  36. </md-card>
  37. </div>
  38. </div>
  39. </div>
  40. <script>
  41. Vue.use(VueMaterial.default);
  42. var app = new Vue({
  43. el: '#app',
  44. delimiters: ['${', '}'],
  45. data: {
  46. show_empty: false,
  47. schedule: {},
  48. history: [],
  49. filtered_history: [],
  50. oldid: null,
  51. diff: null,
  52. last_id: null,
  53. {% if isinstance(id, str) %}
  54. id: "{{id}}",
  55. {% else %}
  56. id: null,
  57. {% end %}
  58. },
  59. mounted: function() {
  60. this.getHistory();
  61. },
  62. methods: {
  63. getHistory: function() {
  64. self = this;
  65. var data = axios.get('/api/schedules/' + this.id + '/history').then(function(response) {
  66. self.history = response.data.history;
  67. self.updateFilter();
  68. self.schedule = response.data.schedule;
  69. self.last_id = response.data.last_id;
  70. });
  71. },
  72. updateFilter: function() {
  73. if (this.show_empty) {
  74. this.filtered_history = this.history;
  75. return;
  76. }
  77. self = this;
  78. this.filtered_history = _.filter(self.history, 'changes');
  79. },
  80. toggleShowEmpty: function() {
  81. this.updateFilter();
  82. },
  83. compareSelected: function() {
  84. if (!(this.oldid && this.diff)) {
  85. return;
  86. }
  87. window.location = '/diff.html?id=' + this.id + '&oldid=' + this.oldid + '&diff=' + this.diff;
  88. }
  89. }
  90. });
  91. </script>
  92. <style>
  93. body {
  94. background-color: white;
  95. padding: 6px;
  96. }
  97. .md-table {
  98. height: 80%;
  99. }
  100. .placeholder {
  101. width: 36px;
  102. display: inline-block;
  103. }
  104. </style>
  105. {% end %}