Rejiggled error display.

This commit is contained in:
Cory McWilliams 2024-04-17 20:56:33 -04:00
parent 848ef21c7c
commit 5448e773d8
4 changed files with 75 additions and 42 deletions

View File

@ -207,9 +207,7 @@ class TfIssuesAppElement extends LitElement {
} }
render() { render() {
let header = html` let header = html` <h1>Tilde Friends Issues</h1> `;
<h1>Tilde Friends Issues</h1>
`;
if (this.selected) { if (this.selected) {
return html` return html`
${header} ${header}

View File

@ -141,12 +141,21 @@ function socket(request, response, client) {
} }
} }
response.send( response.send(
JSON.stringify(Object.assign({ JSON.stringify(
action: 'session', Object.assign(
credentials: credentials, {
parentApp: parentApp, action: 'session',
id: blobId, credentials: credentials,
}, await core.getIdentityInfo(credentials?.session?.name, packageOwner, packageName))), parentApp: parentApp,
id: blobId,
},
await core.getIdentityInfo(
credentials?.session?.name,
packageOwner,
packageName
)
)
),
0x1 0x1
); );

View File

@ -169,15 +169,35 @@ class TfNavigationElement extends LitElement {
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%" style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%"
@click=${self.toggle_id_dropdown} @click=${self.toggle_id_dropdown}
> >
${self.names[this.identity]}${self.names[this.identity] === this.identity ? '' : html` - ${this.identity}`} ${self.names[this.identity]}${self.names[this.identity] ===
this.identity
? ''
: html` - ${this.identity}`}
</button> </button>
<div id="id_dropdown" class="w3-dropdown-content w3-bar-block w3-card-4" style="max-width: 100%"> <div
<button class="w3-bar-item w3-button w3-border" @click=${() => window.location.href = "/~core/identity"}>Manage Identities...</button> id="id_dropdown"
<button class="w3-bar-item w3-button w3-border" @click=${self.edit_profile}>Edit Profile...</button> class="w3-dropdown-content w3-bar-block w3-card-4"
style="max-width: 100%"
>
<button
class="w3-bar-item w3-button w3-border"
@click=${() => (window.location.href = '/~core/identity')}
>
Manage Identities...
</button>
<button
class="w3-bar-item w3-button w3-border"
@click=${self.edit_profile}
>
Edit Profile...
</button>
${this.identities.map( ${this.identities.map(
(x) => html` (x) => html`
<button <button
class="w3-bar-item w3-button ${x === self.identity ? 'w3-cyan' : ''}" class="w3-bar-item w3-button ${x === self.identity
? 'w3-cyan'
: ''}"
@click=${() => self.set_active_identity(x)} @click=${() => self.set_active_identity(x)}
style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap"
> >
@ -243,6 +263,10 @@ class TfNavigationElement extends LitElement {
} }
} }
clear_error() {
this.status = {};
}
/** /**
* TODOC * TODOC
* @returns * @returns
@ -319,22 +343,23 @@ class TfNavigationElement extends LitElement {
@click=${() => (self.show_permissions = !self.show_permissions)} @click=${() => (self.show_permissions = !self.show_permissions)}
>🎛</a >🎛</a
> >
${status.message
? html`
<span
class="w3-bar-item"
style="vertical-align: top; white-space: pre; color: ${this
.status.color ?? kErrorColor}"
>${this.status.message}</span
>
`
: undefined}
${this.render_permissions()} ${this.render_permissions()}
${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
? html`
<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">
<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>
<div style="color: ${this.status.color ?? kErrorColor}"><b>ERROR:</b><p style="white-space: pre">${this.status.message}</p></div>
</div>
</div>
`
: undefined}
`; `;
} }
} }

View File

@ -540,13 +540,18 @@ async function getProcessBlob(blobId, key, options) {
}, },
}; };
process.sendIdentities = async function () { process.sendIdentities = async function () {
process.app.send(Object.assign({ process.app.send(
action: 'identities', Object.assign(
}, await getIdentityInfo( {
process?.credentials?.session?.name, action: 'identities',
options?.packageOwner, },
options?.packageName await getIdentityInfo(
))); process?.credentials?.session?.name,
options?.packageOwner,
options?.packageName
)
)
);
}; };
process.setActiveIdentity = async function (identity) { process.setActiveIdentity = async function (identity) {
if ( if (
@ -586,7 +591,7 @@ async function getProcessBlob(blobId, key, options) {
process.credentials?.session?.name, process.credentials?.session?.name,
options.packageOwner, options.packageOwner,
options.packageName options.packageName
) ),
] ]
); );
return id; return id;
@ -1555,14 +1560,13 @@ async function getActiveIdentity(user, packageOwner, packageName) {
} }
async function getIdentityInfo(user, packageOwner, packageName) { async function getIdentityInfo(user, packageOwner, packageName) {
let identities = await ssb.getIdentities( let identities = await ssb.getIdentities(user);
user
);
let names = new Object(); let names = new Object();
for (let identity of identities) { for (let identity of identities) {
names[identity] = identity; names[identity] = identity;
} }
await ssb.sqlAsync(` await ssb.sqlAsync(
`
SELECT author, name FROM ( SELECT author, name FROM (
SELECT SELECT
messages.author, messages.author,
@ -1577,15 +1581,12 @@ async function getIdentityInfo(user, packageOwner, packageName) {
[JSON.stringify(identities)], [JSON.stringify(identities)],
function (row) { function (row) {
names[row.author] = row.name; names[row.author] = row.name;
}); }
);
return { return {
identities: identities, identities: identities,
identity: await getActiveIdentity( identity: await getActiveIdentity(user, packageOwner, packageName),
user,
packageOwner,
packageName
),
names: names, names: names,
}; };
} }