diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-07 10:47:10 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-07 11:06:46 +0200 |
commit | fea294bb29a2b58e93993914c11603278ebc7456 (patch) | |
tree | 4a1d5f6ba99b7df63117b383b7e64302de237bab /core/src | |
parent | 16e1d1cb12229270d61d89dfda93399d056d456c (diff) | |
download | nextcloud-server-fea294bb29a2b58e93993914c11603278ebc7456.tar.gz nextcloud-server-fea294bb29a2b58e93993914c11603278ebc7456.zip |
Move unified search to OCS api
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/services/UnifiedSearchService.js | 11 | ||||
-rw-r--r-- | core/src/views/UnifiedSearch.vue | 22 |
2 files changed, 17 insertions, 16 deletions
diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js index 60f78e8cd2f..c52cf5e46f7 100644 --- a/core/src/services/UnifiedSearchService.js +++ b/core/src/services/UnifiedSearchService.js @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import { generateUrl } from '@nextcloud/router' +import { generateOcsUrl } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' import axios from '@nextcloud/axios' @@ -35,15 +35,15 @@ export const regexFilterNot = /-in:([a-z_-]+)/ig */ export async function getTypes() { try { - const { data } = await axios.get(generateUrl('/search/providers'), { + const { data } = await axios.get(generateOcsUrl('search', 2) + 'providers', { params: { // Sending which location we're currently at from: window.location.pathname.replace('/index.php', '') + window.location.search, }, }) - if (Array.isArray(data) && data.length > 0) { + if ('ocs' in data && 'data' in data.ocs && Array.isArray(data.ocs.data) && data.ocs.data.length > 0) { // Providers are sorted by the api based on their order key - return data + return data.ocs.data } } catch (error) { console.error(error) @@ -60,8 +60,9 @@ export async function getTypes() { * @returns {Promise} */ export function search(type, query, cursor) { - return axios.get(generateUrl(`/search/providers/${type}/search?term=${query}`), { + return axios.get(generateOcsUrl('search', 2) + `providers/${type}/search`, { params: { + term: query, cursor, // Sending which location we're currently at from: window.location.pathname.replace('/index.php', '') + window.location.search, diff --git a/core/src/views/UnifiedSearch.vue b/core/src/views/UnifiedSearch.vue index 1ce55f0675f..3406cd9db09 100644 --- a/core/src/views/UnifiedSearch.vue +++ b/core/src/views/UnifiedSearch.vue @@ -363,23 +363,23 @@ export default { const request = await search(type, query) // Process results - if (request.data.entries.length > 0) { - this.$set(this.results, type, request.data.entries) + if (request.data.ocs.data.entries.length > 0) { + this.$set(this.results, type, request.data.ocs.data.entries) } else { this.$delete(this.results, type) } // Save cursor if any - if (request.data.cursor) { - this.$set(this.cursors, type, request.data.cursor) - } else if (!request.data.isPaginated) { + if (request.data.ocs.data.cursor) { + this.$set(this.cursors, type, request.data.ocs.data.cursor) + } else if (!request.data.ocs.data.isPaginated) { // If no cursor and no pagination, we save the default amount // provided by server's initial state `defaultLimit` this.$set(this.limits, type, this.defaultLimit) } // Check if we reached end of pagination - if (request.data.entries.length < this.defaultLimit) { + if (request.data.ocs.data.entries.length < this.defaultLimit) { this.$set(this.reached, type, true) } @@ -410,16 +410,16 @@ export default { const request = await search(type, this.query, this.cursors[type]) // Save cursor if any - if (request.data.cursor) { - this.$set(this.cursors, type, request.data.cursor) + if (request.data.ocs.data.cursor) { + this.$set(this.cursors, type, request.data.ocs.data.cursor) } - if (request.data.entries.length > 0) { - this.results[type].push(...request.data.entries) + if (request.data.ocs.data.entries.length > 0) { + this.results[type].push(...request.data.ocs.data.entries) } // Check if we reached end of pagination - if (request.data.entries.length < this.defaultLimit) { + if (request.data.ocs.data.entries.length < this.defaultLimit) { this.$set(this.reached, type, true) } } else |