starting to implement search page

This commit is contained in:
Jonas Heinrich 2020-11-05 10:20:16 +01:00
parent d016d6fb16
commit d29fc6c8f6
2 changed files with 14 additions and 4 deletions

View File

@ -78,9 +78,12 @@ class SettingsController extends ApiController {
* @NoAdminRequired * @NoAdminRequired
*/ */
public function setMenuState($menuState = ""): JSONResponse { public function setMenuState($menuState = ""): JSONResponse {
if ($menuState == 'SEARCH') {
return true;
};
$legalArguments = ['TOP', 'RECENT', 'NEW', 'FAVORITES', 'CATEGORIES']; $legalArguments = ['TOP', 'RECENT', 'NEW', 'FAVORITES', 'CATEGORIES'];
if (!in_array($menuState, $legalArguments)) { if (!in_array($menuState, $legalArguments)) {
$menuState = 'TOP'; return new JSONResponse(['status' => 'error'], Http::STATUS_BAD_REQUEST);
} }
return $this->setSetting( return $this->setSetting(
'menuState', 'menuState',

View File

@ -75,10 +75,9 @@ export default {
}, },
created() { created() {
this.loadSettings() this.loadSettings()
console.log('my route ', this.$route.name)
}, },
mounted() { mounted() {
this.loadStations() this.onRoute()
this.scroll() this.scroll()
}, },
methods: { methods: {
@ -162,6 +161,8 @@ export default {
loadStations(menuState = 'TOP') { loadStations(menuState = 'TOP') {
const vm = this const vm = this
const queryBase = this.$apiUrl + '/json/stations'
if (vm.offset === 0) { if (vm.offset === 0) {
vm.pageLoading = true vm.pageLoading = true
} }
@ -173,7 +174,13 @@ export default {
sortBy = 'lastchangetime' sortBy = 'lastchangetime'
} }
this.$jquery.getJSON(this.$apiUrl + '/json/stations', let queryURI = queryBase
if (menuState === 'SEARCH') {
const searchQuery = vm.$route.params.query
queryURI = queryBase + '/byname/' + searchQuery
}
this.$jquery.getJSON(queryURI,
{ {
limit: 20, limit: 20,
order: sortBy, order: sortBy,