Don't pop up the error modal for connecting/status messages.

This commit is contained in:
Cory McWilliams 2024-04-18 12:46:06 -04:00
parent 96037d4da6
commit bd14168627

View File

@ -344,22 +344,28 @@ class TfNavigationElement extends LitElement {
>🎛</a >🎛</a
> >
${this.render_permissions()} ${this.render_permissions()}
${this.status?.message && !this.status.is_error
? html`
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
<div class="w3-bar-item" style="color: ${this.status.color ?? kStatusColor}">${this.status.message}</div>
`
: undefined}
${Object.keys(this.spark_lines) ${Object.keys(this.spark_lines)
.sort() .sort()
.map((x) => this.spark_lines[x])} .map((x) => this.spark_lines[x])}
${this.render_login()} ${this.render_identity()} ${this.render_login()} ${this.render_identity()}
</div> </div>
${this.status.message ${this.status?.is_error
? html` ? html`
<link type="text/css" rel="stylesheet" href="/static/w3.css" /> <link type="text/css" rel="stylesheet" href="/static/w3.css" />
<div class="w3-model w3-animate-top" style="position: absolute; left: 50%; transform: translate(-50%); z-index: 1"> <div class="w3-model w3-animate-top" style="position: absolute; left: 50%; transform: translate(-50%); z-index: 1">
<dijv class="w3-modal-content w3-card-4" style="display: block; padding: 1em"> <dijv class="w3-modal-content w3-card-4" style="display: block; padding: 1em">
<span @click=${self.clear_error} class="w3-button w3-display-topright">&times;</span> <span @click=${self.clear_error} class="w3-button w3-display-topright">&times;</span>
<div style="color: ${this.status.color ?? kErrorColor}"><b>ERROR:</b><p style="white-space: pre">${this.status.message}</p></div> <div style="color: ${this.status.color ?? kErrorColor}"><b>ERROR:</b><p style="white-space: pre">${this.status.message}</p></div>
</div>
</div> </div>
` </div>
: undefined} `
: undefined}
`; `;
} }
} }
@ -1105,9 +1111,9 @@ function api_postMessage(message) {
function api_error(error) { function api_error(error) {
if (error) { if (error) {
if (typeof error == 'string') { if (typeof error == 'string') {
setStatusMessage('⚠️ ' + error, '#f00'); setStatusMessage('⚠️ ' + error, kErrorColor);
} else { } else {
setStatusMessage('⚠️ ' + error.message + '\n' + error.stack, '#f00'); setStatusMessage('⚠️ ' + error.message + '\n' + error.stack, kErrorColor);
} }
} }
console.log('error', error); console.log('error', error);
@ -1324,6 +1330,7 @@ function setStatusMessage(message, color) {
document.getElementsByTagName('tf-navigation')[0].status = { document.getElementsByTagName('tf-navigation')[0].status = {
message: message, message: message,
color: color, color: color,
is_error: color == kErrorColor,
}; };
} }