remember menu state

This commit is contained in:
Jonas Heinrich 2018-08-11 14:53:01 +02:00
parent 7a9341a9ec
commit c3cfcab967
3 changed files with 35 additions and 15 deletions

View File

@ -5,16 +5,6 @@
$this->create('radio_index', '/') $this->create('radio_index', '/')
->actionInclude('radio/index.php'); ->actionInclude('radio/index.php');
/** return [
'resources' => [
'station' => ['url' => '/stations'],
],
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
]
]; **/
return [ return [
'resources' => [ 'resources' => [
'station' => ['url' => '/stations'], 'station' => ['url' => '/stations'],
@ -22,6 +12,8 @@ return [
], ],
'routes' => [ 'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'settings#getMenuState', 'url' => '/getMenuState', 'verb' => 'GET'],
['name' => 'settings#saveMenuState', 'url' => '/saveMenuState', 'verb' => 'POST'],
['name' => 'station_api#preflighted_cors', 'url' => '/api/0.1/{path}', ['name' => 'station_api#preflighted_cors', 'url' => '/api/0.1/{path}',
'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']] 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']]
] ]

View File

@ -305,8 +305,37 @@ $(function(){
}); });
}; };
function load_menu_state() {
var menu_state = 0;
var baseUrl = OC.generateUrl('/apps/radio/getMenuState');
$.get(baseUrl, function ( data ) {
if ("menu_state" in data) {
menu_state = data["menu_state"];
}
switch_menu(menu_state);
return true;
});
}
function save_menu_state(menu_state) {
var baseUrl = OC.generateUrl('/apps/radio/saveMenuState');
var settings = {
"menu_state": menu_state
};
$.ajax({
url: baseUrl,
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(settings)
}).done(function(data){
return true;
});
}
function switch_menu(type) { function switch_menu(type) {
var state = Number(type);
$('#filestable').hide(); $('#filestable').hide();
$('#emptycontent').addClass('hidden'); $('#emptycontent').addClass('hidden');
$('.nofilterresults').addClass('hidden'); $('.nofilterresults').addClass('hidden');
@ -316,7 +345,8 @@ $(function(){
searchTimeout = setTimeout(function(){ searchTimeout = setTimeout(function(){
$('#app-navigation').find('li').removeClass("active"); $('#app-navigation').find('li').removeClass("active");
$("tbody > tr").remove(); $("tbody > tr").remove();
switch (type) { save_menu_state(state)
switch (state) {
case 0: case 0:
$('li.nav-files').addClass('active'); $('li.nav-files').addClass('active');
radio_query(1); radio_query(1);
@ -357,5 +387,5 @@ $(function(){
}); });
// On app start, load top list // On app start, load top list
switch_menu(0); load_menu_state();
}); });

View File

@ -1,8 +1,6 @@
<?php <?php
style('radio', 'main'); style('radio', 'main');
script('radio', 'main'); script('radio', 'main');
OC_Util::addScript('search', 'search', true);
OC_Util::addScript('search', 'searchprovider');
?> ?>
<div id="content" class="app-files" role="main"> <div id="content" class="app-files" role="main">