history.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-table id="history-table" v-model="history">
  7. <md-table-toolbar>
  8. <h1 class="md-title">History</h1>
  9. </md-table-toolbar>
  10. <md-table-row slot="md-table-row" slot-scope="{item}">
  11. <md-table-cell>
  12. (<a v-if="item.seq > 1" :href="'/diff.html?id=' + id + '&oldid=' + item.id + '&diff=' + lastid">cur</a><span v-if="item.seq == 1">cur</span> | <a :href="'/diff.html?id=' + id + '&diff=' + item.id">prev</a>)
  13. <md-radio name="oldid" v-model="oldid" :value="item.id" v-if="item.seq > 1" :seq="item.seq"></md-radio><span id="placeholder" v-if="item.seq == 1"> ---- </span>
  14. <md-radio name="diff" v-model="diff" :value="item.id" :seq="item.seq"></md-radio>
  15. </md-table-cell>
  16. <md-table-cell md-label="commit ID" md-sort-by="id">${ item.id }</md-table-cell>
  17. <md-table-cell md-label="message" md-sort-by="message">${ item.message }</md-table-cell>
  18. <md-table-cell md-label="changes" md-sort-by="message">+${ item.insertions || 0 },-${ item.deletions || 0 }</md-table-cell>
  19. </md-table-row>
  20. </md-table>
  21. </div>
  22. </div>
  23. </div>
  24. <script>
  25. Vue.use(VueMaterial.default);
  26. var app = new Vue({
  27. el: '#app',
  28. delimiters: ['${', '}'],
  29. data: {
  30. history: [],
  31. oldid: null,
  32. diff: null,
  33. lasstid: null,
  34. {% if isinstance(id, str) %}
  35. id: "{{id}}",
  36. {% else %}
  37. id: null,
  38. {% end %}
  39. },
  40. mounted: function() {
  41. this.getHistory();
  42. },
  43. methods: {
  44. getHistory: function() {
  45. self = this;
  46. var data = axios.get('/api/history/' + this.id).then(function(response) {
  47. console.log(response);
  48. self.history = response.data.history;
  49. self.lastid = response.data.lastid;
  50. });
  51. }
  52. }
  53. });
  54. </script>
  55. <style>
  56. body {
  57. background-color: white;
  58. }
  59. .md-table {
  60. width: 60%;
  61. min-height: 800px;
  62. max-height: 800px;
  63. }
  64. </style>
  65. {% end %}