Goals.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="row">
  3. <div class="col-md-12">
  4. <div class="card">
  5. <div class="card-header">
  6. <h5 class="card-title">Development Goals View</h5>
  7. <div class="card-tools">
  8. <button type="button" class="btn btn-tool" data-card-widget="collapse">
  9. <i class="fas fa-minus"></i>
  10. </button>
  11. <div class="btn-group">
  12. <button type="button" class="btn btn-tool dropdown-toggle" data-toggle="dropdown">
  13. <i class="fas fa-wrench"></i>
  14. </button>
  15. <div class="dropdown-menu dropdown-menu-right" role="menu">
  16. <a href="javascript://" class="dropdown-item">Action</a>
  17. <a href="javascript://" class="dropdown-item">Another action</a>
  18. <a href="javascript://" class="dropdown-item">Something else here</a>
  19. <a class="dropdown-divider"></a>
  20. <a href="javascript://" class="dropdown-item">Separated link</a>
  21. </div>
  22. </div>
  23. <button type="button" class="btn btn-tool" data-card-widget="remove">
  24. <i class="fas fa-times"></i>
  25. </button>
  26. </div>
  27. </div>
  28. <div class="card-body">
  29. <div class="row">
  30. <div class="col-md-4">
  31. <p class="text-center">
  32. <strong>Goal Completion</strong>
  33. </p>
  34. <div
  35. v-for="(goal, index) of goals"
  36. v-bind:key="goal.title"
  37. class="progress-group"
  38. >
  39. {{goal.title}}
  40. <span class="float-right">
  41. <b>{{goal.completed}}</b>/{{goal.target}}
  42. </span>
  43. <div class="progress progress-sm">
  44. <div
  45. class="progress-bar"
  46. :class="goal.bg"
  47. :style="{ width: completionPct(index) }"
  48. ></div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="card-footer">
  55. <div class="row">
  56. <div class="col-sm-3 col-6">
  57. <div class="description-block border-right">
  58. <span class="description-percentage text-success"><i class="fas fa-caret-up"></i> 17%</span>
  59. <h5 class="description-header">$35,210.43</h5>
  60. <span class="description-text">TOTAL REVENUE</span>
  61. </div>
  62. </div>
  63. <div class="col-sm-3 col-6">
  64. <div class="description-block border-right">
  65. <span class="description-percentage text-warning"><i class="fas fa-caret-left"></i> 0%</span>
  66. <h5 class="description-header">$10,390.90</h5>
  67. <span class="description-text">TOTAL COST</span>
  68. </div>
  69. </div>
  70. <div class="col-sm-3 col-6">
  71. <div class="description-block border-right">
  72. <span class="description-percentage text-success"><i class="fas fa-caret-up"></i> 20%</span>
  73. <h5 class="description-header">$24,813.53</h5>
  74. <span class="description-text">TOTAL PROFIT</span>
  75. </div>
  76. </div>
  77. <div class="col-sm-3 col-6">
  78. <div class="description-block">
  79. <span class="description-percentage text-danger"><i class="fas fa-caret-down"></i> 18%</span>
  80. <h5 class="description-header">1200</h5>
  81. <span class="description-text">GOAL COMPLETIONS</span>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. /* Import modules. */
  92. import numeral from 'numeral'
  93. export default {
  94. data: () => {
  95. return {
  96. goals: []
  97. }
  98. },
  99. computed: {
  100. completionPct() {
  101. // NOTE: We use this "method" to allow for the parameter.
  102. // https://stackoverflow.com/a/40539522
  103. return _goalId => {
  104. /* Validate goals. */
  105. if (!this.goals) {
  106. return ''
  107. }
  108. /* Calculate completion pct. */
  109. const pct = this.goals[_goalId].completed / this.goals[_goalId].target
  110. // console.log('COMPLETION PCT', pct)
  111. /* Set formatted. */
  112. const formatted = numeral(pct).format('0.0%')
  113. // console.log('COMPLETION FORMATTED', formatted)
  114. /* Return style. */
  115. return formatted
  116. }
  117. }
  118. },
  119. methods: {
  120. loadSampleChart() {
  121. // var ctx = document.getElementById('myChart').getContext('2d');
  122. // new window.Chart(ctx, {
  123. // type: 'bar',
  124. // data: {
  125. // labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
  126. // datasets: [{
  127. // label: '# of Votes',
  128. // data: [12, 19, 3, 5, 2, 3],
  129. // backgroundColor: [
  130. // 'rgba(255, 99, 132, 0.2)',
  131. // 'rgba(54, 162, 235, 0.2)',
  132. // 'rgba(255, 206, 86, 0.2)',
  133. // 'rgba(75, 192, 192, 0.2)',
  134. // 'rgba(153, 102, 255, 0.2)',
  135. // 'rgba(255, 159, 64, 0.2)'
  136. // ],
  137. // borderColor: [
  138. // 'rgba(255, 99, 132, 1)',
  139. // 'rgba(54, 162, 235, 1)',
  140. // 'rgba(255, 206, 86, 1)',
  141. // 'rgba(75, 192, 192, 1)',
  142. // 'rgba(153, 102, 255, 1)',
  143. // 'rgba(255, 159, 64, 1)'
  144. // ],
  145. // borderWidth: 1
  146. // }]
  147. // },
  148. // options: {
  149. // scales: {
  150. // yAxes: [{
  151. // ticks: {
  152. // beginAtZero: true
  153. // }
  154. // }]
  155. // }
  156. // }
  157. // });
  158. },
  159. loadSalesChart() {
  160. // /* Set JQuery. */
  161. // // const $ = window.$
  162. // /* Set Chart. */
  163. // const Chart = window.Chart
  164. // // Get context with jQuery - using jQuery's .get() method.
  165. // // var salesChartCanvas = $('#salesChart').get(0).getContext('2d')
  166. // var salesChartCanvas = document.getElementById('salesChart').getContext('2d');
  167. // var salesChartData = {
  168. // labels : ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  169. // datasets: [
  170. // {
  171. // label : 'Digital Goods',
  172. // backgroundColor : 'rgba(60,141,188,0.9)',
  173. // borderColor : 'rgba(60,141,188,0.8)',
  174. // pointRadius : false,
  175. // pointColor : '#3b8bba',
  176. // pointStrokeColor : 'rgba(60,141,188,1)',
  177. // pointHighlightFill : '#fff',
  178. // pointHighlightStroke: 'rgba(60,141,188,1)',
  179. // data : [28, 48, 40, 19, 86, 27, 90]
  180. // },
  181. // {
  182. // label : 'Electronics',
  183. // backgroundColor : 'rgba(210, 214, 222, 1)',
  184. // borderColor : 'rgba(210, 214, 222, 1)',
  185. // pointRadius : false,
  186. // pointColor : 'rgba(210, 214, 222, 1)',
  187. // pointStrokeColor : '#c1c7d1',
  188. // pointHighlightFill : '#fff',
  189. // pointHighlightStroke: 'rgba(220,220,220,1)',
  190. // data : [65, 59, 80, 81, 56, 55, 40]
  191. // },
  192. // ]
  193. // }
  194. // var salesChartOptions = {
  195. // maintainAspectRatio : false,
  196. // responsive : true,
  197. // legend: {
  198. // display: false
  199. // },
  200. // scales: {
  201. // xAxes: [{
  202. // gridLines : {
  203. // display : false,
  204. // }
  205. // }],
  206. // yAxes: [{
  207. // gridLines : {
  208. // display : false,
  209. // }
  210. // }]
  211. // }
  212. // }
  213. // // This will get the first returned node in the jQuery collection.
  214. // new Chart(salesChartCanvas, {
  215. // type: 'line',
  216. // data: salesChartData,
  217. // options: salesChartOptions
  218. // }
  219. // )
  220. }
  221. },
  222. created: function () {
  223. // /* Add goal. */
  224. // this.goals.push({
  225. // title: 'Bull Run to $1k by Dec 2020',
  226. // completed: 391,
  227. // target: 1000,
  228. // bg: 'bg-primary',
  229. // })
  230. // /* Add goal. */
  231. // this.goals.push({
  232. // title: 'Development Roadmap',
  233. // completed: 7,
  234. // target: 19,
  235. // bg: 'bg-primary',
  236. // })
  237. // /* Add goal. */
  238. // this.goals.push({
  239. // title: 'Infrastructure Funding Goal',
  240. // completed: 31,
  241. // target: 100,
  242. // bg: 'bg-warning',
  243. // })
  244. // /* Add goal. */
  245. // this.goals.push({
  246. // title: 'SHA256 Total Hash Rate %',
  247. // completed: 4,
  248. // target: 80,
  249. // bg: 'bg-danger',
  250. // })
  251. },
  252. mounted: function () {
  253. // this.loadSampleChart()
  254. // this.loadSalesChart()
  255. },
  256. }
  257. </script>