summaryrefslogtreecommitdiffstats
path: root/settings/ajax
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-08-14 15:48:38 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-10-15 15:21:40 +0200
commitb091394a90a22767ec08259eb19a2b0d0294c25d (patch)
tree8621831f140a8126a933203e14edf213fd58e628 /settings/ajax
parent6824a5ce7f5752c2a3ebbe9e2f3a85eb3aafa05b (diff)
downloadnextcloud-server-b091394a90a22767ec08259eb19a2b0d0294c25d.tar.gz
nextcloud-server-b091394a90a22767ec08259eb19a2b0d0294c25d.zip
introduce new app page layout
filter installed and not-installed apps properly kill unneeded file load category 'Installed' on page load adding documentation links new apps mgmt: first style adjustment apps mgmt: only show license and preview if they exist adding buttons new apps mgmt: fix for mobile use app icon if available new apps mgmt: position enable/disable toggle to the right new apps mgmt: proper display of icons or previews new apps mgmt: fix loading spinner reenable group selection for apps new apps mgmt: position enable button normally again new apps mgmt: clarify wording from 'Installed' to 'Enabled' reintroduce enable/disable Move rating image path generation to client-side Move expression outside of l10n fix group handling add buttons for 'More apps' and 'Add your app' again disable changed date of app for now adding recommended label style 'Recommended' app tag fixing php warning sort by rating adding meta-category 'Recommended' Only show existing documentation links lacy loading of screenshots making group based app activation work again adding support to get the app icon not only by the app name but also simply by the fixed name 'app.svg' adding app.svg for all core apps query string '?installed' is not longer needed update and uninstall is back + error feedback remove unneeded parameter fix alignment of 'recommended' label
Diffstat (limited to 'settings/ajax')
-rw-r--r--settings/ajax/apps/categories.php30
-rw-r--r--settings/ajax/apps/index.php65
-rw-r--r--settings/ajax/apps/ocs.php68
-rw-r--r--settings/ajax/updateapp.php21
4 files changed, 107 insertions, 77 deletions
diff --git a/settings/ajax/apps/categories.php b/settings/ajax/apps/categories.php
new file mode 100644
index 00000000000..3bde28be99b
--- /dev/null
+++ b/settings/ajax/apps/categories.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+OC_JSON::checkAdminUser();
+
+$l = OC_L10N::get('settings');
+
+$categories = array(
+ array('id' => 0, 'displayName' => (string)$l->t('Enabled') ),
+ array('id' => 1, 'displayName' => (string)$l->t('Not enabled') ),
+);
+
+if(OC_Config::getValue('appstoreenabled', true)) {
+ $categories[] = array('id' => 2, 'displayName' => (string)$l->t('Recommended') );
+ // apps from external repo via OCS
+ $ocs = OC_OCSClient::getCategories();
+ foreach($ocs as $k => $v) {
+ $categories[] = array(
+ 'id' => $k,
+ 'displayName' => str_replace('ownCloud ', '', $v)
+ );
+ }
+}
+
+OCP\JSON::success($categories);
diff --git a/settings/ajax/apps/index.php b/settings/ajax/apps/index.php
new file mode 100644
index 00000000000..24fba8be312
--- /dev/null
+++ b/settings/ajax/apps/index.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+OC_JSON::checkAdminUser();
+
+$l = OC_L10N::get('settings');
+
+$category = intval($_GET['category']);
+$apps = array();
+
+switch($category) {
+ // installed apps
+ case 0:
+ $apps = \OC_App::listAllApps(true);
+ $apps = array_filter($apps, function($app) {
+ return $app['active'];
+ });
+ break;
+ // not-installed apps
+ case 1:
+ $apps = \OC_App::listAllApps(true);
+ $apps = array_filter($apps, function($app) {
+ return !$app['active'];
+ });
+ break;
+ default:
+ if ($category === 2) {
+ $apps = \OC_App::getAppstoreApps('approved');
+ $apps = array_filter($apps, function($app) {
+ return isset($app['internalclass']) && $app['internalclass'] === 'recommendedapp';
+ });
+ } else {
+ $apps = \OC_App::getAppstoreApps('approved', $category);
+ }
+ if (!$apps) {
+ $apps = array();
+ }
+ usort($apps, function ($a, $b) {
+ $a = (int)$a['score'];
+ $b = (int)$b['score'];
+ if ($a === $b) {
+ return 0;
+ }
+ return ($a > $b) ? -1 : 1;
+ });
+ break;
+}
+
+// fix groups to be an array
+$apps = array_map(function($app){
+ $groups = array();
+ if (is_string($app['groups'])) {
+ $groups = json_decode($app['groups']);
+ }
+ $app['groups'] = $groups;
+ $app['canUnInstall'] = !$app['active'] && $app['removable'];
+ return $app;
+}, $apps);
+
+OCP\JSON::success(array("apps" => $apps));
diff --git a/settings/ajax/apps/ocs.php b/settings/ajax/apps/ocs.php
deleted file mode 100644
index aad0690e01c..00000000000
--- a/settings/ajax/apps/ocs.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-OC_JSON::checkAdminUser();
-
-$l = \OC::$server->getL10N('settings');
-
-if(OC_Config::getValue('appstoreenabled', true)==false) {
- OCP\JSON::success(array('type' => 'external', 'data' => array()));
-}
-
-$enabledApps=OC_App::getEnabledApps();
-
-if(is_null($enabledApps)) {
- OCP\JSON::error(array('data' => array('message' => $l->t('Unable to load list from App Store'))));
-}
-
-$apps=array();
-
-// apps from external repo via OCS
-$categoryNames=OC_OCSClient::getCategories();
-if(is_array($categoryNames)) {
- $categories=array_keys($categoryNames);
- $page=0;
- $filter='approved';
- $externalApps=OC_OCSClient::getApplications($categories, $page, $filter);
- foreach($externalApps as $app) {
- // show only external apps that aren't enabled yet
- $local=false;
- foreach($enabledApps as $a) {
- if($a === $app['name']) {
- $local=true;
- }
- }
-
- if(!$local) {
- if($app['preview'] === '') {
- $pre=OC_Helper::imagePath('settings', 'trans.png');
- } else {
- $pre=$app['preview'];
- }
- if($app['label'] === 'recommended') {
- $label='3rd Party';
- } else {
- $label='Recommended';
- }
- $apps[]=array(
- 'name'=>$app['name'],
- 'id'=>$app['id'],
- 'active'=>false,
- 'description'=>$app['description'],
- 'author'=>$app['personid'],
- 'license'=>$app['license'],
- 'preview'=>$pre,
- 'internal'=>false,
- 'internallabel'=>$label,
- 'update'=>false,
- );
- }
- }
-}
-
-OCP\JSON::success(array('type' => 'external', 'data' => $apps));
diff --git a/settings/ajax/updateapp.php b/settings/ajax/updateapp.php
index 6375a41024a..3e28c65285d 100644
--- a/settings/ajax/updateapp.php
+++ b/settings/ajax/updateapp.php
@@ -12,30 +12,33 @@ if (!array_key_exists('appid', $_POST)) {
OCP\JSON::error(array(
'message' => 'No AppId given!'
));
- exit;
+ return;
}
$appId = $_POST['appid'];
if (!is_numeric($appId)) {
- $appId = OC_Appconfig::getValue($appId, 'ocsid', null);
- $isShipped = OC_App::isShipped($appId);
-
+ $appId = \OC::$server->getAppConfig()->getValue($appId, 'ocsid', null);
if ($appId === null) {
OCP\JSON::error(array(
'message' => 'No OCS-ID found for app!'
));
exit;
}
-} else {
- $isShipped = false;
}
$appId = OC_App::cleanAppId($appId);
-\OC_Config::setValue('maintenance', true);
-$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
-\OC_Config::setValue('maintenance', false);
+$config = \OC::$server->getConfig();
+$config->setSystemValue('maintenance', true);
+try {
+ $result = OC_Installer::updateAppByOCSId($appId);
+ $config->setSystemValue('maintenance', false);
+} catch(Exception $ex) {
+ $config->setSystemValue('maintenance', false);
+ OC_JSON::error(array("data" => array( "message" => $ex->getMessage() )));
+ return;
+}
if($result !== false) {
OC_JSON::success(array('data' => array('appid' => $appId)));