fixed more indentations
This commit is contained in:
parent
acf8990de1
commit
f031591753
9 changed files with 148 additions and 148 deletions
|
@ -19,29 +19,29 @@ class AdminSettingsController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return JSONResponse
|
* @return JSONResponse
|
||||||
*/
|
*/
|
||||||
public function index(): JSONResponse {
|
public function index(): JSONResponse {
|
||||||
return new JSONResponse($this->settingsService->getAppValues());
|
return new JSONResponse($this->settingsService->getAppValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $key
|
* @param $key
|
||||||
*
|
*
|
||||||
* @return JSONResponse
|
* @return JSONResponse
|
||||||
*/
|
*/
|
||||||
public function show($key): JSONResponse {
|
public function show($key): JSONResponse {
|
||||||
return new JSONResponse($this->settingsService->getAppValue($key));
|
return new JSONResponse($this->settingsService->getAppValue($key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $key
|
* @param $key
|
||||||
* @param $value
|
* @param $value
|
||||||
*
|
*
|
||||||
* @return JSONResponse
|
* @return JSONResponse
|
||||||
*/
|
*/
|
||||||
public function update($key, $value): JSONResponse {
|
public function update($key, $value): JSONResponse {
|
||||||
return new JSONResponse($this->settingsService->setAppValue($key, $value));
|
return new JSONResponse($this->settingsService->setAppValue($key, $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,25 +7,25 @@ use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
class DiffTask extends Entity implements JsonSerializable {
|
class DiffTask extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
protected $userId;
|
protected $userId;
|
||||||
protected $groupfolderId;
|
protected $groupfolderId;
|
||||||
protected $relativePath;
|
protected $relativePath;
|
||||||
protected $snapshotId;
|
protected $snapshotId;
|
||||||
protected $timestamp;
|
protected $timestamp;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('id','integer');
|
$this->addType('id','integer');
|
||||||
$this->addType('groupfolderId','integer');
|
$this->addType('groupfolderId','integer');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize() {
|
public function jsonSerialize() {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'userId' => $this->userId,
|
'userId' => $this->userId,
|
||||||
'groupfolderId' => $this->groupfolderId,
|
'groupfolderId' => $this->groupfolderId,
|
||||||
'relativePath' => $this->relativePath,
|
'relativePath' => $this->relativePath,
|
||||||
'snapshotId' => $this->snapshotId,
|
'snapshotId' => $this->snapshotId,
|
||||||
'timestamp' => $this->timestamp,
|
'timestamp' => $this->timestamp,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper;
|
||||||
*/
|
*/
|
||||||
class DiffTaskMapper extends QBMapper {
|
class DiffTaskMapper extends QBMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class);
|
parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find(int $id, string $userId) {
|
public function find(int $id, string $userId) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->getTableName())
|
->from($this->getTableName())
|
||||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
|
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
|
||||||
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
|
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
|
||||||
|
|
||||||
return $this->findEntity($qb);
|
return $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(string $userId) {
|
public function findAll(string $userId) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->getTableName())
|
->from($this->getTableName())
|
||||||
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
|
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
|
||||||
|
|
||||||
return $this->findEntities($qb);
|
return $this->findEntities($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,49 +7,49 @@ use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
class DiffTaskResult extends Entity implements JsonSerializable {
|
class DiffTaskResult extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
protected $taskId;
|
protected $taskId;
|
||||||
protected $timestamp;
|
protected $timestamp;
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
protected $beforeFileExists;
|
protected $beforeFileExists;
|
||||||
protected $beforePath;
|
protected $beforePath;
|
||||||
protected $beforeSize;
|
protected $beforeSize;
|
||||||
|
|
||||||
protected $currentFileExists;
|
protected $currentFileExists;
|
||||||
protected $currentFileId;
|
protected $currentFileId;
|
||||||
|
|
||||||
protected $currentPath;
|
protected $currentPath;
|
||||||
protected $currentSize;
|
protected $currentSize;
|
||||||
protected $reverted;
|
protected $reverted;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('id','integer');
|
$this->addType('id','integer');
|
||||||
$this->addType('taskId','integer');
|
$this->addType('taskId','integer');
|
||||||
$this->addType('beforeFileExists','boolean');
|
$this->addType('beforeFileExists','boolean');
|
||||||
$this->addType('beforeSize','integer');
|
$this->addType('beforeSize','integer');
|
||||||
$this->addType('currentFileExists','boolean');
|
$this->addType('currentFileExists','boolean');
|
||||||
$this->addType('currentFileId','integer');
|
$this->addType('currentFileId','integer');
|
||||||
$this->addType('currentSize','integer');
|
$this->addType('currentSize','integer');
|
||||||
$this->addType('reverted','boolean');
|
$this->addType('reverted','boolean');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize() {
|
public function jsonSerialize() {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'taskId' => $this->taskId,
|
'taskId' => $this->taskId,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'before' => [
|
'before' => [
|
||||||
'fileExists' => $this->beforeFileExists,
|
'fileExists' => $this->beforeFileExists,
|
||||||
'path' => $this->beforePath,
|
'path' => $this->beforePath,
|
||||||
'size' => $this->beforeSize,
|
'size' => $this->beforeSize,
|
||||||
],
|
],
|
||||||
'current' => [
|
'current' => [
|
||||||
'fileExists' => $this->currentFileExists,
|
'fileExists' => $this->currentFileExists,
|
||||||
'fileId' => $this->currentFileId,
|
'fileId' => $this->currentFileId,
|
||||||
'path' => $this->currentPath,
|
'path' => $this->currentPath,
|
||||||
'size' => $this->currentSize,
|
'size' => $this->currentSize,
|
||||||
],
|
],
|
||||||
'reverted' => $this->reverted,
|
'reverted' => $this->reverted,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper;
|
||||||
*/
|
*/
|
||||||
class DiffTaskResultMapper extends QBMapper {
|
class DiffTaskResultMapper extends QBMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class);
|
parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find(int $id) {
|
public function find(int $id) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->getTableName())
|
->from($this->getTableName())
|
||||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
|
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
|
||||||
|
|
||||||
return $this->findEntity($qb);
|
return $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(int $taskId) {
|
public function findAll(int $taskId) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from($this->getTableName())
|
->from($this->getTableName())
|
||||||
->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId)));
|
->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId)));
|
||||||
|
|
||||||
return $this->findEntities($qb);
|
return $this->findEntities($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markReverted(int $id) {
|
public function markReverted(int $id) {
|
||||||
$taskResult = $this->find($id);
|
$taskResult = $this->find($id);
|
||||||
|
|
|
@ -5,12 +5,12 @@ namespace OCA\GroupfolderFilesystemSnapshots\Entity;
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
|
|
||||||
class Snapshot implements JsonSerializable {
|
class Snapshot implements JsonSerializable {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $id,
|
private string $id,
|
||||||
private string $name,
|
private string $name,
|
||||||
private ?\DateTimeImmutable $createdTimestamp = null,
|
private ?\DateTimeImmutable $createdTimestamp = null,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): string {
|
public function getId(): string {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
@ -24,7 +24,7 @@ class Snapshot implements JsonSerializable {
|
||||||
return $this->createdTimestamp;
|
return $this->createdTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): mixed {
|
public function jsonSerialize(): mixed {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
|
|
|
@ -3,34 +3,34 @@
|
||||||
namespace OCA\GroupfolderFilesystemSnapshots\Helpers;
|
namespace OCA\GroupfolderFilesystemSnapshots\Helpers;
|
||||||
|
|
||||||
class FileHelper {
|
class FileHelper {
|
||||||
private static function seperateFilesFromFolders($parentDir, $items) {
|
private static function seperateFilesFromFolders($parentDir, $items) {
|
||||||
$files = [];
|
$files = [];
|
||||||
$folders = [];
|
$folders = [];
|
||||||
|
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) {
|
if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) {
|
||||||
$folders[] = $item;
|
$folders[] = $item;
|
||||||
} else {
|
} else {
|
||||||
$files[] = $item;
|
$files[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($files, $folders);
|
return array($files, $folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFilesAndFolders($dir) {
|
public static function getFilesAndFolders($dir) {
|
||||||
$scan = array_diff(scandir($dir), array('..', '.'));
|
$scan = array_diff(scandir($dir), array('..', '.'));
|
||||||
|
|
||||||
return self::seperateFilesFromFolders($dir, $scan);
|
return self::seperateFilesFromFolders($dir, $scan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFilesizesOfFiles($prefix, array $files) {
|
public static function getFilesizesOfFiles($prefix, array $files) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach($files as $index=>$file) {
|
foreach($files as $index=>$file) {
|
||||||
$result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file);
|
$result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ class SettingsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAppValue(string $key, string $value): string {
|
public function setAppValue(string $key, string $value): string {
|
||||||
if(in_array($key, self::$VALID_APP_SETTINGS)) {
|
if(in_array($key, self::$VALID_APP_SETTINGS)) {
|
||||||
if($value !== '') {
|
if($value !== '') {
|
||||||
$this->config->setAppValue(Application::APP_ID, $key, $value);
|
$this->config->setAppValue(Application::APP_ID, $key, $value);
|
||||||
|
@ -38,5 +38,5 @@ class SettingsService {
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,21 +6,21 @@ use OCP\Settings\ISettings;
|
||||||
|
|
||||||
class SnapshotsAdmin implements ISettings {
|
class SnapshotsAdmin implements ISettings {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse
|
||||||
*/
|
*/
|
||||||
public function getForm() {
|
public function getForm() {
|
||||||
return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin');
|
return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSection() {
|
public function getSection() {
|
||||||
return 'groupfolder_filesystem_snapshots';
|
return 'groupfolder_filesystem_snapshots';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue