Skip to content

Commit

Permalink
feat: make update data opt-in
Browse files Browse the repository at this point in the history
The update section is new in Nextcloud 28, and therefore it's still possible to change the default to false.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Nov 7, 2023
1 parent c30b59c commit 5d9269b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,19 @@ function updateMonitoringUrl(event) {

const url = new URL($endpointUrl.value)
url.searchParams.delete('format')
url.searchParams.delete('skipUpdate')
url.searchParams.delete('skipApps')
url.searchParams.delete('skipUpdate')

for (const $param of $params) {
if ($param.name === 'format_json' && $param.checked) {
url.searchParams.set('format', 'json')
}
if ($param.name === 'skip_update' && $param.checked) {
url.searchParams.set('skipUpdate', 'true')
}
if ($param.name === 'skip_apps' && $param.checked) {
url.searchParams.set('skipApps', 'true')
}
if ($param.name === 'skip_update' && !$param.checked) {
url.searchParams.set('skipUpdate', 'false')
}
}

$endpointUrl.value = url.toString()
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function checkAuthorized(): bool {
* @PublicPage
* @BruteForceProtection(action=serverinfo)
*/
public function info(bool $skipUpdate = false, bool $skipApps = false): DataResponse {
public function info(bool $skipApps = false, bool $skipUpdate = true): DataResponse {
if (!$this->checkAuthorized()) {
$response = new DataResponse(['message' => 'Unauthorized']);
$response->throttle();
Expand All @@ -122,7 +122,7 @@ public function info(bool $skipUpdate = false, bool $skipApps = false): DataResp
}
return new DataResponse([
'nextcloud' => [
'system' => $this->systemStatistics->getSystemStatistics($skipUpdate, $skipApps),
'system' => $this->systemStatistics->getSystemStatistics($skipApps, $skipUpdate),
'storage' => $this->storageStatistics->getStorageStatistics(),
'shares' => $this->shareStatistics->getShareStatistics()
],
Expand Down
10 changes: 5 additions & 5 deletions lib/SystemStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(IConfig $config, IAppManager $appManager, Installer
*
* @throws \OCP\Files\InvalidPathException
*/
public function getSystemStatistics(bool $skipUpdate = false, bool $skipApps = false): array {
public function getSystemStatistics(bool $skipApps = false, bool $skipUpdate = true): array {
$processorUsage = $this->getProcessorUsage();
$memoryUsage = $this->os->getMemory();

Expand All @@ -73,14 +73,14 @@ public function getSystemStatistics(bool $skipUpdate = false, bool $skipApps = f
'swap_free' => $memoryUsage->getSwapFree() * 1024,
];

if (!$skipUpdate) {
$data['update'] = $this->getServerUpdateInfo();
}

if (!$skipApps) {
$data['apps'] = $this->getAppsInfo();
}

if (!$skipUpdate) {
$data['update'] = $this->getServerUpdateInfo();
}

return $data;
}

Expand Down
8 changes: 4 additions & 4 deletions templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ function FormatMegabytes(int $byte): string {
<input type="checkbox" class="update-monitoring-endpoint-url" name="format_json" id="format_json">
<label for="format_json"><?php p($l->t('Output in JSON')) ?></label>
</div>
<div class="monitoring-url-param">
<input type="checkbox" class="update-monitoring-endpoint-url" name="skip_update" id="skip_update">
<label for="skip_update"><?php p($l->t('Skip server update')) ?></label>
</div>
<div class="monitoring-url-param">
<input type="checkbox" class="update-monitoring-endpoint-url" name="skip_apps" id="skip_apps">
<label for="skip_apps"><?php p($l->t('Skip app updates (including app updates will send an external request to the app store)')) ?></label>
</div>
<div class="monitoring-url-param">
<input type="checkbox" class="update-monitoring-endpoint-url" name="skip_update" id="skip_update" checked>
<label for="skip_update"><?php p($l->t('Skip server update')) ?></label>
</div>
</div>

<p>
Expand Down

0 comments on commit 5d9269b

Please sign in to comment.