index.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {% extends "base.html" %}
  2. {% block body %}
  3. <div id="app">
  4. <div class="md-layout">
  5. <div class="md-layout-item">
  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
  13. <md-button href="/schedule.html" class="md-icon-button md-primary">
  14. <md-icon>add_circle_outline</md-icon>
  15. </md-button>
  16. </div>
  17. </md-card-header>
  18. <md-card-content>
  19. <md-table id="schedules-table" v-model="schedules">
  20. <md-table-row slot="md-table-row" slot-scope="{item}">
  21. <md-table-cell md-label="#" md-sort-by="id" md-numeric><a :href="'/schedule.html?id=' + item.id">${ item.id }</a></md-table-cell>
  22. <md-table-cell md-label="title" md-sort-by="title"><a :href="'/schedule.html?id=' + item.id">${ item.title }</a></md-table-cell>
  23. <md-table-cell md-label="url" md-sort-by="email"><a :href="item.url" target="_new">${ item.url }</a></md-table-cell>
  24. <md-table-cell md-label="trigger" md-sort-by="trigger">${ triggerString(item) }</md-table-cell>
  25. <md-table-cell md-label="history" md-sort-by="email">
  26. <md-button :href="'/history.html?id=' + item.id" class="md-icon-button md-primary">
  27. <md-icon>history</md-icon>
  28. </md-button>
  29. </md-table-cell>
  30. </md-table-row>
  31. </md-table>
  32. </md-card-content>
  33. </md-card>
  34. </div>
  35. </div>
  36. </div>
  37. <script>
  38. Vue.use(VueMaterial.default);
  39. var app = new Vue({
  40. el: '#app',
  41. delimiters: ['${', '}'],
  42. data: {
  43. schedules: []
  44. },
  45. mounted: function() {
  46. this.getSchedules();
  47. },
  48. computed: {
  49. },
  50. methods: {
  51. getSchedules: function() {
  52. self = this;
  53. var data = axios.get('/api/schedules').then(function(response) {
  54. var schedules = [];
  55. _.forEach(response.data.schedules || {}, function(value, key) {
  56. value.id = key;
  57. schedules.push(value);
  58. });
  59. self.schedules = schedules;
  60. });
  61. },
  62. triggerString: function(item) {
  63. if (item.trigger == 'cron') {
  64. return 'cron: ' + item.cron_crontab;
  65. }
  66. if (item.trigger == 'interval') {
  67. trigger = 'interval: ';
  68. _.each(['weeks', 'days', 'hours', 'minutes', 'seconds'], function(value, key) {
  69. if ('interval_' + value) {
  70. if (trigger) {
  71. trigger = trigger + ' ';
  72. }
  73. trigger = trigger + ''
  74. }
  75. });
  76. return trigger;
  77. }
  78. return '';
  79. }
  80. }
  81. });
  82. </script>
  83. <style>
  84. body {
  85. background-color: white;
  86. padding: 6px;
  87. }
  88. .md-table {
  89. height: 80%;
  90. }
  91. </style>
  92. {% end %}