Skip to content

Commit

Permalink
many small improvements to prepare the client for the Nextcloud 10 re…
Browse files Browse the repository at this point in the history
…lease
  • Loading branch information
schiessle committed Aug 8, 2016
1 parent b5328ec commit a6cef57
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 37 deletions.
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

$template = new Template('survey_client', 'admin');
$template->assign('is_enabled', \OC::$server->getJobList()->has('OCA\Survey_Client\MonthlyReport', null));
$template->assign('is_enabled', \OC::$server->getJobList()->has('OCA\Survey_Client\BackgroundJobs\MonthlyReport', null));
$template->assign('last_sent', $lastSentReportDate);
$template->assign('last_report', $lastReport);
$template->assign('categories', $collector->getCategories());
Expand Down
1 change: 1 addition & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
always have full control over he content send to Nextcloud and can disable
it again at any time.
</description>
<namespace>Survey_Client</namespace>
<licence>AGPL</licence>
<author>Joas Schilling, Björn Schiessle</author>
<version>0.1.5</version>
Expand Down
4 changes: 2 additions & 2 deletions appinfo/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
*
*/

if (!\OC::$server->getJobList()->has('OCA\Survey_Client\MonthlyReport', null)) {
\OC::$server->getJobList()->add('OCA\Survey_Client\AdminNotification');
if (!\OC::$server->getJobList()->has('OCA\Survey_Client\BackgroundJobs\MonthlyReport', null)) {
\OC::$server->getJobList()->add('OCA\Survey_Client\BackgroundJobs\AdminNotification');
}
4 changes: 2 additions & 2 deletions appinfo/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
*
*/

if (!\OC::$server->getJobList()->has('OCA\Survey_Client\MonthlyReport', null)) {
\OC::$server->getJobList()->add('OCA\Survey_Client\AdminNotification');
if (!\OC::$server->getJobList()->has('OCA\Survey_Client\BackgroundJobs\MonthlyReport', null)) {
\OC::$server->getJobList()->add('OCA\Survey_Client\BackgroundJobs\AdminNotification');
}
6 changes: 5 additions & 1 deletion css/admin.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#survey_client textarea {
height: 400px;
height: 150px;
width: 300px;
}

#survey_client button {
margin: 20px 0;
}
2 changes: 1 addition & 1 deletion js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(document).ready(function() {

OC.AppConfig.postCall('setValue', {
app: 'survey_client',
key: $(this).attr('name').substring(24),
key: $(this).attr('name').substring(14),
value: $(this).attr('checked') ? 'yes' : 'no'
}, function() {
$button.attr('disabled', false);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

namespace OCA\Survey_Client;
namespace OCA\Survey_Client\BackgroundJobs;

use OC\BackgroundJob\QueuedJob;

Expand All @@ -33,7 +33,7 @@ protected function run($argument) {
->setDateTime(new \DateTime())
->setSubject('updated')
->setObject('dummy', 23)
->setLink($urlGenerator->getAbsoluteURL('index.php/settings/admin#goto-usage-report'));
->setLink($urlGenerator->getAbsoluteURL('index.php/settings/admin#usage-report'));

$enableAction = $notification->createAction();
$enableAction->setLabel('enable')
Expand Down
2 changes: 1 addition & 1 deletion monthlyreport.php → lib/BackgroundJobs/MonthlyReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

namespace OCA\Survey_Client;
namespace OCA\Survey_Client\BackgroundJobs;

use OC\BackgroundJob\TimedJob;
use OCA\Survey_Client\AppInfo\Application;
Expand Down
2 changes: 1 addition & 1 deletion categories/apps.php → lib/Categories/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getCategory() {
* @return string
*/
public function getDisplayName() {
return (string) $this->l->t('App list <em>(For each app: name, version, is enabled?)</em>');
return (string) $this->l->t('App list <em>(for each app: name, version, is enabled?)</em>');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion categories/database.php → lib/Categories/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getCategory() {
* @return string
*/
public function getDisplayName() {
return (string) $this->l->t('Database Environment <em>(type, version, database size)</em>');
return (string) $this->l->t('Database environment <em>(type, version, database size)</em>');
}

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
use OCP\IL10N;

/**
* Class Files_Sharing
* Class FilesSharing
*
* @package OCA\Survey_Client\Categories
*/
class Files_Sharing implements ICategory {
class FilesSharing implements ICategory {
/** @var IDBConnection */
protected $connection;

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions categories/php.php → lib/Categories/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @package OCA\Survey_Client\Categories
*/
class php implements ICategory {
class Php implements ICategory {
/** @var IniGetWrapper */
protected $phpIni;

Expand All @@ -57,7 +57,7 @@ public function getCategory() {
* @return string
*/
public function getDisplayName() {
return (string) $this->l->t('php Environment <em>(version, memory limit, max. execution time, max. file size)</em>');
return (string) $this->l->t('PHP environment <em>(version, memory limit, max. execution time, max. file size)</em>');
}

/**
Expand Down
9 changes: 4 additions & 5 deletions categories/owncloud.php → lib/Categories/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
use OCP\IL10N;

/**
* Class OwnCloud
* Class Server
*
* @package OCA\Survey_Client\Categories
*/
class OwnCloud implements ICategory {
class Server implements ICategory {
/** @var \OCP\IConfig */
protected $config;

Expand All @@ -50,14 +50,14 @@ public function __construct(IConfig $config, IL10N $l) {
* @return string
*/
public function getCategory() {
return 'owncloud';
return 'server';
}

/**
* @return string
*/
public function getDisplayName() {
return (string) $this->l->t('ownCloud Instance Details <em>(version, theme, memcache used, locking/previews/avatars enabled?)</em>');
return (string) $this->l->t('Server instance details <em>(version, memcache used, locking/previews/avatars enabled?)</em>');
}

/**
Expand All @@ -66,7 +66,6 @@ public function getDisplayName() {
public function getData() {
return [
'version' => $this->config->getSystemValue('version'),
'theme' => $this->config->getSystemValue('theme', 'none'),
'code' => $this->codeLocation(),
'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
'enable_previews' => $this->config->getSystemValue('enable_previews', true) ? 'yes' : 'no',
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions collector.php → lib/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
use OCA\Survey_Client\Categories\Apps;
use OCA\Survey_Client\Categories\Database;
use OCA\Survey_Client\Categories\Encryption;
use OCA\Survey_Client\Categories\Files_Sharing;
use OCA\Survey_Client\Categories\FilesSharing;
use OCA\Survey_Client\Categories\ICategory;
use OCA\Survey_Client\Categories\OwnCloud;
use OCA\Survey_Client\Categories\php;
use OCA\Survey_Client\Categories\Php;
use OCA\Survey_Client\Categories\Server;
use OCA\Survey_Client\Categories\Stats;
use OCP\AppFramework\Http;
use OCP\Http\Client\IClientService;
Expand All @@ -38,7 +38,7 @@

class Collector {

const SURVEY_SERVER_URL = 'http://localhost/ownCloud/master/core/';
const SURVEY_SERVER_URL = 'https://surveyserver.nextcloud.com/';

/** @var ICategory[] */
protected $categories;
Expand Down Expand Up @@ -76,7 +76,7 @@ public function __construct(IClientService $clientService, IConfig $config, IDBC
}

protected function registerCategories() {
$this->categories[] = new OwnCloud(
$this->categories[] = new Server(
$this->config,
$this->l
);
Expand All @@ -97,7 +97,7 @@ protected function registerCategories() {
$this->connection,
$this->l
);
$this->categories[] = new Files_Sharing(
$this->categories[] = new FilesSharing(
$this->connection,
$this->l
);
Expand Down Expand Up @@ -157,8 +157,6 @@ public function sendReport() {
$report = $this->getReport();

$client = $this->clientService->newClient();
$this->config->setAppValue('survey_client', 'last_sent', time());
$this->config->setAppValue('survey_client', 'last_report', json_encode($report));

try {
$response = $client->post(self::SURVEY_SERVER_URL . 'ocs/v2.php/apps/survey_server/api/v1/survey', [
Expand All @@ -175,6 +173,8 @@ public function sendReport() {
}

if ($response->getStatusCode() === Http::STATUS_OK) {
$this->config->setAppValue('survey_client', 'last_sent', time());
$this->config->setAppValue('survey_client', 'last_report', json_encode($report));
return new \OC_OCS_Result(
$report,
100// HTTP::STATUS_OK, TODO: <status>failure</status><statuscode>200</statuscode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($appName, IRequest $request, Collector $collector, I
* @return \OC_OCS_Result
*/
public function enableMonthly() {
$this->jobList->add('OCA\Survey_Client\MonthlyReport');
$this->jobList->add('OCA\Survey_Client\BackgroundJobs\MonthlyReport');

$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
Expand All @@ -71,7 +71,7 @@ public function enableMonthly() {
* @return \OC_OCS_Result
*/
public function disableMonthly() {
$this->jobList->remove('OCA\Survey_Client\MonthlyReport');
$this->jobList->remove('OCA\Survey_Client\BackgroundJobs\MonthlyReport');

$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
Expand Down
9 changes: 5 additions & 4 deletions notifier.php → lib/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ public function prepare(INotification $notification, $languageCode) {
// Read the language from the notification
$l = $this->l10nFactory->get('survey_client', $languageCode);

$notification->setParsedSubject((string) $l->t('Do you want to send monthly usage statistics to ownCloud?'));
$notification->setParsedSubject((string) $l->t(
'Do you want to help us to improve Nextcloud by providing some anonymized data about your setup and usage? You can disable it at any time in the admin settings again.'));

foreach ($notification->getActions() as $action) {
if ($action->getLabel() === 'enable') {
$action->setParsedLabel((string) $l->t('Yes'));
} else if ($action->getLabel() === 'disable') {
if ($action->getLabel() === 'disable') {
$action->setParsedLabel((string) $l->t('Not now'));
} else if ($action->getLabel() === 'enable') {
$action->setParsedLabel((string) $l->t('Send usage'));
}
$notification->addParsedAction($action);
}
Expand Down
13 changes: 11 additions & 2 deletions templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
<h2><?php p($l->t('Usage report')); ?></h2>

<p>
<?php p($l->t('When the server receives a new report of your instance, all entries from previous reports are removed. So in case you disable one of the settings below, you can send a new report, to delete the data, that is currently stored on the server.')); ?>
<?php p($l->t('You can help us to improve Nextcloud be sending us some data about your current setup and usage.')); ?>
</p>

<p>
<?php p($l->t('We take your privacy seriously. The data are anonymized and you can enable/disable it at any time, by default it is always disabled. Below you can also adjust what kind of data are send and always see the last report send to us. When the server receives a new report of your instance, all entries from previous reports are removed. In case you disable one of the settings below, you can send a new report, to delete the data, that is currently stored on the server.')); ?>
</p>

<button><?php p($l->t('Send new report now')); ?></button>
Expand All @@ -37,7 +41,7 @@
<label for="survey_client_monthly_report"><?php p($l->t('Send "Usage report" monthly')); ?></label>
</p>

<h3><?php p($l->t('Data Control')); ?></h3>
<h3><?php p($l->t('Data to send')); ?></h3>
<?php
foreach ($_['categories'] as $category => $data) {
?>
Expand All @@ -50,9 +54,14 @@
}
?>

<?php if (!empty($_['last_report'])): ?>

<h3><?php p($l->t('Last report')); ?></h3>

<p><textarea title="<?php p($l->t('Last report')); ?>" class="last_report" readonly="readonly"><?php p($_['last_report']);?></textarea></p>

<em class="last_sent"><?php p($l->t('Sent on: %s', [$_['last_sent']])); ?></em>

<?php endif; ?>

</div>

0 comments on commit a6cef57

Please sign in to comment.