manager-dashboard.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {% extends 'manager-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 mb-3" style="background: linear-gradient(to bottom left, #cc3300 0%, #ffcc00 100%);">
  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>
  11. <td>
  12. <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Review Count
  13. </td>
  14. <td>
  15. <i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Positive (5* & 4*)
  16. </td>
  17. <td>
  18. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i> Negative (3* & Less)
  19. </td>
  20. </tr>
  21. <td>This month (so far)</td>
  22. <td>{{ google_this_month_pos }}</td>
  23. <td>{{ google_this_month_neg }}</td>
  24. </tr>
  25. <tr>
  26. <td>Last month</td>
  27. <td>{{ google_last_month_pos }}</td>
  28. <td>{{ google_last_month_neg }}</td>
  29. </tr>
  30. </table>
  31. </div>
  32. </div>
  33. </div>
  34. <!-- <div class="col-sm-6 col-md-4">-->
  35. <!-- <div class="card text-white bg-danger mb-3">-->
  36. <!-- <div class="card-header"><h5 class="card-title">Yelp <span><i class="fa fa-yelp" aria-hidden="true"></i></span></h5></div>-->
  37. <!-- <div class="card-body">-->
  38. <!-- <table class="table">-->
  39. <!-- <tr>-->
  40. <!-- <td><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Total Review</td>-->
  41. <!-- <td>{{ yelp_total }}</td>-->
  42. <!-- </tr>-->
  43. <!-- <tr>-->
  44. <!-- <td><i class="fa fa-line-chart" aria-hidden="true"></i> Growth</td>-->
  45. <!-- <td>{{ yelp_total_growth }}%</td>-->
  46. <!-- </tr>-->
  47. <!-- </table>-->
  48. <!-- </div>-->
  49. <!-- </div>-->
  50. <!-- </div>-->
  51. <div class="col-sm-6 col-md-6">
  52. <div class="card text-white mb-3" style="background: linear-gradient(to bottom left, #000099 0%, #00ccff 100%);">
  53. <div class="card-header"><h5 class="card-title">Facebook <span><i class="fa fa-facebook" aria-hidden="true"></i></span></h5></div>
  54. <div class="card-body">
  55. <table class="table">
  56. <tr>
  57. <td>
  58. <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Review Count
  59. </td>
  60. <td>
  61. <i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Recommended
  62. </td>
  63. <td>
  64. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i> Not Recommended
  65. </td>
  66. </tr>
  67. <tr>
  68. <td>This month (so far)</td>
  69. <td>{{ facebook_this_month_pos }}</td>
  70. <td>{{ facebook_this_month_neg }}</td>
  71. </tr>
  72. <tr>
  73. <td>Last month</td>
  74. <td>{{ facebook_last_month_pos }}</td>
  75. <td>{{ facebook_last_month_neg }}</td>
  76. </tr>
  77. </table>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <!-- canvas-->
  83. <canvas class="my-4" id="myChart" width="900" height="300"></canvas>
  84. </div>
  85. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  86. <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>
  87. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
  88. <script>
  89. var ctx = document.getElementById("myChart");
  90. var location_id = document.getElementById("location_id").value;
  91. console.log(location_id);
  92. var endpoint = '/user/api/analytics';
  93. params = {
  94. "location_id":location_id.trim()
  95. }
  96. console.log(params)
  97. $.ajax({
  98. type: "get",
  99. url: endpoint,
  100. data: params,
  101. dataType: 'json',
  102. success: function(data) {
  103. console.log(data)
  104. var myBarChart = new Chart(ctx, {
  105. type: 'bar',
  106. data: {
  107. labels: data.label,
  108. datasets: [
  109. {
  110. label: 'Google',
  111. data: data.google,
  112. borderColor: 'rgb(255, 204, 0)',
  113. backgroundColor: 'rgb(255, 204, 0)',
  114. borderWidth: 1,
  115. fill: false
  116. },
  117. {
  118. label: 'Facebook',
  119. data: data.facebook,
  120. borderColor: 'rgb(0, 51, 204)',
  121. backgroundColor: 'rgb(0, 51, 204)',
  122. borderWidth: 1,
  123. fill: false
  124. }]
  125. },
  126. options: {
  127. scales: {
  128. yAxes: [{
  129. display: true,
  130. scaleLabel: {
  131. display: true,
  132. fontSize: 16,
  133. fontStyle: 'italic',
  134. labelString: 'Total review count'
  135. },
  136. ticks: {
  137. beginAtZero: true,
  138. stepSize: 1
  139. }
  140. }],
  141. xAxes: [{
  142. display: true,
  143. scaleLabel: {
  144. display: true,
  145. fontSize: 16,
  146. fontStyle: 'italic',
  147. labelString: 'Day of the month'
  148. },
  149. gridLines: {
  150. drawOnChartArea:false
  151. }
  152. }]
  153. },
  154. title: {
  155. display: true,
  156. fontSize: 16,
  157. text: "Review of this month in all platforms."
  158. }
  159. }
  160. });
  161. },
  162. error: function(error_data) {
  163. console.log(error_data);
  164. }
  165. });
  166. </script>
  167. {% endblock %}