From 64bbd383de64c07a48fca9b769f54a68eaa1cf6b Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 13 Apr 2024 16:52:30 -0400 Subject: [PATCH] Trying to make the navigation bar fit again with a new dropdown. Good grief, CSS. --- core/client.js | 63 +++++++++++++++++++++++++------------------------- src/httpd.js.c | 4 ++-- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/core/client.js b/core/client.js index bcb0ffdf..522c786e 100644 --- a/core/client.js +++ b/core/client.js @@ -100,10 +100,10 @@ class TfNavigationElement extends LitElement { get_spark_line(key, options) { if (!this.spark_lines[key]) { let spark_line = document.createElement('tf-sparkline'); - spark_line.style.display = 'flex'; - spark_line.style.flexDirection = 'row'; - spark_line.style.flex = '0 50 5em'; spark_line.title = key; + spark_line.classList.add('w3-bar-item'); + spark_line.classList.add('w3-hide-small'); + spark_line.style.paddingRight = '0'; if (options) { if (options.max) { spark_line.max = options.max; @@ -121,11 +121,11 @@ class TfNavigationElement extends LitElement { */ render_login() { if (this?.credentials?.session?.name) { - return html`logout ${this.credentials.session.name}`; } else { - return html`login`; } @@ -145,8 +145,8 @@ class TfNavigationElement extends LitElement { `; @@ -155,7 +155,7 @@ class TfNavigationElement extends LitElement { `; @@ -210,6 +210,7 @@ class TfNavigationElement extends LitElement { render() { let self = this; return html` +
(this.show_version = !this.show_version)} >😎 ${this.version?.number} TF apps edit (self.show_permissions = !self.show_permissions)} >🎛️ - ${this.status.message} - + ${status.message ? html` + ${this.status.message} + ` : undefined} ${this.render_permissions()} - ${Object.keys(this.spark_lines) - .sort() - .map((x) => this.spark_lines[x]) - .map((x) => [ - html`${x.dataset.emoji}`, - x, - ])} + ${Object.keys(this.spark_lines) + .sort() + .map((x) => this.spark_lines[x])} + ${this.render_login()} ${this.render_identity()} - ${this.render_login()}
`; } @@ -619,13 +618,13 @@ class TfSparkLineElement extends LitElement { ) / 10.0; return html` ${this.lines.map((x) => this.render_line(x))} - ${max} + ${this.dataset.emoji}${max} `; diff --git a/src/httpd.js.c b/src/httpd.js.c index 4b764e84..aabb5cf1 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -328,8 +328,8 @@ static JSValue _httpd_websocket_upgrade(JSContext* context, JSValueConst this_va const char* session = tf_http_get_cookie(tf_http_request_get_header(request, "cookie"), "session"); JSValue jwt = _authenticate_jwt(context, session); tf_free((void*)session); - JSValue name = JS_GetPropertyStr(context, jwt, "name"); - const char* name_string = JS_ToCString(context, name); + JSValue name = !JS_IsUndefined(jwt) ? JS_GetPropertyStr(context, jwt, "name") : JS_UNDEFINED; + const char* name_string = !JS_IsUndefined(name) ? JS_ToCString(context, name) : NULL; const char* session_token = _make_session_jwt(ssb, name_string); const char* cookie = _make_set_session_cookie_header(request, session_token); tf_free((void*)session_token);