mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Add apps category 'all installed'
Signed-off-by: Felix A. Epp <work@felixepp.de>
This commit is contained in:
parent
91a4676fc0
commit
89ac71355d
2 changed files with 32 additions and 7 deletions
|
|
@ -49,6 +49,7 @@ use OCP\L10N\IFactory;
|
|||
class AppSettingsController extends Controller {
|
||||
const CAT_ENABLED = 0;
|
||||
const CAT_DISABLED = 1;
|
||||
const CAT_ALL_INSTALLED = 2;
|
||||
|
||||
/** @var \OCP\IL10N */
|
||||
private $l10n;
|
||||
|
|
@ -103,7 +104,7 @@ class AppSettingsController extends Controller {
|
|||
*/
|
||||
public function viewApps($category = '') {
|
||||
if ($category === '') {
|
||||
$category = 'enabled';
|
||||
$category = 'installed';
|
||||
}
|
||||
|
||||
$params = [];
|
||||
|
|
@ -128,6 +129,7 @@ class AppSettingsController extends Controller {
|
|||
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
|
||||
|
||||
$formattedCategories = [
|
||||
['id' => self::CAT_ALL_INSTALLED, 'ident' => 'installed', 'displayName' => (string)$this->l10n->t('All installed')],
|
||||
['id' => self::CAT_ENABLED, 'ident' => 'enabled', 'displayName' => (string)$this->l10n->t('Enabled')],
|
||||
['id' => self::CAT_DISABLED, 'ident' => 'disabled', 'displayName' => (string)$this->l10n->t('Not enabled')],
|
||||
];
|
||||
|
|
@ -270,6 +272,24 @@ class AppSettingsController extends Controller {
|
|||
|
||||
switch ($category) {
|
||||
// installed apps
|
||||
case 'installed':
|
||||
$apps = $appClass->listAllApps();
|
||||
|
||||
foreach($apps as $key => $app) {
|
||||
$newVersion = \OC\Installer::isUpdateAvailable($app['id'], $this->appFetcher);
|
||||
$apps[$key]['update'] = $newVersion;
|
||||
}
|
||||
|
||||
usort($apps, function ($a, $b) {
|
||||
$a = (string)$a['name'];
|
||||
$b = (string)$b['name'];
|
||||
if ($a === $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a < $b) ? -1 : 1;
|
||||
});
|
||||
break;
|
||||
// enabled apps
|
||||
case 'enabled':
|
||||
$apps = $appClass->listAllApps();
|
||||
$apps = array_filter($apps, function ($app) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
|
||||
var categories = [
|
||||
{displayName: t('settings', 'Enabled'), ident: 'enabled', id: '0'},
|
||||
{displayName: t('settings', 'Not enabled'), ident: 'disabled', id: '1'}
|
||||
{displayName: t('settings', 'Not enabled'), ident: 'disabled', id: '1'},
|
||||
{displayName: t('settings', 'All installed'), ident: 'installed', id: '2'}
|
||||
];
|
||||
|
||||
var source = $("#categories-template").html();
|
||||
|
|
@ -95,7 +96,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
return _.extend({level: 0}, app);
|
||||
});
|
||||
var source
|
||||
if (categoryId === 'enabled' || categoryId === 'disabled') {
|
||||
if (categoryId === 'enabled' || categoryId === 'disabled' || categoryId === 'installed') {
|
||||
source = $("#app-template-installed").html();
|
||||
$('#apps-list').addClass('installed');
|
||||
} else {
|
||||
|
|
@ -106,11 +107,15 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
|
||||
if (appList.length) {
|
||||
appList.sort(function(a,b) {
|
||||
var levelDiff = b.level - a.level;
|
||||
if (levelDiff === 0) {
|
||||
return OC.Util.naturalSortCompare(a.name, b.name);
|
||||
if (a.active !== b.active) {
|
||||
return (a.active ? -1 : 1)
|
||||
} else {
|
||||
var levelDiff = b.level - a.level;
|
||||
if (levelDiff === 0) {
|
||||
return OC.Util.naturalSortCompare(a.name, b.name);
|
||||
}
|
||||
return levelDiff;
|
||||
}
|
||||
return levelDiff;
|
||||
});
|
||||
|
||||
var firstExperimental = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue