Skip to content

Commit fb58164

Browse files
authored
Merge pull request #3204 from benderl/user-management-improvements
User-Management improvements
2 parents cea69b8 + 672bdee commit fb58164

293 files changed

Lines changed: 399 additions & 304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
<div
3+
v-if="showIcon"
4+
id="mqtt-connection-indicator"
5+
>
6+
<q-badge
7+
rounded
8+
align="middle"
9+
:color="connected ? 'positive' : 'negative'"
10+
class="non-selectable"
11+
>
12+
<q-icon
13+
:name="connected ? 'link' : 'link_off'"
14+
size="sm"
15+
>
16+
<q-tooltip v-if="connected">Verbindung hergestellt</q-tooltip>
17+
<q-tooltip v-else>Verbindung getrennt</q-tooltip>
18+
</q-icon>
19+
</q-badge>
20+
</div>
21+
<q-dialog
22+
v-model="showModal"
23+
persistent
24+
>
25+
<q-card>
26+
<q-card-section class="row items-center">
27+
<q-avatar icon="link_off" color="negative" text-color="white" />
28+
<span class="text-h6 q-ml-sm">Verbindung getrennt!</span>
29+
</q-card-section>
30+
<q-card-section class="row">
31+
Die Verbindung zur openWB ist unterbrochen.<br />
32+
Es wird versucht, die Verbindung wieder herzustellen...
33+
</q-card-section>
34+
</q-card>
35+
</q-dialog>
36+
</template>
37+
38+
<script setup lang="ts">
39+
import { computed, watch, ref } from 'vue';
40+
import { useMqttStore } from 'src/stores/mqtt-store';
41+
42+
const mqttStore = useMqttStore();
43+
44+
const connected = computed(() => mqttStore.mqttClientConnected);
45+
46+
const showIcon = ref(!connected.value);
47+
const iconTimeout = ref<ReturnType<typeof setTimeout> | null>(null);
48+
const showModal = computed(() => !connected.value);
49+
50+
watch(connected, (newValue) => {
51+
if (!newValue) {
52+
console.warn('MQTT-Verbindung verloren!');
53+
showIcon.value = true;
54+
if (iconTimeout.value) {
55+
clearTimeout(iconTimeout.value);
56+
}
57+
} else {
58+
console.info('MQTT-Verbindung wiederhergestellt!');
59+
if (iconTimeout.value) {
60+
clearTimeout(iconTimeout.value);
61+
}
62+
iconTimeout.value = setTimeout(() => {
63+
showIcon.value = false;
64+
}, 5000);
65+
}
66+
});
67+
</script>

packages/modules/web_themes/koala/source/src/components/UserIndicator.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<div id="user-indicator" v-if="userManagementActive">
2+
<div id="user-indicator" v-if="connected && userManagementActive">
33
<q-dialog v-model="showLogoutDialog" persistent>
44
<q-card>
55
<q-card-section class="row items-center">
66
<q-avatar icon="logout" color="negative" text-color="white" />
7-
<span class="q-ml-sm">Willst Du Dich wirklich abmelden?</span>
7+
<span class="text-h6 q-ml-sm">Willst Du Dich wirklich abmelden?</span>
88
</q-card-section>
99

1010
<q-card-actions align="right">
@@ -23,7 +23,7 @@
2323
<q-card>
2424
<q-card-section class="row items-center">
2525
<q-avatar icon="login" color="positive" text-color="white" />
26-
<span class="q-ml-sm">Gib Deine Anmeldedaten ein.</span>
26+
<span class="text-h6 q-ml-sm">Gib Deine Anmeldedaten ein.</span>
2727
</q-card-section>
2828

2929
<q-form @submit="login">
@@ -98,7 +98,7 @@
9898
<q-card>
9999
<q-card-section class="row items-center">
100100
<q-avatar icon="login" color="warning" text-color="white" />
101-
<span class="q-ml-sm">Kennwort vergessen</span>
101+
<span class="text-h6 q-ml-sm">Kennwort vergessen</span>
102102
</q-card-section>
103103

104104
<q-form>
@@ -282,6 +282,8 @@ const resetPasswordDisabled = computed(() => {
282282
);
283283
});
284284
285+
const connected = computed(() => mqttStore.mqttClientConnected);
286+
285287
const stringIsEmpty = (myString: string) => {
286288
return !myString || myString.length === 0;
287289
};
@@ -386,6 +388,7 @@ watch(anonymousAccessAllowed, (newValue) => {
386388
387389
onMounted(() => {
388390
if (
391+
connected.value &&
389392
userManagementActive.value &&
390393
!anonymousAccessAllowed.value &&
391394
!loggedIn.value

packages/modules/web_themes/koala/source/src/layouts/MainLayout.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<q-btn dense flat round icon="menu" @click="drawer = !drawer" />
66
<q-toolbar-title>openWB</q-toolbar-title>
77
<q-space />
8+
<connection-indicator />
89
<user-indicator />
910
</q-toolbar>
1011
</q-header>
@@ -135,6 +136,7 @@
135136
<script setup lang="ts">
136137
import { ref, computed, onMounted } from 'vue';
137138
import UserIndicator from 'src/components/UserIndicator.vue';
139+
import ConnectionIndicator from 'src/components/ConnectionIndicator.vue';
138140
import { useMqttStore } from 'src/stores/mqtt-store';
139141
const mqttStore = useMqttStore();
140142

packages/modules/web_themes/koala/source/src/stores/mqtt-store.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const useMqttStore = defineStore('mqtt', () => {
4040
}
4141

4242
// local variables
43-
let mqttClient: mqtt.MqttClient | undefined = undefined;
43+
let mqttClient: mqtt.MqttClient | null = null;
4444
const mqttConnectionOptions: IClientOptions = {
4545
protocol: location.protocol == 'https:' ? 'wss' : 'ws',
4646
protocolVersion: 5,
@@ -61,6 +61,7 @@ export const useMqttStore = defineStore('mqtt', () => {
6161
// State
6262
const subscriptions = ref<TopicCount>({});
6363
const topics = ref<TopicList>({});
64+
const mqttClientConnected = ref(false);
6465

6566
// General functions and methods for the store - BEGIN
6667
/**
@@ -78,6 +79,7 @@ export const useMqttStore = defineStore('mqtt', () => {
7879
mqttClient = mqtt.connect(connectUrl, options);
7980
mqttClient.on('connect', () => {
8081
console.debug('connected to broker');
82+
mqttClientConnected.value = true;
8183
$q.notify({
8284
type: 'positive',
8385
message: `MQTT-Verbindung hergestellt.${mqttUser ? ` Angemeldet als ${mqttUser}.` : ''}`,
@@ -96,6 +98,7 @@ export const useMqttStore = defineStore('mqtt', () => {
9698
});
9799
mqttClient.on('error', (error) => {
98100
console.error('Client error', error);
101+
mqttClientConnected.value = false;
99102
$q.notify({
100103
type: 'negative',
101104
message:
@@ -149,6 +152,25 @@ export const useMqttStore = defineStore('mqtt', () => {
149152
removeTopic(topic);
150153
}
151154
});
155+
mqttClient.on('end', () => {
156+
mqttClientConnected.value = false;
157+
console.error('mqtt connection ended');
158+
});
159+
mqttClient.on('close', () => {
160+
mqttClientConnected.value = false;
161+
console.error('mqtt connection closed');
162+
});
163+
mqttClient.on('offline', () => {
164+
mqttClientConnected.value = false;
165+
console.error('mqtt connection offline');
166+
});
167+
mqttClient.on('disconnect', () => {
168+
mqttClientConnected.value = false;
169+
console.error('mqtt connection disconnected');
170+
});
171+
mqttClient.on('reconnect', () => {
172+
console.error('mqtt connection reconnecting...');
173+
});
152174
} catch (error) {
153175
console.error('error connecting to broker:', error);
154176
$q.notify({
@@ -3881,6 +3903,7 @@ export const useMqttStore = defineStore('mqtt', () => {
38813903
return {
38823904
topics,
38833905
subscriptions,
3906+
mqttClientConnected,
38843907
initialize,
38853908
updateTopic,
38863909
updateState: updateTopic, // alias for compatibility with older code

web/settings/assets/ActiveBatControlConfiguration-CDMl-HlO.js renamed to web/settings/assets/ActiveBatControlConfiguration-DZ9nhXzw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/settings/assets/ChargePointInstallation-BQXZqXD6.js renamed to web/settings/assets/ChargePointInstallation-CyX7hKUk.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/settings/assets/CloudConfiguration-BQB585rw.js renamed to web/settings/assets/CloudConfiguration-C9eVEUkD.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/settings/assets/DataManagement-ZRZO6eGQ.js renamed to web/settings/assets/DataManagement-DbgO6XLV.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)