-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2023 T-Systems International | ||
* | ||
* @author M. Mura <[email protected]> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\NMCTheme\Controller; | ||
|
||
use OCA\NMCTheme\Service\NMCFilesService; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\Files\NotFoundException; | ||
use OCP\IRequest; | ||
|
||
class AjaxController extends Controller { | ||
|
||
/** @var NMCFilesService */ | ||
private $filesService; | ||
|
||
public function __construct(string $appName, IRequest $request, NMCFilesService $filesService) { | ||
parent::__construct($appName, $request); | ||
$this->filesService = $filesService; | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
*/ | ||
public function getStorageStats(string $dir = '/'): JSONResponse { | ||
$storageInfo = $this->filesService->buildFileStorageStatistics($dir ?: '/'); | ||
$l = \OC::$server->getL10N('files'); | ||
|
||
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); | ||
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); | ||
$maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]); | ||
|
||
$storageInfo['uploadMaxFilesize'] = $maxUploadFileSize; | ||
$storageInfo['maxHumanFilesize'] = $maxHumanFileSize; | ||
$storageInfo['usedSpacePercent'] = $storageInfo['relative']; | ||
|
||
try { | ||
return new JSONResponse([ | ||
'status' => 'success', | ||
'data' => $storageInfo, | ||
]); | ||
} catch (NotFoundException $e) { | ||
return new JSONResponse([ | ||
'status' => 'error', | ||
'data' => [ | ||
'message' => 'Folder not found' | ||
], | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2023 T-Systems International | ||
* | ||
* @author M. Mura <[email protected]> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\NMCTheme\Controller; | ||
|
||
use OCA\NMCTheme\Service\NMCFilesService; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\IRequest; | ||
|
||
class ApiController extends Controller { | ||
|
||
/** @var NMCFilesService */ | ||
private $filesService; | ||
|
||
public function __construct(string $appName, IRequest $request, NMCFilesService $filesService) { | ||
parent::__construct($appName, $request); | ||
$this->filesService = $filesService; | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
*/ | ||
public function getStorageStats(string $dir = '/'): JSONResponse { | ||
$storageInfo = $this->filesService->buildFileStorageStatistics($dir ?: '/'); | ||
return new JSONResponse(['message' => 'ok', 'data' => $storageInfo]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters