diff --git a/gui/app/components/search/search-view.js b/gui/app/components/search/search-view.js index 80d543c5..2f88a2f1 100644 --- a/gui/app/components/search/search-view.js +++ b/gui/app/components/search/search-view.js @@ -17,20 +17,43 @@ export default Component.extend({ searchSvc: service('search'), results: A([]), validSearch: true, + keywords: '' , + matchFilter: null, - init() { + // init() { + // this._super(...arguments); + // }, + + didReceiveAttrs() { this._super(...arguments); + this.set('keywords', this.get('filter')); + this.set('matchFilter', this.get('matchFilter')); this.fetch(); + console.log('receive a'); }, + didReceiveAttrs() { + this._super(...arguments); + // this.set('keywords', this.get('filter')); + this.set('matchFilter', this.get('matchFilter')); + this.fetch(); + console.log('update a'); + }, + + // didUpdateAttrs() { + // this._super(...arguments); + // this.fetch(); + // console.log('update a'); + // }, + fetch() { let payload = { - keywords: this.get('filter'), - doc: this.get('matchDoc'), - attachment: this.get('matchFile'), - tag: this.get('matchTag'), - content: this.get('matchContent'), - slog: this.get('slog') + keywords: this.get('keywords'), + doc: this.get('matchFilter.matchDoc'), + attachment: this.get('matchFilter.matchFile'), + tag: this.get('matchFilter.matchTag'), + content: this.get('matchFilter.matchContent'), + slog: this.get('matchFilter.slog') }; payload.keywords = payload.keywords.trim(); @@ -51,7 +74,7 @@ export default Component.extend({ actions: { onSearch() { - if (this.get('filter').trim().length < 3) { + if (this.get('keywords').trim().length < 3) { this.set('validSearch', false); return; } diff --git a/gui/app/pods/search/controller.js b/gui/app/pods/search/controller.js index 6e2a26a7..fc8d845f 100644 --- a/gui/app/pods/search/controller.js +++ b/gui/app/pods/search/controller.js @@ -14,12 +14,11 @@ import Controller from '@ember/controller'; export default Controller.extend({ appMeta: service(), - queryParams: ['filter', 'matchDoc', 'matchContent', 'matchTag', 'matchFile', 'slog'], filter: '', matchDoc: true, matchContent: true, matchTag: true, matchFile: true, - slog: false, + slog: false }); diff --git a/gui/app/pods/search/route.js b/gui/app/pods/search/route.js index 5efb5ab3..e157710c 100644 --- a/gui/app/pods/search/route.js +++ b/gui/app/pods/search/route.js @@ -13,6 +13,27 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout import Route from '@ember/routing/route'; export default Route.extend(AuthenticatedRouteMixin, { + matchFilter: null, + + beforeModel(transition) { + let matchFilter = { + matchDoc: is.undefined(transition.to.queryParams.matchDoc) ? true : (transition.to.queryParams.matchDoc == 'true'), + matchContent: is.undefined(transition.to.queryParams.matchContent) ? true : (transition.to.queryParams.matchContent == 'true'), + matchTag: is.undefined(transition.to.queryParams.matchTag) ? true : (transition.to.queryParams.matchTag == 'true'), + matchFile: is.undefined(transition.to.queryParams.matchFile) ? true : (transition.to.queryParams.matchFile == 'true'), + slog: is.undefined(transition.to.queryParams.slog) ? false : (transition.to.queryParams.slog === 'true'), + }; + + this.set('matchFilter', matchFilter); + }, + + setupController: function (controller, model) { + this._super(controller, model); + + controller.set('model', model); + controller.set('matchFilter', this.get('matchFilter')); + }, + activate() { this.get('browser').setTitle('Search'); } diff --git a/gui/app/pods/search/template.hbs b/gui/app/pods/search/template.hbs index 791c321a..4fe16ee7 100644 --- a/gui/app/pods/search/template.hbs +++ b/gui/app/pods/search/template.hbs @@ -5,19 +5,19 @@
Your search query is too short