From d016d6fb16612fb15888d2cea837bae86d4e3d37 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 5 Nov 2020 09:51:48 +0100 Subject: [PATCH] starting to implement search page --- appinfo/routes.php | 91 +++++++++++++++++++++++++++++------ src/components/Main.vue | 1 + src/components/Navigation.vue | 6 +++ src/router.js | 2 +- 4 files changed, 83 insertions(+), 17 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 7e77f72..51f07a7 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -27,21 +27,80 @@ return [ 'station_api' => ['url' => '/api/0.1/stations'] ], 'routes' => [ - // Web page templates - ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], - ['name' => 'page#index', 'url' => '/top', 'verb' => 'GET', 'postfix' => 'top'], - ['name' => 'page#index', 'url' => '/recent', 'verb' => 'GET', 'postfix' => 'recent'], - ['name' => 'page#index', 'url' => '/new', 'verb' => 'GET', 'postfix' => 'new'], - ['name' => 'page#index', 'url' => '/favorites', 'verb' => 'GET', 'postfix' => 'favorites'], - ['name' => 'page#index', 'url' => '/categories', 'verb' => 'GET', 'postfix' => 'categories'], - ['name' => 'page#index', 'url' => '/search', 'verb' => 'GET', 'postfix' => 'search'], - // Settings - ['name' => 'settings#set_menu_state', 'url' => '/settings/menuState', 'verb' => 'POST'], - ['name' => 'settings#get_menu_state', 'url' => '/settings/menuState', 'verb' => 'GET'], - ['name' => 'settings#set_volume_state', 'url' => '/settings/volumeState', 'verb' => 'POST'], - ['name' => 'settings#get_volume_state', 'url' => '/settings/volumeState', 'verb' => 'GET'], - // Api - ['name' => 'station_api#preflighted_cors', 'url' => '/api/0.1/{path}', - 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']] + + // Web page templates + [ + 'name' => 'page#index', + 'url' => '/', + 'verb' => 'GET' + ], + [ + 'name' => 'page#index', + 'url' => '/top', + 'verb' => 'GET', + 'postfix' => 'top' + ], + [ + 'name' => 'page#index', + 'url' => '/recent', + 'verb' => 'GET', + 'postfix' => 'recent' + ], + [ + 'name' => 'page#index', + 'url' => '/new', + 'verb' => 'GET', + 'postfix' => 'new' + ], + [ + 'name' => 'page#index', + 'url' => '/favorites', + 'verb' => 'GET', + 'postfix' => 'favorites' + ], + [ + 'name' => 'page#index', + 'url' => '/categories', + 'verb' => 'GET', + 'postfix' => 'categories' + ], + [ + 'name' => 'page#index', + 'url' => '/search/{query}', + 'verb' => 'GET', + 'postfix' => 'search', + 'requirements' => ['query' => '.+'], + ], + + // Settings + [ + 'name' => 'settings#set_menu_state', + 'url' => '/settings/menuState', + 'verb' => 'POST' + ], + [ + 'name' => 'settings#get_menu_state', + 'url' => '/settings/menuState', + 'verb' => 'GET' + ], + [ + 'name' => 'settings#set_volume_state', + 'url' => '/settings/volumeState', + 'verb' => 'POST' + ], + [ + 'name' => 'settings#get_volume_state', + 'url' => '/settings/volumeState', + 'verb' => 'GET' + ], + + // Api + [ + 'name' => 'station_api#preflighted_cors', + 'url' => '/api/0.1/{path}', + 'verb' => 'OPTIONS', + 'requirements' => ['path' => '.+'] + ] + ] ]; diff --git a/src/components/Main.vue b/src/components/Main.vue index 0e626df..e0ec6d7 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -75,6 +75,7 @@ export default { }, created() { this.loadSettings() + console.log('my route ', this.$route.name) }, mounted() { this.loadStations() diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue index 8767e2b..2f07ff5 100644 --- a/src/components/Navigation.vue +++ b/src/components/Navigation.vue @@ -22,6 +22,7 @@ icon="icon-files-dark" :title="t('radio', 'Categories')" /> @@ -45,5 +46,10 @@ export default { AppNavigationItem, Player, }, + computed: { + isSearch() { + return this.$route.name === 'SEARCH' + }, + }, } diff --git a/src/router.js b/src/router.js index ee1cab7..f55923d 100644 --- a/src/router.js +++ b/src/router.js @@ -39,7 +39,7 @@ const router = new Router({ name: 'CATEGORIES', }, { - path: '/search', + path: '/search/:query', component: Main, name: 'SEARCH', },