Examples of code I've written in PHP, Javascript, SCSS, etc.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

3 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <template v-if="!loading">
  3. <sidebar :role="user.role" :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/coin-stack.svg"
  8. alt="wallet" class="icon"/><p>Credits:
  9. {{(user.credits/100).toLocaleString('en')}}</p></section>
  10. <section class="alerts-pane"><h4>News and Announcements</h4>
  11. <p>We've just launched. Thanks for joining us! Some features are still
  12. being tested.</p>
  13. </section>
  14. <section class="recent-pane"><h4>Recent Activity</h4>
  15. <table>
  16. <thead><th>Date</th><th>Name</th><th>Status</th></thead>
  17. <tbody>
  18. <tr v-bind:key='order.id' v-for='order in orders.slice(0, 10)'>
  19. <template v-if="order.status != 'pending'">
  20. <td>{{order.updated_at}}</td>
  21. <td>{{order.service.name}}</td>
  22. <td :class="order.status"
  23. class="status"><span>{{order.status.charAt(0).toUpperCase() +
  24. order.status.slice(1)}}</span></td>
  25. </template>
  26. </tr>
  27. </tbody>
  28. </table>
  29. </section>
  30. </div>
  31. <past-orders :token="token" :orders="orders" v-else-if="active === '#orders'"
  32. id="main">
  33. </past-orders>
  34. <new-order :preferred="user.payment_method" :token="token" :active="active"
  35. :credits="user.credits" v-else-if="active ===
  36. '#new-order' || active === '#credits'" id="main" @update-user='getUser'
  37. @update-orders='getOrders'>
  38. </new-order>
  39. <div id="main" v-else-if="active === '#exit'">
  40. <section class="logout-pane">
  41. <h3>Are you sure you want to logout?</h3>
  42. <a href="/logout">Logout</a>
  43. </section>
  44. </div>
  45. <settings :token="token" :user="user" class="settings-page" id="main"
  46. v-else-if="active === '#settings'">
  47. </settings>
  48. <transaction-end @purchase-complete="getUser" :token="token" :user="user"
  49. :active="active" v-else-if="active ==
  50. '#transaction-complete' || active == '#transaction-failed'">
  51. </transaction-end>
  52. <support v-else-if="active == '#support'" :user="user" :token="token"></support>
  53. </transition>
  54. </template>
  55. </template>
  56. <script>
  57. import Sidebar from './sidebar.vue'
  58. import Settings from './settings.vue'
  59. import PastOrders from './orders.vue'
  60. import NewOrder from './services.vue'
  61. import TransactionEnd from './transaction-endpoint.vue'
  62. import Support from './support.vue'
  63. function getServices() {
  64. return fetch("/panel/services", {
  65. method: 'GET',
  66. headers: {'Content-Type': 'application/json',
  67. 'Accept': 'application/json',
  68. 'X-XSRF-TOKEN': this.token}
  69. }).then(response => {
  70. response.json().then(data => {this.services = data})
  71. })
  72. }
  73. function getUser() {
  74. return fetch("/panel/user", {
  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.user = data
  83. })
  84. }
  85. function getOrders() {
  86. return fetch("/panel/orders", {
  87. method: 'GET',
  88. headers: {'Content-Type': 'application/json',
  89. 'Accept': 'application/json',
  90. 'X-XSRF-TOKEN': this.token},
  91. }).then(response => {
  92. return response.json()
  93. }).then(data => {
  94. this.orders = data
  95. })
  96. }
  97. export default {
  98. components: {
  99. Sidebar, Settings, PastOrders, NewOrder,
  100. TransactionEnd, Support
  101. },
  102. data() {
  103. return {active: window.location.hash, user: null,
  104. token: null, orders: null, loading: true,}
  105. },
  106. methods: {getUser, getServices, getOrders, },
  107. created() {
  108. let loaders = []
  109. loaders.push(this.getUser())
  110. loaders.push(this.getServices())
  111. loaders.push(this.getOrders())
  112. Promise.all(loaders).then(() => {
  113. this.loading = false
  114. })
  115. }
  116. }
  117. </script>