diff --git a/core/client.js b/core/client.js index 5d522992..1d7b31e0 100644 --- a/core/client.js +++ b/core/client.js @@ -1,7 +1,6 @@ -import {LitElement, html} from '/static/lit/lit-all.min.js'; +import {LitElement, html, css} from '/static/lit/lit-all.min.js'; let gSocket; -let gCredentials; let gPermissions; let gCurrentFile; @@ -28,6 +27,106 @@ const k_api = { setHash: {args: ['hash'], func: api_setHash}, }; +const k_global_style = css` + a:link { + color: #268bd2; + } + + a:visited { + color: #6c71c4; + } + + a:hover { + color: #859900; + } + + a:active { + color: #2aa198; + } +`; + +class TfNavigationElement extends LitElement { + static get properties() { + return { + credentials: {type: Object}, + permissions: {type: Object}, + show_permissions: {type: Boolean}, + status: {type: Object}, + }; + } + + constructor() { + super(); + this.permissions = {}; + this.show_permissions = false; + this.status = {}; + } + + toggle_edit(event) { + event.preventDefault(); + if (editing()) { + closeEditor(); + } else { + edit(); + } + } + + reset_permission(key) { + send({action: "resetPermission", permission: key}); + } + + render_login() { + if (this?.credentials?.session?.name) { + return html`logout ${this.credentials.session.name}`; + } else { + return html`login`; + } + } + + render_permissions() { + if (this.show_permissions) { + return html` +
+
+
This app has the following permissions:
+ ${Object.keys(this.permissions).map(key => html` +
+ ${key}: ${this.permissions[key] ? 'โœ… Allowed' : 'โŒ Denied'} + +
+ `)} + +
+
+ `; + } + } + + render() { + let self = this; + return html` + + ๐Ÿ˜Ž + Tilde Friends + apps + edit + self.show_permissions = !self.show_permissions}>๐ŸŽ›๏ธ + ${this.status.message} + + ${this.render_permissions()} + + ${this.render_login()} + `; + } +} +customElements.define('tf-navigation', TfNavigationElement); + class TfFilesElement extends LitElement { static get properties() { return { @@ -68,6 +167,10 @@ class TfFilesElement extends LitElement {