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

Tabbed navigation #617

Merged
merged 13 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/server/assets/admin/_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
System admin
</div>

<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<nav class="nav nav-tabs navbar-expand-md navbar-light bg-light">
<div class="container">
{{template "navtoggle" .}}
<div class="collapse navbar-collapse" id="navbar">
<div class="collapse navbar-collapse mt-2" id="navbar">
{{if .currentRealm}}
<ul class="navbar-nav mr-auto">
<li class="nav-item">
Expand All @@ -24,15 +24,15 @@

<ul class="nav nav-pills justify-content-center mb-3">
<li class="nav-item">
<a class="nav-link{{if stringContains .currentPath "/admin/realms"}} active{{end}}" href="/admin/realms">Realms</a>
<a class="nav-link{{if eq .currentPath.File "realms"}} active{{end}}" href="/admin/realms">Realms</a>
</li>

<li class="nav-item">
<a class="nav-link{{if stringContains .currentPath "/admin/users"}} active{{end}}" href="/admin/users">System admins</a>
<a class="nav-link{{if eq .currentPath.File "users"}} active{{end}}" href="/admin/users">System admins</a>
</li>

<li class="nav-item">
<a class="nav-link{{if stringContains .currentPath "/admin/info"}} active{{end}}" href="/admin/info">Info</a>
<a class="nav-link{{if eq .currentPath.File "info"}} active{{end}}" href="/admin/info">Info</a>
</li>
</ul>
{{end}}
2 changes: 1 addition & 1 deletion cmd/server/assets/admin/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/admin/realms/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/admin/realms/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/admin/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/admin/users/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/apikeys/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/apikeys/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/apikeys/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/apikeys/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/codestatus/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/codestatus/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
18 changes: 7 additions & 11 deletions cmd/server/assets/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
<title>{{if .title}}{{.title}}{{else}}Diagnosis Verification Server{{end}}</title>

<style type="text/css">
div.realm-header {
background-color: #0055b1;
}

div.admin-header {
background-color:#D66402
}
Expand Down Expand Up @@ -187,23 +183,23 @@
{{define "navbar"}}
<header class="mb-3">
{{if .currentRealm}}
<div href="/" class="d-block px-3 py-2 text-center text-bold text-white realm-header">
<div href="/" class="d-block px-3 py-2 text-center text-bold text-white bg-primary">
{{.currentRealm.Name}}{{if .currentRealm.RegionCode}} - {{.currentRealm.RegionCode}}{{end}}
</div>
{{end}}

<nav class="navbar navbar-expand-md navbar-dark bg-primary">
<nav class="nav nav-tabs navbar-expand-md navbar-light bg-light">
<div class="container">
{{template "navtoggle" .}}

<div class="collapse navbar-collapse" id="navbar">
<div class="collapse navbar-collapse mt-2" id="navbar">
{{if .currentRealm}}
<ul class="navbar-nav mr-auto">
<ul class="nav mr-auto flex-column flex-md-row">
<li class="nav-item">
<a class="nav-link" href="/home">Issue code</a>
<a class="nav-link {{if eq .currentPath.File "home"}}active{{end}}" href="/home">Issue code</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/code/status">Check code status</a>
<a class="nav-link {{if eq .currentPath.Dir "/code/"}}active{{end}}" href="/code/status">Check code status</a>
</li>
</ul>
{{end}}
Expand All @@ -224,7 +220,7 @@

{{/* defines the user dropdown menu */}}
{{define "navdropdown"}}
<ul class="navbar-nav ml-auto">
<ul class="navbar-nav ml-3">
{{if .currentUser}}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="profile-menu" data-toggle="dropdown" aria-haspopup="true"
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</style>
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "firebase" .}}
</head>

<body class="bg-light">
<body class="tab-content">
<main role="main" class="container">
{{template "flash" .}}

Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/register-phone.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{template "firebase" .}}
</head>

<body class="bg-light">
<body class="tab-content">
{{template "navbar" .}}
<main role="main" class="container">
{{template "flash" .}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/reset-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "firebase" .}}
</head>

<body class="bg-light">
<body class="tab-content">
{{if .currentUser}}
{{template "navbar" .}}
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/select-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "firebase" .}}
</head>

<body class="bg-light">
<body class="tab-content">
<main role="main" class="container">
{{template "flash" .}}

Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/select-realm.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/login/verify-email.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{template "firebase" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/realm.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
10 changes: 5 additions & 5 deletions cmd/server/assets/realmadmin/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand All @@ -26,10 +26,10 @@ <h1>Realm settings</h1>
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#express" role="tab" aria-controls="express" aria-selected="true">ENX</a>
<a class="nav-link" id="home-tab" data-toggle="tab" href="#express" role="tab" aria-controls="express" aria-selected="true">ENX</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="home-tab" data-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="codes-tab" data-toggle="tab" href="#codes" role="tab" aria-controls="codes" aria-selected="false">Codes</a>
Expand All @@ -48,10 +48,10 @@ <h1>Realm settings</h1>

<div class="card-body">
<div class="tab-content">
<div class="tab-pane active" id="express" role="tabpanel" aria-labelledby="express-tab">
<div class="tab-pane" id="express" role="tabpanel" aria-labelledby="express-tab">
{{template "realmadmin/_form_express" .}}
</div>
<div class="tab-pane" id="general" role="tabpanel" aria-labelledby="general-tab">
<div class="tab-pane active" id="general" role="tabpanel" aria-labelledby="general-tab">
{{template "realmadmin/_form_general" .}}
</div>
<div class="tab-pane" id="codes" role="tabpanel" aria-labelledby="codes-tab">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/realmadmin/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/realmkeys.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/users/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/users/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{template "firebase" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{template "head" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/users/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{template "floatingform" .}}
</head>

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

<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/assets/users/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{template "firebase" .}}
</head>

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

<main role="main" class="container">
Expand Down
4 changes: 4 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func realMain(ctx context.Context) error {
requireSession := middleware.RequireSession(ctx, sessions, h)
r.Use(requireSession)

// Include the current URI
currentPath := middleware.CurrentPath()
r.Use(currentPath)

// Create common middleware
requireAuth := middleware.RequireAuth(ctx, cacher, auth, db, h, config.SessionIdleTimeout, config.SessionDuration)
requireVerified := middleware.RequireVerified(ctx, auth, db, h, config.SessionDuration)
Expand Down
Loading