Skip to content

Commit

Permalink
Jellyseerr count options (#648)
Browse files Browse the repository at this point in the history
* Jellyseerr count options
* Lint tabs
* Update Jellyseerr.php
* Update Jellyseerr.php

---------

Co-authored-by: Martijn <martijn.niji@gmail.com>
  • Loading branch information
imrancio and mvdkleijn authored Jan 26, 2024
1 parent be7c48e commit 7516e22
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 31 deletions.
70 changes: 40 additions & 30 deletions Jellyseerr/Jellyseerr.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,59 @@ function __construct() {

public function test()
{
$this->attrs["headers"] = [
"accept" => "application/json",
"X-Api-Key" => $this->config->apikey,
];
$attrs = $this->getRequestAttrs();
$test = parent::appTest($this->url("auth/me"), $attrs);

Check failure on line 17 in Jellyseerr/Jellyseerr.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\Jellyseerr\Jellyseerr::test() calls parent::appTest() but App\SupportedApps\Jellyseerr\Jellyseerr does not extend any class.

$test = parent::appTest($this->url("auth/me"), $this->attrs);

echo $test->status;
echo $test->status;
}

public function livestats()
{
$status = "inactive";
$data = [];
$this->attrs["headers"] = [
"accept" => "application/json",
"X-Api-Key" => $this->config->apikey,
];

$pendingRequestsCount = json_decode(
parent::execute($this->url("request/count"), $this->attrs)->getBody()
);

$pendingIssueCount = json_decode(
parent::execute($this->url("issue/count"), $this->attrs)->getBody()
);

if ($pendingRequestsCount || $pendingIssueCount)
$status = "inactive";
$data = [];
$attrs = $this->getRequestAttrs();
$requestsType = $this->getConfigValue("requests", "pending");
$requestsCount = json_decode(
parent::execute($this->url("request/count"), $attrs)->getBody()

Check failure on line 29 in Jellyseerr/Jellyseerr.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\Jellyseerr\Jellyseerr::livestats() calls parent::execute() but App\SupportedApps\Jellyseerr\Jellyseerr does not extend any class.
);
$issuesType = $this->getConfigValue("issues", "open");
$issuesCount = json_decode(
parent::execute($this->url("issue/count"), $attrs)->getBody()

Check failure on line 33 in Jellyseerr/Jellyseerr.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\Jellyseerr\Jellyseerr::livestats() calls parent::execute() but App\SupportedApps\Jellyseerr\Jellyseerr does not extend any class.
);

if ($requestsCount || $issuesCount)
{
$data["requests"] = $pendingRequestsCount->pending ?? 0;
$data["issues"] = $pendingIssueCount->open ?? 0;
}
$data["requests"] = $requestsCount->$requestsType ?? 0;
$data["issues"] = $issuesCount->$issuesType ?? 0;
}

return parent::getLiveStats($status, $data);

Check failure on line 42 in Jellyseerr/Jellyseerr.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\Jellyseerr\Jellyseerr::livestats() calls parent::getLiveStats() but App\SupportedApps\Jellyseerr\Jellyseerr does not extend any class.
}

public function url($endpoint)
{
$api_url =
parent::normaliseurl($this->config->url) .
"api/v1/" .
$endpoint;
parent::normaliseurl($this->config->url) .

Check failure on line 48 in Jellyseerr/Jellyseerr.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\Jellyseerr\Jellyseerr::url() calls parent::normaliseurl() but App\SupportedApps\Jellyseerr\Jellyseerr does not extend any class.
"api/v1/" .
$endpoint;

return $api_url;
return $api_url;
}

public function getRequestAttrs()
{
$attrs["headers"] = [
"accept" => "application/json",
"X-Api-Key" => $this->config->apikey,
];

return $attrs;
}

public function getConfigValue($key, $default = null)
{
return isset($this->config) && isset($this->config->$key)
? $this->config->$key
: $default;
}
}
16 changes: 15 additions & 1 deletion Jellyseerr/config.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="items" style="flex-wrap: wrap;">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
Expand All @@ -11,4 +11,18 @@
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
<div class="input">
<label>Requests count</label>
{!! Form::select('config[requests]', ['pending' => 'Pending', 'approved' => 'Approved', 'declined' => 'Declined', 'processing' => 'Processing', 'available' => 'Available', 'movie' => 'Movie', 'tv' => 'TV', 'total' => 'Total'], isset($item) && isset($item->getconfig()->requests) ? $item->getconfig()->requests : null, [
'id' => 'requests',
'class' => 'form-control config-item',
]) !!}
</div>
<div class="input">
<label>Issues count</label>
{!! Form::select('config[issues]', ['open' => 'Open', 'closed' => 'Closed', 'video' => 'Video', 'audio' => 'Audio', 'subtitles' => 'Subtitles', 'others' => 'Others', 'total' => 'Total'], isset($item) && isset($item->getconfig()->issues) ? $item->getconfig()->issues : null, [
'id' => 'issues',
'class' => 'form-control config-item',
]) !!}
</div>
</div>

0 comments on commit 7516e22

Please sign in to comment.