manager-dashboard.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. {% extends 'manager-base.html' %}
  2. {% block content %}
  3. <!--cart-->
  4. <div class="row">
  5. <div class="col-sm-4 col-md-4">
  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
  16. </td>
  17. <td>
  18. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i> Negative
  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-4 col-md-4">
  35. <div class="card text-white mb-3" style="background: linear-gradient(to bottom left, #000099 0%, #00ccff 100%);">
  36. <div class="card-header"><h5 class="card-title">Facebook <span><i class="fa fa-facebook" aria-hidden="true"></i></span></h5></div>
  37. <div class="card-body">
  38. <table class="table">
  39. <tr>
  40. <td>
  41. <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Review Count
  42. </td>
  43. <td>
  44. <i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Positive
  45. </td>
  46. <td>
  47. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i> Negative
  48. </td>
  49. </tr>
  50. <tr>
  51. <td>This month (so far)</td>
  52. <td>{{ facebook_this_month_pos }}</td>
  53. <td>{{ facebook_this_month_neg }}</td>
  54. </tr>
  55. <tr>
  56. <td>Last month</td>
  57. <td>{{ facebook_last_month_pos }}</td>
  58. <td>{{ facebook_last_month_neg }}</td>
  59. </tr>
  60. </table>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="col-sm-4 col-md-4">
  65. <div class="card text-white mb-3" style="background: linear-gradient(to bottom left, #ff0000 0%, #ff9999 100%);">
  66. <div class="card-header"><h5 class="card-title">Yelp <span><i class="fa fa-yelp" aria-hidden="true"></i></span></h5></div>
  67. <div class="card-body">
  68. <table class="table">
  69. <tr>
  70. <td>
  71. <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Review Count
  72. </td>
  73. <td>
  74. <i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Positive
  75. </td>
  76. <td>
  77. <i class="fa fa-thumbs-o-down" aria-hidden="true"></i> Negative
  78. </td>
  79. </tr>
  80. <tr>
  81. <td>This month (so far)</td>
  82. <td>{{ yelp.this_month_pos }}</td>
  83. <td>{{ yelp.this_month_neg }}</td>
  84. </tr>
  85. <tr>
  86. <td>Last month</td>
  87. <td>{{ yelp.last_month_pos }}</td>
  88. <td>{{ yelp.last_month_neg }}</td>
  89. </tr>
  90. </table>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <div style="text-align: center">
  96. <span style="font-size: small; color: darkgrey;">
  97. <b>NB: For Google and Yelp 5* & 4* is considered to be a positive review. And less than 4* is considered a negative review.</b>
  98. </span>
  99. </div>
  100. <!-- canvas-->
  101. <canvas class="my-4" id="myChart" width="900" height="300"></canvas>
  102. </div>
  103. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  104. <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>
  105. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
  106. <script>
  107. var ctx = document.getElementById("myChart");
  108. var location_id = document.getElementById("location_id").value;
  109. console.log(location_id);
  110. var endpoint = '/user/api/analytics';
  111. params = {
  112. "location_id":location_id.trim()
  113. }
  114. console.log(params)
  115. $.ajax({
  116. type: "get",
  117. url: endpoint,
  118. data: params,
  119. dataType: 'json',
  120. success: function(data) {
  121. console.log(data)
  122. var myBarChart = new Chart(ctx, {
  123. type: 'bar',
  124. data: {
  125. labels: data.label,
  126. datasets: [
  127. {
  128. label: 'Google',
  129. data: data.google,
  130. borderColor: 'rgb(255, 204, 0)',
  131. backgroundColor: 'rgb(255, 204, 0)',
  132. borderWidth: 1,
  133. fill: false
  134. },
  135. {
  136. label: 'Facebook',
  137. data: data.facebook,
  138. borderColor: 'rgb(0, 51, 204)',
  139. backgroundColor: 'rgb(0, 51, 204)',
  140. borderWidth: 1,
  141. fill: false
  142. },
  143. {
  144. label: 'Yelp',
  145. data: data.yelp,
  146. borderColor: 'rgb(255, 28, 28)',
  147. backgroundColor: 'rgb(255, 94, 94)',
  148. borderWidth: 1,
  149. fill: false
  150. }]
  151. },
  152. options: {
  153. scales: {
  154. yAxes: [{
  155. display: true,
  156. scaleLabel: {
  157. display: true,
  158. fontSize: 16,
  159. fontStyle: 'italic',
  160. labelString: 'Total review count'
  161. },
  162. ticks: {
  163. beginAtZero: true,
  164. stepSize: 1
  165. }
  166. }],
  167. xAxes: [{
  168. display: true,
  169. scaleLabel: {
  170. display: true,
  171. fontSize: 16,
  172. fontStyle: 'italic',
  173. labelString: 'Day of the month'
  174. },
  175. gridLines: {
  176. drawOnChartArea:false
  177. }
  178. }]
  179. },
  180. title: {
  181. display: true,
  182. fontSize: 16,
  183. text: "Review of this month in all platforms."
  184. }
  185. }
  186. });
  187. },
  188. error: function(error_data) {
  189. console.log(error_data);
  190. }
  191. });
  192. </script>
  193. {% endblock %}