Просмотр исходного кода

feature: Show username in header (#270)

James Read 2 лет назад
Родитель
Сommit
f60ab6ce85
5 измененных файлов с 16 добавлено и 1 удалено
  1. 3 0
      OliveTin.proto
  2. 2 0
      internal/grpcapi/grpcApi.go
  3. 2 0
      webui.dev/index.html
  4. 2 0
      webui.dev/js/marshaller.js
  5. 7 1
      webui.dev/style.css

+ 3 - 0
OliveTin.proto

@@ -39,9 +39,12 @@ message Entity {
 
 message GetDashboardComponentsResponse {
 	string title = 1;
+
 	repeated Action actions = 2;
 	repeated Entity entities = 3;
 	repeated DashboardComponent dashboards = 4;
+
+	string authenticated_user = 5;
 }
 
 message GetDashboardComponentsRequest {}

+ 2 - 0
internal/grpcapi/grpcApi.go

@@ -221,6 +221,8 @@ func (api *oliveTinAPI) GetDashboardComponents(ctx ctx.Context, req *pb.GetDashb
 
 	dashboardCfgToPb(res, cfg.Dashboards)
 
+	res.AuthenticatedUser = user.Username
+
 	return res, nil
 }
 

+ 2 - 0
webui.dev/index.html

@@ -35,6 +35,8 @@
 					</li>
 				</ul>
 			</nav>
+
+			<span id = "username">&nbsp;</span>
 		</header>
 
 		<main title = "main content">

+ 2 - 0
webui.dev/js/marshaller.js

@@ -19,6 +19,8 @@ export function marshalDashboardComponentsJsonToHtml (json) {
   marshalActionsJsonToHtml(json)
   marshalDashboardStructureToHtml(json)
 
+  document.getElementById('username').innerText = json.authenticatedUser
+
   changeDirectory(null)
 }
 

+ 7 - 1
webui.dev/style.css

@@ -72,9 +72,15 @@ nav ul li a:hover {
   text-align: center;
   display: inline-grid;
   place-items: center;
+  margin-left: 1em;
   padding: 0;
 }
 
+#username {
+  margin-right: 1em;
+  font-size: small;
+}
+
 nav {
   display: none;
   left: -250px;
@@ -120,6 +126,7 @@ h1 {
   display: inline;
   font-size: small;
   padding-left: .5em;
+  flex-grow: 1;
 }
 
 nav ul {
@@ -375,7 +382,6 @@ header {
   flex-direction: row;
   z-index: 3;
   align-items: center;
-  padding-left: 1em;
   padding-bottom: .2em;
   padding-top: 1em;
   position: fixed;