diff --git a/qortal-ui-plugins/plugins/core/qdn/publish/publish.src.js b/qortal-ui-plugins/plugins/core/qdn/publish/publish.src.js
index 8caa1e43..c68a25da 100644
--- a/qortal-ui-plugins/plugins/core/qdn/publish/publish.src.js
+++ b/qortal-ui-plugins/plugins/core/qdn/publish/publish.src.js
@@ -22,7 +22,11 @@ class PublishData extends LitElement {
showName: { type: Boolean },
showService: { type: Boolean },
showIdentifier: { type: Boolean },
+ showMetadata: { type: Boolean },
+ tags: { type: Array },
serviceLowercase: { type: String },
+ metadata: { type: Array },
+ categories: { type: Array },
names: { type: Array },
registeredName: { type: String },
selectedName: { type: String },
@@ -101,11 +105,37 @@ class PublishData extends LitElement {
- this.selectName(e)} style="min-width: 130px; max-width:100%; width:100%;">
- ${this.registeredName}
+ this.selectName(e)} style="min-width: 130px; max-width:100%; width:100%;">
+
+ ${this.registeredName}
+
+
+
+
+
+
+
+
+
+
+ ${this.categories.map((c, index) => html`
+ ${c.name}
+ `)}
+
+
+
+
+
+
+
+
+
+
+
${this.renderUploadField()}
+
@@ -279,15 +309,27 @@ class PublishData extends LitElement {
postBody = Buffer.from(fileBuffer).toString('base64');
}
- let uploadDataUrl = `/arbitrary/${this.service}/${registeredName}${urlSuffix}`
+ // Optional metadata
+ let title = encodeURIComponent(this.shadowRoot.getElementById('title').value);
+ let description = encodeURIComponent(this.shadowRoot.getElementById('description').value);
+ let category = encodeURIComponent(this.shadowRoot.getElementById('category').value);
+ let tag1 = encodeURIComponent(this.shadowRoot.getElementById('tag1').value);
+ let tag2 = encodeURIComponent(this.shadowRoot.getElementById('tag2').value);
+ let tag3 = encodeURIComponent(this.shadowRoot.getElementById('tag3').value);
+ let tag4 = encodeURIComponent(this.shadowRoot.getElementById('tag4').value);
+ let tag5 = encodeURIComponent(this.shadowRoot.getElementById('tag5').value);
+
+ let metadataQueryString = `title=${title}&description=${description}&category=${category}&tags=${tag1}&tags=${tag2}&tags=${tag3}&tags=${tag4}&tags=${tag5}`
+
+ let uploadDataUrl = `/arbitrary/${this.service}/${registeredName}${urlSuffix}?${metadataQueryString}&apiKey=${this.getApiKey()}`
if (identifier != null && identifier.trim().length > 0) {
- uploadDataUrl = `/arbitrary/${service}/${registeredName}/${this.identifier}${urlSuffix}`
+ uploadDataUrl = `/arbitrary/${service}/${registeredName}/${this.identifier}${urlSuffix}?${metadataQuery}&apiKey=${this.getApiKey()}`
}
let uploadDataRes = await parentEpml.request('apiCall', {
type: 'api',
method: 'POST',
- url: `${uploadDataUrl}?apiKey=${this.getApiKey()}`,
+ url: `${uploadDataUrl}`,
body: `${postBody}`,
})
@@ -389,6 +431,7 @@ class PublishData extends LitElement {
this.showName = false;
this.showService = false
this.showIdentifier = false
+ this.showMetadata = false;
const urlParams = new URLSearchParams(window.location.search)
this.name = urlParams.get('name')
@@ -406,6 +449,9 @@ class PublishData extends LitElement {
if (urlParams.get('showIdentifier') === "true") {
this.showIdentifier = true
}
+ if (urlParams.get('showMetadata') === "true") {
+ this.showMetadata = true
+ }
if (this.identifier != null) {
if (this.identifier === "null" || this.identifier.trim().length == 0) {
@@ -413,6 +459,9 @@ class PublishData extends LitElement {
}
}
+ this.categories = [];
+ this.tags = ["tag 1", "tag 2", "tag 3", "tag 4", "tag 5"];
+
// Default to true so the message doesn't appear and disappear quickly
this.portForwardingEnabled = true
this.names = []
@@ -440,6 +489,17 @@ class PublishData extends LitElement {
setTimeout(fetchNames, this.config.user.nodeSettings.pingInterval)
}
+ const fetchCategories = () => {
+ parentEpml.request('apiCall', {
+ url: `/arbitrary/categories`
+ }).then(res => {
+
+ setTimeout(() => {
+ this.categories = res
+ }, 1)
+ })
+ }
+
const fetchPeersSummary = () => {
parentEpml.request('apiCall', {
url: `/peers/summary`
@@ -463,6 +523,7 @@ class PublishData extends LitElement {
parentEpml.subscribe('config', c => {
if (!configLoaded) {
setTimeout(fetchNames, 1)
+ setTimeout(fetchCategories, 1)
setTimeout(fetchPeersSummary, 1)
configLoaded = true
}
@@ -496,9 +557,30 @@ class PublishData extends LitElement {
}
}
- selectName(e) {
- const name = this.shadowRoot.getElementById('registeredName').innerHTML
+ fetchResourceMetadata() {
+ let identifier = this.identifier != null ? this.identifier : "default";
+
+ parentEpml.request('apiCall', {
+ url: `/arbitrary/metadata/${this.service}/${this.name}/${identifier}?apiKey=${this.getApiKey()}`
+ }).then(res => {
+
+ setTimeout(() => {
+ this.metadata = res
+ if (this.metadata != null && this.metadata.category != null) {
+ this.shadowRoot.getElementById('category').value = this.metadata.category;
+ }
+ else {
+ this.shadowRoot.getElementById('category').value = "";
+ }
+ }, 1)
+ })
+ }
+
+ selectName() {
+ const name = this.shadowRoot.getElementById('registeredName').value
this.selectedName = name
+ this.name = name
+ this.fetchResourceMetadata();
}
getApiKey() {