Skip to content

Commit af4bfc5

Browse files
committed
New Admin UI. Protocol connections managemnt tab. In development.
1 parent d108308 commit af4bfc5

8 files changed

+3377
-3813
lines changed

src/AdminUI/src/App.vue

+20-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
</v-btn>
1515
<v-menu v-if="loggedInUser" offset-y>
1616
<template v-slot:activator="{ props }">
17-
<v-btn v-bind="props" text class="ml-2" size="small">
18-
{{ loggedInUser }}
17+
<v-btn v-bind="props" text class="ml-2">
1918
<v-icon right size="small">mdi-account-circle</v-icon>
19+
{{ loggedInUser }}
2020
</v-btn>
2121
</template>
2222
<v-list>
@@ -46,7 +46,7 @@ const vuetifyTheme = useTheme();
4646
const { locale, t } = useI18n();
4747
4848
const currentLocale = ref(locale.value);
49-
const loggedInUser = ref(null);
49+
const loggedInUser = ref("?");
5050
5151
const availableLocales = [
5252
{ title: 'English', value: 'en' },
@@ -74,7 +74,23 @@ const setLoggedInUser = (username) => {
7474
7575
const logout = () => {
7676
loggedInUser.value = null;
77-
router.push('/login');
77+
fetch('/Invoke/auth/signout', {
78+
method: 'POST',
79+
headers: {
80+
'Content-Type': 'application/json',
81+
},
82+
})
83+
.then(response => response.json())
84+
.then(data => {
85+
if (data.ok) {
86+
router.push('/login');
87+
} else {
88+
console.error('Logout failed!');
89+
}
90+
})
91+
.catch(error => {
92+
console.error('Error during logout:', error);
93+
});
7894
};
7995
8096
watch(currentLocale, (newLocale) => {

src/AdminUI/src/components/AdminPage.vue

+26-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<template>
2-
<v-container fluid class="admin-page">
3-
<v-card class="fill-height d-flex flex-column">
2+
<v-container fluid class="admin-page ma-0 pa-0">
3+
<v-card class="fill-height d-flex flex-column elevation-0">
44
<v-tabs v-model="activeTab" color="primary" align-tabs="center">
5-
<v-tab :value="1" @click="fetchUsersAndRoles">{{
5+
<v-tab :value="1" @click="fetchUsersAndRoles"><v-icon>mdi-account-multiple</v-icon> {{
66
$t('admin.tabs.userManagement') }}</v-tab>
7-
<v-tab :value="2" @click="fetchRoles">{{ $t('admin.tabs.rolesManagement') }}</v-tab>
8-
<v-tab :value="3" @click="fetchProtocolDriverInstances">{{ $t('admin.tabs.protocolDriverInstances') }}</v-tab>
9-
<v-tab :value="4">{{ $t('admin.tabs.systemSettings') }}</v-tab>
10-
<v-tab :value="5">{{ $t('admin.tabs.logs') }}</v-tab>
7+
<v-tab :value="2" @click="fetchRoles"><v-icon>mdi-shield-account</v-icon> {{ $t('admin.tabs.rolesManagement') }}</v-tab>
8+
<v-tab :value="3" @click="fetchProtocolDriverInstances"><v-icon>mdi-cogs</v-icon> {{ $t('admin.tabs.protocolDriverInstances') }}</v-tab>
9+
<v-tab :value="4" @click="fetchProtocolConnections"><v-icon>mdi-lan-connect</v-icon> {{ $t('admin.tabs.protocolConnections') }}</v-tab>
10+
<v-tab :value="5"><v-icon>mdi-cog</v-icon> {{ $t('admin.tabs.systemSettings') }}</v-tab>
11+
<v-tab :value="6"><v-icon>mdi-file-document-outline</v-icon> {{ $t('admin.tabs.logs') }}</v-tab>
1112
</v-tabs>
1213

13-
<v-card-text>
14+
<v-card-text class="ma-0 pa-0">
1415
<v-window v-model="activeTab">
1516
<v-window-item :value="1">
1617
<user-management-tab ref="userManagementTabRef" />
@@ -25,10 +26,14 @@
2526
</v-window-item>
2627

2728
<v-window-item :value="4">
28-
<system-settings-tab ref="systemSettingsTabRef" />
29+
<protocol-connections-tab ref="protocolConnectionsTabRef" />
2930
</v-window-item>
3031

3132
<v-window-item :value="5">
33+
<system-settings-tab ref="systemSettingsTabRef" />
34+
</v-window-item>
35+
36+
<v-window-item :value="6">
3237
<logs-tab ref="logsTab" />
3338
</v-window-item>
3439
</v-window>
@@ -42,15 +47,17 @@
4247
import UserManagementTab from './UserManagementTab.vue';
4348
import RolesManagementTab from './RolesManagementTab.vue';
4449
import ProtocolDriverInstancesTab from './ProtocolDriverInstancesTab.vue';
50+
import ProtocolConnectionsTab from './ProtocolConnectionsTab.vue';
4551
import SystemSettingsTab from './SystemSettingsTab.vue';
4652
import LogsTab from './LogsTab.vue';
4753
import { ref } from 'vue';
4854
49-
const userManagementTabRef = ref(1);
50-
const rolesManagementTabRef = ref(2);
51-
const protocolDriverInstancesTabRef = ref(3);
52-
const systemSettingsTabRef = ref(4);
53-
const logsTab = ref(5);
55+
const userManagementTabRef = ref(null);
56+
const rolesManagementTabRef = ref(null);
57+
const protocolDriverInstancesTabRef = ref(null);
58+
const protocolConnectionsTabRef = ref(null);
59+
const systemSettingsTabRef = ref(null);
60+
const logsTab = ref(null);
5461
const activeTab = ref(1);
5562
5663
const fetchUsersAndRoles = async () => {
@@ -70,6 +77,11 @@ const fetchProtocolDriverInstances = async () => {
7077
await protocolDriverInstancesTabRef.value.fetchProtocolDriverInstances();
7178
}
7279
80+
const fetchProtocolConnections = async () => {
81+
if (protocolConnectionsTabRef?.value?.fetchProtocolConnections)
82+
await protocolConnectionsTabRef.value.fetchProtocolConnections();
83+
}
84+
7385
</script>
7486
7587
<style scoped>

src/AdminUI/src/components/LoginPage.vue

-59
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ const parseCookie = (str) => {
136136
}, {})
137137
}
138138
139-
function LoadFavicon(href) {
140-
let link = document.createElement('link')
141-
link.type = 'image/x-icon'
142-
link.rel = 'shortcut icon'
143-
link.href = href
144-
document.getElementsByTagName('head')[0].appendChild(link)
145-
}
146-
147139
function testLogin() {
148140
let ck = parseCookie(document.cookie)
149141
if ('json-scada-user' in ck) {
@@ -188,55 +180,4 @@ function testLogin() {
188180
})
189181
}
190182
191-
function tryLogin() {
192-
fetch('/Invoke/auth/signin', {
193-
headers: {
194-
Accept: 'application/json',
195-
'Content-Type': 'application/json',
196-
},
197-
method: 'POST',
198-
body: JSON.stringify({
199-
username: document.getElementById('username').value,
200-
password: document.getElementById('password').value,
201-
}),
202-
})
203-
.then((resp) => resp.json())
204-
.then((data) => {
205-
if ('ok' in data && data.ok == false) {
206-
document.getElementById('divloginerror').style.display = ''
207-
setTimeout(function () {
208-
document.getElementById('divloginerror').style.display = 'none'
209-
}, 3000)
210-
}
211-
})
212-
.catch((error) => {
213-
console.log('Error on a fetch operation: ' + error.message)
214-
})
215-
.finally(() => {
216-
testLogin()
217-
document.getElementById('password').value = ''
218-
})
219-
}
220-
221-
function tryLogout() {
222-
fetch('/Invoke/auth/signout', {
223-
headers: {
224-
Accept: 'application/json',
225-
'Content-Type': 'application/json',
226-
},
227-
method: 'POST',
228-
body: JSON.stringify({
229-
username: document.getElementById('username').value,
230-
}),
231-
})
232-
.then((response) => {
233-
// console.log(response)
234-
})
235-
.catch((error) => {
236-
console.log('Error on a fetch operation: ' + error.message)
237-
})
238-
.finally(() => {
239-
testLogin()
240-
})
241-
}
242183
</script>

0 commit comments

Comments
 (0)