Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consumer pages #30

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"elasticsearch/elasticsearch": "^v8.14.0",
"guzzlehttp/guzzle": "^7.0",
"symfony/uid": "^6.4",
"symfony/yaml": "^6.4",
"twig/twig": "^3.14"
},
"require-dev": {
Expand Down
74 changes: 73 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions docs/assets/app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions lib/Controller/SourcesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ public function destroy(int $id): JSONResponse
public function logs(int $id): JSONResponse
{
try {
$source = $this->sourceMapper->find($id);
$callLogs = $this->callLogMapper->findAll(null, null, ['source_id' => $source->getId()]);
$callLogs = $this->callLogMapper->findAll(null, null, ['source_id' => $id]);
return new JSONResponse($callLogs);
} catch (DoesNotExistException $e) {
return new JSONResponse(['error' => 'Source not found'], 404);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cron/ActionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function run($argument)
}

// if the next run is in the the future, we don't need to do anything
if ($job->getNextRun() && $job->getNextRun() > $this->time->getTime()) {
if ($job->getNextRun() && $job->getNextRun() > new DateTime()) {
return;
}

Expand Down
12 changes: 9 additions & 3 deletions lib/Db/CallLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class CallLog extends Entity implements JsonSerializable
protected ?int $sourceId = null;
protected ?int $actionId = null;
protected ?int $synchronizationId = null;
protected ?string $userId = null;
protected ?string $sessionId = null;
protected ?DateTime $expires = null;
protected ?DateTime $created = null;

Expand All @@ -28,6 +30,8 @@ public function __construct() {
$this->addType('sourceId', 'integer');
$this->addType('actionId', 'integer');
$this->addType('synchronizationId', 'integer');
$this->addType('userId', 'string');
$this->addType('sessionId', 'string');
$this->addType('expires', 'datetime');
$this->addType('created', 'datetime');
}
Expand Down Expand Up @@ -73,9 +77,11 @@ public function jsonSerialize(): array
'response' => $this->response,
'sourceId' => $this->sourceId,
'actionId' => $this->actionId,
'synchronizationId' => $this->synchronizationId,
'expires' => isset($this->expires) ? $this->expires->format('c') : null,
'created' => isset($this->created) ? $this->created->format('c') : null,
'synchronizationId' => $this->synchronizationId,
'userId' => $this->userId,
'sessionId' => $this->sessionId,
'expires' => $this->expires,
'created' => $this->created,
];
}
}
6 changes: 0 additions & 6 deletions lib/Db/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class Consumer extends Entity implements JsonSerializable
protected ?string $uuid = null;
protected ?string $name = null; // The name of the consumer
protected ?string $description = null; // The description of the consumer
protected ?string $reference = null; // The reference of the consumer
protected ?string $version = '0.0.0'; // The version of the consumer
protected ?array $domains = []; // The domains the consumer is allowed to run from
protected ?array $ips = []; // The ips the consumer is allowed to run from
protected ?string $authorizationType = null; // The authorization type of the consumer, should be one of the following: 'none', 'basic', 'bearer', 'apiKey', 'oauth2', 'jwt'. Keep in mind that the consumer needs to be able to handle the authorization type.
Expand All @@ -37,8 +35,6 @@ public function __construct() {
$this->addType('uuid', 'string');
$this->addType('name', 'string');
$this->addType('description', 'string');
$this->addType('reference', 'string');
$this->addType('version', 'string');
$this->addType('domains', 'json');
$this->addType('ips', 'json');
$this->addType('authorizationType', 'string');
Expand Down Expand Up @@ -100,8 +96,6 @@ public function jsonSerialize(): array
'uuid' => $this->uuid,
'name' => $this->name,
'description' => $this->description,
'reference' => $this->reference,
'version' => $this->version,
'domains' => $this->domains,
'ips' => $this->ips,
'authorizationType' => $this->authorizationType,
Expand Down
6 changes: 3 additions & 3 deletions lib/Db/ConsumerMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public function updateFromArray(int $id, array $object): Consumer
$obj->hydrate($object);

// Set or update the version
$version = explode('.', $obj->getVersion());
$version[2] = (int)$version[2] + 1;
$obj->setVersion(implode('.', $version));
// $version = explode('.', $obj->getVersion());
// $version[2] = (int)$version[2] + 1;
// $obj->setVersion(implode('.', $version));

return $this->update($obj);
}
Expand Down
29 changes: 16 additions & 13 deletions lib/Db/JobLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
class JobLog extends Entity implements JsonSerializable
{
protected ?string $uuid = null;
protected string $level = 'INFO'; // log level
protected string $message = 'success'; // log message
protected ?string $jobId = null; // the id of the job in the job
protected ?string $jobListId = null; // the id of the job in the job list
protected ?string $jobClass = 'OCA\OpenConnector\Action\PingAction';
protected ?array $arguments = null;
protected ?int $executionTime = 3600; // the execution time in seconds
protected ?string $userId = null; // the user which the job is running for security reasons
protected ?array $stackTrace = []; // stack trace
protected ?DateTime $expires = null; // when the log will be cleared
protected ?DateTime $lastRun = null; // the last time the job was run
protected ?DateTime $nextRun = null; // the next time the job will be run
protected ?DateTime $created = null; // the date and time the job was created
protected string $level = 'INFO';
protected string $message = 'success';
protected ?string $jobId = null;
protected ?string $jobListId = null;
protected ?string $jobClass = 'OCA\OpenConnector\Action\PingAction';
protected ?array $arguments = null;
protected ?int $executionTime = 3600;
protected ?string $userId = null;
protected ?string $sessionId = null;
protected ?array $stackTrace = [];
protected ?DateTime $expires = null;
protected ?DateTime $lastRun = null;
protected ?DateTime $nextRun = null;
protected ?DateTime $created = null;

public function __construct() {
$this->addType('uuid', 'string');
Expand All @@ -33,6 +34,7 @@ public function __construct() {
$this->addType('arguments', 'json');
$this->addType('executionTime', 'integer');
$this->addType('userId', 'string');
$this->addType('sessionId', 'string');
$this->addType('stackTrace', 'json');
$this->addType('expires', 'datetime');
$this->addType('lastRun', 'datetime');
Expand Down Expand Up @@ -83,6 +85,7 @@ public function jsonSerialize(): array
'arguments' => $this->arguments,
'executionTime' => $this->executionTime,
'userId' => $this->userId,
'sessionId' => $this->sessionId,
'stackTrace' => $this->stackTrace,
'expires' => isset($this->expires) ? $this->expires->format('c') : null,
'lastRun' => isset($this->lastRun) ? $this->lastRun->format('c') : null,
Expand Down
6 changes: 6 additions & 0 deletions lib/Db/SynchronizationContractLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class SynchronizationContractLog extends Entity implements JsonSerializable
protected ?string $synchronizationContractId = null;
protected ?array $source = [];
protected ?array $target = [];
protected ?string $userId = null;
protected ?string $sessionId = null;
protected ?DateTime $expires = null;
protected ?DateTime $created = null;

Expand All @@ -22,6 +24,8 @@ public function __construct() {
$this->addType('synchronizationContractId', 'string');
$this->addType('source', 'json');
$this->addType('target', 'json');
$this->addType('userId', 'string');
$this->addType('sessionId', 'string');
$this->addType('expires', 'datetime');
$this->addType('created', 'datetime');
}
Expand Down Expand Up @@ -65,6 +69,8 @@ public function jsonSerialize(): array
'synchronizationContractId' => $this->synchronizationContractId,
'source' => $this->source,
'target' => $this->target,
'userId' => $this->userId,
'sessionId' => $this->sessionId,
'expires' => $this->expires,
'created' => $this->created,
];
Expand Down
Loading