Skip to content

Commit

Permalink
Merge pull request #1635 from slntopp/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SazukinPavel authored Apr 4, 2024
2 parents 4d0c8e5 + 917e645 commit 92940ec
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 59 deletions.
6 changes: 3 additions & 3 deletions admin-ui/src/components/modules/cpanel/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</v-col>
<v-col cols="6">
<v-select
:items="plans.list"
:items="plans"
:value="billingPlanId"
@change="setValue('billingPlan', $event)"
item-text="title"
Expand Down Expand Up @@ -91,7 +91,7 @@ export default {
if (!this.isEdit) {
this.$emit("set-instance", getDefaultInstance());
} else {
const plan = this.plans.list.find(
const plan = this.plans.find(
(p) => p.uuid == this.instance.billing_plan
);
this.setValue("billingPlan", plan);
Expand All @@ -103,7 +103,7 @@ export default {
return this.instance.billing_plan || this.instance.billingPlan.uuid;
},
products() {
const plan = this.plans.list.find((p) => p.uuid == this.billingPlanId);
const plan = this.plans.find((p) => p.uuid == this.billingPlanId);
return Object.keys(plan?.products || {}).map((key) => ({
...plan.products[key],
key,
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/src/components/modules/custom/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
item-text="title"
item-value="uuid"
:value="instance.plan"
:items="plans.list"
:items="plans"
:rules="planRules"
@change="(newVal) => setValue('billing_plan', newVal)"
/>
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/components/modules/empty/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
item-text="title"
item-value="uuid"
:value="instance.billing_plan"
:items="plans.list"
:items="plans"
:rules="planRules"
@change="changeBilling"
/>
Expand Down Expand Up @@ -94,7 +94,7 @@ export default {
},
methods: {
changeBilling(val) {
this.bilingPlan = this.plans.list.find((p) => p.uuid === val);
this.bilingPlan = this.plans.find((p) => p.uuid === val);
if (this.bilingPlan) {
this.products = Object.keys(this.bilingPlan.products).map((key) => ({
key,
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
},
},
watch: {
"plans.list"() {
"plans"() {
this.changeBilling(this.instance.billing_plan);
},
autoEnabled: {
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/components/modules/ione/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
item-text="title"
item-value="uuid"
:value="instance.billing_plan"
:items="plans.list"
:items="plans"
:rules="planRules"
@change="changeBilling"
/>
Expand Down Expand Up @@ -203,7 +203,7 @@ export default {
this.setValue("config.template_id", +osId);
},
changeBilling(val) {
this.bilingPlan = this.plans.list.find((p) => p.uuid === val);
this.bilingPlan = this.plans.find((p) => p.uuid === val);
if (this.bilingPlan) {
this.products = Object.keys(this.bilingPlan.products);
}
Expand Down Expand Up @@ -284,7 +284,7 @@ export default {
},
},
watch: {
"plans.list"() {
"plans"() {
this.changeBilling(this.instance.billing_plan);
},
existing() {
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/src/components/modules/keyweb/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
item-value="uuid"
:value="instance.billing_plan"
@change="setValue('billing_plan', $event)"
:items="plans.list"
:items="plans"
:rules="planRules"
/>
</v-col>
Expand Down Expand Up @@ -148,7 +148,7 @@ const rules = ref({
});
const billingPlan = computed(() =>
plans.value.list.find((p) => p.uuid === instance.value.billing_plan)
plans.value.find((p) => p.uuid === instance.value.billing_plan)
);
const fullProduct = computed(() => billingPlan.value?.products[product.value]);
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/components/modules/openai/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
item-text="title"
item-value="uuid"
:value="instance.billing_plan"
:items="plans.list"
:items="plans"
:rules="planRules"
@change="changeBilling"
/>
Expand Down Expand Up @@ -56,7 +56,7 @@ export default {
},
methods: {
changeBilling(val) {
this.bilingPlan = this.plans.list.find((p) => p.uuid === val);
this.bilingPlan = this.plans.find((p) => p.uuid === val);
if (this.bilingPlan) {
this.products = Object.keys(this.bilingPlan.products).map((key) => ({
key,
Expand All @@ -70,7 +70,7 @@ export default {
},
},
watch: {
"plans.list"() {
"plans"() {
this.changeBilling(this.instance.billing_plan);
},
accountId() {
Expand Down
8 changes: 4 additions & 4 deletions admin-ui/src/components/modules/ovh/instanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<v-col cols="6">
<v-autocomplete
:filter="defaultFilterObject"
label="ype"
label="Type"
:items="ovhTypes"
:rules="rules.req"
v-model="ovhType"
Expand Down Expand Up @@ -208,7 +208,7 @@ export default {
addProducts(instance) {
const { plan, billing_plan } = instance;
const { products } =
this.plans.list.find((el) => el.uuid === plan.uuid) || {};
this.plans.find((el) => el.uuid === plan.uuid) || {};
if (billing_plan.kind === "STATIC") {
instance.products = [];
Expand Down Expand Up @@ -262,7 +262,7 @@ export default {
const data = JSON.parse(JSON.stringify(this.instance));
if (path.includes("billing_plan")) {
const plan = this.plans.list.find(({ uuid }) => val === uuid);
const plan = this.plans.find(({ uuid }) => val === uuid);
const title = plan?.title.split(" ");
title.pop();
Expand Down Expand Up @@ -401,7 +401,7 @@ export default {
},
computed: {
filtredPlans() {
return this.plans?.list?.filter((p) => p.type.includes(this.ovhType));
return this.plans?.filter((p) => p.type.includes(this.ovhType));
},
tariffs() {
const tariffs = this.flavors[this.instance?.billing_plan?.uuid];
Expand Down
10 changes: 7 additions & 3 deletions admin-ui/src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,15 @@ export function getFullDate(period) {
result.day = Math.floor(period / dayEqualent);
period -= result.day * dayEqualent;

if (result.day === 90) {
result.day = 0;
result.quarter = 1;
return result;
}

result.year = Math.floor(result.day / 360);
result.day -= result.year * 365;

result.quarter = Math.floor(result.day / 90);
result.day -= result.quarter * 90;

result.month = Math.floor(result.day / 30);
result.day -= result.month * 30;

Expand Down Expand Up @@ -475,6 +478,7 @@ export function getBillingPeriod(period) {
"1 months": "Monthly",
"1 days": "Daily",
"1 years": "Yearly",
"1 quarters": "Quarter",
"1 hourss": "Hourly",
};
return beautifulAnnotations[period] || period;
Expand Down
47 changes: 26 additions & 21 deletions admin-ui/src/views/InstanceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
item-text="title"
v-model="serviceProviderId"
:items="servicesProviders"
:rules="rules.req"
:loading="isLoading"
readonly
disabled
/>
</v-col>
<v-col v-if="type === 'custom'" cols="4" md="3" lg="2">
Expand Down Expand Up @@ -116,11 +117,6 @@ export default {
meta: {},
plans: {
list: [],
products: [],
},
formValid: false,
rules: {
req: [(v) => !!v || "required field"],
Expand Down Expand Up @@ -277,14 +273,14 @@ export default {
serviceInstanceGroups() {
if (
!this.service ||
!this.service.instancesGroups ||
!this.service?.instancesGroups ||
!this.type ||
!this.serviceProviderId
) {
return [];
}
return this.service.instancesGroups.filter(
return this.service?.instancesGroups.filter(
(ig) => ig.type === this.type && ig.sp === this.serviceProviderId
);
},
Expand All @@ -293,16 +289,28 @@ export default {
return igs;
},
allPlans() {
return this.$store.getters["plans/all"] || [];
},
plans() {
return this.allPlans
.map((plan) => ({
...plan,
sp: this.servicesProviders.find((sp) =>
sp.meta.plans?.includes(plan.uuid)
)?.uuid,
}))
.filter((plan) => !!plan.sp);
},
planRules() {
return this.rules.req;
},
isInstanceControlsShowed() {
return (
this.type &&
this.serviceProviderId &&
(!(this.isEdit || this.$route.params.instanceId) ||
((this.isEdit || this.$route.params.instanceId) &&
this.plans.list.length)) &&
this.isEdit ||
this.$route.params.instanceId) &&
!this.isLoading
);
},
Expand Down Expand Up @@ -331,6 +339,7 @@ export default {
this.$store.dispatch("namespaces/fetch"),
this.$store.dispatch("services/fetch"),
this.$store.dispatch("servicesProviders/fetch", { anonymously: false }),
this.$store.dispatch("plans/fetch"),
]);
const instanceId = this.$route.params.instanceId;
if (instanceId) {
Expand Down Expand Up @@ -372,18 +381,14 @@ export default {
watch: {
serviceProviderId(sp_uuid) {
if (!sp_uuid) return;
this.plans.list = [];
api.plans.list({ sp_uuid, anonymously: false }).then((res) => {
res.pool.forEach((plan) => {
const end = plan.uuid.length > 8 ? "..." : "";
const title = `${plan.title} (${plan.uuid.slice(0, 8)}${end})`;
this.plans.list.push({ ...plan, title });
});
});
this.instanceGroupTitle = this.service.instancesGroups.find(
this.instanceGroupTitle = this.service?.instancesGroups.find(
(ig) => ig.sp === sp_uuid
)?.title;
},
"instance.billing_plan"(plan) {
this.serviceProviderId =
plan.sp || this.plans.find((p) => p.uuid === plan)?.sp;
},
instanceGroupTitle(newVal) {
this.instanceGroup = this.serviceInstanceGroups.find(
(ig) => ig.title === newVal
Expand All @@ -402,7 +407,7 @@ export default {
}
this.isEdit = false;
},
["plans.list"](newVal) {
["plans"](newVal) {
if (newVal && this.instance?.billingPlan?.uuid) {
this.instance.billing_plan = this.instance?.billingPlan?.uuid;
delete this.instance.billingPlan;
Expand Down
13 changes: 0 additions & 13 deletions admin-ui/src/views/Instances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,12 @@
v-model="newInstance.customTitle"
:rules="rules.req"
/>
<v-autocomplete
dense
:filter="defaultFilterObject"
label="service provider"
style="width: 300px"
item-text="title"
item-value="uuid"
:items="typedServiceProviders"
v-model="newInstance.serviceProviderId"
:rules="rules.req"
/>

<v-btn
:to="{
name: 'Instance create',
params: {
serviceId,
serviceProviderId: newInstance.serviceProviderId,
accountId: newInstance.account,
type:
newInstance.type === 'custom'
Expand Down Expand Up @@ -142,7 +130,6 @@ export default {
service: [],
type: "",
customTitle: "",
serviceProviderId: "",
account: "",
},
rules: {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/Pallinder/go-randomdata v1.2.0
github.com/arangodb/go-driver v1.6.1
github.com/arangodb/go-driver v1.6.2
github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2Aawl
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg=
github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y=
github.com/arangodb/go-driver v1.6.1 h1:bnhrpbA4U1NU13JOWs5sWWYMtQwdjKT0+jkl8dSndyY=
github.com/arangodb/go-driver v1.6.1/go.mod h1:ywucwwi34GBxxXFWw/ym+7/66//L4K9abxk/sFJro2k=
github.com/arangodb/go-driver v1.6.2 h1:3o4inejwR7VMmsKvQJ6hepx4au9sUT6C/RDrXykuD1g=
github.com/arangodb/go-driver v1.6.2/go.mod h1:2BCE6y3DNSLqIXnDvf4CR6WdzZZloYudEy+sasimLiQ=
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g=
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down

0 comments on commit 92940ec

Please sign in to comment.