Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Admin/User.vue
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
</tfoot> | </tfoot> | ||||
</table> | </table> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="tab-pane" id="user-subscriptions" role="tabpanel" aria-labelledby="tab-subscriptions"> | <div class="tab-pane" id="user-subscriptions" role="tabpanel" aria-labelledby="tab-subscriptions"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<table class="table table-sm table-hover"> | <table class="table table-sm table-hover mb-0"> | ||||
<thead class="thead-light"> | <thead class="thead-light"> | ||||
<tr> | <tr> | ||||
<th scope="col">Subscription</th> | <th scope="col">Subscription</th> | ||||
<th scope="col">Price</th> | <th scope="col">Price</th> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<tr v-for="(sku, sku_id) in skus" :id="'sku' + sku_id" :key="sku_id"> | <tr v-for="(sku, sku_id) in skus" :id="'sku' + sku.id" :key="sku_id"> | ||||
<td>{{ sku.name }}</td> | <td>{{ sku.name }}</td> | ||||
<td>{{ sku.price }}</td> | <td>{{ sku.price }}</td> | ||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
<tfoot class="table-fake-body"> | <tfoot class="table-fake-body"> | ||||
<tr> | <tr> | ||||
<td colspan="2">This user has no subscriptions.</td> | <td colspan="2">This user has no subscriptions.</td> | ||||
</tr> | </tr> | ||||
</tfoot> | </tfoot> | ||||
</table> | </table> | ||||
<small v-if="discount > 0" class="hint"> | <small v-if="discount > 0" class="hint"> | ||||
<hr class="m-0"> | <hr class="m-0"> | ||||
¹ applied discount: {{ discount }}% - {{ discount_description }} | ¹ applied discount: {{ discount }}% - {{ discount_description }} | ||||
</small> | </small> | ||||
<div class="mt-2"> | |||||
<button type="button" class="btn btn-danger" id="reset2fa" v-if="has2FA" @click="reset2FADialog">Reset 2-Factor Auth</button> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="tab-pane" id="user-domains" role="tabpanel" aria-labelledby="tab-domains"> | <div class="tab-pane" id="user-domains" role="tabpanel" aria-labelledby="tab-domains"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<table class="table table-sm table-hover"> | <table class="table table-sm table-hover"> | ||||
<thead class="thead-light"> | <thead class="thead-light"> | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | <div class="container"> | ||||
<button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button> | <button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button> | ||||
<button type="button" class="btn btn-primary modal-action" @click="submitOneOff()"> | <button type="button" class="btn btn-primary modal-action" @click="submitOneOff()"> | ||||
<svg-icon icon="check"></svg-icon> Submit | <svg-icon icon="check"></svg-icon> Submit | ||||
</button> | </button> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="reset-2fa-dialog" class="modal" tabindex="-1" role="dialog"> | |||||
<div class="modal-dialog" role="document"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h5 class="modal-title">2-Factor Authentication Reset</h5> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<p>This will remove 2-Factor Authentication entitlement as well | |||||
as the user-configured factors.</p> | |||||
<p>Please, make sure to confirm the user identity properly.</p> | |||||
</div> | |||||
<div class="modal-footer"> | |||||
<button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button> | |||||
<button type="button" class="btn btn-danger modal-action" @click="reset2FA()"> | |||||
<svg-icon icon="check"></svg-icon> Reset | |||||
</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import TransactionLog from '../Widgets/TransactionLog' | import TransactionLog from '../Widgets/TransactionLog' | ||||
export default { | export default { | ||||
beforeRouteUpdate (to, from, next) { | beforeRouteUpdate (to, from, next) { | ||||
Show All 11 Lines | export default { | ||||
oneoff_amount: '', | oneoff_amount: '', | ||||
oneoff_currency: 'CHF', | oneoff_currency: 'CHF', | ||||
oneoff_description: '', | oneoff_description: '', | ||||
oneoff_negative: false, | oneoff_negative: false, | ||||
discount: 0, | discount: 0, | ||||
discount_description: '', | discount_description: '', | ||||
discounts: [], | discounts: [], | ||||
external_email: '', | external_email: '', | ||||
has2FA: false, | |||||
wallet: {}, | wallet: {}, | ||||
walletReload: false, | walletReload: false, | ||||
domains: [], | domains: [], | ||||
skus: [], | skus: [], | ||||
sku2FA: null, | |||||
users: [], | users: [], | ||||
user: { | user: { | ||||
aliases: [], | aliases: [], | ||||
wallet: {}, | wallet: {}, | ||||
skus: {}, | skus: {}, | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | export default { | ||||
price: this.$root.priceLabel(sku.cost, count - sku.units_free, this.discount) | price: this.$root.priceLabel(sku.cost, count - sku.units_free, this.discount) | ||||
} | } | ||||
if (sku.range) { | if (sku.range) { | ||||
item.name += ' ' + count + ' ' + sku.range.unit | item.name += ' ' + count + ' ' + sku.range.unit | ||||
} | } | ||||
this.skus.push(item) | this.skus.push(item) | ||||
if (sku.title == '2fa') { | |||||
this.has2FA = true | |||||
this.sku2FA = sku.id | |||||
} | |||||
} | } | ||||
}) | }) | ||||
}) | }) | ||||
// Fetch users | // Fetch users | ||||
// TODO: Multiple wallets | // TODO: Multiple wallets | ||||
axios.get('/api/v4/users?owner=' + user_id) | axios.get('/api/v4/users?owner=' + user_id) | ||||
.then(response => { | .then(response => { | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | export default { | ||||
penalizeDialog() { | penalizeDialog() { | ||||
this.oneOffDialog(true) | this.oneOffDialog(true) | ||||
}, | }, | ||||
reload() { | reload() { | ||||
// this is to reload transaction log | // this is to reload transaction log | ||||
this.walletReload = true | this.walletReload = true | ||||
this.$nextTick(() => { this.walletReload = false }) | this.$nextTick(() => { this.walletReload = false }) | ||||
}, | }, | ||||
reset2FA() { | |||||
$('#reset-2fa-dialog').modal('hide') | |||||
axios.post('/api/v4/users/' + this.user.id + '/reset2FA') | |||||
.then(response => { | |||||
if (response.data.status == 'success') { | |||||
this.$toast.success(response.data.message) | |||||
this.skus = this.skus.filter(sku => sku.id != this.sku2FA) | |||||
this.has2FA = false | |||||
} | |||||
}) | |||||
}, | |||||
reset2FADialog() { | |||||
$('#reset-2fa-dialog').modal() | |||||
}, | |||||
submitDiscount() { | submitDiscount() { | ||||
$('#discount-dialog').modal('hide') | $('#discount-dialog').modal('hide') | ||||
axios.put('/api/v4/wallets/' + this.user.wallets[0].id, { discount: this.wallet.discount_id }) | axios.put('/api/v4/wallets/' + this.user.wallets[0].id, { discount: this.wallet.discount_id }) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.wallet = Object.assign({}, this.wallet, response.data) | this.wallet = Object.assign({}, this.wallet, response.data) | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |