Skip to content

Commit

Permalink
Merge pull request #1165 from slntopp/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
dimquaa authored Oct 10, 2023
2 parents 2c685ca + f4c3b00 commit ba49f92
Show file tree
Hide file tree
Showing 65 changed files with 2,055 additions and 1,095 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: WillAbides/setup-go-faster@v1.11.0
uses: WillAbides/setup-go-faster@v1.12.0
with:
go-version: 1.19
- name: Static Check
Expand Down
66 changes: 56 additions & 10 deletions admin-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@

<v-app-bar v-if="isLoggedIn" app color="background" elevation="0">
<v-row style="width: 100%" justify="center" align="center">
<v-col cols="5">
<v-col cols="8">
<app-search />
</v-col>
<v-col class="d-flex justify-start">
Expand All @@ -276,7 +276,6 @@
</v-btn>
</v-col>
<v-col class="d-flex justify-end align-center">
<balance title="Balance: " loged-in-user />
<languages v-if="false" />
<v-menu offset-y transition="slide-y-transition">
<template v-slot:activator="{ on, attrs }">
Expand All @@ -301,6 +300,9 @@
>
</v-list-item-content>
</v-list-item>
<v-list-item>
<balance title="Balance: " loged-in-user />
</v-list-item>
<v-divider></v-divider>
<v-list-item @click="logoutHandler">
<v-list-item-title>Logout</v-list-item-title>
Expand All @@ -312,6 +314,23 @@
<v-spacer></v-spacer>
</v-app-bar>

<instances-table-modal
v-if="overlay.uuid"
:uuid="overlay.uuid"
:visible="overlay.isVisible"
@close="() => { overlay.isVisible = false }"
>
<template #activator>
<v-btn
color="success"
style="position: absolute; top: 90px; right: 25px; z-index: 100"
@click="overlay.isVisible = true"
>
{{ overlay.buttonTitle }}
</v-btn>
</template>
</instances-table-modal>

<v-main>
<router-view />
</v-main>
Expand All @@ -321,21 +340,34 @@
</template>

<script>
import api from "@/api.js";
import config from "@/config.js";
import balance from "@/components/balance.vue";
import languages from "@/components/languages.vue";
import appSearch from "@/components/search/search.vue";
import AppSnackbar from "@/components/snackbar.vue";
import instancesTableModal from "@/components/instances_table_modal.vue";
export default {
name: "App",
components: { AppSnackbar, balance, appSearch, languages },
components: {
AppSnackbar,
balance,
appSearch,
languages,
instancesTableModal
},
data: () => ({
isMenuMinimize: true,
isMouseOnMenu: false,
easterEgg: false,
config,
navTitles: config.navTitles ?? {},
overlay: {
isVisible: false,
buttonTitle: '',
uuid: ''
}
}),
methods: {
logoutHandler() {
Expand Down Expand Up @@ -420,14 +452,26 @@ export default {
},
},
created() {
// window.addEventListener("message", ({ data, origin }) => {
// const url = `https://app.${location.host.split(".").slice(1).join(".")}`;
window.addEventListener("message", ({ data, origin }) => {
if (origin.includes("localhost") || !data) return;
if (data === "ready") return;
if (data.type === "get-user") {
const setting = "plugin-chats-overlay";
api.settings.get([setting]).then((res) => {
const { title } = JSON.parse(res[setting]);
// if (origin !== url) return;
// if (data === 'ready') return;
// this.$store.commit("auth/setToken", data);
// location.assign("/admin");
// });
this.overlay.buttonTitle = title;
this.overlay.uuid = data.value.uuid;
});
return;
}
if (data.type === "open-user") {
window.open(`/admin/accounts/${data.value.uuid}`, "_blank");
return;
}
console.log(data, origin);
});
this.$store.dispatch("auth/load");
Expand Down Expand Up @@ -464,6 +508,8 @@ export default {
});
this.$router.afterEach((to) => {
this.overlay.uuid = "";
this.overlay.buttonTitle = "";
this.setTitle(to.name);
});
Expand Down
35 changes: 19 additions & 16 deletions admin-ui/src/components/ServicesProvider/info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
>
Edit
</v-btn>
<v-btn class="mx-2" @click="downloadFile">
Download {{ isJson ? "JSON" : "YAML" }}
</v-btn>
<download-template-button
:name="downloadedFileName"
:template="template"
class="mx-2"
:type="isJson ? 'JSON' : 'YAML'"
/>
<v-switch
class="mr-2"
style="margin-top: 5px; padding-top: 0"
Expand Down Expand Up @@ -93,7 +96,7 @@
color="background-light"
>
<nocloud-table
table-name="sp-binded-plans"
table-name="sp-binded-plans"
:items="plans"
:headers="headers"
:loading="isPlanLoading"
Expand Down Expand Up @@ -155,11 +158,16 @@ import extentionsMap from "@/components/extentions/map.js";
import nocloudTable from "@/components/table.vue";
import ConfirmDialog from "@/components/confirmDialog.vue";
import { format } from "date-fns";
import { downloadJSONFile, downloadYAMLFile } from "@/functions.js";
import DownloadTemplateButton from "@/components/ui/downloadTemplateButton.vue";
export default {
name: "services-provider-info",
components: { JsonEditor, nocloudTable, ConfirmDialog },
components: {
DownloadTemplateButton,
JsonEditor,
nocloudTable,
ConfirmDialog,
},
props: { template: { type: Object, required: true } },
mixins: [snackbar],
data: () => ({
Expand Down Expand Up @@ -321,16 +329,6 @@ export default {
this.isDeleteLoading = false;
});
},
downloadFile() {
const name = this.template.title
? this.template.title.replaceAll(" ", "_")
: "unknown_sp";
if (this.isJson) {
downloadJSONFile(this.template, name);
} else {
downloadYAMLFile(this.template, name);
}
},
},
mounted() {
this.provider = this.template;
Expand Down Expand Up @@ -385,6 +383,11 @@ export default {
import("@/components/modules/custom/serviceProviderInfo.vue");
}
},
downloadedFileName() {
return this.template.title
? this.template.title.replaceAll(" ", "_")
: "unknown_sp";
},
},
};
</script>
Expand Down
46 changes: 37 additions & 9 deletions admin-ui/src/components/account/info.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
<template>
<v-card elevation="0" color="background-light" class="pa-4">
<div style="position: absolute; top: 0; right: 75px">
<div>
<v-chip color="primary" outlined
>Balance: {{ account.balance?.toFixed(2) }}
{{ account.currency }}</v-chip
>
</div>
</div>

<v-row>
<v-col cols="6">
<v-text-field
v-model="uuid"
readonly
label="UUID"
style="width: 330px"
/>
<v-col cols="3">
<v-text-field v-model="uuid" readonly label="UUID" />
</v-col>
<v-col cols="6">
<v-col cols="3">
<v-text-field v-model="title" label="name" style="width: 330px" />
</v-col>
<v-col cols="3">
<v-select
:readonly="isCurrencyReadonly"
:items="currencies"
v-model="currency"
label="currency"
style="width: 330px"
/>
</v-col>
</v-row>
<v-card-title class="px-0">Instances:</v-card-title>

Expand Down Expand Up @@ -105,6 +118,7 @@ export default {
navTitles: config.navTitles ?? {},
uuid: "",
title: "",
currency: "",
keys: [],
selected: [],
isVisible: false,
Expand All @@ -131,7 +145,14 @@ export default {
this.selected = [];
},
editAccount() {
const newAccount = { ...this.account, title: this.title };
const newAccount = {
...this.account,
title: this.title,
currency: this.currency,
};
if (!newAccount.data) {
newAccount.data = {};
}
newAccount.data.ssh_keys = this.keys;
this.isEditLoading = true;
Expand All @@ -156,6 +177,7 @@ export default {
},
mounted() {
this.title = this.account.title;
this.currency = this.account.currency;
this.uuid = this.account.uuid;
this.keys = this.account.data?.ssh_keys || [];
if (this.namespaces.length < 2) {
Expand All @@ -175,6 +197,9 @@ export default {
services() {
return this.$store.getters["services/all"];
},
currencies() {
return this.$store.getters["currencies/all"].filter((c) => c !== "NCU");
},
servicesProviders() {
return this.$store.getters["servicesProviders/all"];
},
Expand All @@ -189,6 +214,9 @@ export default {
(i) => i.access.namespace === accountNamespace.uuid
);
},
isCurrencyReadonly() {
return this.account.currency && this.account.currency !== "NCU";
},
},
};
</script>
Expand Down
7 changes: 6 additions & 1 deletion admin-ui/src/components/account/reports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
<reports_table
table-name="reports"
hide-account
:duration="duration"
@input:duration="duration = $event"
:filters="filters"
hide-service
show-dates
/>
</template>

<script setup>
import { toRefs, computed } from "vue";
import { toRefs, computed, ref } from "vue";
import Reports_table from "@/components/reports_table.vue";
const props = defineProps(["account"]);
const { account } = toRefs(props);
const duration = ref({ to: null, from: null });
const filters = computed(() => {
return {
account: [account.value.uuid],
Expand Down
Loading

0 comments on commit ba49f92

Please sign in to comment.