From 2d3f865e406b2be6920c6da22eb266ebe8b2a58d Mon Sep 17 00:00:00 2001 From: Sergei Birukov Date: Sun, 24 Mar 2024 14:35:37 +0300 Subject: [PATCH] Update layout. Add i18n into templates Add getUiTrafficStats --- webui/src/App.vue | 31 ++++- webui/src/components/Client.vue | 6 +- webui/src/components/ClientAddress.vue | 9 +- webui/src/components/ClientAvatar.vue | 40 +++---- webui/src/components/ClientControls.vue | 34 ++++-- webui/src/components/ClientInfo.vue | 97 ++++++++------- webui/src/components/ClientName.vue | 124 ++++++++------------ webui/src/components/ClientNewButton.vue | 2 +- webui/src/components/ClientTrafficStat.vue | 39 ++++++ webui/src/components/Footer.vue | 13 +- webui/src/components/Header.vue | 17 +-- webui/src/components/ModalCreateClient.vue | 28 ++++- webui/src/components/ModalDeleteClient.vue | 31 ++++- webui/src/components/UpdateNotification.vue | 25 ++-- webui/src/components/icons/IconDelete.vue | 7 +- webui/src/components/icons/IconEdit.vue | 2 +- webui/src/components/icons/IconRX.vue | 16 +++ webui/src/components/icons/IconTX.vue | 16 +++ webui/src/services/api.js | 2 +- webui/src/store/store.js | 2 + 20 files changed, 333 insertions(+), 208 deletions(-) create mode 100644 webui/src/components/ClientTrafficStat.vue create mode 100644 webui/src/components/icons/IconRX.vue create mode 100644 webui/src/components/icons/IconTX.vue diff --git a/webui/src/App.vue b/webui/src/App.vue index 3402b486..3c0f047b 100644 --- a/webui/src/App.vue +++ b/webui/src/App.vue @@ -8,7 +8,7 @@
-

Clients

+

{{ $t('clients') }}

@@ -23,7 +23,7 @@

- There are no clients yet.

+ {{ $t('noClients') }}

@@ -84,10 +84,19 @@ import { storeToRefs } from 'pinia'; const i18n = useI18n(); const store = useStore(); -const { authenticated, requiresPassword } = storeToRefs(store); -const { clients, clientCreateShowModal, clientToDelete, qrcode, prefersDarkScheme, uiTheme, uiChartType } = - storeToRefs(store); +const { + authenticated, + requiresPassword, + clients, + clientCreateShowModal, + clientToDelete, + qrcode, + prefersDarkScheme, + uiTheme, + uiChartType, + uiTrafficStats, +} = storeToRefs(store); const currentRelease = ref(null); const latestRelease = ref(null); @@ -122,6 +131,7 @@ onBeforeMount(() => { getChartType(); getRelease(); getLang(); + getUiTrafficStats(); }); onBeforeUnmount(() => { @@ -178,4 +188,15 @@ async function getChartType() { uiChartType.value = 0; }); } + +async function getUiTrafficStats() { + api + .getUiTrafficStats() + .then((res) => { + uiTrafficStats.value = res; + }) + .catch(() => { + uiTrafficStats.value = false; + }); +} diff --git a/webui/src/components/Client.vue b/webui/src/components/Client.vue index 207527a6..8526222d 100644 --- a/webui/src/components/Client.vue +++ b/webui/src/components/Client.vue @@ -6,8 +6,8 @@ -
-
+
+
@@ -26,9 +26,7 @@ import ClientInfo from '@/components/ClientInfo.vue'; import ClientAvatar from '@/components/ClientAvatar.vue'; import ClientControls from '@/components/ClientControls.vue'; - defineProps({ client: {}, }); - diff --git a/webui/src/components/ClientAddress.vue b/webui/src/components/ClientAddress.vue index 61e19c35..6827eb74 100644 --- a/webui/src/components/ClientAddress.vue +++ b/webui/src/components/ClientAddress.vue @@ -1,24 +1,21 @@ diff --git a/webui/src/components/ClientTrafficStat.vue b/webui/src/components/ClientTrafficStat.vue new file mode 100644 index 00000000..315ce38e --- /dev/null +++ b/webui/src/components/ClientTrafficStat.vue @@ -0,0 +1,39 @@ + + + diff --git a/webui/src/components/Footer.vue b/webui/src/components/Footer.vue index c9670bd6..575e13f2 100644 --- a/webui/src/components/Footer.vue +++ b/webui/src/components/Footer.vue @@ -1,11 +1,12 @@ diff --git a/webui/src/components/Header.vue b/webui/src/components/Header.vue index 27d69cc9..d10ac1e2 100644 --- a/webui/src/components/Header.vue +++ b/webui/src/components/Header.vue @@ -1,5 +1,5 @@ - + + diff --git a/webui/src/components/icons/IconDelete.vue b/webui/src/components/icons/IconDelete.vue index e09dee76..985951bc 100644 --- a/webui/src/components/icons/IconDelete.vue +++ b/webui/src/components/icons/IconDelete.vue @@ -1,10 +1,5 @@ + + diff --git a/webui/src/components/icons/IconTX.vue b/webui/src/components/icons/IconTX.vue new file mode 100644 index 00000000..09e81c2c --- /dev/null +++ b/webui/src/components/icons/IconTX.vue @@ -0,0 +1,16 @@ + + + diff --git a/webui/src/services/api.js b/webui/src/services/api.js index 8fc4f5a2..d938e819 100644 --- a/webui/src/services/api.js +++ b/webui/src/services/api.js @@ -40,7 +40,7 @@ export default class API { return res.slice(0, 2); } - async getuiTrafficStats() { + async getUiTrafficStats() { return this.call({ method: 'get', path: '/ui-traffic-stats', diff --git a/webui/src/store/store.js b/webui/src/store/store.js index 5e57db87..2e69f2f6 100644 --- a/webui/src/store/store.js +++ b/webui/src/store/store.js @@ -24,6 +24,7 @@ export const useStore = defineStore('store', () => { const uiChartType = ref(0); const uiShowCharts = ref(localStorage.getItem('uiShowCharts') === '1'); + const uiTrafficStats = ref(false); function login(e) { e.preventDefault(); @@ -180,6 +181,7 @@ export const useStore = defineStore('store', () => { prefersDarkScheme, uiChartType, uiShowCharts, + uiTrafficStats, login, logout, createClient,