My SMM panel
 
 
 
 
 
 

215 lines
6.9 KiB

  1. <template>
  2. <sidebar :active="active"></sidebar>
  3. <transition name="fade" mode="out-in">
  4. <div v-if="active === ''" id="main">
  5. <section class="welcome-pane"><h3>Welcome, {{user.name}}!</h3></section>
  6. <section class="credits-pane"><img src="../../images/wallet2.svg" alt="wallet" class="icon"/><p>Credits: ${{user.credits}}</p></section>
  7. <section class="alerts-pane"><h4>News and Announcements</h4>
  8. <p>We've just launched. Thanks for joining us.</p>
  9. </section>
  10. <section class="recent-pane"><h4>Recent Activity</h4>
  11. <table>
  12. <thead><th>Date</th><th>Name</th><th>Status</th> <th>Quantity</th></thead>
  13. <tbody>
  14. <tr v-bind:key='order.id' v-for='order in orders.slice(0, 10)'>
  15. <template v-if="order.status != 'pending'">
  16. <td>{{order.updated_at}}</td>
  17. <td>{{order.service.name}}</td>
  18. <td :class="order.status"
  19. class="status"><span>{{order.status.charAt(0).toUpperCase() +
  20. order.status.slice(1)}}</span></td>
  21. <td>{{order.quantity}}</td>
  22. </template>
  23. </tr>
  24. </tbody>
  25. </table>
  26. </section>
  27. </div>
  28. <div v-else-if="active === '#orders'" id="main">
  29. <section class="pending-pane">
  30. <h4>Pending Orders</h4>
  31. <ul>
  32. <template v-bind:key='order.id' v-for="order in orders">
  33. <div class="pending-item" v-if="order.status == 'pending'">
  34. <div class="pending-heading">
  35. <li @click="togglePending($event)">{{order.service.name}} ({{order.updated_at}})</li>
  36. <img class="chevron" src="../../images/chevron-down.svg" alt="">
  37. </div>
  38. <div class="pending-content">
  39. <p>ID: {{order.id}}<br>URL: {{order.url}}<br>Quantity: {{order.quantity}}<br>Note: {{order.note}}</p>
  40. </div>
  41. </div>
  42. </template>
  43. </ul>
  44. </section>
  45. <section class="history-pane">
  46. <h4>Order History</h4>
  47. <table>
  48. <thead><th>Date</th><th>ID</th><th>Name</th><th>Status</th> <th>Quantity</th></thead>
  49. <tbody>
  50. <tr @click="toggleOrderItem($event)" v-bind:key='order.id' v-for='order in orders.slice(historyPage*10-10, historyPage*10)'>
  51. <td>{{order.updated_at}}</td>
  52. <td>{{order.id}}</td>
  53. <td>{{order.service.name}}</td>
  54. <td :class="order.status"
  55. class="status"><span>{{order.status.charAt(0).toUpperCase() +
  56. order.status.slice(1)}}</span></td>
  57. <td>{{order.quantity}}</td>
  58. </tr>
  59. </tbody>
  60. </table>
  61. <img @click="moveHistory(false)" class="nav-btn left" src="../../images/arrow-left-circle-fill.svg" alt="">
  62. <p class="nav-legend">{{historyPage}}/{{Math.ceil(orders.length/10)}}</p>
  63. <img @click="moveHistory(true)" class="nav-btn right" src="../../images/arrow-right-circle-fill.svg" alt="">
  64. </section>
  65. </div>
  66. <div id="main" v-else-if="active === '#exit'">
  67. <section class="logout-pane">
  68. <h3>Are you sure you want to logout?</h3>
  69. <a href="/logout">Logout</a>
  70. </section>
  71. </div>
  72. <div class="settings-page" id="main" v-else-if="active === '#settings'">
  73. <section class="change-name-pane">
  74. <h3>Settings</h3>
  75. <h4>Name</h4>
  76. <input :value="user.name" name="name" id="changed_name" type="text">
  77. <button @click="changeName">Save <loading src="../../images/loading-white.svg" alt=""></loading></button>
  78. <span></span>
  79. </section>
  80. <section class="change-email-pane">
  81. <h4>Email</h4>
  82. <input :value="user.email" name="email" type="text" id="changed_email">
  83. <button @click="changeEmail">Save<img class="loading-icon" src="../../images/loading-white.svg" alt=""></button>
  84. <span></span>
  85. </section>
  86. <section class="change-password-pane">
  87. <h4>Change Password</h4>
  88. <h5>Current Password</h5><input name="current_passowrd" id="current_password" type="password">
  89. <h5>New Password</h5><input id="new_password" name="passowrd" type="password">
  90. <h5>Confirm Password</h5><input id="confirm_password" name="confirm_passowrd" type="password">
  91. <button @click="changePassword">Save<img class="loading-icon" src="../../images/loading-white.svg" alt=""></button>
  92. <span></span>
  93. </section>
  94. </div>
  95. </transition>
  96. </template>
  97. <script>
  98. import Sidebar from './sidebar.vue'
  99. import Loading from '../icons/loading.vue'
  100. function togglePending(event) {
  101. event.target.parentNode.parentNode.classList.toggle('selected')
  102. }
  103. function toggleOrderItem(event) {
  104. event.target.parentNode.parentNode.classList.toggle('selected')
  105. }
  106. function moveHistory(forward) {
  107. if (forward) {
  108. this.historyPage += 1
  109. } else {
  110. this.historyPage -= 1
  111. }
  112. if (this.historyPage < 1) {
  113. this.historyPage = 1
  114. return
  115. } else if (this.historyPage > this.orders.length/10+1) {
  116. this.historyPage -= 1
  117. return
  118. }
  119. }
  120. function changeName() {
  121. let name = document.getElementById('changed_name').value
  122. let info = document.querySelector('.change-name-pane span')
  123. let pane = document.querySelector('.change-name-pane')
  124. pane.classList.add('loading')
  125. pane.classList.remove('error')
  126. fetch("/panel/change-name", {
  127. method: 'POST',
  128. headers: {'Content-Type': 'application/json',
  129. 'Accept': 'application/json',
  130. 'X-XSRF-TOKEN': this.token},
  131. body: JSON.stringify({'name': name}),
  132. }).then(response => {
  133. if (response.ok) {
  134. response.json().then(data => {this.user = data})
  135. pane.classList.add('completed')
  136. info.textContent = 'Completed'
  137. } else {
  138. pane.classList.add('error')
  139. info.textContent = 'Error: ' + response.status
  140. }
  141. pane.classList.remove('loading')
  142. })
  143. }
  144. function changeEmail() {
  145. let email = document.getElementById('changed_email').value
  146. let info = document.querySelector('.change-email-pane span')
  147. let pane = document.querySelector('.change-email-pane')
  148. pane.classList.add('loading')
  149. pane.classList.remove('error')
  150. fetch("/panel/change-name", {
  151. method: 'POST',
  152. headers: {'Content-Type': 'application/json',
  153. 'Accept': 'application/json',
  154. 'X-XSRF-TOKEN': this.token},
  155. body: JSON.stringify({'email': email}),
  156. }).then(response => {
  157. if (response.ok) {
  158. pane.classList.add('completed')
  159. info.textContent = 'Completed'
  160. } else {
  161. pane.classList.add('error')
  162. info.textContent = 'Error: ' + response.status
  163. }
  164. pane.classList.remove('loading')
  165. })
  166. }
  167. function changePassword() {
  168. let info = document.querySelector('.change-password-pane span')
  169. let pane = document.querySelector('.change-password-pane')
  170. pane.classList.add('loading')
  171. pane.classList.remove('error')
  172. fetch("/panel/change-password", {
  173. method: 'POST',
  174. headers: {'Content-Type': 'application/json',
  175. 'Accept': 'application/json',
  176. 'X-XSRF-TOKEN': this.token},
  177. body: JSON.stringify({'current_password': document.getElementById('current_password').value, 'password': document.getElementById('new_password').value, 'password_confirmation': document.getElementById('confirm_password').value}),
  178. }).then(response => {
  179. response.json().then(data => {console.log(data)})
  180. if (response.ok) {
  181. pane.classList.add('completed')
  182. info.textContent = 'Completed'
  183. } else {
  184. pane.classList.add('error')
  185. info.textContent = 'Error: ' + response.status
  186. }
  187. pane.classList.remove('loading')
  188. })
  189. }
  190. export default {
  191. components: {
  192. Sidebar, Loading
  193. },
  194. data() {
  195. return {active: window.location.hash, user: '',
  196. token: '', orders: '', historyPage: 1}
  197. },
  198. methods: {togglePending, toggleOrderItem, moveHistory, changeName, changeEmail, changePassword}
  199. }
  200. </script>