diff --git a/core/src/components/show-plugin.js b/core/src/components/show-plugin.js index e85131b8..92651ef6 100644 --- a/core/src/components/show-plugin.js +++ b/core/src/components/show-plugin.js @@ -182,10 +182,14 @@ class ShowPlugin extends connect(store)(LitElement) { diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index ef110ef1..3441ad0a 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -112,6 +112,10 @@ class WebBrowser extends LitElement { font-size: 16px; background-color: var(--white); } + input { + outline: none + } + paper-progress { --paper-progress-active-color: var(--mdc-theme-primary); @@ -236,7 +240,75 @@ class WebBrowser extends LitElement { }) } + async extractComponents(url) { + if (!url.startsWith("qortal://")) { + return null; + } + + url = url.replace(/^(qortal\:\/\/)/, ""); + if (url.includes("/")) { + let parts = url.split("/"); + const service = parts[0].toUpperCase(); + parts.shift(); + const name = parts[0]; + parts.shift(); + let identifier; + + if (parts.length > 0) { + identifier = parts[0]; // Do not shift yet + // Check if a resource exists with this service, name and identifier combination + let responseObj = await parentEpml.request('apiCall', { + url: `/arbitrary/resource/status/${service}/${name}/${identifier}?apiKey=${this.getApiKey()}` + }) + + if (responseObj.totalChunkCount > 0) { + // Identifier exists, so don't include it in the path + parts.shift(); + } + else { + identifier = null; + } + } + + const path = parts.join("/"); + + const components = {}; + components["service"] = service; + components["name"] = name; + components["identifier"] = identifier; + components["path"] = path; + return components; + } + + return null; + } + + async _handleKeyDown(e) { + if (e.key === 'Enter') { + const value = e.target.value + let newQuery = value; + if (newQuery.endsWith('/')) { + newQuery = newQuery.slice(0, -1); + } + const res = await this.extractComponents(newQuery) + if (!res) return + const { service, name, identifier, path } = res + let query = `?service=${service}` + if (name) { + query = query + `&name=${name}` + } + if (identifier) { + query = query + `&identifier=${identifier}` + } + if (path) { + query = query + `&path=${path}` + } + window.location = window.location.origin + window.location.pathname + query + } + } + render() { + return html`
@@ -245,7 +317,7 @@ class WebBrowser extends LitElement { this.goForward()} title="${translate('browserpage.bchange1')}" class="address-bar-button">arrow_forward_ios this.refresh()} title="${translate('browserpage.bchange2')}" class="address-bar-button">refresh this.goBackToList()} title="${translate('browserpage.bchange3')}" class="address-bar-button">home - + ${this.renderFullScreen()} this.delete()} title="${translate('browserpage.bchange4')} ${this.service} ${this.name} ${translate('browserpage.bchange5')}" class="address-bar-button float-right">delete ${this.renderBlockUnblockButton()}