Skip to content

Commit

Permalink
- Fixed change of ovh vps tariff
Browse files Browse the repository at this point in the history
  • Loading branch information
639852 committed Sep 3, 2024
1 parent 026f4ca commit d4880e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
29 changes: 19 additions & 10 deletions src/components/cloud/modules/ovh vps/openInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
<span style="font-weight: 700; text-align: left">{{ $t('ram') }}:</span>
{{ tariffs[planCode].resources.ram / 1024 }} Gb
<span style="font-weight: 700; text-align: left">{{ $t('disk') }}:</span>
{{ tariffs[planCode].resources.disk / 1024 }} Gb
{{ driveSize }} Gb
</div>
</a-spin>
</a-modal>
Expand Down Expand Up @@ -322,7 +322,7 @@
{{ $t("cloud_Size") }}
</div>
<div class="block__value">
{{ (VM.resources.drive_size / 1024).toFixed(2) }} GB
{{ ((VM.resources.drive_size ?? VM.resources.disk) / 1024).toFixed(2) }} GB
</div>
</div>
</div>
Expand Down Expand Up @@ -760,8 +760,10 @@ export default defineComponent({
return { code: this.userdata.currency ?? this.defaultCurrency }
},
renewalProps () {
const key = `${this.VM.config.duration} ${this.VM.config.planCode}`
const { period } = this.VM.billingPlan.products[key]
const { products = {} } = this.plans.find(({ uuid }) => uuid === this.VM.billingPlan.uuid) ?? {}
const key = this.VM.product ?? `${this.VM.config.duration} ${this.VM.config.planCode}`
const { period } = products[key] ?? {}

const currentPeriod = this.toDate(this.VM.data.expiration)
const newPeriod = this.toDate(this.VM.data.expiration + +period)

Expand Down Expand Up @@ -795,6 +797,11 @@ export default defineComponent({

return tariffs
},
driveSize () {
const { disk, drive_size: size } = this.tariffs[this.planCode].resources

return (size ?? disk) / 1024
},
networking () {
const { networking } = this.VM?.state?.meta

Expand Down Expand Up @@ -1116,7 +1123,9 @@ export default defineComponent({
const service = this.services.find(({ uuid }) =>
uuid === this.VM.uuidService
)
const instance = service.instancesGroups
const newService = JSON.parse(JSON.stringify(service))
const instance = newService.instancesGroups
.find(({ sp }) => sp === this.VM.sp).instances
.find(({ uuid }) => uuid === this.VM.uuid)
Expand All @@ -1130,15 +1139,15 @@ export default defineComponent({
this.$confirm({
title: this.$t('Do you want to switch tariff?'),
content: `${this.$t('invoice_Price')}: ${price} ${this.currency.code}`,
content: `${this.$t('Tariff price')}: ${price} ${this.currency.code}`,
okText: this.$t('Yes'),
cancelText: this.$t('Cancel'),
onOk: async () => {
await this.updateService(service)
await this.updateService(newService)
await this.sendAction('upgrade')
await this.fetch()
this.modal.switch = false
this.openNotificationWithIcon('success', { message: this.$t('Done') })
},
onCancel () {}
})
Expand Down Expand Up @@ -1199,8 +1208,8 @@ export default defineComponent({
data.action = 'backup_restore'
data.params = { type: 'full', restorePoint: this.option.recover }
}
if (action === 'get_upgrade_price') {
data.params = { newPlanCode: this.planCode }
if (['get_upgrade_price', 'upgrade'].includes(action)) {
data.params = { newPlanCode: this.planCode.split(' ')[1] }
}
return this.invokeAction(data)
Expand Down
4 changes: 3 additions & 1 deletion src/components/services/custom/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,9 @@ export default {
)
const account = access.namespace ?? this.namespace

await this.createInvoice(instance, uuid, account, this.baseURL)
if (this.getProducts.price > 0) {
await this.createInvoice(instance, uuid, account, this.baseURL)
}
localStorage.setItem('order', 'Invoice')
this.$router.push({ path: '/billing' })
})
Expand Down
4 changes: 3 additions & 1 deletion src/components/services/virtual/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ export default {
)
const account = access.namespace ?? this.namespace
await this.createInvoice(instance, uuid, account, this.baseURL)
if (this.getProducts.price > 0) {
await this.createInvoice(instance, uuid, account, this.baseURL)
}
localStorage.setItem('order', 'Invoice')
this.$router.push({ path: '/billing' })
})
Expand Down
2 changes: 1 addition & 1 deletion src/routes/cloud/cloudPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default {
case 'suspended':
case 'suspend':
case 'pending':
return 'var(--bright_font)'
return 'var(--gloomy_font)'
default:
return 'var(--err)'
}
Expand Down

0 comments on commit d4880e2

Please sign in to comment.