Commit 44846dd4 by Johannes Edmeier

Show logged in username and hide logout when not logged in

closes #792
parent 5de849a4
...@@ -53,13 +53,8 @@ body { ...@@ -53,13 +53,8 @@ body {
border-color: transparent; border-color: transparent;
} }
//navbar color fixes .navbar-link::after {
.navbar-item .button.is-icon { border-color: currentColor;
color: $navbar-item-color;
&:hover {
color: $navbar-item-hover-color;
}
} }
.navbar .badge { .navbar .badge {
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
<script th:inline="javascript"> <script th:inline="javascript">
var SBA = { var SBA = {
uiSettings: /*[[${uiSettings}]]*/ {} uiSettings: /*[[${uiSettings}]]*/ {},
user: /*[[${user}]]*/ null
} }
</script> </script>
<script lang="javascript" src="assets/js/vendors.js" defer></script> <script lang="javascript" src="assets/js/vendors.js" defer></script>
......
...@@ -20,6 +20,8 @@ import faGitter from '@fortawesome/fontawesome-free-brands/faGitter'; ...@@ -20,6 +20,8 @@ import faGitter from '@fortawesome/fontawesome-free-brands/faGitter';
import faStackOverflow from '@fortawesome/fontawesome-free-brands/faStackOverflow'; import faStackOverflow from '@fortawesome/fontawesome-free-brands/faStackOverflow';
import farTimesCircle from '@fortawesome/fontawesome-free-regular/faTimesCircle'; import farTimesCircle from '@fortawesome/fontawesome-free-regular/faTimesCircle';
import faBan from '@fortawesome/fontawesome-free-solid/faBan'; import faBan from '@fortawesome/fontawesome-free-solid/faBan';
import faBell from '@fortawesome/fontawesome-free-solid/faBell';
import faBellSlash from '@fortawesome/fontawesome-free-solid/faBellSlash';
import faBook from '@fortawesome/fontawesome-free-solid/faBook'; import faBook from '@fortawesome/fontawesome-free-solid/faBook';
import faCheck from '@fortawesome/fontawesome-free-solid/faCheck'; import faCheck from '@fortawesome/fontawesome-free-solid/faCheck';
import faDownload from '@fortawesome/fontawesome-free-solid/faDownload'; import faDownload from '@fortawesome/fontawesome-free-solid/faDownload';
...@@ -33,13 +35,12 @@ import faStepBackward from '@fortawesome/fontawesome-free-solid/faStepBackward'; ...@@ -33,13 +35,12 @@ import faStepBackward from '@fortawesome/fontawesome-free-solid/faStepBackward';
import faStepForward from '@fortawesome/fontawesome-free-solid/faStepForward'; import faStepForward from '@fortawesome/fontawesome-free-solid/faStepForward';
import faTimesCircle from '@fortawesome/fontawesome-free-solid/faTimesCircle'; import faTimesCircle from '@fortawesome/fontawesome-free-solid/faTimesCircle';
import faTrash from '@fortawesome/fontawesome-free-solid/faTrash'; import faTrash from '@fortawesome/fontawesome-free-solid/faTrash';
import faBell from '@fortawesome/fontawesome-free-solid/faBell'; import faUserCircle from '@fortawesome/fontawesome-free-solid/faUserCircle';
import faBellSlash from '@fortawesome/fontawesome-free-solid/faBellSlash';
import FontAwesomeIcon from '@fortawesome/vue-fontawesome'; import FontAwesomeIcon from '@fortawesome/vue-fontawesome';
//solid //solid
fontawesome.library.add(faTrash, faDownload, faStepForward, faStepBackward, faCheck, faQuestionCircle, faBan, faTimesCircle, faMinusCircle, faExclamation, fontawesome.library.add(faTrash, faDownload, faStepForward, faStepBackward, faCheck, faQuestionCircle, faBan, faTimesCircle, faMinusCircle, faExclamation,
faBook, faSignOutAlt, faExclamationTriangle, faPencilAlt, faBell, faBellSlash); faBook, faSignOutAlt, faExclamationTriangle, faPencilAlt, faBell, faBellSlash, faUserCircle);
//regular //regular
fontawesome.library.add(farTimesCircle); fontawesome.library.add(farTimesCircle);
//brands //brands
......
...@@ -33,12 +33,19 @@ ...@@ -33,12 +33,19 @@
<component :is="view.handle" :applications="applications" :error="error"/> <component :is="view.handle" :applications="applications" :error="error"/>
</router-link> </router-link>
<div class="navbar-item"> <div class="navbar-item has-dropdown is-hoverable" v-if="userName">
<form action="logout" method="post"> <a class="navbar-link">
<button class="button is-icon" type="submit" value="logout"> <font-awesome-icon icon="user-circle" size="lg"/>&nbsp;<span v-text="userName"/>
Logout&nbsp;<font-awesome-icon icon="sign-out-alt" size="lg"/> </a>
</button> <div class="navbar-dropdown">
</form> <a class="navbar-item">
<form action="logout" method="post">
<button class="button is-icon" type="submit" value="logout">
<font-awesome-icon icon="sign-out-alt"/>&nbsp;Log out
</button>
</form>
</a>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -50,7 +57,8 @@ ...@@ -50,7 +57,8 @@
export default { export default {
data: () => ({ data: () => ({
showMenu: false, showMenu: false,
brand: '<img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>' brand: '<img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>',
userName: null
}), }),
props: { props: {
views: { views: {
...@@ -68,8 +76,14 @@ ...@@ -68,8 +76,14 @@
}, },
created() { created() {
/* global SBA */ /* global SBA */
if (SBA && SBA.uiSettings) { if (SBA) {
this.brand = SBA.uiSettings.brand || this.brand; if (SBA.uiSettings) {
this.brand = SBA.uiSettings.brand || this.brand;
}
if (SBA.user) {
this.userName = SBA.user.name;
}
} }
}, },
mounted() { mounted() {
......
...@@ -18,6 +18,7 @@ package de.codecentric.boot.admin.server.ui.web; ...@@ -18,6 +18,7 @@ package de.codecentric.boot.admin.server.ui.web;
import de.codecentric.boot.admin.server.web.AdminController; import de.codecentric.boot.admin.server.web.AdminController;
import java.security.Principal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -46,6 +47,11 @@ public class UiController { ...@@ -46,6 +47,11 @@ public class UiController {
return uiSettings; return uiSettings;
} }
@ModelAttribute(value = "user", binding = false)
public Principal getUiSettings(Principal principal) {
return principal;
}
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE) @GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
public String index() { public String index() {
return "index"; return "index";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment