user-dashboard.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {% extends 'user-base.html' %}
  2. {% block content %}
  3. <!--cart-->
  4. <div class="row">
  5. <div class="col-sm-6 col-md-6">
  6. <div class="card text-white bg-secondary mb-3">
  7. <div class="card-header"><h5 class="card-title">Google <span><i class="fa fa-google" aria-hidden="true"></i></span></h5></div>
  8. <div class="card-body">
  9. <table class="table">
  10. <tr><td><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Reviews</td> <td>Count</td></tr>
  11. <tr>
  12. <td>This month (so far)</td>
  13. <td>{{ google_this_month }}</td>
  14. </tr>
  15. <tr>
  16. <td>Last month</td>
  17. <td>{{ google_last_month }}</td>
  18. </tr>
  19. </table>
  20. </div>
  21. </div>
  22. </div>
  23. <!-- <div class="col-sm-6 col-md-4">-->
  24. <!-- <div class="card text-white bg-danger mb-3">-->
  25. <!-- <div class="card-header"><h5 class="card-title">Yelp <span><i class="fa fa-yelp" aria-hidden="true"></i></span></h5></div>-->
  26. <!-- <div class="card-body">-->
  27. <!-- <table class="table">-->
  28. <!-- <tr>-->
  29. <!-- <td><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Total Review</td>-->
  30. <!-- <td>{{ yelp_total }}</td>-->
  31. <!-- </tr>-->
  32. <!-- <tr>-->
  33. <!-- <td><i class="fa fa-line-chart" aria-hidden="true"></i> Growth</td>-->
  34. <!-- <td>{{ yelp_total_growth }}%</td>-->
  35. <!-- </tr>-->
  36. <!-- </table>-->
  37. <!-- </div>-->
  38. <!-- </div>-->
  39. <!-- </div>-->
  40. <div class="col-sm-6 col-md-6">
  41. <div class="card text-white bg-primary mb-3">
  42. <div class="card-header"><h5 class="card-title">Facebook <span><i class="fa fa-facebook" aria-hidden="true"></i></span></h5></div>
  43. <div class="card-body">
  44. <table class="table">
  45. <tr>
  46. <td><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Reviews</td> <td>Count</td></tr>
  47. <tr>
  48. <td>This month (so far)</td>
  49. <td>{{ facebook_this_month }}</td>
  50. </tr>
  51. <tr>
  52. <td>Last month</td>
  53. <td>{{ facebook_last_month }}</td>
  54. </tr>
  55. </table>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- canvas-->
  61. <canvas class="my-4" id="myChart" width="900" height="300"></canvas>
  62. </div>
  63. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  64. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js" integrity="sha256-TQq84xX6vkwR0Qs1qH5ADkP+MvH0W+9E7TdHJsoIQiM=" crossorigin="anonymous"></script>
  65. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
  66. <script>
  67. var ctx = document.getElementById("myChart");
  68. var location_id = document.getElementById("location_id").value;
  69. console.log(location_id.value)
  70. var endpoint = '/user/api/analytics';
  71. params = {
  72. "location_id":location_id.trim()
  73. }
  74. console.log(params)
  75. $.ajax({
  76. type: "get",
  77. url: endpoint,
  78. data: params,
  79. dataType: 'json',
  80. success: function(data) {
  81. console.log(data)
  82. var myBarChart = new Chart(ctx, {
  83. type: 'bar',
  84. data: {
  85. labels: data.label,
  86. datasets: [
  87. {
  88. label: 'Google',
  89. data: data.google,
  90. borderColor: 'rgb(255, 204, 0)',
  91. backgroundColor: 'rgb(255, 204, 0)',
  92. borderWidth: 1,
  93. fill: false
  94. },
  95. {
  96. label: 'Facebook',
  97. data: data.facebook,
  98. borderColor: 'rgb(0, 51, 204)',
  99. backgroundColor: 'rgb(0, 51, 204)',
  100. borderWidth: 1,
  101. fill: false
  102. }]
  103. },
  104. options: {
  105. scales: {
  106. yAxes: [{
  107. display: true,
  108. scaleLabel: {
  109. display: true,
  110. fontSize: 16,
  111. fontStyle: 'italic',
  112. labelString: 'Total review count'
  113. },
  114. ticks: {
  115. beginAtZero: true,
  116. stepSize: 1
  117. }
  118. }],
  119. xAxes: [{
  120. display: true,
  121. scaleLabel: {
  122. display: true,
  123. fontSize: 16,
  124. fontStyle: 'italic',
  125. labelString: 'Day of the month'
  126. },
  127. gridLines: {
  128. drawOnChartArea:false
  129. }
  130. }]
  131. },
  132. title: {
  133. display: true,
  134. fontSize: 16,
  135. text: "Review of this month in all platforms."
  136. }
  137. }
  138. });
  139. },
  140. error: function(error_data) {
  141. console.log(error_data);
  142. }
  143. });
  144. </script>
  145. {% endblock %}