index.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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="schedules-table" v-model="schedules">
  7. <md-table-toolbar>
  8. <h1 class="md-title">Schedules <a href="schedule.html">add new</a></h1>
  9. </md-table-toolbar>
  10. <md-table-row slot="md-table-row" slot-scope="{item}">
  11. <md-table-cell md-label="#" md-sort-by="id" md-numeric><a :href="settingsUrl(item)">${ item.id }</a></md-table-cell>
  12. <md-table-cell md-label="title" md-sort-by="title"><a :href="settingsUrl(item)">${ item.title }</a></md-table-cell>
  13. <md-table-cell md-label="url" md-sort-by="email">${ item.url }</md-table-cell>
  14. </md-table-row>
  15. </md-table>
  16. </div>
  17. </div>
  18. </div>
  19. <script>
  20. Vue.use(VueMaterial.default);
  21. var app = new Vue({
  22. el: '#app',
  23. delimiters: ['${', '}'],
  24. data: {
  25. schedules: []
  26. },
  27. mounted: function() {
  28. this.getSchedules();
  29. },
  30. computed: {
  31. },
  32. methods: {
  33. settingsUrl: function(item) {
  34. if (!(item && item.id !== undefined)) {
  35. return '';
  36. }
  37. return '/schedule.html?id=' + item.id;
  38. },
  39. getSchedules: function() {
  40. self = this;
  41. var data = axios.get('/api/schedules').then(function(response) {
  42. console.log(response);
  43. var schedules = [];
  44. _.forEach(response.data.schedules || {}, function(value, key) {
  45. value.id = key;
  46. schedules.push(value);
  47. });
  48. self.schedules = schedules;
  49. });
  50. }
  51. }
  52. });
  53. </script>
  54. <style>
  55. body {
  56. background-color: white;
  57. }
  58. .md-table {
  59. width: 60%;
  60. min-height: 400px;
  61. max-height: 800px;
  62. }
  63. </style>
  64. {% end %}