My SMM panel
 
 
 
 
 
 

111 lines
3.0 KiB

  1. <template>
  2. <template v-if="!loading">
  3. <sidebar :active="active"></sidebar>
  4. <transition name="fade" mode="out-in">
  5. <div v-if="active === ''" id="main">
  6. <section class="welcome-pane"><h3>Welcome, {{user.name}}!</h3></section>
  7. <section class="credits-pane"><img src="../../images/wallet2.svg" alt="wallet" class="icon"/><p>Credits: ${{user.credits}}</p></section>
  8. <section class="alerts-pane"><h4>News and Announcements</h4>
  9. <p>We've just launched. Thanks for joining us.</p>
  10. </section>
  11. <section class="recent-pane"><h4>Recent Activity</h4>
  12. <table>
  13. <thead><th>Date</th><th>Name</th><th>Status</th> <th>Quantity</th></thead>
  14. <tbody>
  15. <tr v-bind:key='order.id' v-for='order in orders.slice(0, 10)'>
  16. <template v-if="order.status != 'pending'">
  17. <td>{{order.updated_at}}</td>
  18. <td>{{order.service.name}}</td>
  19. <td :class="order.status"
  20. class="status"><span>{{order.status.charAt(0).toUpperCase() +
  21. order.status.slice(1)}}</span></td>
  22. <td>{{order.quantity}}</td>
  23. </template>
  24. </tr>
  25. </tbody>
  26. </table>
  27. </section>
  28. </div>
  29. <PastOrders :orders="orders" v-else-if="active === '#orders'" id="main">
  30. </PastOrders>
  31. <NewOrder :token="token" :credits="user.credits" v-else-if="active ===
  32. '#new-order'" id="main" @updateUser='getUser'>
  33. </NewOrder>
  34. <div id="main" v-else-if="active === '#exit'">
  35. <section class="logout-pane">
  36. <h3>Are you sure you want to logout?</h3>
  37. <a href="/logout">Logout</a>
  38. </section>
  39. </div>
  40. <settings :token="token" :user="user" class="settings-page" id="main" v-else-if="active === '#settings'"></settings>
  41. </transition>
  42. </template>
  43. </template>
  44. <script>
  45. import Sidebar from './sidebar.vue'
  46. import Settings from './settings.vue'
  47. import PastOrders from './orders.vue'
  48. import NewOrder from './services.vue'
  49. /* function getServices() { */
  50. /* } */
  51. function getServices() {
  52. return fetch("/panel/services", {
  53. method: 'GET',
  54. headers: {'Content-Type': 'application/json',
  55. 'Accept': 'application/json',
  56. 'X-XSRF-TOKEN': this.token}
  57. }).then(response => {
  58. response.json().then(data => {this.services = data})
  59. })
  60. }
  61. function getUser() {
  62. return fetch("/panel/user", {
  63. method: 'GET',
  64. headers: {'Content-Type': 'application/json',
  65. 'Accept': 'application/json',
  66. 'X-XSRF-TOKEN': this.token},
  67. }).then(response => {
  68. return response.json()
  69. }).then(data => {
  70. this.user = data
  71. })
  72. }
  73. function getOrders() {
  74. return fetch("/panel/orders", {
  75. method: 'GET',
  76. headers: {'Content-Type': 'application/json',
  77. 'Accept': 'application/json',
  78. 'X-XSRF-TOKEN': this.token},
  79. }).then(response => {
  80. return response.json()
  81. }).then(data => {
  82. this.orders = data
  83. })
  84. }
  85. export default {
  86. components: {
  87. Sidebar, Settings, PastOrders, NewOrder
  88. },
  89. data() {
  90. return {active: window.location.hash, user: null,
  91. token: null, orders: null, loading: true,}
  92. },
  93. methods: {getUser, getServices, getOrders},
  94. created() {
  95. let loaders = []
  96. loaders.push(this.getUser())
  97. loaders.push(this.getServices())
  98. loaders.push(this.getOrders())
  99. Promise.all(loaders).then(() => {
  100. this.loading = false
  101. })
  102. }
  103. }
  104. </script>