From 469c1af0efd53457c9c0a2429fea12610ea053a2 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 17 Mar 2023 22:11:34 +0000 Subject: [PATCH] Added new search features to the SEARCH_QDN_RESOURCES action. Existing action renamed to LIST_QDN_RESOURCES, which is an alternative for listing QDN resources without using a search query. --- Q-Apps.md | 28 +++++++++++++++++++++++----- src/main/resources/q-apps/q-apps.js | 21 ++++++++++++++++++--- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Q-Apps.md b/Q-Apps.md index 75e78164..a0a7e344 100644 --- a/Q-Apps.md +++ b/Q-Apps.md @@ -138,6 +138,7 @@ Here is a list of currently supported actions: - GET_ACCOUNT_DATA - GET_ACCOUNT_NAMES - GET_NAME_DATA +- LIST_QDN_RESOURCES - SEARCH_QDN_RESOURCES - GET_QDN_RESOURCE_STATUS - FETCH_QDN_RESOURCE @@ -209,16 +210,33 @@ let res = await qortalRequest({ ``` +### List QDN resources +``` +let res = await qortalRequest({ + action: "LIST_QDN_RESOURCES", + service: "THUMBNAIL", + identifier: "qortal_avatar", // Optional + default: true, // Optional + includeStatus: false, // Optional - will take time to respond, so only request if necessary + includeMetadata: false, // Optional - will take time to respond, so only request if necessary + limit: 100, + offset: 0, + reverse: true +}); +``` + ### Search QDN resources ``` let res = await qortalRequest({ action: "SEARCH_QDN_RESOURCES", service: "THUMBNAIL", - identifier: "qortal_avatar", // Optional - default: true, // Optional - nameListFilter: "FollowedNames", // Optional - includeStatus: false, - includeMetadata: false, + query: "search query goes here", // Optional - searches both "identifier" and "name" fields + identifier: "search query goes here", // Optional - searches only the "identifier" field + name: "search query goes here", // Optional - searches only the "name" field + prefix: false, // Optional - if true, only the beginning of fields are matched in all of the above filters + default: false, // Optional - if true, only resources without identifiers are returned + includeStatus: false, // Optional - will take time to respond, so only request if necessary + includeMetadata: false, // Optional - will take time to respond, so only request if necessary limit: 100, offset: 0, reverse: true diff --git a/src/main/resources/q-apps/q-apps.js b/src/main/resources/q-apps/q-apps.js index 40c8716c..bc93b45c 100644 --- a/src/main/resources/q-apps/q-apps.js +++ b/src/main/resources/q-apps/q-apps.js @@ -155,12 +155,27 @@ window.addEventListener("message", (event) => { window.location = buildResourceUrl(data.service, data.name, data.identifier, data.path); break; - case "SEARCH_QDN_RESOURCES": + case "LIST_QDN_RESOURCES": url = "/arbitrary/resources?"; if (data.service != null) url = url.concat("&service=" + data.service); if (data.identifier != null) url = url.concat("&identifier=" + data.identifier); - if (data.default != null) url = url.concat("&default=" + data.default); - if (data.nameListFilter != null) url = url.concat("&namefilter=" + data.nameListFilter); + if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString()); + if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString()); + if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString()); + if (data.limit != null) url = url.concat("&limit=" + data.limit); + if (data.offset != null) url = url.concat("&offset=" + data.offset); + if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString()); + response = httpGet(url); + break; + + case "SEARCH_QDN_RESOURCES": + url = "/arbitrary/resources/search?"; + if (data.service != null) url = url.concat("&service=" + data.service); + if (data.query != null) url = url.concat("&query=" + data.query); + if (data.identifier != null) url = url.concat("&identifier=" + data.identifier); + if (data.name != null) url = url.concat("&name=" + data.name); + if (data.prefix != null) url = url.concat("&prefix=" + new Boolean(data.prefix).toString()); + if (data.default != null) url = url.concat("&default=" + new Boolean(data.default).toString()); if (data.includeStatus != null) url = url.concat("&includestatus=" + new Boolean(data.includeStatus).toString()); if (data.includeMetadata != null) url = url.concat("&includemetadata=" + new Boolean(data.includeMetadata).toString()); if (data.limit != null) url = url.concat("&limit=" + data.limit);