From 7a9b72a33a6bcd8e78fd9b71a5edd9f8a1765f6e Mon Sep 17 00:00:00 2001 From: Jiiks Date: Tue, 4 Dec 2018 09:30:49 +0200 Subject: [PATCH] Initial search --- client/src/dev/serveremu.js | 19 ++++++++++++++----- client/src/ui/components/bd/ThemesView.vue | 6 +++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/src/dev/serveremu.js b/client/src/dev/serveremu.js index b66d6af1..11a823d5 100644 --- a/client/src/dev/serveremu.js +++ b/client/src/dev/serveremu.js @@ -7,12 +7,20 @@ export default class ServerEmu { await new Promise(r => setTimeout(r, Math.random() * 3000)); + let docs = this._themes; + + if (args && args.sterm) { + const { sterm } = args; + const reg = new RegExp(sterm, 'gi'); + docs = docs.filter(doc => doc.tags.includes(sterm) || reg.exec(doc.name) || reg.exec(doc.description)); + } + return { - docs: this._themes, + docs, pagination: { - total: this._themes.length, - pages: this._themes.length / 9, - limit: 0, + total: docs.length, + pages: docs.length / 9, + limit: 9, page: 1 } } @@ -39,7 +47,8 @@ export default class ServerEmu { version: this.randomVersion(), repository: this.dummyRepo, files: this.dummyFiles, - author: this.dummyAuthor + author: this.dummyAuthor, + description: '' }); } diff --git a/client/src/ui/components/bd/ThemesView.vue b/client/src/ui/components/bd/ThemesView.vue index 8b583b52..56cc20c4 100644 --- a/client/src/ui/components/bd/ThemesView.vue +++ b/client/src/ui/components/bd/ThemesView.vue @@ -98,12 +98,12 @@ async refreshLocal() { await this.ThemeManager.refreshThemes(); }, - async refreshOnline() { + async refreshOnline(sterm) { this.searchHint = ''; if (this.loadingOnline || this.loadingMore) return; this.loadingOnline = true; try { - const getThemes = await BdWebApi.themes.get(); + const getThemes = await BdWebApi.themes.get({ sterm }); this.onlineThemes = getThemes; if (!this.onlineThemes.docs) return; this.searchHint = `${this.onlineThemes.pagination.total} Results`; @@ -142,7 +142,7 @@ }, searchInput(e) { if (this.loadingOnline || this.loadingMore) return; - this.refreshOnline(); + this.refreshOnline(e.target.value); }, async scrollend(e) { if (this.loadingOnline || this.loadingMore) return;