|
| 1 | +<template> |
| 2 | + <v-container fluid class="pa-0" :fill-height="$vuetify.breakpoint.lgAndUp"> |
| 3 | + <div class="w-full h-full"> |
| 4 | + <v-app-bar height="60" :dense="$vuetify.breakpoint.mdAndDown"> |
| 5 | + <v-btn icon to="/"> |
| 6 | + <v-icon>{{ mdiArrowLeft }}</v-icon> |
| 7 | + </v-btn> |
| 8 | + <v-toolbar-title> |
| 9 | + <div class="py-16">Account Usage</div> |
| 10 | + </v-toolbar-title> |
| 11 | + <v-progress-linear |
| 12 | + :active="loading" |
| 13 | + :indeterminate="loading" |
| 14 | + absolute |
| 15 | + bottom |
| 16 | + ></v-progress-linear> |
| 17 | + </v-app-bar> |
| 18 | + <v-container> |
| 19 | + <v-row> |
| 20 | + <v-col cols="12" md="9" offset-md="1" xl="8" offset-xl="2"> |
| 21 | + <h5 class="text-h4 mb-3 mt-3">Overview</h5> |
| 22 | + <p class="text--secondary"> |
| 23 | + This is the summary of the sent messages and received messages in |
| 24 | + <code |
| 25 | + v-if="$store.getters.getBillingUsage" |
| 26 | + class="font-weight-bold" |
| 27 | + >{{ |
| 28 | + $store.getters.getBillingUsage.start_timestamp | billingPeriod |
| 29 | + }}</code |
| 30 | + >. |
| 31 | + </p> |
| 32 | + <v-row v-if="$store.getters.getBillingUsage"> |
| 33 | + <v-col cols="12" md="4"> |
| 34 | + <v-alert |
| 35 | + dark |
| 36 | + dense |
| 37 | + :icon="mdiCallMade" |
| 38 | + prominent |
| 39 | + type="info" |
| 40 | + text |
| 41 | + > |
| 42 | + <h2 class="text-h4 font-weight-bold mt-4"> |
| 43 | + {{ $store.getters.getBillingUsage.sent_messages | decimal }} |
| 44 | + </h2> |
| 45 | + <p class="text--secondary mt-n1">Messages Sent</p> |
| 46 | + </v-alert> |
| 47 | + </v-col> |
| 48 | + <v-col cols="12" md="4"> |
| 49 | + <v-alert |
| 50 | + dark |
| 51 | + dense |
| 52 | + :icon="mdiCallReceived" |
| 53 | + prominent |
| 54 | + type="warning" |
| 55 | + text |
| 56 | + > |
| 57 | + <div class="d-flex"> |
| 58 | + <h2 class="text-h4 font-weight-bold mt-4"> |
| 59 | + {{ |
| 60 | + $store.getters.getBillingUsage.received_messages |
| 61 | + | decimal |
| 62 | + }} |
| 63 | + </h2> |
| 64 | + </div> |
| 65 | + <p class="text--secondary mt-n1">Messages Received</p> |
| 66 | + </v-alert> |
| 67 | + </v-col> |
| 68 | + <v-col cols="12" md="4"> |
| 69 | + <v-alert |
| 70 | + dense |
| 71 | + :icon="mdiCreditCard" |
| 72 | + prominent |
| 73 | + type="success" |
| 74 | + text |
| 75 | + > |
| 76 | + <h2 class="text-h4 font-weight-bold mt-4"> |
| 77 | + {{ $store.getters.getBillingUsage.total_cost | money }} |
| 78 | + </h2> |
| 79 | + <p class="text--secondary mt-n1">Total Cost</p> |
| 80 | + </v-alert> |
| 81 | + </v-col> |
| 82 | + </v-row> |
| 83 | + <h5 class="text-h4 mb-3 mt-12">Usage History</h5> |
| 84 | + <p class="text--secondary"> |
| 85 | + Summary of all the sent and received messages in the past 12 |
| 86 | + months |
| 87 | + </p> |
| 88 | + <v-simple-table> |
| 89 | + <template #default> |
| 90 | + <thead> |
| 91 | + <tr class="text-uppercase"> |
| 92 | + <th class="text-left">Period</th> |
| 93 | + <th class="text-left"> |
| 94 | + Sent |
| 95 | + <span v-if="$vuetify.breakpoint.lgAndUp">Messages</span> |
| 96 | + </th> |
| 97 | + <th class="text-left"> |
| 98 | + Received |
| 99 | + <span v-if="$vuetify.breakpoint.lgAndUp">Messages</span> |
| 100 | + </th> |
| 101 | + <th class="text-right"> |
| 102 | + <span v-if="$vuetify.breakpoint.lgAndUp">Total</span> Cost |
| 103 | + </th> |
| 104 | + </tr> |
| 105 | + </thead> |
| 106 | + <tbody> |
| 107 | + <tr |
| 108 | + v-for="billingUsage in $store.getters |
| 109 | + .getBillingUsageHistory" |
| 110 | + :key="billingUsage.id" |
| 111 | + > |
| 112 | + <td> |
| 113 | + {{ billingUsage.start_timestamp | billingPeriod }} |
| 114 | + </td> |
| 115 | + <td> |
| 116 | + {{ billingUsage.sent_messages | decimal }} |
| 117 | + </td> |
| 118 | + <td> |
| 119 | + {{ billingUsage.received_messages }} |
| 120 | + </td> |
| 121 | + <td class="text-right font-weight-bold"> |
| 122 | + {{ billingUsage.total_cost | money }} |
| 123 | + </td> |
| 124 | + </tr> |
| 125 | + </tbody> |
| 126 | + </template> |
| 127 | + </v-simple-table> |
| 128 | + </v-col> |
| 129 | + </v-row> |
| 130 | + </v-container> |
| 131 | + </div> |
| 132 | + </v-container> |
| 133 | +</template> |
| 134 | + |
| 135 | +<script lang="ts"> |
| 136 | +import Vue from 'vue' |
| 137 | +import { |
| 138 | + mdiArrowLeft, |
| 139 | + mdiAccountCircle, |
| 140 | + mdiShieldCheck, |
| 141 | + mdiDelete, |
| 142 | + mdiContentSave, |
| 143 | + mdiEye, |
| 144 | + mdiEyeOff, |
| 145 | + mdiCallReceived, |
| 146 | + mdiCallMade, |
| 147 | + mdiCreditCard, |
| 148 | + mdiSquareEditOutline, |
| 149 | +} from '@mdi/js' |
| 150 | +
|
| 151 | +export default Vue.extend({ |
| 152 | + name: 'BillingIndex', |
| 153 | + middleware: ['auth'], |
| 154 | + data() { |
| 155 | + return { |
| 156 | + mdiEye, |
| 157 | + mdiEyeOff, |
| 158 | + mdiArrowLeft, |
| 159 | + mdiAccountCircle, |
| 160 | + mdiShieldCheck, |
| 161 | + mdiDelete, |
| 162 | + mdiContentSave, |
| 163 | + mdiCallReceived, |
| 164 | + mdiCallMade, |
| 165 | + mdiCreditCard, |
| 166 | + mdiSquareEditOutline, |
| 167 | + loading: true, |
| 168 | + } |
| 169 | + }, |
| 170 | + head() { |
| 171 | + return { |
| 172 | + title: 'Usage & Billing - Http SMS', |
| 173 | + } |
| 174 | + }, |
| 175 | + computed: { |
| 176 | + apiKey() { |
| 177 | + if (this.$store.getters.getUser === null) { |
| 178 | + return '' |
| 179 | + } |
| 180 | + return this.$store.getters.getUser.api_key |
| 181 | + }, |
| 182 | + }, |
| 183 | + async mounted() { |
| 184 | + if (!this.$store.getters.getAuthUser) { |
| 185 | + await this.$store.dispatch('setNextRoute', this.$route.path) |
| 186 | + await this.$router.push({ name: 'index' }) |
| 187 | + setTimeout(this.loadData, 2000) |
| 188 | + return |
| 189 | + } |
| 190 | + await this.loadData() |
| 191 | + }, |
| 192 | +
|
| 193 | + methods: { |
| 194 | + async loadData() { |
| 195 | + await Promise.all([ |
| 196 | + this.$store.dispatch('loadBillingUsage'), |
| 197 | + this.$store.dispatch('loadBillingUsageHistory'), |
| 198 | + ]) |
| 199 | + this.loading = false |
| 200 | + }, |
| 201 | + }, |
| 202 | +}) |
| 203 | +</script> |
0 commit comments