[fix] Keep only uninstalled apps or multi-instance apps on app install list.

This commit is contained in:
opi 2014-12-01 09:30:00 +01:00
parent 974e8774fb
commit ae5a79c914
2 changed files with 13 additions and 11 deletions

View file

@ -938,7 +938,7 @@ app = Sammy('#main', function (sam) {
sam.get('#/apps', function (c) { sam.get('#/apps', function (c) {
c.api('/apps', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
// Keep only installed apps // Keep only installed apps
data2 = { 'apps': [], 'installed': true } data2 = { 'apps': [], 'installed_apps': true }
$.each(data['apps'], function(k, v) { $.each(data['apps'], function(k, v) {
if (v['installed']) data2['apps'].push(v); if (v['installed']) data2['apps'].push(v);
}); });
@ -952,13 +952,15 @@ app = Sammy('#main', function (sam) {
sam.get('#/apps/install', function (c) { sam.get('#/apps/install', function (c) {
c.api('/apps', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
c.api('/apps?raw', function(dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps?raw', function(dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
// Keep only uninstalled apps // Keep only uninstalled apps, or multi-instance apps
data2 = { 'apps': [] } data2 = { 'apps': [], 'installed_apps': false }
$.each(data['apps'], function(k, v) { $.each(data['apps'], function(k, v) {
if (dataraw[v['id']].manifest.multi_instance) v['installed'] = false; if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance == "true") && !v['id'].match(/__[0-9]{1,5}$/)) {
if (!v['installed'] && !v['id'].match(/__[0-9]{1,5}$/)) data2['apps'].push(v); data2['apps'].push(v);
}
}); });
// Sort app list
c.arraySortById(data2.apps); c.arraySortById(data2.apps);
c.view('app/app_list', data2); c.view('app/app_list', data2);
}); });

View file

@ -1,4 +1,4 @@
{{#installed}} {{#installed_apps}}
<div class="btn-breadcrumb"> <div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a> <a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a> <a href="#/apps">{{t 'applications'}}</a>
@ -9,9 +9,9 @@
<span class="fa-plus"></span> {{t 'install'}} <span class="fa-plus"></span> {{t 'install'}}
</a> </a>
</div> </div>
{{/installed}} {{/installed_apps}}
{{^installed}} {{^installed_apps}}
<div class="btn-breadcrumb"> <div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a> <a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a> <a href="#/apps">{{t 'applications'}}</a>
@ -23,7 +23,7 @@
<span class="fa-refresh"></span> {{t 'refresh_app_list'}} <span class="fa-refresh"></span> {{t 'refresh_app_list'}}
</a> </a>
</div> </div>
{{/installed}} {{/installed_apps}}
<div class="separator"></div> <div class="separator"></div>
@ -45,7 +45,7 @@
</div> </div>
{{^installed}} {{^installed_apps}}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-download"></span> {{t 'custom_app_install'}}</h2> <h2 class="panel-title"><span class="fa-fw fa-download"></span> {{t 'custom_app_install'}}</h2>
@ -70,4 +70,4 @@
</div> </div>
</div> </div>
{{/installed}} {{/installed_apps}}