Skip to content

Commit

Permalink
Merge pull request #239 from Support-pl/dev
Browse files Browse the repository at this point in the history
fixed some bugs
  • Loading branch information
639852 authored Jul 29, 2023
2 parents d33c8a9 + f75d089 commit 909026e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
10 changes: 8 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export default {
created() {
window.addEventListener('message', ({ data, origin }) => {
if (!origin.includes('https://api.')) return;
this.$store.commit("nocloud/auth/setToken", data);
this.$store.commit("nocloud/auth/setToken", data.token);
sessionStorage.removeItem("user");
location.reload();
if (data.uuid) this.$router.replace({ name: 'openCloud_new', params: { uuid: data.uuid } });
else location.reload();
});
this.$store.dispatch("nocloud/auth/load");
Expand Down Expand Up @@ -56,6 +58,10 @@ export default {
if (mustBeLoggined && !isLogged) {
this.$router.replace("login");
}
if (this.$route.query.lang !== this.$i18n.locale) {
this.$i18n.locale = this.$route.query.lang;
}
});
document.title = "Cloud";
Expand Down
4 changes: 1 addition & 3 deletions src/components/appMain/appHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,7 @@ export default {
.catch(err => {
const message = err.response?.data?.message ?? err.message;
this.openNotificationWithIcon('error', {
message: this.$t(message)
});
this.$notification.error({ message: this.$t(message) });
console.error(err);
});
},
Expand Down
48 changes: 24 additions & 24 deletions src/components/appMain/newPaaS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,8 @@ export default {
);
const id = `${sp.title} ${location.id}`;
if (this.showcase === '') {
locations.push({ ...location, sp: sp.uuid, id });
} else if (findedLocation) {
locations.push({ ...location, sp: sp.uuid, id });
if (this.showcase === '' || findedLocation) {
locations.push({ ...location, sp: sp.uuid, id, showcase: showcase.uuid });
}
});
});
Expand All @@ -708,9 +706,11 @@ export default {
return titles;
},
locationDescription() {
const locationItem = this.locations.find((el) => el.id === this.locationId);
const { showcase: showcaseUuid } = this.locations.find((el) => el.id === this.locationId) ?? {};
const showcase = this.showcases.find(({ uuid }) => uuid === showcaseUuid);
const { locale } = this.$i18n;
return locationItem?.extra.description;
return showcase?.promo[locale]?.service.description;
},
itemSP() {
const { sp } = this.locations.find((el) => el.id === this.locationId) || {};
Expand Down Expand Up @@ -741,9 +741,16 @@ export default {
//--------------Plans-----------------
filteredPlans() {
const locationItem = this.locations.find((el) => el.id === this.locationId);
const { plans } = this.showcases.find(({ uuid, locations }) => {
if (this.showcase === '') {
return locations?.find(({ id }) => id === this.locationId);
}
return uuid === this.showcase;
});
return this.getPlans.filter(({ type }) =>
(locationItem.type) ? locationItem.type === type : true
return this.getPlans.filter(({ uuid, type }) =>
((locationItem.type) ? locationItem.type === type : true) &&
plans.includes(uuid)
);
},
//UNKNOWN and STATIC
Expand Down Expand Up @@ -887,19 +894,25 @@ export default {
this.showcase = this.$route.query.service ?? "";
this.$store.dispatch("nocloud/sp/fetchShowcases");
this.$store.dispatch("nocloud/sp/fetch", !this.isLoggedIn)
.then(() => {
.then(async () => {
const data = localStorage.getItem("data");
const { query } = this.$route;
if (data || ('data' in query)) {
try {
await new Promise((resolve) => setTimeout(resolve, 100));
this.dataLocalStorage = (data)
? JSON.parse(localStorage.getItem("data"))
: JSON.parse(query.data);
this.tarification = this.dataLocalStorage.tarification ?? '';
this.vmName = this.dataLocalStorage.titleVM ?? '';
this.locationId = this.dataLocalStorage.locationId ?? '';
this.locationId = this.locations.find(({ id }) => {
const locationId = this.dataLocalStorage.locationId.split('-');
locationId.shift();
return id.includes(locationId.join('-'));
})?.id ?? '';
this.activeKey = null;
if (this.dataLocalStorage.config) {
Expand Down Expand Up @@ -1499,15 +1512,8 @@ export default {
anonymously: !this.isLoggedIn
})
.then(({ pool }) => {
const { plans } = this.showcases.find(({ uuid, locations }) => {
if (this.showcase === '') {
return locations?.find(({ id }) => id === this.locationId);
}
return uuid === this.showcase;
}) ?? { plans: pool.map(({ uuid }) => uuid) };
const uuid = plans?.find((el) => this.filteredPlans.find((plan) => el === plan.uuid));
this.plan = uuid ?? pool[0]?.uuid ?? '';
this.plan = this.filteredPlans[0]?.uuid ?? pool[0]?.uuid ?? '';
if (this.dataLocalStorage.billing_plan) {
this.plan = this.dataLocalStorage.billing_plan.uuid;
Expand Down Expand Up @@ -1558,12 +1564,6 @@ export default {
}
});
}
// getAddons: function (newVal) {
// this.options.addons.os = +newVal.os[0].id;
// },
// activeKey: function(){
// this.activeKey.push('tarif')
// }
},
};
</script>
Expand Down

0 comments on commit 909026e

Please sign in to comment.