diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index a8d7cdc..b0307ef 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -78,9 +78,12 @@ class SettingsController extends ApiController { * @NoAdminRequired */ public function setMenuState($menuState = ""): JSONResponse { + if ($menuState == 'SEARCH') { + return true; + }; $legalArguments = ['TOP', 'RECENT', 'NEW', 'FAVORITES', 'CATEGORIES']; if (!in_array($menuState, $legalArguments)) { - $menuState = 'TOP'; + return new JSONResponse(['status' => 'error'], Http::STATUS_BAD_REQUEST); } return $this->setSetting( 'menuState', diff --git a/src/components/Main.vue b/src/components/Main.vue index e0ec6d7..3e60ea4 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -75,10 +75,9 @@ export default { }, created() { this.loadSettings() - console.log('my route ', this.$route.name) }, mounted() { - this.loadStations() + this.onRoute() this.scroll() }, methods: { @@ -162,6 +161,8 @@ export default { loadStations(menuState = 'TOP') { const vm = this + const queryBase = this.$apiUrl + '/json/stations' + if (vm.offset === 0) { vm.pageLoading = true } @@ -173,7 +174,13 @@ export default { 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, order: sortBy,