Skip to content

Commit

Permalink
- Added authorization button in telegram
Browse files Browse the repository at this point in the history
- Fixed authorization through the admin panel
- Fixed display of markers on the map by type
  • Loading branch information
639852 committed Aug 1, 2023
1 parent 4871d68 commit 87d15a9
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"markdown-it": "^13.0.1",
"markdown-it-emoji": "^2.0.2",
"md5": "^2.2.1",
"nocloud-ui": "^1.0.6",
"nocloud-ui": "^1.0.7",
"nocloudjsrest": "^1.5.9",
"qrcode.vue": "^1.7.0",
"qrcodejs": "^1.0.0",
Expand Down
12 changes: 9 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ export default {
components: { updateNotification },
created() {
window.addEventListener('message', ({ data, origin }) => {
if (!origin.includes('https://api.')) return;
console.log(data, origin);
if (!origin.includes('8081')) return;
this.$store.commit("nocloud/auth/setToken", data.token);
sessionStorage.removeItem("user");
if (data.uuid) this.$router.replace({ name: 'openCloud_new', params: { uuid: data.uuid } });
else location.reload();
if (data.uuid) {
this.$router.replace({ name: 'openCloud_new', params: { uuid: data.uuid } });
setTimeout(() => { location.reload() }, 100);
} else if (this.$route.name.includes('login')) {
this.$router.replace({ name: 'root' });
location.reload();
}
});
this.$store.dispatch("nocloud/auth/load");
Expand Down
44 changes: 36 additions & 8 deletions src/components/appMain/appHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
:key="button.icon"
>
<div
v-if="button.onClickFuncion && button.type == undefined"
v-if="button.onClickFuncion && button.type == undefined && button.icon != 'telegram'"
class="icon__wrapper"
:class="[
{ active__btn: getState(button.name) },
Expand All @@ -59,6 +59,17 @@
<div class="header__btn--no-image">{{ button.name }}</div>
</div>

<div
v-else-if="button.icon === 'telegram'"
class="icon__wrapper"
:class="[button.additionalClass]"
@click="button.onClickFuncion"
>
<svg fill="currentColor" width="30px" height="30px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path d="M 26.070313 3.996094 C 25.734375 4.011719 25.417969 4.109375 25.136719 4.21875 L 25.132813 4.21875 C 24.847656 4.332031 23.492188 4.902344 21.433594 5.765625 C 19.375 6.632813 16.703125 7.757813 14.050781 8.875 C 8.753906 11.105469 3.546875 13.300781 3.546875 13.300781 L 3.609375 13.277344 C 3.609375 13.277344 3.25 13.394531 2.875 13.652344 C 2.683594 13.777344 2.472656 13.949219 2.289063 14.21875 C 2.105469 14.488281 1.957031 14.902344 2.011719 15.328125 C 2.101563 16.050781 2.570313 16.484375 2.90625 16.722656 C 3.246094 16.964844 3.570313 17.078125 3.570313 17.078125 L 3.578125 17.078125 L 8.460938 18.722656 C 8.679688 19.425781 9.949219 23.597656 10.253906 24.558594 C 10.433594 25.132813 10.609375 25.492188 10.828125 25.765625 C 10.933594 25.90625 11.058594 26.023438 11.207031 26.117188 C 11.265625 26.152344 11.328125 26.179688 11.390625 26.203125 C 11.410156 26.214844 11.429688 26.21875 11.453125 26.222656 L 11.402344 26.210938 C 11.417969 26.214844 11.429688 26.226563 11.441406 26.230469 C 11.480469 26.242188 11.507813 26.246094 11.558594 26.253906 C 12.332031 26.488281 12.953125 26.007813 12.953125 26.007813 L 12.988281 25.980469 L 15.871094 23.355469 L 20.703125 27.0625 L 20.8125 27.109375 C 21.820313 27.550781 22.839844 27.304688 23.378906 26.871094 C 23.921875 26.433594 24.132813 25.875 24.132813 25.875 L 24.167969 25.785156 L 27.902344 6.65625 C 28.007813 6.183594 28.035156 5.742188 27.917969 5.3125 C 27.800781 4.882813 27.5 4.480469 27.136719 4.265625 C 26.769531 4.046875 26.40625 3.980469 26.070313 3.996094 Z M 25.96875 6.046875 C 25.964844 6.109375 25.976563 6.101563 25.949219 6.222656 L 25.949219 6.234375 L 22.25 25.164063 C 22.234375 25.191406 22.207031 25.25 22.132813 25.308594 C 22.054688 25.371094 21.992188 25.410156 21.667969 25.28125 L 15.757813 20.75 L 12.1875 24.003906 L 12.9375 19.214844 C 12.9375 19.214844 22.195313 10.585938 22.59375 10.214844 C 22.992188 9.84375 22.859375 9.765625 22.859375 9.765625 C 22.886719 9.3125 22.257813 9.632813 22.257813 9.632813 L 10.082031 17.175781 L 10.078125 17.15625 L 4.242188 15.191406 L 4.242188 15.1875 C 4.238281 15.1875 4.230469 15.183594 4.226563 15.183594 C 4.230469 15.183594 4.257813 15.171875 4.257813 15.171875 L 4.289063 15.15625 L 4.320313 15.144531 C 4.320313 15.144531 9.53125 12.949219 14.828125 10.71875 C 17.480469 9.601563 20.152344 8.476563 22.207031 7.609375 C 24.261719 6.746094 25.78125 6.113281 25.867188 6.078125 C 25.949219 6.046875 25.910156 6.046875 25.96875 6.046875 Z" />
</svg>
</div>

<div
v-else-if="button.icon == 'search'"
class="icon__wrapper"
Expand Down Expand Up @@ -129,7 +140,7 @@
@change="onChange"
/>
<a-range-picker
v-else-if="active === 'invoice'"
v-else-if="active === 'billing'"
show-time
:value="checkedList"
@ok="updateFilter"
Expand Down Expand Up @@ -245,6 +256,15 @@ export default {
icon: "filter",
popover: true,
},
{
name: "support_telegram",
icon: "telegram",
onClickFuncion: () => {
const { token } = this.$store.state.nocloud.auth;
window.open(`https://t.me/nocloud_telegram_bot?start=${token}`, '_blank')
}
},
{
name: "support_plus",
icon: "plus",
Expand Down Expand Up @@ -282,8 +302,8 @@ export default {
},
],
},
invoice: {
title: "Invoice",
billing: {
title: "billing",
needBalance: true,
buttons: [
{
Expand Down Expand Up @@ -405,7 +425,7 @@ export default {
return;
}
if (this.getActiveTab.title.includes('invoice')) {
this.$router.push('/invoice');
this.$router.push('/billing');
return;
}
Expand Down Expand Up @@ -449,7 +469,7 @@ export default {
this.$store.commit("support/updateFilter", info.map((el) => filtered[el]));
}
if (this.active == "invoice" && this.activeInvoiceTab == "Detail") {
if (this.active == "billing" && this.activeInvoiceTab == "Detail") {
const dates = JSON.parse(
localStorage.getItem("detailFilters") ?? "[]"
).map((el) => moment(el));
Expand All @@ -462,7 +482,7 @@ export default {
}
this.$store.commit("nocloud/transactions/updateFilter", info);
} else if (this.active == "invoice") {
} else if (this.active == "billing") {
const filtered = {};
if (!info) {
Expand Down Expand Up @@ -508,6 +528,11 @@ export default {
this.isButtonsVisible = false;
}
const lang = navigator.language.replace(/-[a-z]{2}/i, '');
if (this.langs.includes(lang) && !localStorage.getItem('lang')) {
this.$i18n.locale = lang;
}
this.currencyCode = this.defaultCurrency;
},
computed: {
Expand Down Expand Up @@ -542,7 +567,7 @@ export default {
let filterElem;
if (this.active == "support") {
filterElem = this.getAllTickets;
} else if (this.active == "invoice") {
} else if (this.active == "billing") {
const isInvoice = this.activeInvoiceTab === 'Invoice';
filterElem = (isInvoice) ? this.getAllInvoices : this.transactions;
Expand Down Expand Up @@ -627,6 +652,9 @@ export default {
},
currencyCode(value) {
this.$store.commit('nocloud/auth/setUnloginedCurrency', value);
},
'$i18n.locale'(value) {
localStorage.setItem('lang', value);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/appMain/invoice/openInvoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default {
},
methods: {
goBack() {
this.$router.push("/invoice");
this.$router.push("/billing");
},
showfull() {
this.showFullTable = true;
Expand Down Expand Up @@ -204,12 +204,12 @@ export default {

this.$store.dispatch('invoices/autoFetch')
.catch((err) => {
this.$router.push("/invoice");
this.$router.push("/billing");
console.error(err);
});
},
destroyed() {
if (!this.$route.name.includes('invoice')) {
if (!this.$route.name.includes('billing')) {
sessionStorage.removeItem('invoice');
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/appMain/invoice/openTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
}),
methods: {
goBack() {
this.$router.push("/invoice");
this.$router.push("/billing");
},
date(timestamp) {
if (timestamp < 1) return '-';
Expand Down Expand Up @@ -227,7 +227,7 @@ export default {
});
},
destroyed() {
if (!this.$route.name.includes('invoice')) {
if (!this.$route.name.includes('billing')) {
sessionStorage.removeItem('invoice');
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/appMain/modules/ione/createInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
</div>
<a-row>
<a-col :xs="24" :sm="10">
<a-form-item style="margin-top: 15px" :label="$t('name') | capitalize">
<a-form-item style="margin-top: 15px" :label="$t('server name') | capitalize">
<a-input
:style="{ boxShadow: (vmName.length < 2) ? '0 0 2px 2px var(--err)' : null }"
:value="vmName"
Expand Down
3 changes: 1 addition & 2 deletions src/components/appMain/modules/ovh cloud/createInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ export default {
return { plans, cpu, ram, disk };
},
region() {
const location = this.locationId.split(' ').at(-1);
const { extra, title } = this.itemSP?.locations.find(
({ id }) => id === location
({ id }) => this.locationId.includes(id)
) || {};

if (!extra) return null;
Expand Down
19 changes: 16 additions & 3 deletions src/components/appMain/modules/ovh cloud/openInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ export default {
const opts = {
message: `Error: ${err?.response?.data?.message ?? "Unknown"}.`,
};
if (err.response?.status >= 500) {
opts.message = this.$t('Error: Failed to load data');
}
this.openNotificationWithIcon("error", opts);
})
.finally(() => {
Expand Down Expand Up @@ -856,10 +860,15 @@ export default {
this.openNotificationWithIcon("success", { message: `Done!` });
})
.catch((err) => {
console.error(err);
this.openNotificationWithIcon("error", {
const opts = {
message: `Error: ${err.response?.data?.message ?? "Unknown"}.`
});
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
console.error(err);
})
.finally(() => this.actionLoading = false);
},
Expand Down Expand Up @@ -894,6 +903,10 @@ export default {
const opts = {
message: `Error: ${err?.response?.data?.message ?? "Unknown"}.`,
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
});
},
Expand Down
19 changes: 16 additions & 3 deletions src/components/appMain/modules/ovh dedicated/openInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ export default {
const opts = {
message: `Error: ${err?.response?.data?.message ?? "Unknown"}.`,
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
this.actionLoading = false;
});
Expand Down Expand Up @@ -665,10 +669,15 @@ export default {
this.openNotificationWithIcon("success", { message: `Done!` });
})
.catch((err) => {
console.error(err);
this.openNotificationWithIcon("error", {
const opts = {
message: `Error: ${err.response?.data?.message ?? "Unknown"}.`
});
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
console.error(err);
})
.finally(() => this.actionLoading = false);
},
Expand Down Expand Up @@ -700,6 +709,10 @@ export default {
const opts = {
message: `Error: ${err?.response?.data?.message ?? "Unknown"}.`,
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
});
},
Expand Down
17 changes: 13 additions & 4 deletions src/components/appMain/modules/ovh vps/openInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,15 @@ export default {
this.openNotificationWithIcon("success", { message: `Done!` });
})
.catch((err) => {
console.error(err);
this.openNotificationWithIcon("error", {
const opts = {
message: `Error: ${err.response?.data?.message ?? "Unknown"}.`
});
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
console.error(err);
})
.finally(() => this.actionLoading = false);
},
Expand Down Expand Up @@ -877,6 +882,10 @@ export default {
const opts = {
message: `Error: ${err?.response?.data?.message ?? "Unknown"}.`,
};
if (err.response?.status >= 500) {
opts.message = `Error: ${this.$t('Failed to load data')}`;
}
this.openNotificationWithIcon("error", opts);
});
},
Expand Down Expand Up @@ -915,7 +924,7 @@ export default {
.catch((err) => {
const message = err.response?.data?.message ?? err.message ?? err;
if (message === 'HTTP Error 500: "Internal server error"') return;
if (err.response?.status >= 500) return;
this.openNotificationWithIcon('error', { message: this.$t(message) });
console.error(err);
});
Expand Down
25 changes: 13 additions & 12 deletions src/components/appMain/newPaaS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,16 @@ export default {
locations() {
const locations = [];
this.getSP.forEach((sp) => {
sp.locations.forEach((location) => {
const showcase = this.showcases.find(({ uuid }) => uuid === this.showcase);
const findedLocation = showcase?.locations?.find(
({ id }) => id.includes(location.id)
this.showcases.forEach((showcase) => {
showcase.locations?.forEach((location) => {
const sp = this.getSP.find(({ locations, type }) =>
locations.find(({ id, type: locationType }) =>
location.id.includes(id) && locationType.includes(type)
)
);
const id = `${sp.title} ${location.id}`;
if (this.showcase === '' || findedLocation) {
locations.push({ ...location, sp: sp.uuid, id, showcase: showcase.uuid });
if (this.showcase === '' || this.showcase === showcase.uuid) {
locations.push({ ...location, sp: sp?.uuid, showcase: showcase.uuid });
}
});
});
Expand All @@ -710,6 +710,7 @@ export default {
const showcase = this.showcases.find(({ uuid }) => uuid === showcaseUuid);
const { locale } = this.$i18n;
if (!showcase?.promo) return;
return showcase?.promo[locale]?.service.description;
},
itemSP() {
Expand Down Expand Up @@ -741,9 +742,9 @@ export default {
//--------------Plans-----------------
filteredPlans() {
const locationItem = this.locations.find((el) => el.id === this.locationId);
const { plans } = this.showcases.find(({ uuid, locations }) => {
const { plans } = this.showcases.find(({ uuid }) => {
if (this.showcase === '') {
return locations?.find(({ id }) => id === this.locationId);
return uuid === locationItem.showcase;
}
return uuid === this.showcase;
});
Expand Down Expand Up @@ -1285,7 +1286,7 @@ export default {
this.$message.success(this.$t("Order created successfully"));
this.deployService(result.uuid);
if (this.modal.goToInvoice) {
this.$router.push(`/invoice/${res.invoiceid}`);
this.$router.push(`/billing/${res.invoiceid}`);
}
} else {
throw "error";
Expand All @@ -1309,7 +1310,7 @@ export default {
this.$message.success(this.$t("Order update successfully"));
this.deployService(result.uuid);
if (this.modal.goToInvoice) {
this.$router.push(`/invoice/${result.invoiceid}`);
this.$router.push(`/billing/${result.invoiceid}`);
}
} else {
throw "error";
Expand Down
Loading

0 comments on commit 87d15a9

Please sign in to comment.