diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 9a7aafc9..d34b0b50 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -156,71 +156,6 @@ }, 'GET'); }); - // Add a new apps list - app.post('#/apps/lists', function (c) { - list = { - 'name' : c.params['appslist_name'], - 'url' : c.params['appslist_url'] - } - - c.api('/appslists', function(data) { - store.clear('slide'); - c.redirect('#/apps/lists/' + list.name); - }, 'PUT', list); - }); - - // Show appslist info and operations - app.get('#/apps/lists/:appslist', function (c) { - c.api('/appslists', function(data) { - if (typeof data[c.params['appslist']] !== 'undefined') { - list = { - 'name' : c.params['appslist'], - 'url': data[c.params['appslist']]['url'], - 'lastUpdate': data[c.params['appslist']]['lastUpdate'], - 'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list - }; - c.view('app/app_appslists_info', {appslist: list}); - } - else { - c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']])); - store.clear('slide'); - c.redirect('#/apps/lists'); - } - }, 'GET'); - }); - - // Refresh available apps list - app.get('#/apps/lists/refresh', function (c) { - c.api('/appslists', function(data) { - // c.redirect(store.get('path')); - c.redirect('#/apps/install'); - }, 'PUT'); - }); - - // Refresh specific apps list - app.get('#/apps/lists/:appslist/refresh', function (c) { - c.api('/appslists', function(data) { - c.redirect('#/apps/lists'); - }, 'PUT', {'name' : c.params['appslist']}); - }); - - // Remove apps list - app.get('#/apps/lists/:appslist/remove', function (c) { - c.confirm( - y18n.t('appslist'), - y18n.t('appslists_confirm_remove', [c.params['app']]), - function() { - c.api('/appslists', function() { - c.redirect('#/apps/lists'); - }, 'DELETE', {'name' : c.params['appslist']}); - }, - function() { - store.clear('slide'); - c.redirect('#/apps/lists/'+ c.params['appslist']); - } - ); - }); - // Get app information app.get('#/apps/:app', function (c) { c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9 diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index f8c033f9..ffee7d49 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -364,4 +364,93 @@ ); }); + // List available apps lists + app.get('#/tools/appslists', function (c) { + c.api('/appslists', function(data) { + list = []; + var has_community_list = false; + $.each(data, function(listname, listinfo) { + list.push({ + 'name': listname, + 'url': listinfo['url'], + 'lastUpdate': listinfo['lastUpdate'] + }); + + // Check for community list + if (listname == 'community' || listinfo['url'] == 'https://app.yunohost.org/community.json') { + has_community_list = true; + } + }); + + c.view('tools/tools_appslists_list', { + appslists: list, + has_community_list: has_community_list + }); + }, 'GET'); + }); + + // Add a new apps list + app.post('#/tools/appslists', function (c) { + list = { + 'name' : c.params['appslist_name'], + 'url' : c.params['appslist_url'] + } + + c.api('/appslists', function(data) { + store.clear('slide'); + c.redirect('#/apps/lists/' + list.name); + }, 'PUT', list); + }); + + // Show appslist info and operations + app.get('#/tools/appslists/:appslist', function (c) { + c.api('/appslists', function(data) { + if (typeof data[c.params['appslist']] !== 'undefined') { + list = { + 'name' : c.params['appslist'], + 'url': data[c.params['appslist']]['url'], + 'lastUpdate': data[c.params['appslist']]['lastUpdate'], + 'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list + }; + c.view('tools/tools_appslists_info', {appslist: list}); + } + else { + c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']])); + store.clear('slide'); + c.redirect('#/apps/lists'); + } + }, 'GET'); + }); + + // Refresh available apps list + app.get('#/tools/appslists/refresh', function (c) { + c.api('/appslists', function(data) { + // c.redirect(store.get('path')); + c.redirect('#/apps/install'); + }, 'PUT'); + }); + + // Refresh specific apps list + app.get('#/tools/appslists/:appslist/refresh', function (c) { + c.api('/appslists', function(data) { + c.redirect('#/apps/lists'); + }, 'PUT', {'name' : c.params['appslist']}); + }); + + // Remove apps list + app.get('#/tools/appslists/:appslist/remove', function (c) { + c.confirm( + y18n.t('appslist'), + y18n.t('appslists_confirm_remove', [c.params['app']]), + function() { + c.api('/appslists', function() { + c.redirect('#/apps/lists'); + }, 'DELETE', {'name' : c.params['appslist']}); + }, + function() { + store.clear('slide'); + c.redirect('#/apps/lists/'+ c.params['appslist']); + } + ); + }); })(); diff --git a/src/views/app/app_appslists_info.ms b/src/views/tools/tools_appslists_info.ms similarity index 79% rename from src/views/app/app_appslists_info.ms rename to src/views/tools/tools_appslists_info.ms index 4fa09040..bb41beb6 100644 --- a/src/views/app/app_appslists_info.ms +++ b/src/views/tools/tools_appslists_info.ms @@ -1,8 +1,8 @@
{{t 'home'}} - {{t 'applications'}} - {{t 'appslists'}} - {{appslist.name}} + {{t 'tools'}} + {{t 'appslists'}} + {{appslist.name}}
@@ -32,7 +32,7 @@

{{t 'appslists_info_refresh_desc'}}

- + {{t 'refresh_app_list'}}
@@ -40,7 +40,7 @@

{{t 'appslists_info_remove_desc'}}

- + {{t 'remove'}}
diff --git a/src/views/app/app_appslists_list.ms b/src/views/tools/tools_appslists_list.ms similarity index 95% rename from src/views/app/app_appslists_list.ms rename to src/views/tools/tools_appslists_list.ms index 3a677f9a..7158ba5d 100644 --- a/src/views/app/app_appslists_list.ms +++ b/src/views/tools/tools_appslists_list.ms @@ -1,7 +1,7 @@
{{t 'home'}} - {{t 'applications'}} - {{t 'appslists'}} + {{t 'tools'}} + {{t 'appslists'}}
@@ -13,7 +13,7 @@
{{#appslists}} - +

{{name}} diff --git a/src/views/tools/tools_list.ms b/src/views/tools/tools_list.ms index 17d889dd..218a88e3 100644 --- a/src/views/tools/tools_list.ms +++ b/src/views/tools/tools_list.ms @@ -46,6 +46,10 @@

{{t 'tools_adminpw'}}

+ + +

{{t 'appslists'}}

+

{{t 'tools_download_ca'}}