-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
AdminMain.svelte
225 lines (205 loc) · 6.59 KB
/
AdminMain.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<script>
import Button from "$lib/Button.svelte";
import {redirectToLogout} from "../../utils/helpers.js";
import Nav from "$lib/nav/Nav.svelte";
import NavEntry from "$lib/nav/NavEntry.svelte";
import Users from "./users/Users.svelte";
import ContentWrapper from "./ContentWrapper.svelte";
import Roles from "./roles/Roles.svelte";
import Groups from "./groups/Groups.svelte";
import Scopes from "./scopes/Scopes.svelte";
import Clients from "./clients/Clients.svelte";
import Sessions from "./sessions/Sessions.svelte";
import Attr from "./userAttr/Attr.svelte";
import Config from "./config/Config.svelte";
import IconWrenchScrew from "$lib/icons/IconWrenchScrew.svelte";
import IconUser from "$lib/icons/IconUser.svelte";
import IconOffice from "$lib/icons/IconOffice.svelte";
import IconUsers from "$lib/icons/IconUsers.svelte";
import IconDocText from "$lib/icons/IconDocText.svelte";
import IconShieldCheck from "$lib/icons/IconShieldCheck.svelte";
import IconLogout from "$lib/icons/IconLogout.svelte";
import IconId from "$lib/icons/IconId.svelte";
import RauthyLogo from "../icons/RauthyLogo.svelte";
import Documentation from "./documentation/Documentation.svelte";
import IconBookOpen from "../icons/IconBookOpen.svelte";
export let sessionInfo = {};
export let selected = 'Users';
let title = 'Rauthy Admin';
let isExpanded;
let innerWidth;
$: if (innerWidth) {
isExpanded = innerWidth > 1050;
}
$: if (selected) {
switch (selected) {
case 'Users': {
window.history.pushState({}, '', '/auth/v1/admin/users');
title = 'Users';
break;
}
case 'Attributes': {
window.history.pushState({}, '', '/auth/v1/admin/attributes');
title = 'Attributes';
break;
}
case 'Clients': {
window.history.pushState({}, '', '/auth/v1/admin/clients');
title = 'Clients';
break;
}
case 'Roles': {
window.history.pushState({}, '', '/auth/v1/admin/roles');
title = 'Roles';
break;
}
case 'Groups': {
window.history.pushState({}, '', '/auth/v1/admin/groups');
title = 'Groups';
break;
}
case 'Scopes': {
window.history.pushState({}, '', '/auth/v1/admin/scopes');
title = 'Scopes';
break;
}
case 'Sessions': {
window.history.pushState({}, '', '/auth/v1/admin/sessions');
title = 'Sessions';
break;
}
case 'Config': {
window.history.pushState({}, '', '/auth/v1/admin/config');
title = 'Config';
break;
}
case 'Docs': {
window.history.pushState({}, '', '/auth/v1/admin/docs');
title = 'Docs';
break;
}
case 'Logout': redirectToLogout(); break;
}
}
</script>
<svelte:window bind:innerWidth/>
<svelte:head>
<title>{title}</title>
</svelte:head>
<main>
<Nav bind:selected bind:isExpanded widthExpanded={140} widthCollapsed={60}>
<div slot="logo">
<div
style:width={isExpanded ? '120px' : '55px'}
style:margin-top={isExpanded ? '32px' : '40px'}
style:margin-bottom={isExpanded ? '13px' : '22px'}
>
<RauthyLogo/>
</div>
</div>
<div slot="entries">
<NavEntry label="Users">
<IconUser/>
</NavEntry>
<NavEntry label="Attributes">
<IconDocText/>
</NavEntry>
<NavEntry label="Clients">
<IconOffice/>
</NavEntry>
<NavEntry label="Roles">
<IconShieldCheck/>
</NavEntry>
<NavEntry label="Groups">
<IconUsers/>
</NavEntry>
<NavEntry label="Scopes">
<IconId/>
</NavEntry>
<NavEntry label="Sessions">
<IconShieldCheck/>
</NavEntry>
<NavEntry label="Config">
<IconWrenchScrew/>
</NavEntry>
<NavEntry label="Docs">
<IconBookOpen/>
</NavEntry>
<NavEntry label="Logout">
<IconLogout/>
</NavEntry>
</div>
</Nav>
{#if 'Users' === selected}
<ContentWrapper>
<Users/>
</ContentWrapper>
{:else if 'Attributes' === selected}
<ContentWrapper>
<Attr/>
</ContentWrapper>
{:else if 'Clients' === selected}
<ContentWrapper>
<Clients/>
</ContentWrapper>
{:else if 'Roles' === selected}
<ContentWrapper>
<Roles/>
</ContentWrapper>
{:else if 'Groups' === selected}
<ContentWrapper>
<Groups/>
</ContentWrapper>
{:else if 'Scopes' === selected}
<ContentWrapper>
<Scopes/>
</ContentWrapper>
{:else if 'Sessions' === selected}
<ContentWrapper>
<Sessions/>
</ContentWrapper>
{:else if 'Config' === selected}
<ContentWrapper>
<Config/>
</ContentWrapper>
{:else if 'Docs' === selected}
<ContentWrapper>
<Documentation/>
</ContentWrapper>
{:else}
<ContentWrapper bind:selected>
<h1>ADMIN PAGE</h1>
<div>
<h3>Info:</h3>
{#if sessionInfo}
<div>
{sessionInfo.id}
</div>
<div>
{sessionInfo.user_id}
</div>
<div>
{sessionInfo.roles}
</div>
<div>
{sessionInfo.groups}
</div>
<div>
{sessionInfo.exp}
</div>
{/if}
<Button on:click={redirectToLogout}>Logout</Button>
</div>
</ContentWrapper>
{/if}
</main>
<style>
main {
width: 100vw;
display: flex;
align-items: center;
flex-direction: row;
overflow-y: auto;
overflow-x: hidden;
}
</style>