Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit 199ed9f

Browse files
authored
Tabbed navigation (#617)
* pretty nav * margins * remove old css * Include path var to template * fix names * typo * abbreviate * update * default to general * add inject * a line * take string param
1 parent 4c1f0d2 commit 199ed9f

31 files changed

+113
-53
lines changed

cmd/server/assets/admin/_nav.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
System admin
55
</div>
66

7-
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
7+
<nav class="nav nav-tabs navbar-expand-md navbar-light bg-light">
88
<div class="container">
99
{{template "navtoggle" .}}
10-
<div class="collapse navbar-collapse" id="navbar">
10+
<div class="collapse navbar-collapse mt-2" id="navbar">
1111
{{if .currentRealm}}
1212
<ul class="navbar-nav mr-auto">
1313
<li class="nav-item">
@@ -24,15 +24,15 @@
2424

2525
<ul class="nav nav-pills justify-content-center mb-3">
2626
<li class="nav-item">
27-
<a class="nav-link{{if stringContains .currentPath "/admin/realms"}} active{{end}}" href="/admin/realms">Realms</a>
27+
<a class="nav-link{{if .currentPath.IsFile "realms"}} active{{end}}" href="/admin/realms">Realms</a>
2828
</li>
2929

3030
<li class="nav-item">
31-
<a class="nav-link{{if stringContains .currentPath "/admin/users"}} active{{end}}" href="/admin/users">System admins</a>
31+
<a class="nav-link{{if .currentPath.IsFile "users"}} active{{end}}" href="/admin/users">System admins</a>
3232
</li>
3333

3434
<li class="nav-item">
35-
<a class="nav-link{{if stringContains .currentPath "/admin/info"}} active{{end}}" href="/admin/info">Info</a>
35+
<a class="nav-link{{if .currentPath.IsFile "info"}} active{{end}}" href="/admin/info">Info</a>
3636
</li>
3737
</ul>
3838
{{end}}

cmd/server/assets/admin/info.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{{template "head" .}}
77
</head>
88

9-
<body class="bg-light">
9+
<body class="tab-content">
1010
{{template "admin/navbar" .}}
1111

1212
<main role="main" class="container">

cmd/server/assets/admin/realms/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{template "head" .}}
99
</head>
1010

11-
<body class="bg-light">
11+
<body class="tab-content">
1212
{{template "admin/navbar" .}}
1313

1414
<main role="main" class="container">

cmd/server/assets/admin/realms/new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{template "floatingform" .}}
1010
</head>
1111

12-
<body class="bg-light">
12+
<body class="tab-content">
1313
{{template "admin/navbar" .}}
1414

1515
<main role="main" class="container">

cmd/server/assets/admin/users/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{template "head" .}}
1010
</head>
1111

12-
<body class="bg-light">
12+
<body class="tab-content">
1313
{{template "admin/navbar" .}}
1414

1515
<main role="main" class="container">

cmd/server/assets/admin/users/new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{template "floatingform" .}}
1111
</head>
1212

13-
<body class="bg-light">
13+
<body class="tab-content">
1414
{{template "admin/navbar" .}}
1515

1616
<main role="main" class="container">

cmd/server/assets/apikeys/edit.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{template "floatingform" .}}
1010
</head>
1111

12-
<body class="bg-light">
12+
<body class="tab-content">
1313
{{template "navbar" .}}
1414

1515
<main role="main" class="container">

cmd/server/assets/apikeys/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{template "head" .}}
99
</head>
1010

11-
<body class="bg-light">
11+
<body class="tab-content">
1212
{{template "navbar" .}}
1313

1414
<main role="main" class="container">

cmd/server/assets/apikeys/new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{template "floatingform" .}}
1010
</head>
1111

12-
<body class="bg-light">
12+
<body class="tab-content">
1313
{{template "navbar" .}}
1414

1515
<main role="main" class="container">

cmd/server/assets/apikeys/show.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "head" .}}
1212
</head>
1313

14-
<body class="bg-light">
14+
<body class="tab-content">
1515
{{template "navbar" .}}
1616

1717
<main role="main" class="container">

cmd/server/assets/codestatus/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{template "head" .}}
1111
</head>
1212

13-
<body class="bg-light">
13+
<body class="tab-content">
1414
{{template "navbar" .}}
1515

1616
<main role="main" class="container">

cmd/server/assets/codestatus/show.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{template "head" .}}
88
</head>
99

10-
<body class="bg-light">
10+
<body class="tab-content">
1111
{{template "navbar" .}}
1212

1313
<main role="main" class="container">

cmd/server/assets/header.html

+7-11
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
<title>{{if .title}}{{.title}}{{else}}Diagnosis Verification Server{{end}}</title>
3030

3131
<style type="text/css">
32-
div.realm-header {
33-
background-color: #0055b1;
34-
}
35-
3632
div.admin-header {
3733
background-color:#D66402
3834
}
@@ -187,23 +183,23 @@
187183
{{define "navbar"}}
188184
<header class="mb-3">
189185
{{if .currentRealm}}
190-
<div href="/" class="d-block px-3 py-2 text-center text-bold text-white realm-header">
186+
<div href="/" class="d-block px-3 py-2 text-center text-bold text-white bg-primary">
191187
{{.currentRealm.Name}}{{if .currentRealm.RegionCode}} - {{.currentRealm.RegionCode}}{{end}}
192188
</div>
193189
{{end}}
194190

195-
<nav class="navbar navbar-expand-md navbar-dark bg-primary">
191+
<nav class="nav nav-tabs navbar-expand-md navbar-light bg-light">
196192
<div class="container">
197193
{{template "navtoggle" .}}
198194

199-
<div class="collapse navbar-collapse" id="navbar">
195+
<div class="collapse navbar-collapse mt-2" id="navbar">
200196
{{if .currentRealm}}
201-
<ul class="navbar-nav mr-auto">
197+
<ul class="nav mr-auto flex-column flex-md-row">
202198
<li class="nav-item">
203-
<a class="nav-link" href="/home">Issue code</a>
199+
<a class="nav-link {{if .currentPath.IsFile "home"}}active{{end}}" href="/home">Issue code</a>
204200
</li>
205201
<li class="nav-item">
206-
<a class="nav-link" href="/code/status">Check code status</a>
202+
<a class="nav-link {{if .currentPath.IsDir "/code/"}}active{{end}}" href="/code/status">Check code status</a>
207203
</li>
208204
</ul>
209205
{{end}}
@@ -224,7 +220,7 @@
224220

225221
{{/* defines the user dropdown menu */}}
226222
{{define "navdropdown"}}
227-
<ul class="navbar-nav ml-auto">
223+
<ul class="navbar-nav ml-3">
228224
{{if .currentUser}}
229225
<li class="nav-item dropdown">
230226
<a class="nav-link dropdown-toggle" href="#" id="profile-menu" data-toggle="dropdown" aria-haspopup="true"

cmd/server/assets/home.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</style>
2424
</head>
2525

26-
<body class="bg-light">
26+
<body class="tab-content">
2727
{{template "navbar" .}}
2828

2929
<main role="main" class="container">

cmd/server/assets/login/login.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{template "firebase" .}}
99
</head>
1010

11-
<body class="bg-light">
11+
<body class="tab-content">
1212
<main role="main" class="container">
1313
{{template "flash" .}}
1414

cmd/server/assets/login/register-phone.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "firebase" .}}
1212
</head>
1313

14-
<body class="bg-light">
14+
<body class="tab-content">
1515
{{template "navbar" .}}
1616
<main role="main" class="container">
1717
{{template "flash" .}}

cmd/server/assets/login/reset-password.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{template "firebase" .}}
99
</head>
1010

11-
<body class="bg-light">
11+
<body class="tab-content">
1212
{{if .currentUser}}
1313
{{template "navbar" .}}
1414
{{end}}

cmd/server/assets/login/select-password.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{template "firebase" .}}
99
</head>
1010

11-
<body class="bg-light">
11+
<body class="tab-content">
1212
<main role="main" class="container">
1313
{{template "flash" .}}
1414

cmd/server/assets/login/select-realm.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{template "head" .}}
1111
</head>
1212

13-
<body class="bg-light">
13+
<body class="tab-content">
1414
{{template "navbar" .}}
1515

1616
<main role="main" class="container">

cmd/server/assets/login/verify-email.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{template "firebase" .}}
88
</head>
99

10-
<body class="bg-light">
10+
<body class="tab-content">
1111
{{template "navbar" .}}
1212

1313
<main role="main" class="container">

cmd/server/assets/realm.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "floatingform" .}}
1212
</head>
1313

14-
<body class="bg-light">
14+
<body class="tab-content">
1515
{{template "navbar" .}}
1616

1717
<main role="main" class="container">

cmd/server/assets/realmadmin/edit.html

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "floatingform" .}}
1212
</head>
1313

14-
<body class="bg-light">
14+
<body class="tab-content">
1515
{{template "navbar" .}}
1616

1717
<main role="main" class="container">
@@ -31,7 +31,7 @@ <h1>Realm settings</h1>
3131
</li>
3232
{{end}}
3333
<li class="nav-item" role="presentation">
34-
<a class="nav-link" id="general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
34+
<a class="nav-link active" id="general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
3535
</li>
3636
<li class="nav-item" role="presentation">
3737
<a class="nav-link" id="codes-tab" data-toggle="tab" href="#codes" role="tab" aria-controls="codes" aria-selected="false">Codes</a>
@@ -51,11 +51,11 @@ <h1>Realm settings</h1>
5151
<div class="card-body">
5252
<div class="tab-content">
5353
{{if not $realm.EnableENExpress}}
54-
<div class="tab-pane" id="express" role="tabpanel" aria-labelledby="express-tab">
54+
<div class="tab-pane" id="express-tab" role="tabpanel" aria-labelledby="express-tab">
5555
{{template "realmadmin/_form_express" .}}
5656
</div>
5757
{{end}}
58-
<div class="tab-pane" id="general" role="tabpanel" aria-labelledby="general-tab">
58+
<div class="tab-pane active" id="general" role="tabpanel" aria-labelledby="general-tab">
5959
{{template "realmadmin/_form_general" .}}
6060
</div>
6161
<div class="tab-pane" id="codes" role="tabpanel" aria-labelledby="codes-tab">
@@ -96,17 +96,18 @@ <h1>Realm settings</h1>
9696

9797
<script type="text/javascript">
9898
$(function(){
99-
let hash = window.location.hash;
100-
if (hash) {
101-
$(`ul.nav a[href="${hash}"]`).tab('show');
102-
}
99+
changeTab(window.location.hash);
103100

104101
$('.nav-tabs a').on('click', function(event) {
105-
$(this).tab('show');
102+
changeTab(this.hash);
103+
});
104+
105+
function changeTab(hash) {
106+
$(`ul.nav a[href="${hash}"]`).tab('show');
106107
let mem = $('body').scrollTop() || $('html').scrollTop();
107-
window.location.hash = this.hash;
108+
window.location.hash = hash;
108109
$('html,body').scrollTop(mem);
109-
});
110+
}
110111

111112
{{if $realm.EnableENExpress}}
112113
let $showAdvancedSettings = $('#show-advanced-settings');

cmd/server/assets/realmadmin/show.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{template "head" .}}
1010
</head>
1111

12-
<body class="bg-light">
12+
<body class="tab-content">
1313
{{template "navbar" .}}
1414

1515
<main role="main" class="container">

cmd/server/assets/realmkeys.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
{{template "head" .}}
160160
</head>
161161

162-
<body class="bg-light">
162+
<body class="tab-content">
163163
{{template "navbar" .}}
164164

165165
<main role="main" class="container">

cmd/server/assets/users/edit.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{template "floatingform" .}}
1111
</head>
1212

13-
<body class="bg-light">
13+
<body class="tab-content">
1414
{{template "navbar" .}}
1515

1616
<main role="main" class="container">

cmd/server/assets/users/import.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{template "firebase" .}}
1414
</head>
1515

16-
<body class="bg-light">
16+
<body class="tab-content">
1717
{{template "navbar" .}}
1818

1919
<main role="main" class="container">

cmd/server/assets/users/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{{template "head" .}}
1313
</head>
1414

15-
<body class="bg-light">
15+
<body class="tab-content">
1616
{{template "navbar" .}}
1717

1818
<main role="main" class="container">

cmd/server/assets/users/new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{template "floatingform" .}}
1111
</head>
1212

13-
<body class="bg-light">
13+
<body class="tab-content">
1414
{{template "navbar" .}}
1515

1616
<main role="main" class="container">

cmd/server/assets/users/show.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "firebase" .}}
1212
</head>
1313

14-
<body class="bg-light">
14+
<body class="tab-content">
1515
{{template "navbar" .}}
1616

1717
<main role="main" class="container">

cmd/server/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ func realMain(ctx context.Context) error {
181181
requireSession := middleware.RequireSession(ctx, sessions, h)
182182
r.Use(requireSession)
183183

184+
// Include the current URI
185+
currentPath := middleware.InjectCurrentPath()
186+
r.Use(currentPath)
187+
184188
// Create common middleware
185189
requireAuth := middleware.RequireAuth(ctx, cacher, auth, db, h, config.SessionIdleTimeout, config.SessionDuration)
186190
requireVerified := middleware.RequireVerified(ctx, auth, db, h, config.SessionDuration)

0 commit comments

Comments
 (0)